From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 13 13:16:45 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3CCA916A4CE for ; Tue, 13 Jan 2004 13:16:45 -0800 (PST) Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id EBB3443D58 for ; Tue, 13 Jan 2004 13:16:43 -0800 (PST) (envelope-from cristjc@comcast.net) Received: from blossom.cjclark.org (c-24-6-186-224.client.comcast.net[24.6.186.224]) by comcast.net (rwcrmhc11) with ESMTP id <20040113211643013006trs8e>; Tue, 13 Jan 2004 21:16:43 +0000 Received: from blossom.cjclark.org (localhost. [127.0.0.1]) by blossom.cjclark.org (8.12.9p2/8.12.8) with ESMTP id i0DLGg43000664 for ; Tue, 13 Jan 2004 13:16:42 -0800 (PST) (envelope-from cristjc@comcast.net) Received: (from cjc@localhost) by blossom.cjclark.org (8.12.9p2/8.12.9/Submit) id i0DLGfKG000663 for freebsd-hackers@freebsd.org; Tue, 13 Jan 2004 13:16:41 -0800 (PST) (envelope-from cristjc@comcast.net) X-Authentication-Warning: blossom.cjclark.org: cjc set sender to cristjc@comcast.net using -f Date: Tue, 13 Jan 2004 13:16:41 -0800 From: "Crist J. Clark" To: freebsd-hackers@freebsd.org Message-ID: <20040113211641.GA99925@blossom.cjclark.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-URL: http://people.freebsd.org/~cjc/ Subject: Measuring Time on Serial Port Events X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: "Crist J. Clark" List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2004 21:16:45 -0000 I'm doing some work involving measuring latencies of communications over serial ports. To avoid clock synchronizations issues if we were running on separate machines, a configuration is a modem hooked into /dev/cuaa0 and another in /dev/cuaa1. We talk to the modem on cuaa0 which calls the modem on cuaa1, we tell it to answer, and then we throw data back and forth and take timestamps. Right now, all of the code is running in userland. I am trying to figure out what tuning we could do to get things as accurate as possible. That is, the information we want is the time that a bunch of bits to leave the COM port versus when they arrive on the other one. Since things look more like, Userland | OS | Comms Hardware | | | | [measuring]<->|<-[ sio ]->|<---- UART ---->|<-------> [ program ] | [driver] | | And this doesn't account for delays between when we get the data in userland and then have to make gettimeofday() calls for timestamps and other potential delays. I'm concerned how far off our measurements in userland will be from when bits actually arrive and leave on the wire. The data we are concerned with has latencies of a few 100 ms, but calibrations on the PSTN are a typically 50-ms-ish. We need to have a few significant digits below that. Any pointers? -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org