Learning OVS (open vswitch) using mininet — Part 3

In this post, I am basically going to cover the topic of openflow. I am going to show the flowtable entries which are added by SDN  controller in switch.

Step 1 : I am creating topology using 4 hosts. I have used the –mac option to keep the MAC address simple for the hosts.

root@mininet-vm:~# mn –topo=single,4 –mac
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1) (h3, s1) (h4, s1)
*** Configuring hosts
h1 h2 h3 h4
*** Starting controller
c0
*** Starting 1 switches
s1 …
*** Starting CLI:
mininet> dump
<Host h1: h1-eth0:10.0.0.1 pid=2062>
<Host h2: h2-eth0:10.0.0.2 pid=2065>
<Host h3: h3-eth0:10.0.0.3 pid=2067>
<Host h4: h4-eth0:10.0.0.4 pid=2069>
<OVSSwitch s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None,s1-eth3:None,s1-eth4:None pid=2074>
<Controller c0: 127.0.0.1:6633 pid=2055>
mininet> net
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
h3 h3-eth0:s1-eth3
h4 h4-eth0:s1-eth4
s1 lo:  s1-eth1:h1-eth0 s1-eth2:h2-eth0 s1-eth3:h3-eth0 s1-eth4:h4-eth0
c0

Step 2 : Let’s dump the current port settings on open vSwitch after creating the four hosts. Hosts are connected to different ports on open vswitch. Below output help us to match the port number with the portname. In flowtables we can only see the port number hence this output helps to match port number with port name.

mininet> sh ovs-ofctl dump-ports-desc s1
OFPST_PORT_DESC reply (xid=0x2):
1(s1-eth1): addr:7e:cc:5e:8b:a6:5d
config:     0
state:      0
current:    10GB-FD COPPER
speed: 10000 Mbps now, 0 Mbps max
2(s1-eth2): addr:52:06:cb:a1:c7:2c
config:     0
state:      0
current:    10GB-FD COPPER
speed: 10000 Mbps now, 0 Mbps max
3(s1-eth3): addr:62:9f:a7:47:d5:f0
config:     0
state:      0
current:    10GB-FD COPPER
speed: 10000 Mbps now, 0 Mbps max
4(s1-eth4): addr:8a:0a:6e:fe:13:da
config:     0
state:      0
current:    10GB-FD COPPER
speed: 10000 Mbps now, 0 Mbps max
LOCAL(s1): addr:4a:7a:a0:aa:9a:46
config:     0
state:      0
speed: 0 Mbps now, 0 Mbps max

Step 3 : You can check the statistics of each port using below command.

mininet> sh ovs-ofctl dump-ports s1
OFPST_PORT reply (xid=0x2): 5 ports
port  3: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
tx pkts=0, bytes=0, drop=0, errs=0, coll=0
port  1: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
tx pkts=0, bytes=0, drop=0, errs=0, coll=0
port  4: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
tx pkts=0, bytes=0, drop=0, errs=0, coll=0
port  2: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
tx pkts=0, bytes=0, drop=0, errs=0, coll=0
port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
tx pkts=0, bytes=0, drop=0, errs=0, coll=0

Step 4 : Lets initially print the flow tables. It’s showing nothing as this is a new topology and no host in this topology has tried to connect other hosts.
 
mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):

By the way, if you want to see the controller attached to the switch below command can used to print the information about the controller.

mininet> sh ovs-vsctl get-controller s1
ptcp:6634
tcp:127.0.0.1:6633

Step 5 : Lets create some traffic. We are going to ping h2 host from h1. We can notice first packet has taken more time, because the first packet will follow the path (h1–>s1–>c1–>s1–>h2) and subsequent will follow the path (h1–>s1–>h2)

mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=6.34 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=1.04 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.061 ms
^C
— 10.0.0.2 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.061/2.482/6.340/2.757 ms

Step 6 : Dump the flow table which was created during the first packet. We can see the new ARP rules are added. In the last you are seeing the :1 and :2 these are the port number of the switch, remember the Step 2.

mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=0.027s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=0, priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,arp_spa=10.0.0.1,arp_tpa=10.0.0.2,arp_op=2 actions=output:2
cookie=0x0, duration=5.032s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=5, priority=65535,arp,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01,arp_spa=10.0.0.2,arp_tpa=10.0.0.1,arp_op=2 actions=output:1
cookie=0x0, duration=0.029s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=0, priority=65535,arp,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01,arp_spa=10.0.0.2,arp_tpa=10.0.0.1,arp_op=1 actions=output:1
cookie=0x0, duration=5.031s, table=0, n_packets=3, n_bytes=294, idle_timeout=60, idle_age=3, priority=65535,icmp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,icmp_type=8,icmp_code=0 actions=output:2
cookie=0x0, duration=5.029s, table=0, n_packets=3, n_bytes=294, idle_timeout=60, idle_age=3, priority=65535,icmp,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:1

Step 7 : Similarly ping in reverse direction will add some more flowtable entries.

mininet> h2 ping h1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=2.16 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.937 ms
64 bytes from 10.0.0.1: icmp_seq=3 ttl=64 time=0.068 ms
^C
— 10.0.0.1 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.068/1.057/2.167/0.861 ms

Step 8 : Checking the content of flows in s1.

mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=49.62s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=49, priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,arp_spa=10.0.0.1,arp_tpa=10.0.0.2,arp_op=2 actions=output:2
cookie=0x0, duration=54.625s, table=0, n_packets=2, n_bytes=84, idle_timeout=60, idle_age=0, priority=65535,arp,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01,arp_spa=10.0.0.2,arp_tpa=10.0.0.1,arp_op=2 actions=output:1
cookie=0x0, duration=0.005s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=0, priority=65535,arp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,arp_spa=10.0.0.1,arp_tpa=10.0.0.2,arp_op=1 actions=output:2
cookie=0x0, duration=49.622s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=49, priority=65535,arp,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01,arp_spa=10.0.0.2,arp_tpa=10.0.0.1,arp_op=1 actions=output:1
cookie=0x0, duration=54.624s, table=0, n_packets=3, n_bytes=294, idle_timeout=60, idle_age=52, priority=65535,icmp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,icmp_type=8,icmp_code=0 actions=output:2
cookie=0x0, duration=5.009s, table=0, n_packets=3, n_bytes=294, idle_timeout=60, idle_age=3, priority=65535,icmp,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,icmp_type=8,icmp_code=0 actions=output:1
cookie=0x0, duration=54.622s, table=0, n_packets=3, n_bytes=294, idle_timeout=60, idle_age=52, priority=65535,icmp,in_port=2,vlan_tci=0x0000,dl_src=00:00:00:00:00:02,dl_dst=00:00:00:00:00:01,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:1
cookie=0x0, duration=5.009s, table=0, n_packets=3, n_bytes=294, idle_timeout=60, idle_age=3, priority=65535,icmp,in_port=1,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s