From owner-freebsd-net@FreeBSD.ORG Thu Mar 30 22:06:56 2006 Return-Path: X-Original-To: net@freebsd.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0339516A422 for ; Thu, 30 Mar 2006 22:06:55 +0000 (UTC) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id A99A443D49 for ; Thu, 30 Mar 2006 22:06:55 +0000 (GMT) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.11/8.12.11) with ESMTP id k2UM6afr098321; Thu, 30 Mar 2006 14:06:36 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.11/8.12.3/Submit) id k2UM6aNg098320; Thu, 30 Mar 2006 14:06:36 -0800 (PST) (envelope-from rizzo) Date: Thu, 30 Mar 2006 14:06:36 -0800 From: Luigi Rizzo To: Mikhail Teterin Message-ID: <20060330140636.A98058@xorpc.icir.org> References: <200603301657.43218.mi+mx@aldan.algebra.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <200603301657.43218.mi+mx@aldan.algebra.com>; from mi+mx@aldan.algebra.com on Thu, Mar 30, 2006 at 04:57:42PM -0500 Cc: net@freebsd.org, ugen@worldbank.org, archie@dellroad.org, ugen@netvision.net.il Subject: Re: Is there an API for ipfw? 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, 30 Mar 2006 22:06:56 -0000 On Thu, Mar 30, 2006 at 04:57:42PM -0500, Mikhail Teterin wrote: > Hi! > > I'm writing an application that, needs to be able to quickly alter the > bandwidth between another machine and the host. > > The only way I can do that -- without another machine's cooperation -- is by > using the firewall, such as the dummynet functionality of ipfw. > > Is there any way to create/alter such a pipe from a C-program without using > system("ipfw ....")? you can surely use the setsockopt/ioctl interface that is used by ipfw2.c - however, before doing that, i suggest that you look at the actual time consumed by system("ipfw ....") and how often you need to do it - if it turns out that you are using for the task only 5% or less of the available CPU time, in my opinion it is not worth the effort. If you are doing it a lot more often, you should probably also consider the effect of such frequent changes to the pipe's configuration - e.g. pipes respond with a delay which is inversely proportional to the bandwidth, so in many cases still doesn't make sense to change the pipe's rate 100 times per second. cheers luigi > If not ipfw, perhaps, other firewall modules in FreeBSD-6.x? > > Thanks a lot! > > -mi