From owner-freebsd-net@FreeBSD.ORG Thu Nov 6 17:06:38 2008 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 38B651065686 for ; Thu, 6 Nov 2008 17:06:38 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 157908FC17 for ; Thu, 6 Nov 2008 17:06:38 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTP id 9932146B03; Thu, 6 Nov 2008 12:06:37 -0500 (EST) Date: Thu, 6 Nov 2008 17:06:37 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Ivo Vachkov In-Reply-To: Message-ID: References: User-Agent: Alpine 1.10 (BSF 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: FreeBSD Net Subject: Re: BPF question X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2008 17:06:38 -0000 On Thu, 6 Nov 2008, Ivo Vachkov wrote: > I am using simple write() calls to send packets over BPF file descriptor. > The BPF file descriptor is in buffered read mode (I assume this is the > default and I do not set it explicitly). From what I see my write() calls > are somewhat buffered. Since timing is relatively important for my project > I'd like to ask if there is a way "flush" the write buffer. Setting O_DIRECT > flag on the file descriptor doesn't seem to have any effect. The write(2) system call does no buffering in userspace (unlike, say, fwrite(3)), and when you write to a BPF device it essentially goes straight into the network interface output queue, so there should be no need for a flush mechanism. Could you describe the buffering effect you're seeing a bit more? Robert N M Watson Computer Laboratory University of Cambridge