NETEM(8) | Linux | NETEM(8) |
netem - Network Emulator
tc qdisc ... dev DEVICE ] add netem OPTIONS
OPTIONS := [ LIMIT ] [ DELAY ] [ LOSS ] [ CORRUPT ] [ DUPLICATION ] [ REORDERING ] [ RATE ] [ SLOT ] [ SEED ]
LIMIT := limit packets
DELAY := delay TIME [ JITTER [
CORRELATION ]]]
[ distribution { uniform | normal | pareto |
paretonormal } ]
LOSS := loss { random PERCENT [
CORRELATION ] |
state p13 [ p31 [ p32 [ p23 [
p14]]]] |
gemodel p [ r [ 1-h [ 1-k ]]] } [
ecn ]
CORRUPT := corrupt PERCENT [ CORRELATION ]]
DUPLICATION := duplicate PERCENT [ CORRELATION ]]
REORDERING := reorder PERCENT [ CORRELATION ] [ gap DISTANCE ]
RATE := rate RATE [ PACKETOVERHEAD [ CELLSIZE [ CELLOVERHEAD ]]]]
SLOT := slot { MIN_DELAY [ MAX_DELAY ]
|
distribution { uniform | normal | pareto |
paretonormal | FILE } DELAY JITTER }
[ packets PACKETS ] [ bytes BYTES ]
SEED := seed VALUE
The netem queue discipline provides Network Emulation functionality for testing protocols by emulating the properties of real-world networks.
The queue discipline provides one or more network impairments to packets such as: delay, loss, duplication, and packet corruption.
The Markov chain states are:
Rate throttling impacted by several factors including the kernel clock granularity. This will show up in an artificial packet compression (bursts).
These slot options can provide a crude approximation of bursty MACs such as DOCSIS, WiFi, and LTE.
Slot emulation is limited by several factors: the kernel clock granularity, as with a rate, and attempts to deliver many packets within a slot will be smeared by the timer resolution, and by the underlying native bandwidth also.
It is possible to combine slotting with a rate, in which case complex behaviors where either the rate, or the slot limits on bytes or packets per slot, govern the actual delivered rate.
Netem is limited by the timer granularity in the kernel. Rate and delay maybe impacted by clock interrupts.
Mixing forms of reordering may lead to unexpected results. For any method of reordering to work, some delay is necessary. If the delay is less than the inter-packet arrival time then no reordering will be seen. Due to mechanisms like TSQ (TCP Small Queues), for TCP performance test results to be realistic netem must be placed on the ingress of the receiver host.
Combining netem with other qdisc is possible but may not always work because netem use skb control block to set delays.
# tc qdisc add dev eth0 root netem delay 100ms
# tc qdisc change dev eth0 root netem delay 100ms 10ms 25%
# tc qdisc change dev eth0 root netem delay 100ms 20ms distribution normal
# tc qdisc change dev eth0 root netem loss 0.1%
An optional correlation may also be added. This causes the random number generator to be less random and can be used to emulate packet burst losses.
# tc qdisc change dev eth0 root netem duplicate 1%
# tc qdisc change dev eth0 root netem loss 0.3% 25%
There are two different ways to specify reordering. The gap method uses a fixed sequence and reorders every Nth packet.
# tc qdisc change dev eth0 root netem gap 5 delay 10ms
The reorder form uses a percentage of the packets to get misordered.
# tc qdisc change dev eth0 root netem delay 10ms reorder 25% 50%
In this example, 25% of packets (with a correlation of 50%) will get sent immediately, others will be delayed by 10ms.
Packets will also get reordered if jitter is large enough.
# tc qdisc change dev eth0 root netem delay 100ms 75ms
If you don't want this behavior then replace the internal queue discipline tfifo with a simple FIFO queue discipline.
# tc qdisc add dev eth0 root handle 1: netem delay 10ms 100ms # tc qdisc add dev eth0 parent 1:1 pfifo limit 1000
Example of using rate control and cells size.
# tc qdisc add dev eth0 root netem rate 5kbit 20 100 5
It is possible to selectively apply impairment using traffic classification.
# tc qdisc add dev eth0 root handle 1: prio # tc qdisc add dev eth0 parent 1:3 handle 30: tbf rate 20kbit buffer 1600 limit 3000 # tc qdisc add dev eth0 parent 30:1 handle 31: netem delay 200ms 10ms distribution normal # tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 match ip dst 65.172.181.4/32 flowid 1:3
tc(8)
Netem was written by Stephen Hemminger at Linux foundation and was inspired by NISTnet.
Original manpage was created by Fabio Ludovici <fabio.ludovici at yahoo dot it> and Hagen Paul Pfeifer <hagen@jauu.net>.
25 November 2011 | iproute2 |