Skip to contentSkip to conversation

network delay simulation

PATCH Applied Stephen Hemminger 7 participants 19 messages Mar 16, 2004 – Mar 23, 2004

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Still bumming around for how to easily simulate long latencies. There is NISTnet but that is fugly old 2.2 code; and Dummynet, and hitbox which are FreeBSD based. The existing traffic shaper might do, but it seems to be limited to lower speed lines and needs some work (using atomic_set do own locking for instance).

Probably "the cowboy way" would be to right a new net/scheduler to just do FIFO delay.

Any ideas/comments? Somebody have some code sitting in a drawer?

Signature · 2 lines
Stephen Hemminger 		mailto:[email protected]
Open Source Development Lab	http://developer.osdl.org/shemminger
#1 lore raw
Quoted 10 lines · On Tue, 16 Mar 2004 15:10:58 -0800 Stephen Hemminger <[email protected]>…

Still bumming around for how to easily simulate long latencies. There is NISTnet but that is fugly old 2.2 code; and Dummynet, and hitbox which are FreeBSD based. The existing traffic shaper might do, but it seems to be limited to lower speed lines and needs some work (using atomic_set do own locking for instance).

Probably "the cowboy way" would be to right a new net/scheduler to just do FIFO delay.

Any ideas/comments? Somebody have some code sitting in a drawer?

iirc there was a 2.4 port of NistNet. Porting it to 2.6 is probably not that much work.

-Andi

#2 lore raw
Quoted 2 lines · On Wed, 17 Mar 2004 00:00:48 +0100 Andi Kleen <[email protected]> wrote:

iirc there was a 2.4 port of NistNet. Porting it to 2.6 is probably not that much work.

nistnet works, but even akpm remembers it as pretty grotty, who knows maybe the most recent 2.4.x variant was much better, but I doubt it.

#3 lore raw
Quoted 8 lines · On Tue, 16 Mar 2004 17:50:52 -0800 "David S. Miller" <[email protected]> wrote:
Quoted 2 lines · On Wed, 17 Mar 2004 00:00:48 +0100 Andi Kleen <[email protected]> wrote:

iirc there was a 2.4 port of NistNet. Porting it to 2.6 is probably not that much work.

nistnet works, but even akpm remembers it as pretty grotty, who knows maybe the most recent 2.4.x variant was much better, but I doubt it.

For testing it's probably good enough. No need to merge it ;-)

-Andi

#4 lore raw
In reply to David S. Miller
Quoted 9 lines · David S. Miller
Quoted 2 lines · On Wed, 17 Mar 2004 00:00:48 +0100 Andi Kleen <[email protected]> wrote:

iirc there was a 2.4 port of NistNet. Porting it to 2.6 is probably not that much work.

nistnet works, but even akpm remembers it as pretty grotty, who knows maybe the most recent 2.4.x variant was much better, but I doubt it.

whaddya mean "even"?

I wrote a userspace thingy many moons ago which provides variable delays and bandwidth restriction. It's for simulating long, thin pipes. It uses the tap/tun interface to route packets up to userspace where the delay/throttling is implemented. It requires weird policy routing rules, but there are scripts there which set everything up.

http://www.zipworld.com.au/~akpm/linux/patches/stuff/packet-delay.tar.gz

#5 lore raw
In reply to Stephen Hemminger
Quoted 4 lines · On Tue, 16 Mar 2004 15:10:58 -0800 Stephen Hemminger <[email protected]>…

Probably "the cowboy way" would be to right a new net/scheduler to just do FIFO delay.

Any ideas/comments? Somebody have some code sitting in a drawer?

Probably a packet scheduler would be my first choice, you could then even tag packets using classification and therefore delay differently for different flows.

Another thing I've always wanted to do was add a "struct netdev *" argument to dev_alloc_skb(), then we could do things like do SKB allocation failure tests on drivers to stress them in low memory situations and weird patterns of alloc failures. Probably do this in a transitional way via a new routine with a new name that drivers gradually move over to using.

The idea is that we provide an interface by which to upload some bit string of alloc success/failure binary states, and at each alloc the state machine just runs through the bits to decide whether to just quickly return NULL or not.

