Network testing and latency

Dave Johnson dave-gnhlug at davej.org
Wed Mar 8 00:38:01 EST 2006


Ben Scott writes:
> On 3/7/06, Kevin D. Clark <kclark at mtghouse.com> wrote:
> > If all that you want to do is to introduce latency, I would suggest
> > using iptables "dstlimit" and "fuzzy" modules.
> 
>   Will that really create a realistic reproduction of a higher latency
> link, though?  Assuming the throughput demands were minimal, latency
> would remain low, wouldn't it?  And higher throughput demands would
> prolly result in TCP throttling or retransmissions or some such, which
> would be seen more as a bandwidth limit or bad line, not long
> transmission time, per se.

dstlimit and fuzzy are both packet-per-sec limiters not bandwidth
limiters. It makes a big difference if all you packets aren't the same
size.

Note that as mentioned before, limiting bandwidth and introducing
latency and/or jitter are different things.

If you want to simulate a bandwidth limited link you need to both
limit bandwidth and queue packets.  If you simply drop and don't queue
then there is no possibility of latency.

Latency and jitter are side effects due to queuing prior to the
bandwidth limited hop.  Protocols such as TCP are designed to avoid
introducing latency when a slow link is in the path.

Anyway, onto the implementation.

Below script limits bandwidth in both directions when forwarding
through two interfaces.  Note you'll need to setup the appropriate
interfaces and routes.  Each side has it's own bandwidth and queue
with a max size in bytes.  This is equivilant to a full-duplex T1
pipe using a linux box and 2 ethernet interfaces representing the two
endpoints of the T1.

-- 
Dave


run this:
========


# the 2 interfaces you are forwarding through
SIDE_A=eth1
SIDE_B=eth2

# line rates (real and fake)
REALRATE=100mbit
FAKERATE=1500kbit

# max queue size on both ends (bytes)
QUEUESIZE=256kb

# SIDE B -> SIDE A
tc qdisc del dev $SIDE_A root
tc qdisc add dev $SIDE_A root handle 2: cbq bandwidth $REALRATE avpkt 1000
tc class add dev $SIDE_A parent 2: classid 2:1 cbq bandwidth $REALRATE \
  rate ${FAKERATE} allot 1514 maxburst 10 avpkt 1000 bounded prio 8
tc qdisc add dev $SIDE_A parent 2:1 handle 20: bfifo limit $QUEUESIZE
tc filter add dev $SIDE_A protocol ip parent 2: prio 100 u32 match ip \
  protocol 0 0 flowid 2:1

# SIDE A -> SIDE B
tc qdisc del dev $SIDE_B root
tc qdisc add dev $SIDE_B root handle 3: cbq bandwidth $REALRATE avpkt 1000
tc class add dev $SIDE_B parent 3: classid 3:1 cbq bandwidth $REALRATE \
  rate ${FAKERATE} allot 1514 maxburst 10 avpkt 1000 bounded prio 8
tc qdisc add dev $SIDE_B parent 3:1 handle 30: bfifo limit $QUEUESIZE
tc filter add dev $SIDE_B protocol ip parent 3: prio 100 u32 match ip \
  protocol 0 0 flowid 3:1

# show current usage
watch tc -s -d qdisc ls




More information about the gnhlug-discuss mailing list