Software Assignment 4

Due date: 7 April

Goals

Procedure

Link for scripts

Topology creation

Download the updated scripts for this assignment from the link above View the README in that folder on usage instructions for the scripts.

First, create a (4, 4) leaf spine topology with 100 Mbps link as follows. You can modify these parameters for other scenarios.

sudo ./gen_leaf_spine.py 4 4 100

As before, you can SSH to any host. Try this.

ssh 10.0.0.4

Examine the output of the script. The output includes the hosts, links and link capacities in the topology. In this case, the topology is as follows. To enable SSH connections, the scripts creates a link between switch s1 in mininet and root namespace . It configures the IP address of the root namespace to be 10.123.23.1. 

In this assignment, you will need to know the switch port number for each interface on a switch. The figure shows a few switch port numbers. E.g., at switch s1, port  20 is for the interface that connects to the root namespace. The script outputs this mapping for all interfaces. We show the mapping for  s1 below.

*** Switch interface port number mappings
s1
lo :  0
s1-eth1 :  1
s1-eth2 :  2
s1-eth3 :  3
s1-eth4 :  4
s1-eth20 :  20

Default routing rules

There is no default controller in this topology. The script gen_leaf_spine.py explicitly configures OVS routing rules for both SSH connections to hosts from root namespace as well as for routing traffic between the hosts in the topology. The default set of routing rules routes all traffic only via the spine switch s1. You will need to add new rules to route traffic via other spine switches also.

At switch s1, the the following rules are installed to route SSH traffic from root namespace. These rules output IP and ARP traffic destined to IP 10.123.123.1 on switch port 20.

##   switch s1 --> root node
sudo ovs-ofctl add-flow s1 arp,nw_dst=10.123.123.1/32,actions=output:20
sudo ovs-ofctl add-flow s1 ip,nw_dst=10.123.123.1/32,actions=output:20

At spine switch s1, the following rules are installed to route all traffic (including SSH and IPERF) to host h1. These rules output IP and ARP traffic destined to IP 10.0.0.1 on switch port 1. Switch s1 has similar rules to route traffic to other hosts.

## s1 --> host h1
sudo ovs-ofctl add-flow s1 arp,nw_dst=10.0.0.1,actions=output:1
sudo ovs-ofctl add-flow s1 ip,nw_dst=10.0.0.1,actions=output:1

At leaf switch s5, the following rules are installed to route traffic between host h1 and spine switch s1. Other leaf switches have similar rules to route traffic between their hosts and spine s1. Note again that these default rules do not send any traffic to spine switches s2, s3, s4.

sudo ovs-ofctl add-flow s5 priority=100,in_port=1,actions=output:5
sudo ovs-ofctl add-flow s5 priority=100,in_port=5,actions=output:1

Traffic generation

Next, run the traffic generation script  as follows.

mininet@mininet-vm:~/sw4$ ./gen_traffic.py traffic_matrix2
Flow 0    10.0.0.1:10000 --> 10.0.0.2:20000
Flow 1    10.0.0.1:10001 --> 10.0.0.3:20001
Flow 2    10.0.0.1:10002 --> 10.0.0.4:20002
Flow 3    10.0.0.1:10003 --> 10.0.0.2:20003
Flow 4    10.0.0.1:10004 --> 10.0.0.3:20004
Flow 5    10.0.0.1:10005 --> 10.0.0.4:20005
Flow 6    10.0.0.1:10006 --> 10.0.0.2:20006
 Flow 7    10.0.0.1:10007 --> 10.0.0.3:20007
Flow 8    10.0.0.1:10008 --> 10.0.0.4:20008
*** Terminated iperf3 processes.

Output:
-------
Flow 0: 12.8 Mbits/sec
Flow 1: 10.7 Mbits/sec
Flow 2: 12.8 Mbits/sec
Flow 3: 8.72 Mbits/sec
Flow 4: 10.8 Mbits/sec
Flow 5: 10.5 Mbits/sec
Flow 6: 11.2 Mbits/sec
Flow 7: 10.9 Mbits/sec
Flow 8: 11.2 Mbits/sec

Total: 99.62 Mbits/sec

The output shows the IP address and TCP port numbers at both source and destination. For example, Flow 0 is from IP 10.0.0.1 at TCP port number 10000 to IP 10.0.0.2 at TCP port number 20000. In general for a flow i, the script always configures src port to be (10000+i) and for dst port to be (20000 + i).

Note that the total throughput in this case is close to 100 Mbps. Why? This is because all flows in this traffic_matrix2 file are from host h1 to other hosts h2, h3 and h4. Hence these flows are bottlenecked by the capacity of link s5-s1, which is 100 Mbps.

ovs-ofctl basics

Your task is to add new OVS routing rules at leaf and spine switches to implement your custom routing for each flow.  As shown above, you should use the ovs-ofctl command to configure routing rules. Here are some common ovs-ofctl commands. You must refer to manual ovs-ofctl to learn some more commands.
man ovs-ofctl

Show basic info about a switch such has ports, port number, mac etc.

sudo ovs-ofctl show s1


Show list of flows installed in a switch. Note that you also see the number of packets received corresponding to each flow.

mininet@mininet-vm:~/sw4$ sudo ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=5854.818s, table=0, n_packets=1, n_bytes=42, idle_age=5853, arp,arp_tpa=10.0.0.4 actions=output:4
 cookie=0x0, duration=5854.897s, table=0, n_packets=4, n_bytes=168, idle_age=5852, arp,arp_tpa=10.123.123.1 actions=output:20
 cookie=0x0, duration=5854.856s, table=0, n_packets=13473, n_bytes=38735871, idle_age=5841, ip,nw_dst=10.0.0.2 actions=output:2
 cookie=0x0, duration=5854.813s, table=0, n_packets=14332, n_bytes=40256494, idle_age=5841, ip,nw_dst=10.0.0.4 actions=output:4
 cookie=0x0, duration=5854.892s, table=0, n_packets=386, n_bytes=74814, idle_age=5841, ip,nw_dst=10.123.123.1 actions=output:20
 cookie=0x0, duration=5854.861s, table=0, n_packets=1, n_bytes=42, idle_age=5853, arp,arp_tpa=10.0.0.2 actions=output:2
 cookie=0x0, duration=5854.839s, table=0, n_packets=1, n_bytes=42, idle_age=5853, arp,arp_tpa=10.0.0.3 actions=output:3
 cookie=0x0, duration=5854.886s, table=0, n_packets=1, n_bytes=42, idle_age=5852, arp,arp_tpa=10.0.0.1 actions=output:1
 cookie=0x0, duration=5854.88s, table=0, n_packets=40737, n_bytes=2826601, idle_age=5841, ip,nw_dst=10.0.0.1 actions=output:1
 cookie=0x0, duration=5854.834s, table=0, n_packets=13375, n_bytes=37088821, idle_age=5841, ip,nw_dst=10.0.0.3 actions=output:3

Delete all flows at switch s1.
sudo ovs-ofctl del-flows s1 


Custom per-flow routing implementation

The rules for spine switches s2, s3, s4 are similar to s1, except that they do not need rules for SSH connection to root namespace. 

You will customize the per-flow routing by installing rules at leaf switches. For this purpose, OVS allows flows to be matched on additional fields, including TCP source and destination port numbers. Read the section "Flow Syntax" in the man page for ovs-ofctl: man ovs-ofctl.

Remember that TCP connections are bi-directional so you will need to install rules for both the traffic the forward and the reverse directions.

Your custom rules at leaf switches must have a higher priority than 100 so that they are matched before the default routing rules.

Debugging tips.

Evaluation scenarios

Submission instructions