#6 lore raw
Quoted 11 lines · David S. Miller
Quoted 4 lines · On Tue, 16 Mar 2004 15:10:58 -0800 Stephen Hemminger <[email protected]>…

Probably "the cowboy way" would be to right a new net/scheduler to just do FIFO delay.

Any ideas/comments? Somebody have some code sitting in a drawer?

Probably a packet scheduler would be my first choice, you could then even tag packets using classification and therefore delay differently for different flows.

One insight I had a while ago is that packet pacing and artificial delay require a very similar mechanism. I hacked something a while ago that did this in a general way, though it had some problems and I never really followed up on it. Given the recent discussion of pacing on linux-net, this might be something to think about.

-John

#7 lore raw
In reply to David S. Miller
Quoted 1 line · David S. Miller
Quoted 1 line

Any ideas/comments? Somebody have some code sitting in a drawer?

I had something trying to replace nistnet a while back - probably have to go 10 harddrives back to find it.

Quoted 3 lines

Probably a packet scheduler would be my first choice, you could then even tag packets using classification and therefore delay differently for different flows.

This is exactly what i had. You need to be able to choose what flow gets affected and which ones are left alone.
A better approach is to use the action code patches i have because then you can cascade actions that you want and keep adding new error injection actions
example delay for random time between 30 seconds to 1 minute, then fuck the checksum, then simulate congestion ... with each of those actions selectable on how it gets added to the datapath.

Quoted 5 lines

Another thing I've always wanted to do was add a "struct netdev *" argument to dev_alloc_skb(), then we could do things like do SKB allocation failure tests on drivers to stress them in low memory situations and weird patterns of alloc failures. Probably do this in a transitional way via a new routine with a new name that drivers gradually move over to using.

this is valuable. I can bet you over 70% of the drivers will puke like theres no tommorow.
Not just that, the net stack code will too.

Quoted 4 lines

The idea is that we provide an interface by which to upload some bit string of alloc success/failure binary states, and at each alloc the state machine just runs through the bits to decide whether to just quickly return NULL or not.

A simple algorithm is random().

cheers,
jamal

#8 lore raw
Quoted 1 line · On 17 Mar 2004 11:09:26 -0500 jamal <[email protected]> wrote:

A simple algorithm is random().

Yes, but you want to weight it just a bit. Userland could use random() to generate the bit-stream in fact :)

#9 lore raw
Quoted 7 lines · On Wed, 17 Mar 2004 09:51:07 -0800 "David S. Miller" <[email protected]> wrote:
Quoted 1 line · On 17 Mar 2004 11:09:26 -0500 jamal <[email protected]> wrote:

A simple algorithm is random().

Yes, but you want to weight it just a bit. Userland could use random() to generate the bit-stream in fact :)

In an earlier project we had a test suite that failed the Nth allocation, then repeated startup failing from 1 till all allocations in a typical interaction round trip had been tested. Sure led to some nasty failures in the test bed, which was way better than the customer finding it.

Signature · 2 lines
Stephen Hemminger 		mailto:[email protected]
Open Source Development Lab	http://developer.osdl.org/shemminger
#10 lore raw
Quoted 4 lines · On Wed, 17 Mar 2004 10:00:01 -0800 Stephen Hemminger <[email protected]>…

In an earlier project we had a test suite that failed the Nth allocation, then repeated startup failing from 1 till all allocations in a typical interaction round trip had been tested. Sure led to some nasty failures in the test bed, which was way better than the customer finding it.

Yes, but we don't really want alloc_skb() doing this, this makes the failures go to other places (like TCP, netlink, whatever) instead of what you're trying to actually test (RX out of buffer handling in a specific driver).

It is an interesting thing to test too, no doubt.

#11 lore raw

PATCH 1/1 packet delay scheduler

In reply to David S. Miller

Okay, here is a very simple QOS scheduler that delays packets for 2.6. It is good for testing, and might be useful for people who want to put some class of traffic into a "penalty box".

Alexey's tc command is really easy to extend to new disciplines. There is a version which knows about this scheduler at:
http://developer.osdl.org/shemminger/tcp/iproute2-delay.tar.bz2
The only changes were to tc/Makefile and new file tc/q_delay.c

