UDP thoroughput
- From: yavannadil@xxxxxxxxx
- Date: 13 Jun 2006 10:06:28 -0700
Hello!
Sorry if it's a FAQ, but nevertheless:
Let's say I have a server that waits for UDP datagrams, and client that
sends 700 1000-byte datagrams as fast as it can over loop-back
interface. Upon receiving a datagram, server increments and prints a
counter. On average, only 75 datagrams arrive. If I add a timeout to
client, all 700 arrive. net.core.rmem_max = 8388608
Linux 2.6.13 i686
Is it expected behaviour? Is there anything to do about it?
My test code is below.
Thank you for any opinion,
Dmitri
(gone to read Stevens)
server:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
int sock, length, fromlen, n=0;
struct sockaddr_in server;
struct sockaddr_in from;
char buf[2048];
sock=socket(AF_INET, SOCK_DGRAM, 0);
length = sizeof(server);
bzero(&server,length);
server.sin_family=AF_INET;
server.sin_addr.s_addr=INADDR_ANY;
server.sin_port=htons(1234);
bind(sock,(struct sockaddr *)&server,length);
fromlen = sizeof(struct sockaddr_in);
while (1) {
recvfrom(sock,buf,2048,0,(struct sockaddr *)&from,&fromlen);
printf("%d\n", n++);
}
}
client:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int i, sock, length, n;
struct sockaddr_in server, from;
struct hostent *hp;
unsigned char buffer[1095];
sock= socket(AF_INET, SOCK_DGRAM, 0);
server.sin_family = AF_INET;
hp = gethostbyname("localhost");
bcopy((char *)hp->h_addr, (char *)&server.sin_addr, hp->h_length);
server.sin_port = htons(1234);
length=sizeof(struct sockaddr_in);
for (i=0; i<1095; i++) buffer[i]=255;
buffer[0]=17; buffer[1]=0;
for (i=0; i<700; i++) {
sendto(sock,buffer,1095,0,&server,length);
/*usleep(1);*/
}
}
.
- Follow-Ups:
- Re: UDP thoroughput
- From: Phil Frisbie, Jr.
- Re: UDP thoroughput
- From: Spoon
- Re: UDP thoroughput
- Prev by Date: Re: changing routing table preference
- Next by Date: Transparent proxy configuration problem.
- Previous by thread: Re: OpenSwan - Linux VPN to Linux VPN
- Next by thread: Re: UDP thoroughput
- Index(es):
Relevant Pages
|