emulating WAN latency for certain ip addresses - code wrong?

emulating WAN latency for certain ip addresses - code wrong?

Post by ve.. » Sat, 23 Dec 2006 02:14:08



hi-

I'd like to use tc and netem to cause network delay, but only to
certain other machines.

I found this page which (apparently) describes how to do it:
http://linux-net.osdl.org/index.php/Netem

I can get outgoing network delay using:
tc qdisc add dev eth0 root netem delay 200ms

but this adds latency to all outbound traffic.

Further down the page I linked to above, it mentions how to delay to
only one IP address and gives the following code:

tc qdisc add dev eth0 root handle 1: prio
tc qdisc add dev eth0 parent 1:3 handle 30: netem \
     delay 200ms 10ms distribution normal
tc qdisc add dev eth0 parent 30:1 tbf rate 20kbit buffer 1600 limit
3000
tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \
     match ip dst 65.172.181.4/32 flowid 10:3

However, when I've tried this, I get network delay to all ip addresses
- I can't seem to filter to just one ip address.

Does anyone know the solution?

 
 
 

emulating WAN latency for certain ip addresses - code wrong?

Post by Allen McIntos » Sat, 23 Dec 2006 03:46:19



> hi-

> I'd like to use tc and netem to cause network delay, but only to
> certain other machines.

Have you tried (or at least considered) nistnet?

 
 
 

emulating WAN latency for certain ip addresses - code wrong?

Post by ve.. » Sat, 23 Dec 2006 18:24:10


tc comes as part of the iproute2 package and is already installed on
(work) servers. Nistnet requires a separate install and all the
associated bureaucratic hassles.

Thanks for the advice though.

Back to original question - does anyone know why this code won't work?

tc qdisc add dev eth0 root handle 1: prio
tc qdisc add dev eth0 parent 1:3 handle 30: netem \
     delay 200ms 10ms distribution normal
tc qdisc add dev eth0 parent 30:1 tbf rate 20kbit buffer 1600 limit
3000
tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \
     match ip dst 65.172.181.4/32 flowid 10:3

As I said before, I get the 200ms delay to all outbound traffic, not
just to the ip address specified by the tc filter.



> > hi-

> > I'd like to use tc and netem to cause network delay, but only to
> > certain other machines.

> Have you tried (or at least considered) nistnet?

 
 
 

emulating WAN latency for certain ip addresses - code wrong?

Post by Andy Furnis » Fri, 29 Dec 2006 23:33:43



> tc comes as part of the iproute2 package and is already installed on
> (work) servers. Nistnet requires a separate install and all the
> associated bureaucratic hassles.

> Thanks for the advice though.

> Back to original question - does anyone know why this code won't work?

> tc qdisc add dev eth0 root handle 1: prio
> tc qdisc add dev eth0 parent 1:3 handle 30: netem \
>      delay 200ms 10ms distribution normal
> tc qdisc add dev eth0 parent 30:1 tbf rate 20kbit buffer 1600 limit
> 3000
> tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \
>      match ip dst 65.172.181.4/32 flowid 10:3

> As I said before, I get the 200ms delay to all outbound traffic, not
> just to the ip address specified by the tc filter.

Maybe it's because your test traffic would have gone to 1:3 because prio
looks at tos. Try adding

tc filter add dev eth0 protocol ip parent 1:0 prio 4 u32 match u32 0 0
flowid 1:2

Andy.