I have a 1Gb network and I need to run certain TCP performance tests by limiting the rate to 100MB and then 1Gb. My understanding is that hierarchical token bucket (htb) can be used to achieve this as shown below
tc qdisc add dev eth0 root handle 1: htb default 12
tc class add dev eth0 parent 1: classid 1:1 htb rate 1gbps ceil 1gbps
tc class add dev eth0 parent 1: classid 1:10 htb rate 100mbps ceil 100mbps
This should create two root classes 1:1 and 1:10, with 1gb and 100mb bandwidth respectively. Please correct me if my understanding is wrong.
Next, how do i use the above classes in my tcp application? For example when i run my application, which should use only 100 Mb, do i need to specify something in socket options, such that any messages sent by the application now belong to class 1:1 and hence get rate limited to 100 Mb?