3

I'm going to simulate a network latency on three different ports of local host by using tc (traffic control for Linux) commands. I run the following code:

!/bin/bash
tc qdisc add dev lo root handle 1: htb 
tc class add dev lo parent 1: classid 1:1 htb rate 1000Mbps
#1:
tc class add dev lo parent 1:1 classid 1:2 htb rate 1000Mbps
tc qdisc add dev lo handle 2: parent 1:2 netem delay 500ms
tc filter add dev lo pref 2 protocol ip u32 match ip dport 7011 0xffff flowid 1:2
#2:
tc class add dev lo parent 1:1 classid 1:3 htb rate 1000Mbps
tc qdisc add dev lo handle 3: parent 1:3 netem delay 1000ms
tc filter add dev lo pref 3 protocol ip u32 match ip dport 7011 0xffff flowid 1:3
#3:
tc class add dev lo parent 1:1 classid 1:4 htb rate 1000Mbps
tc qdisc add dev lo handle 4: parent 1:4 netem delay 100ms
tc filter add dev lo pref 4 protocol ip u32 match ip dport 7012 0xffff flowid 1:4

However, it doesn't appear to be any delay caused by these filters. I even tried to use sport, but also nothing happened. By the way, I can add delay to local host (127.0.0.1) without filters. But when I add filters for ports it doesn't work.

I could not understand where I'm going wrong.

Folani
  • 31
  • 3

0 Answers0