Reputation: 98
Using SOCK_DGRAM
for UDP
sockets
All packets are 22 bytes
in length (ie 64 including headers
)
client.c
...
no_of_packets--;
sprintf(buf, "#:!0 rem");
sprintf(buf, format , buf);
sprintf(buf_aux, "#: 0 rem");
sprintf(buf_aux, format , buf_aux);
buf[MAX_LINE-1] = '\0';
buf_aux[MAX_LINE-1] = '\0';
len = strlen(buf) + 1;
send(s, buf, len, 0);
while (no_of_packets-- > 1) {
nanosleep(&T, NULL);
send(s, buf, len, 0);
}
send(s, buf_aux, len, 0);
server.c
...
while(1) {
if (len = recv(s, buf, sizeof(buf), 0)){
// do nothing
}
}
When I open Wireshark
to see avg delay between the packets which are sent,
I can see the following:
MIN delay: 0.000 006 795 sec => 6 micro sec
MAX delay: 0.000 260 952 sec => 260 micro sec
But I want to send packets every 512 nano sec (ie., 0.512 micro sec).
How can I achieve this speed?
Upvotes: 3
Views: 1080
Reputation: 136495
On Linux, you can probably do that with a kernel bypass network stack, such as PF_RING ZC (Zero Copy), and FIFO real-time threads that run on isolated cores that:
You may also find Understanding PCIe performance for end host networking white-paper useful.
Upvotes: 3