From owner-freebsd-net@FreeBSD.ORG Mon Aug 27 23:46:06 2007 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F14516A41B for ; Mon, 27 Aug 2007 23:46:06 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.freebsd.org (Postfix) with ESMTP id 1FC2513C45B for ; Mon, 27 Aug 2007 23:46:05 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (7tteuvfetalgfa2h@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id l7RNk4xb028603; Mon, 27 Aug 2007 16:46:04 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id l7RNk4Zh028602; Mon, 27 Aug 2007 16:46:04 -0700 (PDT) (envelope-from jmg) Date: Mon, 27 Aug 2007 16:46:04 -0700 From: John-Mark Gurney To: Weiguang Shi Message-ID: <20070827234604.GU99491@funkthat.com> Mail-Followup-To: Weiguang Shi , freebsd-net@freebsd.org References: <43862.94241.qm@web43132.mail.sp1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43862.94241.qm@web43132.mail.sp1.yahoo.com> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: freebsd-net@freebsd.org Subject: Re: nc captures 1024 bytes X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Aug 2007 23:46:06 -0000 Weiguang Shi wrote this message on Mon, Aug 27, 2007 at 16:37 -0700: > To get the larger packets, I have to fix another hard-coded "1024" This is also a performance problem on slower machines... nc should be fixed to use larger buffers, maybe to the tune of 64KB if not larger... W/ TSO, doing 64KB writes makes sense as it could send the entire segment off to the card... > 630 readwrite(int nfd) > 631 { > 632 struct pollfd pfd[2]; > 633 unsigned char buf[8192]; > 634 int n, wfd = fileno(stdin); > 635 int lfd = fileno(stdout); > 636 int plen; > 637 > 638 plen = jflag ? 8192 : 1024; > 639 > > ----- Original Message ---- > From: Weiguang Shi > To: freebsd-net@freebsd.org > Sent: Monday, August 27, 2007 4:05:26 PM > Subject: nc captures 1024 bytes > > Hi, > > My system is FreeBSD 6.2. I sent a UDP datagram of 1464 bytes to port > 1234 where nc was waiting > % nc -n -u -l 1234 >tt > > Afterwards, the size of tt, however, was only 1024 bytes. > > I noticed this piece of code in nc > > 341 if (uflag) { > 342 int rv, plen; > 343 char buf[8192]; > 344 struct sockaddr_storage z; > 345 > 346 len = sizeof(z); > 347 plen = jflag ? 8192 : 1024; > 348 rv = recvfrom(s, buf, plen, MSG_PEEK, > 349 (struct sockaddr *)&z, &len); > 350 if (rv < 0) > 351 err(1, "recvfrom"); > > Why 1024 instead of something like 1500-20-8=1472? -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."