A trivial example is:
tc qdisc add dev eth0 root delay latency 25ms rate 100mbit

Try it, if others find it useful please consider adding it.

include/linux/pkt_sched.h +6 -0
diff -Nru a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
@@ -432,4 +432,10 @@
 
 #define TCA_ATM_MAX	TCA_ATM_STATE
 
+/* Delay section */
+struct tc_dly_qopt
+{
+	__u32	latency;
+	__u32   limit;
+};	
 #endif
net/sched/Kconfig +11 -0
diff -Nru a/net/sched/Kconfig b/net/sched/Kconfig
@@ -164,6 +164,17 @@
 	  To compile this code as a module, choose M here: the
 	  module will be called sch_dsmark.
 
+config NET_SCH_DELAY
+	tristate "Delay simulator"
+	depends on NET_SCHED
+	help
+	  Say Y if you want to delay packets by a fixed amount of
+	  time. This is often useful to simulate network delay when
+	  testing applications or protocols.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called sch_delay.
+
 config NET_SCH_INGRESS
 	tristate "Ingress Qdisc"
 	depends on NET_SCHED && NETFILTER
net/sched/Makefile +1 -0
diff -Nru a/net/sched/Makefile b/net/sched/Makefile
@@ -22,6 +22,7 @@
 obj-$(CONFIG_NET_SCH_TEQL)	+= sch_teql.o
 obj-$(CONFIG_NET_SCH_PRIO)	+= sch_prio.o
 obj-$(CONFIG_NET_SCH_ATM)	+= sch_atm.o
+obj-$(CONFIG_NET_SCH_DELAY)	+= sch_delay.o
 obj-$(CONFIG_NET_CLS_U32)	+= cls_u32.o
 obj-$(CONFIG_NET_CLS_ROUTE4)	+= cls_route.o
 obj-$(CONFIG_NET_CLS_FW)	+= cls_fw.o
net/sched/sch_delay.c new file +269 -0

269 lines not on this page · raw message

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#12 lore raw

Re: [PATCH] packet delay scheduler

Quoted 3 lines · On Thu, 18 Mar 2004 12:04:51 -0800 Stephen Hemminger <[email protected]>…

Okay, here is a very simple QOS scheduler that delays packets for 2.6. It is good for testing, and might be useful for people who want to put some class of traffic into a "penalty box".

I'm happy with this and added it to my 2.6.x tree.

Could you cook up a 2.4.x variant for me? Thanks.

#13 lore raw

Re: [PATCH] packet delay scheduler

Okay, here is a 2.4 version.

Documentation/Configure.help +8 -0
diff -Nru a/Documentation/Configure.help b/Documentation/Configure.help
@@ -10829,6 +10829,14 @@
   whenever you want). If you want to compile it as a module, say M
   here and read <file:Documentation/modules.txt>.
 
+Network delay simualtor  
+CONFIG_NET_SCH_DELAY
+  Say Y if you want to delay packets by a fixed amount of
+  time. This is often useful to simulate network delay when
+  testing applications or protocols.
+  
+  This code is also available as a module called sch_delay.o
+
 Ingress Qdisc
 CONFIG_NET_SCH_INGRESS
   If you say Y here, you will be able to police incoming bandwidth
include/linux/pkt_sched.h +7 -0
diff -Nru a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
@@ -432,4 +432,11 @@
 
 #define TCA_ATM_MAX	TCA_ATM_STATE
 
+/* Delay section */
+struct tc_dly_qopt
+{
+	__u32	latency;
+	__u32   limit;
+};	
+
 #endif
net/sched/Config.in +1 -0
diff -Nru a/net/sched/Config.in b/net/sched/Config.in
@@ -15,6 +15,7 @@
 tristate '  TEQL queue' CONFIG_NET_SCH_TEQL
 tristate '  TBF queue' CONFIG_NET_SCH_TBF
 tristate '  GRED queue' CONFIG_NET_SCH_GRED
+tristate '  Network delay simulator' CONFIG_NET_SCH_DELAY
 tristate '  Diffserv field marker' CONFIG_NET_SCH_DSMARK
 if [ "$CONFIG_NETFILTER" = "y" ]; then
    tristate '  Ingress Qdisc' CONFIG_NET_SCH_INGRESS
