I'm trying to emulate slow net link with command tc
. I use netem
to emulate delay and packet loss and htb to emulate narrow bandwidth, but I find there is a limit option in netem
, what does this option do? will it affect the final bandwidth?
I googled it and find something in http://manpages.ubuntu.com/manpages/raring/man8/tc-netem.8.html
which says:
limits the effect of selected options to the indicated number of next packets.
But I still can not understand what it does.
How can I use netem on incoming traffic? You need to use the Intermediate Functional Block pseudo-device IFB . This network device allows attaching queuing discplines to incoming packets. Another way is to use another machine as an Ethernet bridge , and apply netem to both Ethernet devices.
NetEm is an enhancement of the Linux traffic control facilities that allow to add delay, packet loss, duplication and more other characteristics to packets outgoing from a selected network interface.
Tc is used to configure Traffic Control in the Linux kernel. Traffic Control consists of the following: SHAPING When traffic is shaped, its rate of transmission is under control. Shaping may be more than lowering the available bandwidth - it is also used to smooth out bursts in traffic for better network behaviour.
I don't know exactly what netem is doing, but I've found that if you don't set "limit" to a higher value, netem doesn't work correctly - i.e. it discards packets at higher speeds and possibly has other problems, essentially not accurately emulating a real network.
From the mailing list mentioned by CarlH, Stephen Hemminger said:
The limit value is in packets at least when using the default qdisc inside netem (tfifo). You can also use pfifo and configure it for packet limit, or bfifo same only bytes. The value 1000 is low, you want about 50% more than the max packet rate * delay, unless you are trying to emulate a router with a small queue.
So for a 1 Gbps link, 1 Gbps / 1500 bytes MTU * 100 ms * 1.5 = 12500.
Command:
sudo tc qdisc add dev eth1 root netem limit 12500 delay 100ms loss 1%
I've been using limit 100000, which seems to work fine, but it seems a lower value may be fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With