All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] Loose determinism when reading pcap and sending as raw ethernet packets
@ 2015-12-08 17:25 Umair Ali
  2015-12-08 20:13 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 6+ messages in thread
From: Umair Ali @ 2015-12-08 17:25 UTC (permalink / raw)
  To: xenomai@xenomai.org

Hi there,

I am reading the pcap file using the following technique:
"
mlockall(MCL_CURRENT|MCL_FUTURE);
fd = open (file.pcap, O_RDONLY);
status = fstat (fd, & s);
size = s.st_size;
 /* Memory-map the file. */
 mapped = mmap (0, size, PROT_READ, MAP_PRIVATE, fd, 0);"


Then i have the pcap file in mapped variable in the form of chracters (hex numbers). I read packet by packet and send them as raw packet over the network with following code:
"struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 5000;
j=24;

 while (j < size){
         i = (unsigned char) mapped[j + 8];
         sendto(sock, &mapped[j+16], i, 0,(struct sockaddr *)&peer, sizeof(peer));
         nanosleep(&ts, NULL);
          j = j+i+16;
}
"

When i run the program and receive the packets on the receiver then i have observed that behaviour of sending raw packets is not constant. Sometimes nanosleep finish little late or quickly.
The slackspot output file is attached for reference. Please guide that what am i doing wrong.


Thanks & Regards
Ali

-------------- next part --------------
A non-text attachment was scrubbed...
Name: slackspot_output
Type: application/octet-stream
Size: 8999 bytes
Desc: slackspot_output
URL: <http://xenomai.org/pipermail/xenomai/attachments/20151208/3763c1b0/attachment.obj>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-12-11 14:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-08 17:25 [Xenomai] Loose determinism when reading pcap and sending as raw ethernet packets Umair Ali
2015-12-08 20:13 ` Gilles Chanteperdrix
2015-12-10 13:20   ` Umair Ali
2015-12-10 15:01     ` Gilles Chanteperdrix
2015-12-10 17:25       ` Umair Ali
2015-12-11 14:59         ` Gilles Chanteperdrix

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.