Date: Thu, 12 Apr 2012 09:54:30 +0200 From: Luigi Rizzo <rizzo@iet.unipi.it> To: Bruce Evans <brde@optusnet.com.au> Cc: Barney Wolff <barney@databus.com>, Andre Oppermann <andre@freebsd.org>, current@freebsd.org, net@freebsd.org Subject: Re: strange ping response times... Message-ID: <20120412075430.GA71623@onelab2.iet.unipi.it> In-Reply-To: <20120412112401.Q981@besplex.bde.org> References: <20120410225257.GB53350@onelab2.iet.unipi.it> <4F84B6DB.5040904@freebsd.org> <20120410230500.GA22829@pit.databus.com> <20120410233211.GA53829@onelab2.iet.unipi.it> <4F855E5E.5000107@freebsd.org> <20120411110036.GA60031@onelab2.iet.unipi.it> <4F857631.8040309@freebsd.org> <20120411131920.GA61027@onelab2.iet.unipi.it> <20120412112401.Q981@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Apr 12, 2012 at 01:18:59PM +1000, Bruce Evans wrote: > On Wed, 11 Apr 2012, Luigi Rizzo wrote: > > >On Wed, Apr 11, 2012 at 02:16:49PM +0200, Andre Oppermann wrote: ... > >ping takes a timestamp in userspace before trying to transmit > >the packet, and then the timestamp for the received packet > >is recorded in the kernel (in the interrupt or netisr thread > >i believe -- anyways, not in userspace). > > No, all timestamps recorded used by ping are recorded in userland. Bruce, look at the code in ping.c -- SO_TIMESTAMP is defined, so the program does (successfully) a setsockopt(s, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on)); and then (verified that at runtime the code follows this path) struct cmsghdr *cmsg = (struct cmsghdr *)&ctrl; msg.msg_controllen = sizeof(ctrl); msg.msg_namelen = sizeof(from); if ((cc = recvmsg(s, &msg, 0)) < 0) { if (errno == EINTR) continue; warn("recvmsg"); continue; } if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMP && cmsg->cmsg_len == CMSG_LEN(sizeof *tv)) { /* Copy to avoid alignment problems: */ memcpy(&now, CMSG_DATA(cmsg), sizeof(now)); tv = &now; } ... > My normal ping -fq localhost RTT is 2-3 usec > (closer to 3; another bug in this area is that the timestamps only > have microseconds resolution so you can't see if 3 is actually > more like 2.5. I was thinking of changing the resolution to > nanoseconds 8-10 years ago, before the FreeBSD-5 pessimizations > and CPU speeds hitting a wall made this not really necessary), > but the kernel I'm testing with uses ipfw which bloats the RTT to 8-9 ipfw overhead obviously depends on your firewall configuration, i have tested without ipfw to remove that noise. cheers luigi
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120412075430.GA71623>