Commit a0bef096 authored by cedgar's avatar cedgar
Browse files

exercise week 6

parent d5866136
This diff is collapsed.
# Quality of Service
To start the topology:
```
sudo ./run_topo.sh
```
to access a host this time you have to use:
```
sudo ip netns exec h1 bash
```
Show discs:
```
tc qdisc show
```
# The Case
In our exercise scenario, there are two hosts connected to the Internet via a single router. We will define some traffic control rules in that router such that the rate of traffic from each of these hosts is controlled and also the different services within each host is prioritized based on their characteristics.
There are five services at each host, their characteristics are as follows:
| Service Name | Requirement | Don't Care |
|-|-|-|
| VoIP | Low latency | Bandwidth |
| Zoom | Low latency, high bandwidth | ----------- |
| Netflix | High bandwidth | Latency |
| SSH | Very low latency | Bandwidth |
| Backup | ----------------- | Latency, bandwidth |
We want to design a traffic classification pipeline such that these five application have the best quality of service possible.
In our scenario, the total bandwidth available to the two hosts are restricted to 10Mbps by the ISP.
TODO (Edgar): We assign x Mbps to SSH, y Mbps to Netflix... also for y Mbps, we assign 90% to h1 and 10% to h2 blabla...
#!/usr/bin/env bash
# limit link badnwdith with HTB
sudo ip netns exec router tc qdisc add dev router-eth3 root handle 1: htb default 1
sudo ip netns exec router tc class add dev router-eth3 parent 1: classid 1:1 htb rate 10Mbit ceil 10Mbit burst 15k
# TASK: define your qdiscs and classes such that the case requirements are met
\ No newline at end of file
#!/usr/bin/env bash
sudo ip netns exec h1 tc qdisc del root dev h1-eth1
sudo ip netns exec h2 tc qdisc del root dev h2-eth1
sudo ip netns exec router tc qdisc del root dev router-eth1
sudo ip netns exec router tc qdisc del root dev router-eth2
sudo ip netns exec router tc qdisc del root dev router-eth3
sudo ip netns exec server tc qdisc del root dev server-eth1
\ No newline at end of file
#!/usr/bin/env bash
# Clean commands
sudo ip netns del h1
sudo ip netns del h2
sudo ip netns del router
sudo ip netns del server
\ No newline at end of file
#!/usr/bin/env bash
# Create namespaces
sudo ip netns add h1
sudo ip netns add h2
sudo ip netns add server
sudo ip netns add router
# enable ip forward at router and isp
sudo ip netns exec router sysctl -w net.ipv4.ip_forward=1
# Bring the loopback interfaces up
sudo ip netns exec h1 ifconfig lo up
sudo ip netns exec h2 ifconfig lo up
sudo ip netns exec server ifconfig lo up
sudo ip netns exec router ifconfig lo up
# Create veth interfaces pairs
sudo ip link add h1-eth1 type veth peer name router-eth1
sudo ip link add h2-eth1 type veth peer name router-eth2
sudo ip link add router-eth3 type veth peer name server-eth1
#declare array of interfaces names
declare -a arr=("h1-eth1" "h2-eth1" "router-eth1" "router-eth2" "router-eth3" "server-eth1")
for intf in "${arr[@]}"
do
#sudo ethtool --offload "$intf" tso off &> /dev/null
#sudo /sbin/ethtool -K "$intf" tso off gso off
#sudo ip link set "$intf" mtu 9500
sudo sysctl net.ipv6.conf.${intf}.disable_ipv6=1
:
done
# Move interface sides to host
sudo ip link set h1-eth1 netns h1
sudo ip link set h2-eth1 netns h2
# home router
sudo ip link set router-eth1 netns router
sudo ip link set router-eth2 netns router
sudo ip link set router-eth3 netns router
# server
sudo ip link set server-eth1 netns server
# Set interface ips
sudo ip netns exec h1 ifconfig h1-eth1 hw ether 00:00:0a:00:01:02 10.0.1.2/24 up
sudo ip netns exec h2 ifconfig h2-eth1 hw ether 00:00:0a:00:02:02 10.0.2.2/24 up
# router
sudo ip netns exec router ifconfig router-eth1 hw ether 00:00:0a:00:01:01 10.0.1.1/24 up
sudo ip netns exec router ifconfig router-eth2 hw ether 00:00:0a:00:02:01 10.0.2.1/24 up
sudo ip netns exec router ifconfig router-eth3 hw ether 00:00:0a:00:03:01 10.0.3.1/24 up
# server
sudo ip netns exec server ifconfig server-eth1 hw ether 00:00:0a:00:03:02 10.0.3.2/24 up
# gateways
sudo ip netns exec h1 route add default gw 10.0.1.1 h1-eth1
sudo ip netns exec h2 route add default gw 10.0.2.1 h2-eth1
sudo ip netns exec server route add default gw 10.0.3.1 server-eth1
\ No newline at end of file
#!/usr/bin/env bash
# Run: $ tmux
# You must run this script in a tmux terminal
function topo {
tmux kill-pane -a -t 0
tmux split-window -h
tmux select-pane -t 0
tmux split-window -v -p 80
tmux select-pane -t 1
tmux split-window -v
tmux select-pane -t 1
tmux split-window -v
tmux select-pane -t 3
tmux split-window -v
# vertical splits
tmux select-pane -t 5
tmux split-window -v -p 80
tmux select-pane -t 6
tmux split-window -v
tmux select-pane -t 6
tmux split-window -v
tmux select-pane -t 8
tmux split-window -v
tmux select-pane -t 0
tmux send "scripts/clean_topo.sh" ENTER
tmux send "scripts/run_topo.sh" ENTER
# SET DEFAULT TC
tmux send "sleep 1; ./class-rate-limit.sh" ENTER
# high priority traffic
tmux select-pane -t 1
tmux send "sleep 2; sudo ip netns exec $1 bash" ENTER
tmux send "sleep 3; ping 10.0.3.2 -i 0.1 -s 500 -Q 1" ENTER
# Voip traffic
tmux select-pane -t 6
tmux send "sleep 2; sudo ip netns exec $1 bash" ENTER
tmux send "sleep 3; ping 10.0.3.2 -i 0.01 -s 1500 -Q 2" ENTER
# video call traffic
tmux select-pane -t 7
tmux send "sleep 2; sudo ip netns exec server bash" ENTER
tmux send "sleep 3; iperf -s -p 7070 -i 1" ENTER
tmux select-pane -t 2
tmux send "sleep 2; sudo ip netns exec $1 bash" ENTER
tmux send "sleep 4; iperf -c 10.0.3.2 -t 500 -i 3 -p 7070" ENTER
# netflix traffic
tmux select-pane -t 8
tmux send "sleep 2; sudo ip netns exec server bash" ENTER
tmux send "sleep 3; iperf -s -p 6789 -i 1" ENTER
tmux select-pane -t 3
tmux send "sleep 2; sudo ip netns exec $1 bash" ENTER
tmux send "sleep 4; iperf -c 10.0.3.2 -t 500 -i 3 -p 6789" ENTER
# backup traffic
tmux select-pane -t 9
tmux send "sleep 2; sudo ip netns exec server bash" ENTER
tmux send "sleep 3; iperf -s -u -p 5000 -i 1" ENTER
tmux select-pane -t 4
tmux send "sleep 2; sudo ip netns exec $1 bash" ENTER
tmux send "sleep 4; iperf -c 10.0.3.2 -t 500 -i 3 -u -b 10M -p 5000" ENTER
}
topo "h1"
\ No newline at end of file
#!/usr/bin/env bash
# Run: $ tmux
# You must run this script in a tmux terminal
function topo {
tmux kill-pane -a -t 0
tmux split-window -h
tmux select-pane -t 0
tmux split-window -v
tmux select-pane -t 2
tmux split-window -v
tmux select-pane -t 1
tmux split-window -v
tmux select-pane -t 4
tmux split-window -v
tmux select-pane -t 0
tmux send "scripts/clean_topo.sh" ENTER
tmux send "scripts/run_topo.sh" ENTER
# SET DEFAULT TC
tmux send "sleep 1; tc-examples/simple-rate-limit.sh" ENTER
tmux select-pane -t 1
tmux send "sleep 2; sudo ip netns exec h1 bash" ENTER
tmux select-pane -t 2
tmux send "sleep 2; sudo ip netns exec h2 bash" ENTER
tmux select-pane -t 4
tmux send "sleep 2; sudo ip netns exec server bash" ENTER
tmux select-pane -t 5
tmux send "sleep 2; sudo ip netns exec server bash" ENTER
tmux select-pane -t 4
tmux send "sleep 3; iperf -s -p 5001 -i 1" ENTER
tmux select-pane -t 5
tmux send "sleep 3; iperf -s -u -p 5002 -i 1" ENTER
tmux select-pane -t 1
tmux send "sleep 4; iperf -c 10.0.3.2 -t 500 -i 3 -p 5001" ENTER
tmux select-pane -t 2
tmux send "sleep 4;iperf -c 10.0.3.2 -t 500 -i 3 -u -b 15M -p 5002" ENTER
}
topo
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment