| 44 | '''It is a little bit tricky to configure delay/loss on a virtual machine'''[[BR]] |
| 45 | Step 1: find our qdisc family number by executing "sudo /sbin/tc qdisc", a sample output could be like the following: |
| 46 | {{{ |
| 47 | [shufeng@center ~]$ sudo /sbin/tc qdisc |
| 48 | qdisc mq 0: dev eth0 root |
| 49 | qdisc htb 150: dev eth1 root refcnt 9 r2q 10 default 1 direct_packets_stat 0 |
| 50 | qdisc netem 140: dev eth1 parent 150:1 limit 1000 |
| 51 | qdisc htb 170: dev eth2 root refcnt 9 r2q 10 default 1 direct_packets_stat 0 |
| 52 | qdisc netem 160: dev eth2 parent 170:1 limit 1000 |
| 53 | qdisc htb 130: dev eth3 root refcnt 9 r2q 10 default 1 direct_packets_stat 0 |
| 54 | qdisc netem 120: dev eth3 parent 130:1 limit 1000 |
| 55 | }}} |
| 56 | Now if the ethernet card you want to change is eth3, you can find the "parent qdisc id" you want to use is "120:1" by looking at the following line: |
| 57 | {{{ |
| 58 | qdisc netem 120: dev eth3 parent 130:1 limit 1000 |
| 59 | }}} |
| 60 | As a result, you change the delay/loss by executing the following: |
| 61 | {{{ |
| 62 | sudo /sbin/tc qdisc add dev eth3 parent 120:1 netem delay 100ms loss 5% |
| 63 | sudo /sbin/tc qdisc change dev eth3 parent 120:1 netem delay 100ms loss 5% |
| 64 | sudo /sbin/tc qdisc del dev eth3 parent 120:1 netem delay 100ms loss 5% |
| 65 | }}} |