CEG5101 Lab02
CEG5101 Lab02
Laboratory 02
Open Virtual Switch (Open vSwitch)
LEARNING OBJECTIVES
EQUIPMENT
DISCUSSION
Task 1: To become familiar with Open vSwitch and its basic operation
1.2 In this activity, we will start with building a simple network by connecting two end
devices with an Open vSwitch and configuring it in the Mininet GUI.
1.3 Launch MiniEdit on your laptop and start adding devices to the workspace from the
device component bar as shown below.
1.4 Note that there are two types of switches in the device components, i.e. switch and
legacy switch , and both are OpenFlow switches. Only that legacy switch operates
in standalone fail-mode and the other switch operates in secure fail-mode. In this lab,
we use open vswitches.
1.5 Next, using the device properties, assign 10.0.0.1/8 and 10.0.0.2/8 to host h1 and h2,
respectively. Click “Run” to start network operation.
1.6 The next step is to verify Open vSwitch information on the switches.
https://www.openvswitch.org
http://mininet.org/walkthrough/
pg. 1
1.7 Launch a new terminal window and issue the command “sudo ovs-vsctl -V” to check
the installed version of Open vSwitch. Here, ovs-vsctl is ovs-vswitched management
utility that displays available virtual switches and their states.
1.8 Next, we will issue the command “sudo ovs-vsctl list-br” to list all active Open
vSwitches. As we can see in the screenshot below, a switch named s5 is an active Open
vSwitch in this network.
1.9 Next, to verify connectivity and check whether switches are forwarding packets
successfully without the controller, send a ping command from one host to another.
As an example, open the host h1 terminal and issue the command “ping 10.0.0.2”. You
will notice that host h2 is unreachable from hosth1.
1.10 This is because no flow table rules enabled so far. Therefore, in the next activity, we
will implement flow table rules within switches.
2.1 In this activity, we will learn Open Flow protocol and implement flow table entries for
forwarding packets from one host to another. The packet forwarding in Openflow is
performed using packet-matching function.
2.2 Continuing with the same network, as created in step 1.3, open a new terminal and
type “sudo ovs-ofctl add-flow s5 action=normal” to add a flow in switch s5. Here, ovs-
ofctl is the command for monitoring and administering OpenFlow switches.
https://www.openvswitch.org
http://mininet.org/walkthrough/
pg. 2
2.3 To verify whether the flow implementation is successful or not, we can print entries
of the switch by issuing the command “sudo ovs-ofctl dump-flows s5”.
2.4 Once the flows are defined, we can verify the connectivity by sending a ping command
from one host to another.
3.1 In this activity, we will learn to delete existing flows and add flows manually using layer
3 information.
3.2 At first, we will type the following command “sudo ovs-ofctl del-flows s5” to delete
existing flows in switch s5. To verify the deletion of flow, we can try printing flows
again using step 2.3.
3.3 To manually enter flow using layer 3 information, we need the information on port
connectivity, i.e, which port of the switch is connected to which host. This can be
found by issuing the command “net” or “links” on the Mininet terminal.
https://www.openvswitch.org
http://mininet.org/walkthrough/
pg. 3
3.4 To have access to the mininet CLI, before you run the network, go to the edit tab and
then select preferences. Make sure that the “start CLI” box is ticked.
3.5 Next, based on the connection information we have, we will issue following
commands,
$ sudo ovs-ofctl add-flow s5 ip,nw_dst=10.0.0.1,action=output:1
$ sudo ovs-ofctl add-flow s5 ip,nw_dst=10.0.0.2,action=output:2
$ sudo ovs-ofctl add-flow s5 arp,action=normal
Here, the first two commands specify that the traffic for destination address 10.0.0.1
and 10.0.0.2 must be forwarded to switch port number 1 and 2, respectively. The third
command adds a flow to allow ARP requests.
https://www.openvswitch.org
http://mininet.org/walkthrough/
pg. 4
3.6 NOTE: Here, the correct use of IP addresses and the switch ports to which hosts are
connected is important for the success of packet forwarding. The switch will match
against the destination IP address and the traffic going to that destination will be
forwarded to the specified switch port.
3.7 Next, we can verify the packet forwarding with manually entered flows by sending a
ping command from one host to another or by printing the flows with the command
“sudo ovs-ofctl dump-flows s5”.
https://www.openvswitch.org
http://mininet.org/walkthrough/
pg. 5