"tc" and "iptable" both can be used for network control.
"iptable" is dangerous as one can accidently block ssh port. "tc" provide extra level of customization for traffic control.
1) for adding delay:
tc qdisc add dev eth0 root netem delay 100ms
if "tc" command not found, then you can install it:
yum -y install tc
Note:name of device "eth0" can be found running "ifconfig" command
The name eth0 can differ in various system.
for checking if delay is introduced or not, run:
tc -s qdisc
for removing all "tc" rules, run this command:
tc qdisc del dev eth0 root netem
and again verfiy :
tc -s qdisc
2) for adding delay in statistically distributed fashion:
tc qdisc add dev eth0 root netem delay 150ms 50ms distribution normal
note: if it gives error "RTNETLINK answers: File exists" then run:
tc qdisc change dev eth0 root netem delay 150ms 50ms distribution normal
There are 3 type of distribution available: normal, pareto, paretonormal
normal distribution looks like this:
and pareto distribution:
3) for dropping packet:
tc qdisc add dev eth0 root netem loss 1%
it wil drop 1% of tcp packets.
note the "add" part. It will give error if any qdisc rule is already added.
In that case use: "change"
i.e. tc qdisc change dev eth0 root netem loss 1%
4) for limiting bandwidth:
tc qdisc add dev eth0 root tbf rate 100kbit burst 16kbit latency 500ms
if you get error:"Invalid argument" then delete the previous rules:
tc qdisc del dev eth0 root netem
5) don't forget to cleanup by running:
tc qdisc del dev eth0 root netem
and verify it:
tc -s qdisc
Comments
Post a Comment