From owner-freebsd-hackers Sat Jan 10 20:17:29 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.7/8.8.7) id UAA09007 for hackers-outgoing; Sat, 10 Jan 1998 20:17:29 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from scanner.worldgate.com (scanner.worldgate.com [198.161.84.3]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id UAA08975 for ; Sat, 10 Jan 1998 20:17:17 -0800 (PST) (envelope-from marcs@znep.com) Received: from znep.com (uucp@localhost) by scanner.worldgate.com (8.8.7/8.8.7) with UUCP id VAA13953 for hackers@freebsd.org; Sat, 10 Jan 1998 21:17:09 -0700 (MST) Received: from localhost (marcs@localhost) by alive.znep.com (8.7.5/8.7.3) with SMTP id VAA07093 for ; Sat, 10 Jan 1998 21:15:52 -0700 (MST) Date: Sat, 10 Jan 1998 21:15:52 -0700 (MST) From: Marc Slemko To: hackers@FreeBSD.ORG Subject: why 100 byte TCP segments? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk Note the below tcpdump: 21:05:47.748479 valis.worldgate.com.1034 > testbed.worldgate.com.http: S 761734757:761734757(0) win 16384 (DF) 21:05:47.748749 testbed.worldgate.com.http > valis.worldgate.com.1034: S 1887037484:1887037484(0) ack 761734758 win 17520 (DF) 21:05:47.749793 valis.worldgate.com.1034 > testbed.worldgate.com.http: . ack 1 win 17520 (DF) 21:05:47.749809 valis.worldgate.com.1034 > testbed.worldgate.com.http: P 1:101(100) ack 1 win 17520 (DF) 21:05:47.749823 valis.worldgate.com.1034 > testbed.worldgate.com.http: FP 101:139(38) ack 1 win 17520 (DF) 21:05:47.749837 testbed.worldgate.com.http > valis.worldgate.com.1034: . ack 140 win 17482 (DF) 21:05:47.752540 testbed.worldgate.com.http > valis.worldgate.com.1034: F 1:1(0) ack 140 win 17520 (DF) 21:05:47.766014 valis.worldgate.com.1034 > testbed.worldgate.com.http: . ack 2 win 17520 (DF) valis is a FreeBSD 2.2 box. The same thing happens on boxes from 2.1.5 to 2.2.5. Don't have a -current box to try it... The connection was generated by the below program. Note that it is a single write() or send() call that generates the data, yet it is split into two packets. While it isn't a big deal here, I noticed this when I was using a simple web benchmark program (ZeusBench) that doesn't disable the Nagle algorithm. In that example, the server was delaying its ack (standard 200ms) and the client wasn't sending the second part of the request (due to Nagle) so you could only get 5 reqs/sec on a persistent connection, ie. multiple sequential requests on one TCP connection. Disabling Nagle fixed this of course. Why is this happening? Is it just a coincidence that 100 bytes is the size of the data area in the first mbuf in a chain? Has it been fixed in -current or should I dig deeper... #include #include #include #include int main () { int s; struct sockaddr_in servaddr; struct hostent *he; char request[2048]; char *file = "/index.html"; char *machine = "testbed.worldgate.com"; int keepalive = 1; sprintf(request, "GET %s HTTP/1.0\r\nUser-Agent: ZeusBench/1.0 with a longer name\r\n" "%sHost: %s\r\nAccept: */*\r\n\r\n", file, keepalive?"Connection: Keep-Alive\r\n":"", machine ); s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) { perror("socket"); exit(1); } bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(80); he = gethostbyname(machine); servaddr.sin_addr.s_addr = ((unsigned long *)(he->h_addr_list[0]))[0]; if (connect(s, (struct sockaddr *) &servaddr, sizeof(servaddr))) { perror("connect"); exit(1); } /* both ways do the same thing */ #ifdef 1 write(s, request, strlen(request)); #else send(s, request, strlen(request), 0); #endif }