From owner-freebsd-net Wed Mar 17 4: 4:23 1999 Delivered-To: freebsd-net@freebsd.org Received: from mail.promo.de (mail.Promo.DE [194.45.188.65]) by hub.freebsd.org (Postfix) with ESMTP id 374A6154C6 for ; Wed, 17 Mar 1999 04:04:12 -0800 (PST) (envelope-from stefan.bethke@hanse.de) Received: from d225.promo.de (d225.Promo.DE [194.45.188.225]) by mail.promo.de (8.8.8/8.8.8) with ESMTP id NAA12284; Wed, 17 Mar 1999 13:03:44 +0100 (CET) Date: Wed, 17 Mar 1999 13:03:43 +0100 From: Stefan Bethke To: boards yan Cc: freebsd-net@FreeBSD.ORG Subject: Re: exhausted Message-ID: <652340.3130664623@d225.promo.de> In-Reply-To: <19990317050858.7049.rocketmail@web704.mail.yahoo.com> Originator-Info: login-id=stefan; server=mail X-Mailer: Mulberry (MacOS) [1.4.2, s/n U-301178] MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org boards yan wrote: > I tried to set the tcp socket Option(SO_RCV,TCP_MAXSEG), but failed > all the time. > > The program seems quite normal. > However, the supervision using tcpdump shows that > the option is unchanged. :-( > > Can anybody give me a reason? [ code deleted ] TCP_MAXSEG: Quoting from Steven's TCP/IP Illustrated, Vol. II, pp. 1023: A process can only decrease the MSS. When a TCP socket is created, tcp_newtcpcb initializes t_maxseg to its default of 512. When a SYN is received from the other end with an MSS option, tcp_input calls tcp_mss, and t_maxseg can be set as high as the outgoing interface MTU (minus 40 bytes for the default IP and TCP headers), which is 1460 for an Ethernet. Therefore, after a call to socket but before a connection is established, = a process can only decrease the MSS from its default of 512. After a connection is established, the process can decrease the MSS from whatever value was selected by tcp_mss. What do you expect from SO_RCVBUF? With the following code it does what it should: #include #include #include #include void main(void) { int fd; struct sockaddr_in sin; int nrbuf; if ((fd =3D socket(PF_INET, SOCK_STREAM, 0)) < 0) { perror ("socket"); return; } nrbuf =3D 65536l; if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &nrbuf, sizeof(nrbuf)) < 0) = { perror ("setsockopt(SO_RCVBUF)"); return; } sin.sin_len =3D sizeof(sin); sin.sin_family =3D AF_INET; sin.sin_addr.s_addr =3D htonl(0x7f000001); sin.sin_port =3D htons(23); if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { perror ("connect"); return; } close (fd); } tcpdump output: 12:54:05.561009 localhost.3828 > localhost.telnet: S 3917041307:3917041307(0) win 65535 (DF) Without the setsockopt, tcpdump shows: 12:49:59.008210 localhost.3783 > localhost.telnet: S 3863968019:3863968019(0) win 16384 (DF) Stefan -- M=FChlendamm 12 | Voice +49-40-256848, +49-177-3504009 D-22089 Hamburg | e-mail: stefan.bethke@hanse.de Germany | stb@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message