{"id":207,"date":"2013-10-23T21:05:48","date_gmt":"2013-10-23T19:05:48","guid":{"rendered":"http:\/\/www.opencloudblog.com\/?p=207"},"modified":"2021-01-17T13:18:28","modified_gmt":"2021-01-17T12:18:28","slug":"opendaylight-and-openvswitch-session-1","status":"publish","type":"post","link":"https:\/\/www.opencloudblog.com\/?p=207","title":{"rendered":"Opendaylight simple Version and Openvswitch"},"content":{"rendered":"<h1>Openvswitch configuration<\/h1>\n<p>After starting the Opendaylight controller we need a Openflow network device. Linux has one &#8211; the Openvswitch. So we use the Openvswitch.<\/p>\n<pre class=\"lang:sh decode:true\" title=\"Openvswitch configuration\">#\r\n# create a bridge with the name openflow\r\n#\r\novs-vsctl add-br openflow\r\n#\r\n# connect the bridge to the opendaylight openflow controller\r\n#\r\novs-vsctl set-controller openflow tcp:127.0.0.1:6633<\/pre>\n<p>After these to commands, executed as root, the controller has detected a new device. Tab device &#8211;&gt; Node Name. Insert here the node name of the created Openvswitch bridge=switch. We use here Openflow-OVS. Do not change other parameters.<\/p>\n<h2>Network namespaces (VRFs)<\/h2>\n<p>Now we need interfaces on the switch. We use the Linux network namespaces (this is a VRF in Linux) &#8212; you may read the article\u00a0\u00a0<a title=\"Linux Network Namespaces\" href=\"http:\/\/www.opencloudblog.com\/?p=42\" target=\"_blank\" rel=\"noopener\">Linux Network Namespaces<\/a>\u00a0.<\/p>\n<p>We create two network namespaces, two openvswitch ports on our openflow bridge and connect each network namespace to one port. Set the ports in the namespaces to up including the loopback interface.<\/p>\n<pre class=\"lang:sh decode:true\" title=\"Create the test infrastructure\">#\r\n# create the network namespaces\r\n#\r\nip netns add ns1\r\nip netns add ns2\r\n#\r\n# create the openvswitch ports on the openflow bridge\r\n#\r\nBRIDGE=openflow\r\n#\r\n#### PORT 1\r\n# create an internal ovs port\r\novs-vsctl add-port $BRIDGE port1 -- set Interface port1 type=internal\r\n# attach it to namespace\r\nip link set port1 netns ns1\r\n# set the ports to up\r\nip netns exec ns1 ip link set dev port1 up\r\nip netns exec ns1 ip link set dev lo up\r\n#\r\n#### PORT 2\r\n# create an internal ovs port\r\novs-vsctl add-port $BRIDGE port2 -- set Interface port2 type=internal\r\n# attach it to namespace\r\nip link set port2 netns ns2\r\n# set the ports to up\r\nip netns exec ns2 ip link set dev port2 up\r\nip netns exec ns2 ip link set dev lo up<\/pre>\n<p>Now the Opendaylight controller should see two ports on the Openvswitch.<\/p>\n<p>Now go ahead and open two console windows. Connect to a network namespace in each window and set the prompt to avoid confusion.<\/p>\n<pre class=\"lang:sh decode:true \" title=\"Console Sessions\">#\r\n# Console for Network Namespace ns1 -- you must be root!!!\r\n#\r\nip netns exec ns1 bash\r\nexport PS1=\"NS 1&gt;\"\r\n#\r\n######################################\r\n#\r\n# Console in Network Namespace ns2\r\n#\r\nip netns exec ns2 bash\r\nexport PS1=\"NS 2&gt;\"<\/pre>\n<p>Now we configure ip addresses on port* in the network namespaces.<\/p>\n<pre class=\"lang:sh decode:true\" title=\"Interface configuration\">#\r\n# Namespace ns1\r\n#\r\nip addr add dev port1 10.0.0.1\/24\r\n#\r\n################\r\n#\r\n# Namespace ns2\r\n#\r\nip addr add dev port2 10.0.0.2\/24<\/pre>\n<p>Now ping from ns2 to ns1 using the command <strong>ping 10.0.0.1<\/strong>, when you are connected with one console to the namespace ns2 (&#8211;&gt; Console Sessions). Or use <strong>ip netns exec ns2 ping 10.0.0.1<\/strong> when you are connected to the default namespace .<\/p>\n<p>The ping does not work &#8211; the flow entries are missing.<\/p>\n<p>In the test setup, port1 has the mac address ce:8d:86:69:01:6e\u00a0and port2 has the mac address\u00a08e:9b:7d:f4:d7:79<\/p>\n<h2>Create Flow Entries<\/h2>\n<p>The switch does not forward a paket without flow entries. We need to create them using Flows &#8211;&gt; Flow entries &#8211;&gt; Add Flow Entry<\/p>\n<h3>MAC Learning<\/h3>\n<p>How to learn the MAC addresses of connected machines. There is no learning without modules.<\/p>\n<h3>ARP<\/h3>\n<p>Create arp packet forwarding entries. We create several of them. One for ARP broadcasts and one for unicasts.<\/p>\n<p>Name=ARPBcast , Node=Openflow-OVS , EthernetType=0x806 , Destination MAC Address=ff:ff:ff:ff:ff:ff , Actions=Flood<br \/>\nName=ARPUcastp1 , Node=Openflow-OVS , EthernetType=0x806 ,\u00a0Destination MAC Address=ce:8d:86:69:01:6e , Actions=Add Output ports port1(1)<br \/>\nName=ARPUcastp2 , Node=Openflow-OVS , EthernetType=0x806 ,\u00a0Destination MAC Address=8e:9b:7d:f4:d7:79\u00a0, Actions=Add Output ports port2(2)<\/p>\n<h3>\u00a0ICMP<\/h3>\n<p>And allow ICMP flows. We add two flows<\/p>\n<p>Name=ICMPp1 , Node=Openflow-OVS , EthernetType=0x800 ,\u00a0Destination MAC Address=ce:8d:86:69:01:6e , Protocol=icmp , Actions=Add Output ports port1(1)<br \/>\nName=ICMPp2 , Node=Openflow-OVS , EthernetType=0x800 ,\u00a0Destination MAC Address=8e:9b:7d:f4:d7:79\u00a0, Protocol=icmp\u00a0, Actions=Add Output ports port2(2)<\/p>\n<h2>Ping<\/h2>\n<p>Now ping between the network namespaces works. In Opendaylight the flow statistics can be seen in the Tab Troubleshoot &#8211;&gt; Switchname &#8211;&gt; Flows or Ports<\/p>\n<h2>Openvswitch Openflow entries<\/h2>\n<p>The Openflow entries created, are pushed down to the Openvswitch. We can show them using the openvswitch command ovs-ofctl.<\/p>\n<pre class=\"scroll:true lang:default decode:true\" title=\"Openvswitch Openflow Rules\">ovs-ofctl dump-flows openflow\r\nNXST_FLOW reply (xid=0x4):\r\n cookie=0x0, duration=1891.001s, table=0, n_packets=944, n_bytes=39648, idle_age=952, priority=500,arp,dl_dst=ff:ff:ff:ff:ff:ff actions=FLOOD\r\n cookie=0x0, duration=953.765s, table=0, n_packets=3, n_bytes=126, idle_age=714, priority=500,arp,dl_dst=8e:9b:7d:f4:d7:79 actions=output:2\r\n cookie=0x0, duration=1005.787s, table=0, n_packets=1, n_bytes=42, idle_age=714, priority=500,arp,dl_dst=ce:8d:86:69:01:6e actions=output:1\r\n cookie=0x0, duration=9.812s, table=0, n_packets=19, n_bytes=1862, idle_age=0, priority=500,icmp,dl_dst=8e:9b:7d:f4:d7:79 actions=output:2\r\n cookie=0x0, duration=35.442s, table=0, n_packets=70, n_bytes=6860, idle_age=0, priority=500,icmp,dl_dst=ce:8d:86:69:01:6e actions=output:1<\/pre>\n<h1>\u00a0Conclusion<\/h1>\n<p>A MAC leaning mechanism is quite helpful &#8211; such helpers are available in Opendaylight. But we do not use them in this example here.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Openvswitch configuration After starting the Opendaylight controller we need a Openflow network device. Linux has one &#8211; the Openvswitch. So we use the Openvswitch. # # create a bridge with the name openflow # ovs-vsctl add-br openflow # # connect the bridge to the opendaylight openflow controller # ovs-vsctl set-controller openflow tcp:127.0.0.1:6633 After these to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/posts\/207"}],"collection":[{"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=207"}],"version-history":[{"count":26,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":911,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=\/wp\/v2\/posts\/207\/revisions\/911"}],"wp:attachment":[{"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.opencloudblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}