Learning OVS (open vswitch) using mininet — Part 4

Continuing in the series, in previous post we have seen how the SDN controller is adding the flowtable entries in the vswitch. In this post I am going to show you some more details on the same topic.

Step 1 : First I am going to delete the existing entries present in switch and verifying that no entry is present in it.

mininet> sh ovs-ofctl del-flows s1
mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):

Step 2 : Lets start the tcpdump in backgound and then start the ping from h1 to h2.

a) Starting tcpdump in background.

mininet@mininet-vm:~$ sudo tcpdump -s0 -i lo -w /tmp/h1pingh2.pcap &
[1] 2484
mininet@mininet-vm:~$ tcpdump: listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes

b) Initiate a ping from h1 to 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=2.57 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=2.17 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.265 ms
64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=0.060 ms
^C
— 10.0.0.2 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 0.060/1.268/2.574/1.118 ms

c) Kill the tcpdump background process.

mininet@mininet-vm:~$ sudo kill 2484
21 packets captured
42 packets received by filter
0 packets dropped by kernel
[1]+  Done                    sudo tcpdump -s0 -i lo -w /tmp/h1pingh2.pcap

Step 3 : Dump the flow tables which are added on switch. Okay we can see that four flow tables are added.

mininet> sh ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=42.955s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=42, 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=42.957s, table=0, n_packets=1, n_bytes=42, idle_timeout=60, idle_age=42, 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=46.958s, table=0, n_packets=3, n_bytes=294, idle_timeout=60, idle_age=44, 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=47.959s, table=0, n_packets=4, n_bytes=392, idle_timeout=60, idle_age=44, 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 4 : Opening the tcpdump captured in Step 2. I have applied the filter of OF (openflow) traffic to keep the output precise. Basically we are looking for that info only.

mininet@mininet-vm:~$ tshark -tad -n -r /tmp/h1pingh2.pcap -Y of
1 2015-09-18 10:12:23.071616    127.0.0.1 -> 127.0.0.1    OF 1.0 74 of_echo_request
2 2015-09-18 10:12:23.071967    127.0.0.1 -> 127.0.0.1    OF 1.0 74 of_echo_reply
4 2015-09-18 10:12:25.594213     10.0.0.1 -> 10.0.0.2     OF 1.0 182 of_packet_in
5 2015-09-18 10:12:25.595114    127.0.0.1 -> 127.0.0.1    OF 1.0 90 of_packet_out
7 2015-09-18 10:12:25.595604     10.0.0.2 -> 10.0.0.1     OF 1.0 182 of_packet_in
8 2015-09-18 10:12:25.596331    127.0.0.1 -> 127.0.0.1    OF 1.0 146 of_flow_add
10 2015-09-18 10:12:26.597366     10.0.0.1 -> 10.0.0.2     OF 1.0 182 of_packet_in
11 2015-09-18 10:12:26.597788    127.0.0.1 -> 127.0.0.1    OF 1.0 146 of_flow_add
13 2015-09-18 10:12:30.598132 00:00:00:00:00:02 -> 00:00:00:00:00:01 OF 1.0 126 of_packet_in
14 2015-09-18 10:12:30.598557    127.0.0.1 -> 127.0.0.1    OF 1.0 146 of_flow_add
16 2015-09-18 10:12:30.600227 00:00:00:00:00:01 -> 00:00:00:00:00:02 OF 1.0 126 of_packet_in
17 2015-09-18 10:12:30.600544    127.0.0.1 -> 127.0.0.1    OF 1.0 146 of_flow_add
19 2015-09-18 10:12:35.070848    127.0.0.1 -> 127.0.0.1    OF 1.0 74 of_echo_request
20 2015-09-18 10:12:35.071205    127.0.0.1 -> 127.0.0.1    OF 1.0 74 of_echo_reply

If you look closely in above output, we can see that Frame 8,11,14, and 17 has added the flow tables in the switch; remember in step 3 also we have seen the four flow tables while dumping the switch table entries.

Opening the frame 8 which has added first entry in switch. It contain various important values.

mininet@mininet-vm:~$ tshark -tad -n -r /tmp/h1pingh2.pcap -O of -Y ‘of && frame.number  == 8’
Frame 8: 146 bytes on wire (1168 bits), 146 bytes captured (1168 bits)
Ethernet II, Src: 00:00:00:00:00:00 (00:00:00:00:00:00), Dst: 00:00:00:00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1 (127.0.0.1)
Transmission Control Protocol, Src Port: 6633 (6633), Dst Port: 60705 (60705), Seq: 33, Ack: 241, Len: 80
OpenFlow
version: 1
type: OFPT_FLOW_MOD (14)
length: 80
xid: 0
of_match
wildcards: 0x0000000000000000
in_port: 2
eth_src: 00:00:00:00:00:02 (00:00:00:00:00:02)
eth_dst: 00:00:00:00:00:01 (00:00:00:00:00:01)
vlan_vid: 65535
vlan_pcp: 0
eth_type: 2048
ip_dscp: 0
ip_proto: 1
ipv4_src: 10.0.0.2 (10.0.0.2)
ipv4_dst: 10.0.0.1 (10.0.0.1)
tcp_src: 0
tcp_dst: 0
cookie: 0
_command: 0
idle_timeout: 60
hard_timeout: 0
priority: 0
buffer_id: 270
out_port: 0
flags: Unknown (0x00000000)
of_action list
of_action_output
type: OFPAT_OUTPUT (0)
len: 8
port: 1
max_len: 0

Step 5 : After few minutes again I tried to ping the h2 from h1, first reply again took more time which was not expected because this time our path of traffic should be (h1–>s1–>h2) instead of (h1–>s1–>c1–>s1–>h2) in step 1.

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=3.43 ms   <<<<
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=2.59 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.303 ms
^C
— 10.0.0.2 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.303/2.112/3.436/1.325 ms

Because of idle_timeout value flowtables added after step1 are automatically purged and new tables are added after Step 5. I verified the same in tcpdump as well.

Step 6 : Again with in few seconds, I pinged h2 from h1 this time first reply didn’t take much time because the flowtables were already present, confirmed the same in tcpdump output that no of_flow_add has been seen this time.

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=0.898 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.067 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.039 ms
64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=0.068 ms
^C
— 10.0.0.2 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 0.039/0.268/0.898/0.363 ms

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