summaryrefslogtreecommitdiff
path: root/polux/application/iproute2/examples/sarft/tc_skript
diff options
context:
space:
mode:
Diffstat (limited to 'polux/application/iproute2/examples/sarft/tc_skript')
-rwxr-xr-xpolux/application/iproute2/examples/sarft/tc_skript31
1 files changed, 31 insertions, 0 deletions
diff --git a/polux/application/iproute2/examples/sarft/tc_skript b/polux/application/iproute2/examples/sarft/tc_skript
new file mode 100755
index 0000000000..528221008c
--- /dev/null
+++ b/polux/application/iproute2/examples/sarft/tc_skript
@@ -0,0 +1,31 @@
+#! /bin/sh
+
+# First delete root qdisc and ebtables rules if they exists
+# If they not exists error message will appear but it is not important.
+tc qdisc del dev plc0 root handle 1:
+ebtables --init-table
+
+# Create the root HTB queuing discipline on plc interface plc0
+tc qdisc add dev plc0 root handle 1: htb default 12
+
+# Now we create root class 1:1. The rate parameter establishes the minimum bandwidth and ceil parametar
+# establishes the maximum bandwidth that will be permitted by the queuing discipline.
+tc class add dev plc0 parent 1: classid 1:1 htb rate 30Mbit ceil 30Mbit burst 300k
+
+# Now we create the class 1:10 to control flows to the A network (packets with destination MAC 00:04:98:02:00:18)
+# and the class 1:11 to control flows to the B network (all others packets).
+# If we want to guarante that network A will have 5Mbit bandwidth, network B need to have
+# guarante bandwidth of 25 Mbit in this example.
+tc class add dev plc0 parent 1:1 classid 1:10 htb rate 5Mbit ceil 10Mbit burst 300k
+tc class add dev plc0 parent 1:1 classid 1:11 htb rate 25Mbit ceil 30Mbit burst 300k
+
+# tc filter will place packets with mark 1 to class 1:10, and
+# place packets with mark 2 to class 1:11
+tc filter add dev plc0 parent 1: protocol all handle 1 fw classid 1:10
+tc filter add dev plc0 parent 1: protocol all handle 2 fw classid 1:11
+
+# ebtables will set mark to 1 for all packets with destination MAC 00:04:98:02:00:18
+# and set mark 2 to all others.
+ebtables -A FORWARD -d 00:04:98:02:00:18 -j mark --set-mark 1 --mark-target ACCEPT
+ebtables -A FORWARD -j mark --set-mark 2 --mark-target ACCEPT
+