I am a newbie network engineer.
I am trying to understand the Linux command tc
.
I made a simple network, consisting of two hosts H1, H2 and a switch S1 connecting them by using Mininet.
Then, I made H1 send UDP packets to H2, through switch S1 by using iPerf2
.
#H1
iperf -s -p 1212 -f m -i 1
#H2
iperf -c 10.0.0.1 -p 1212 -t 10000 -f m -b 70M -u
For limiting the link bandwidth, I made a simple bash script below.
#!/bin/bash
#s1-eth1 is outgoing port from H1 to H2
#its orginal bandwidth 100Mbit/s
sudo tc qdisc del dev s1-eth1 root
sudo tc qdisc add dev s1-eth1 root handle 1:0 htb default 12
sudo tc qdisc add dev s1-eth1 parent 1:0 classid 1:1 htb rate 50Mbit
sudo tc filter add deb s1-eth1 protocol ip parent 1:0 prio 1 u32 match ip dport 1212 0xffff flowid 1:1
I expected that the rx rate of S1 became 50Mbit/s but it didn't.
It showed about 40Mbit/s.
When I changed the settings of this experiment, it showed a smaller value than I set by using the tc
command.
Why did it happen? I looked over the kernel code of Linux tc
but I cannot understand it.
Could you give me a little hint?