net/sched/Makefile +1 -0
diff -Nru a/net/sched/Makefile b/net/sched/Makefile
@@ -14,6 +14,7 @@
 obj-$(CONFIG_NET_SCH_INGRESS)	+= sch_ingress.o 
 obj-$(CONFIG_NET_SCH_CBQ)	+= sch_cbq.o
 obj-$(CONFIG_NET_SCH_CSZ)	+= sch_csz.o
+obj-$(CONFIG_NET_SCH_DELAY)	+= sch_delay.o
 obj-$(CONFIG_NET_SCH_HPFQ)	+= sch_hpfq.o
 obj-$(CONFIG_NET_SCH_HFSC)	+= sch_hfsc.o
 obj-$(CONFIG_NET_SCH_HTB)	+= sch_htb.o
net/sched/sch_delay.c new file +277 -0

277 lines not on this page · raw message

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#14 lore raw

Re: [PATCH] packet delay scheduler

Quoted 1 line · On Fri, 19 Mar 2004 10:47:05 -0800 Stephen Hemminger <[email protected]>…

Okay, here is a 2.4 version.

Applied, thanks Stephen.

#15 lore raw

Re: [PATCH] packet delay scheduler

In reply to Stephen Hemminger

Hi Stephen,

Good effort but we could do more to capture the essence of nistnet. I am not familiar with dummynet so cant comment on it.
For example just with the delaying action nistnet does a lot more (cutnpaste):
Fixed delays, variable delays with loadable delay probability distribution (Default distribution is pareto-normal, empirically parametrized to match observed packet delays), settable mean/variance.

It can also introduce Packet reordering, packet loss, packet duplication, as well as bandwidth limitation to induce congestion.

You get the point: essentially you have barely scratched the surface.

I think putting all the above in one huge monolithic module is wrong this being one of the problems i had with nistnet.

The better alternative is to use the tc extension patches i have because then you could write little modules which do different things and cascade them.

Maybe as an example i can rewrite the fixed delayer you wrote as an action module. The only catch is the patches i have are still in 2.4.x at the moment. Let me know if you are interested and i could pass you the patches.

cheers,
jamal

#16 lore raw

Re: [PATCH] packet delay scheduler

Quoted 3 lines · On 19 Mar 2004 09:52:07 -0500 jamal <[email protected]> wrote:

The better alternative is to use the tc extension patches i have because then you could write little modules which do different things and cascade them.

I agree that this chaining idea of tc actions is the end-all-be-all way to do this kind of stuff.

But for now we can put Stephen's delay scheduler in the tree, and I don't see any real problem with that until your tc action changes are ready for integration.

#17 lore raw

Re: [PATCH] packet delay scheduler

Quoted 3 lines · David S. Miller

But for now we can put Stephen's delay scheduler in the tree, and I don't see any real problem with that until your tc action changes are ready for integration.

Absolutely - sorry intent was just to motivate not reject.

I would say the extension patches are ready for inclusion but we can take that offline. I have a few people testing them under more rigorous conditions at the moment.

cheers,
jamal

#18 lore raw
In reply to Stephen Hemminger
Quoted 9 lines · Stephen Hemminger

Still bumming around for how to easily simulate long latencies.
There is NISTnet but that is fugly old 2.2 code; and Dummynet, and hitbox which are FreeBSD based. The existing traffic shaper might do, but it seems to be limited to lower speed lines and needs some work (using atomic_set
do own locking for instance).

Probably "the cowboy way" would be to right a new net/scheduler to just do FIFO delay.

Any ideas/comments? Somebody have some code sitting in a drawer?

I'll give you licenses to my (closed source) LANforge-ICE WAN emulator which runs as a Linux module and has been benchmarked at 1Gbps full-duplex (well, 999Mbps).

It can do up to about 1 second delay at 1Gbps, but with more delay at this high speed it runs out of memory (seems skb_alloc, or the way I am calling it, will not use high-memory). At lower speeds you can have several seconds of delay.

Please send me email off the list if you are interested.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com