summaryrefslogtreecommitdiffstats
path: root/upstream/archlinux/man8/tc-netem.8
blob: a4cc0d614b135825a22ce61437720ef294677ac6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
.TH NETEM 8 "25 November 2011" "iproute2" "Linux"
.SH NAME
netem \- Network Emulator
.SH SYNOPSIS
.B "tc qdisc ... dev"
.IR DEVICE " ] "
.BR "add netem"
.I OPTIONS

.IR OPTIONS " := [ " LIMIT " ] [ " DELAY " ] [ " LOSS \
" ] [ " CORRUPT " ] [ " DUPLICATION " ] [ " REORDERING " ] [ " RATE \
" ] [ " SLOT " ] [ " SEED " ]"

.IR LIMIT " := "
.B limit
.I packets

.IR DELAY " := "
.BI delay
.IR TIME " [ " JITTER " [ " CORRELATION " ]]]"
.br
       [
.BR distribution " { "uniform " | " normal " | " pareto " | " paretonormal " } ]"

.IR LOSS " := "
.BR loss " { "
.BI random
.IR PERCENT " [ " CORRELATION " ]  |"
.br
.RB "               " state
.IR p13 " [ " p31 " [ " p32 " [ " p23 " [ " p14 "]]]] |"
.br
.RB "               " gemodel
.IR p " [ " r " [ " 1-h " [ " 1-k " ]]] } "
.RB  " [ " ecn " ] "

.IR CORRUPT " := "
.B corrupt
.IR PERCENT " [ " CORRELATION " ]]"

.IR DUPLICATION " := "
.B duplicate
.IR PERCENT " [ " CORRELATION " ]]"

.IR REORDERING " := "
.B reorder
.IR PERCENT " [ " CORRELATION " ] [ "
.B gap
.IR DISTANCE " ]"

.IR RATE " := "
.B rate
.IR RATE " [ " PACKETOVERHEAD " [ " CELLSIZE " [ " CELLOVERHEAD " ]]]]"

.IR SLOT " := "
.BR slot " { "
.IR MIN_DELAY " [ " MAX_DELAY " ] |"
.br
.RB "               " distribution " { "uniform " | " normal " | " pareto " | " paretonormal " | "
.IR FILE " } " DELAY " " JITTER " } "
.br
.RB "             [ " packets
.IR PACKETS " ] [ "
.BR bytes
.IR BYTES " ]"

.IR SEED " := "
.B seed
.I VALUE

.SH DESCRIPTION
The
.B 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.

.SH OPTIONS
.TP
.BI limit " COUNT"
Limits the maximum number of packets the qdisc may hold when doing delay.

.TP
.B delay
.IR TIME " [ " JITTER " [ " CORRELATION " ]]]"
.br
Delays the packets before sending.
The optional parameters allow introducing a delay variation and a correlation.
Delay and jitter values are expressed in milliseconds;
Correlation is set by specifying a percent of how much the previous delay
will impact the current random value.

.TP
.BI distribution " TYPE"
Specifies a pattern for delay distribution.
.RS
.TP
.B uniform
Use an equally weighted distribution of packet delays.
.TP
.B normal
Use a Gaussian distribution of delays.
Sometimes called a Bell Curve.
.TP
.B pareto
Use a Pareto distribution of packet delays.
This is useful to emulate long-tail distributions.
.TP
.B paretonormal
This is a mix of
.B pareto
and
.B normal
distribution which has properties of both Bell curve and long tail.
.RE

.TP
.BI loss " MODEL"
Drop packets based on a loss model.
.I MODEL
can be one of
.RS
.TP
.BI random " PERCENT"
Each packet loss is independent.
.TP
.BI state " P13 [ P31 [ P32 [ P23 P14 ]]]"
Use a 4-state Markov chain to describe packet loss.
.br
.I P13
is the packet loss.
Optional parameters extend the model to 2-state
.IR P31 ,
3-state
.IR P23 ,
.I P32
and 4-state
.IR P14 .

The Markov chain states are:
.RS
.TP
.B 1
good packet reception (no loss).
.TP
.B 2
good reception within a burst.
.TP
.B 3
burst losses.
.TP
.B 4
independent losses.
.RE

.TP
.BI gemodel " PERCENT [ R [ 1-H [ 1-K ]]]"
Use a Gilbert-Elliot (burst loss) model
based on:
.RS
.TP
.I PERCENT
probability of starting bad (lossy) state.
.TP
.I R
probability of exiting bad state.
.TP
.I "1-H"
loss probability in bad state.
.TP
.I "1-K"
loss probability in good state.
.RE
.RE

.TP
.B ecn
Use
Explicit Congestion Notification (ECN)
to mark packets instead of dropping them.
A loss model has to be used for this to be enabled.
.TP
.BI corrupt " PERCENT"
modifies the contents of the packet at a random position
based on
.IR PERCENT .
.TP
.BI duplicate " PERCENT"
creates a copy of the packet before queuing.
.TP
.BI reorder " PERCENT"
modifies the order of packet in the queue.
.TP
.BI gap " DISTANCE"
sends some packets immediately.
The first packets
.I "(DISTANCE - 1)"
are delayed and the next packet is sent immediately.

.TP
.BI rate " RATE [ PACKETOVERHEAD [ CELLSIZE  [ CELLOVERHEAD ]]]"
Delays packets based on packet size to emulate a fixed link speed.
Optional parameters:
.RS
.TP
.I PACKETOVERHEAD
Specify a per packet overhead in bytes.
Used to simulate additional link layer headers.
A negative value can be used to simlate when the Ethernet header is
stripped (e.g. -14) or header compression is used.
.TP
.I CELLSIZE
simulate link layer schemes like ATM.
.TP
.I CELLOVERHEAD
specify per cell overhead.
.RE

Rate throttling impacted by several factors including the kernel clock
granularity. This will show up in an artificial packet compression (bursts).

.TP
.BI slot " MIN_DELAY [  MAX_DELAY  ]"
allows emulating slotted networks.
Defer delivering accumulated packets to within a slot.
Each available slot is configured with a minimum delay to acquire,
and an optional maximum delay.
.TP
.B slot distribution
allows configuring based on distribution similar to
.B distribution
option for packet delays.

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.

.TP
.BI seed " VALUE"
Specifies a seed to guide and reproduce the randomly generated
loss or corruption events.

.SH LIMITATIONS
Netem is limited by the timer granularity in the kernel.
Rate and delay maybe impacted by clock interrupts.
.PP
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.
.PP
Combining netem with other qdisc is possible but may not always
work because netem use skb control block to set delays.

.SH EXAMPLES
.PP
.EX
# tc qdisc add dev eth0 root netem delay 100ms
.EE
.RS 4
Add fixed amount of delay to all packets going out on device eth0.
Each packet will have added delay of 100ms ± 10ms.
.RE
.PP
.EX
# tc qdisc change dev eth0 root netem delay 100ms 10ms 25%
.EE
.RS 4
This causes the added delay of 100ms ± 10ms
and the next packet delay value will be biased by 25% on the most recent delay.
This isn't a true statistical correlation, but an approximation.
.RE
.PP
.EX
# tc qdisc change dev eth0 root netem delay 100ms 20ms distribution normal
.EE
.RS 4
This delays packets according to a normal distribution (Bell curve)
over a range of 100ms ± 20ms.
.RE
.PP
.EX
# tc qdisc change dev eth0 root netem loss 0.1%
.EE
.RS 4
This causes 1/10th of a percent (i.e 1 out of 1000) packets to be
randomly dropped.

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.
.RE
.PP
.EX
# tc qdisc change dev eth0 root netem duplicate 1%
.EE
.RS 4
This causes one percent of the packets sent on eth0 to be duplicated.
.RE
.PP
.EX
# tc qdisc change dev eth0 root netem loss 0.3% 25%
.EE
.RS 4
This will cause 0.3% of packets to be lost,
and each successive probability depends is biased by 25% of the previous one.
.RE
.PP
There are two different ways to specify reordering.
The gap method uses a fixed sequence and reorders every Nth packet.
.EX
# tc qdisc change dev eth0 root netem gap 5 delay 10ms
.EE
.RS 4
This causes every 5th (10th, 15th, …) packet to go to be sent immediately
and every other packet to be delayed by 10ms.
This is predictable and useful for base protocol testing like reassembly.
.RE
.PP
The reorder form uses a percentage of the packets to get misordered.
.EX
# tc qdisc change dev eth0 root netem delay 10ms reorder 25% 50%
.EE
In this example, 25% of packets (with a correlation of 50%) will get sent immediately, others will be delayed by 10ms.
.PP
Packets will also get reordered if jitter is large enough.
.EX
# tc qdisc change dev eth0 root netem delay 100ms 75ms
.EE
.RS 4
If the first packet gets a random delay of 100ms (100ms base - 0ms jitter)
and the second packet is sent 1ms later and gets a delay of 50ms (100ms base - 50ms jitter);
the second packet will be sent first.
This is because the queue discipline tfifo inside netem,
keeps packets in order by time to send.
.RE
.PP
If you don't want this behavior then replace the internal
queue discipline tfifo with a simple FIFO queue discipline.
.EX
# tc qdisc add dev eth0 root handle 1: netem delay 10ms 100ms
# tc qdisc add dev eth0 parent 1:1 pfifo limit 1000
.EE

.PP
Example of using rate control and cells size.
.EX
# tc qdisc add dev eth0 root netem rate 5kbit 20 100 5
.EE
.RS 4
Delay all outgoing packets on device eth0 with a rate of 5kbit, a per packet
overhead of 20 byte, a cellsize of 100 byte and a per celloverhead of 5 bytes.
.RE

.PP
It is possible to selectively apply impairment using traffic classification.
.EX
# 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
.EE
.RS 4
This example uses a priority queueing discipline;
a TBF is added to do rate control; and a simple netem delay.
A filter classifies all packets going to 65.172.181.4 as being priority 3.
.PP
.SH SOURCES
.IP " 1. " 4
Hemminger S. , "Network Emulation with NetEm", Open Source Development Lab,
April 2005
.UR http://devresources.linux-foundation.org/shemminger/netem/LCA2005_paper.pdf
.UE

.IP " 2. " 4
Salsano S., Ludovici F., Ordine A., "Definition of a general and intuitive loss
model for packet networks and its implementation in the Netem module in the
Linux kernel", available at
.UR http://netgroup.uniroma2.it/NetemCLG
.UE

.SH SEE ALSO
.BR tc (8)

.SH AUTHOR
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>.