Set classes of traffic in high_throughput_limits
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 17 Dec 2012 17:13:38 +0000 (12:13 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 17 Dec 2012 17:49:06 +0000 (12:49 -0500)
This patch creates 2 classes for the bandwidth limited test instead of
one. The intent is to have multiple queues in the kernel instead of just
one. That way we can prioritize the control port over the data port and
make sure it gets its share of the bandwidth.

With this update, the control port gets 1/10th of the limit and the data
get the remaining 9/10th. If unused, the data connection can borrow the
remaining bandwidth.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
tests/tools/streaming/high_throughput_limits

index 0e71ad04d926268ca23eff2a10e6d95cd62c5dc8..ebe5020a69f5bcee1419bbc7dba06fd9b97aac9b 100755 (executable)
@@ -49,13 +49,27 @@ fi
 function set_bw_limit
 {
        limit=$1
-       echo -n "Setting bandwidth limits to ${limit}kbits... "
+       ctrlportlimit=$(($limit/10))
+       # failsafe to have at least 1kbit/s for control (in the case where $1 < 10)
+       [ $ctrlportlimit = 0 ] && ctrlportlimit=1
+       # if $1 < 10, we might bust the limit set here, but the
+       # parent qdisc (1:) will always limit us to the right max value
+       dataportlimit=$((9*${ctrlportlimit}))
+
+       echo -n "Setting bandwidth limits to ${limit}kbits, (${ctrlportlimit} for control and ${dataportlimit} for data)... "
        tc qdisc add dev $DEFAULT_IF root handle 1: htb default 15 >/dev/null 2>&1
-       tc class add dev $DEFAULT_IF parent 1: classid 1:1 htb rate ${limit}kbit ceil ${limit}kbit >/dev/null 2>&1
-
-       tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_CTRL_PORT 0xffff flowid 1:1 >/dev/null 2>&1
 
-       tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_DATA_PORT 0xffff flowid 1:1 >/dev/null 2>&1
+       # the total bandwidth is the limit set by the user
+       tc class add dev $DEFAULT_IF parent 1: classid 1:1 htb rate ${limit}kbit ceil ${limit}kbit >/dev/null 2>&1
+       # 1/10 of the bandwidth guaranteed and traffic prioritized for the control port
+       tc class add dev $DEFAULT_IF parent 1:1 classid 1:10 htb rate ${ctrlportlimit}kbit ceil ${limit}kbit prio 1 >/dev/null 2>&1
+       # 9/10 of the bandwidth guaranteed and can borrow up to the total bandwidth (if unused)
+       tc class add dev $DEFAULT_IF parent 1:1 classid 1:11 htb rate ${dataportlimit}kbit ceil ${limit}kbit prio 2 >/dev/null 2>&1
+
+       # filter to assign control traffic to the 1:10 class
+       tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_CTRL_PORT 0xffff flowid 1:10 >/dev/null 2>&1
+       # filter to assign data traffic to the 1:11 class
+       tc filter add dev $DEFAULT_IF parent 1: protocol ip u32 match ip dport $SESSIOND_DATA_PORT 0xffff flowid 1:11 >/dev/null 2>&1
        print_ok
 }
 
This page took 0.026593 seconds and 5 git commands to generate.