Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 May 2006 15:02:53 +0200
From:      Hartmut Brandt <hartmut.brandt@dlr.de>
To:        benjamin@cactus.org
Cc:        freebsd-net@freebsd.org
Subject:   Re: Blocking N consecutive packets with netgraph
Message-ID:  <4475AAFD.5080701@dlr.de>
In-Reply-To: <20060524233846.GA8189@linux.cactus.org>
References:  <20060524233846.GA8189@linux.cactus.org>

next in thread | previous in thread | raw e-mail | index | archive | help
benjamin@cactus.org wrote:

>I need to test a multicast streaming media application by selectively
>dropping packets in the network connecting the source to the viewer.
>
>The capability I need is to drop N consecutive packets, where N ranges
>from 1 to 50 and is chosen via the command line.
>
>I had hoped to do this with dummynet and ipfw, but apparently I can
>only drop packets with a specified probablity.  The network topology
>for this method was to bridge two ethernet nics, then use dummynet pipes
>to vary the bandwith and packet loss rate.
>
>I also tested a method using ipfw to temporarily enable packet block
>rules using a short sleep interval, but there was only very coarse
>control of the number of packets blocked.
>
>Is it feasible to do this with netgraph?  Please outline how this may
>be accomplihsed.
>  
>

Yes. Netgraph is really great for this kind of stuff. Four years ago I 
wrote a node that simulated a space ATM link. The entire
thing controlled remotely via SNMP. Variable delay, various kinds of 
loss and so on. I got around 50MBit/sec throughput on
a 2 CPU 1GHz machine, but the limiting factor was not the CPUs but the 
ATM cards. This year I did the same but for ethernet
frames (to simulate a DVB-S2/RCS system). With two gigabit ethernet  
adaptors I get more than 100MBit/sec through the machine
with a load in the order of 30%. It can probably do more, just didn't 
try it.

Because you can load/unload the nodes without rebooting it is just great 
for development - just be a little careful not to crash the kernel.

Your case should be easy: create a node with two hooks, connect them to 
the 'lower' hooks of the two ethernet nodes. Then in the receive
function you just count the packets and drop as much as you need. What 
you don't drop you just send out the other hook. Control is via
netgraph control messages. You just can enter them via ngctl.

harti




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4475AAFD.5080701>