Pages

Tuesday, March 31, 2015

Open vSwitch flows for L2 Switching

All the SDN controllers have pre-written code for L2 switching. However, for this you need to connect the controller to OVS. If the topology is complicated and all you want to achieve is simple L2 forwarding through OVS, we can just install the flows and forget the controller.

Let's understand what flows are required for a simply topology shown below.

 (10.0.0.1)Host----------(port_no=1) OVS (port_no=2)-------Host(10.0.0.2)

Whenever a host tries to ping another machine, it search for a mac-address of the destination in its mac-address cache. If it does not find it, it sends an arp request to the gateway, which may be a router or a switch. In our topology, the first device that is connected to the host is the OVS. So, flows for arp are required which sends the arp request to the correct destination.
For the topology shown above, the arp flows are as follows:

cookie=0x0, duration=7.096s, table=0, n_packets=0, n_bytes=0, idle_age=7, arp,arp_tpa=10.0.0.2 actions=output:2
cookie=0x0, duration=12.818s, table=0, n_packets=0, n_bytes=0, idle_age=12, arp,arp_tpa=10.0.0.1 actions=output:1

The commands to add them are as follows:

ovs-ofctl add-flow s1 arp,nw_dst=10.0.0.1,actions:output=1
ovs-ofctl add-flow s1 arp,nw_dst=10.0.0.2,actions:output=2

After the host gets an arp reply, it saves the mac-address in its arp cache. When we ping to the same destination next time, icmp packets need to be forwarded to the correct destination.

For the topology shown above, the icmp flows are as follows:

cookie=0x0, duration=84.809s, table=0, n_packets=0, n_bytes=0, idle_age=84, in_port=2,dl_dst=00:00:00:00:00:01 actions=output:1
cookie=0x0, duration=93.627s, table=0, n_packets=0, n_bytes=0, idle_age=93, in_port=1,dl_dst=00:00:00:00:00:02 actions=output:2

The commands to add them are as follows:

ovs-ofctl add-flow s1 in_port=1,dl_dst=00:00:00:00:00:02,actions:output=2
ovs-ofctl add-flow s1 in_port=2,dl_dst=00:00:00:00:00:01,actions:output=1

With these four flows you will be able to establish L2 switching between the hosts without the use of controller.