http://www.opencloudblog.com/?p=207
1)
create a bridge/ovs-switch with the name openflow
#sudo ovs-vsctl add-br openflow
2)
List all controllers
#sudo ovs-vsctl list controller
3)
Connect the bridge/ovs-switch to the opendaylight openflow controller
#ovs-vsctl set-controller openflow tcp:127.0.0.1:6633
Note:
Howto install Opendaylight openflow SDN controller
http://fosshelp.blogspot.in/2014/10/howto-install-opendaylight-sdn.html
4)
Show/Describe all bridges/ovs-switches
#sudo ovs-vsctl show
Bridge openflow
Controller "tcp:127.0.0.1:6633"
is_connected: true
Port openflow
Interface openflow
type: internal
Note:
* controller endpoint 127.0.0.1:6633
* Bridge : openflow
* Local Port : openflow and its interface : openflow
5)
List all controllers
#sudo ovs-vsctl list controller
_uuid : 00a28fc5-acb3-4166-9198-f597b80f2457
connection_mode : []
controller_burst_limit: []
controller_rate_limit: []
enable_async_messages: []
external_ids : {}
inactivity_probe : []
is_connected : true
local_gateway : []
local_ip : []
local_netmask : []
max_backoff : []
other_config : {}
role : other
status : {sec_since_connect="7374", state=ACTIVE}
target : "tcp:127.0.0.1:6633"
Note:
* Status should be like : status : {sec_since_connect="117", state=ACTIVE}
6)
Goto the controller (OpenDaylight)
Goto http://controller-ip:8080/#devices
There you should able to see the newly added ovs-switch/bridge under "Nodes Learned".
Note:
http://fosshelp.blogspot.com/2014/10/howto-install-opendaylight-sdn.html
7)
Create the test infrastructure
7a)
Create 2 Namespaces
#sudo ip netns add ns1
#sudo ip netns add ns2
7b)
Create first internal ovs port "ovs-port1" with interface "ovs-port1" in our OpenvSwitch/bridge "openflow"
#sudo ovs-vsctl add-port openflow ovs-port1 -- set Interface ovs-port1 type=internal
* Name of the port and interface should be same
7b1)
List ports and interfaces in the OpenvSwitch "openflow"
#sudo ovs-vsctl show
Bridge openflow
Controller "tcp:127.0.0.1:6633"
is_connected: true
Port "ovs-port1"
Interface "ovs-port1"
type: internal
Port openflow
Interface openflow
type: internal
7b2)
Attach OpenvSwitch port "ovs-port1" to namespace "ns1"
#sudo ip link set ovs-port1 netns ns1
* Run "#ifconfig -a" in "ns1" namespace to see "ovs-port1" interface.
* Example:#sudo ip netns exec ns1 ifconfig -a
#sudo ip netns exec ns1 ifconfig -a
lo Link encap:Local Loopback
LOOPBACK MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ovs-port1 Link encap:Ethernet HWaddr b2:3c:e9:7c:cb:06
BROADCAST MTU:1500 Metric:1
RX packets:16 errors:0 dropped:16 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1568 (1.5 KB) TX bytes:648 (648.0 B)
7b3)
Set the interfaces in the namespace "ns1" to up
#sudo ip netns exec ns1 ip link set dev ovs-port1 up
#sudo ip netns exec ns1 ip link set dev lo up
Note:
*Check the status of interfaces "lo" and "ovs-port1" in the namespace "ns1"
#sudo ip netns exec ns1 ifconfig -a
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ovs-port1 Link encap:Ethernet HWaddr b2:3c:e9:7c:cb:06
inet6 addr: fe80::b03c:e9ff:fe7c:cb06/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:16 errors:0 dropped:16 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1568 (1.5 KB) TX bytes:1226 (1.2 KB)
7c)
Create second internal ovs port "ovs-port2" with interface "ovs-port2" in our OpenvSwitch/bridge "openflow"
#sudo ovs-vsctl add-port openflow ovs-port2 -- set Interface ovs-port2 type=internal
* Name of the port and interface should be same
7c1)
List ports and interfaces in the OpenvSwitch "openflow"
#sudo ovs-vsctl show
Bridge openflow
Controller "tcp:127.0.0.1:6633"
is_connected: true
Port "ovs-port1"
Interface "ovs-port1"
type: internal
Port openflow
Interface openflow
type: internal
Port "ovs-port2"
Interface "ovs-port2"
type: internal
7c2)
Attach OpenvSwitch port "ovs-port2" to namespace "ns2"
#sudo ip link set ovs-port2 netns ns2
* Run "#ifconfig -a" in "ns2" namespace to see "ovs-port2" interface.
* Example:#sudo ip netns exec ns2 ifconfig -a
#sudo ip netns exec ns2 ifconfig -a
lo Link encap:Local Loopback
LOOPBACK MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ovs-port2 Link encap:Ethernet HWaddr ce:ae:15:19:e2:16
BROADCAST MTU:1500 Metric:1
RX packets:3 errors:0 dropped:3 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:294 (294.0 B) TX bytes:648 (648.0 B)
7c3)
Set the interfaces in the namespace "ns2" to up
#sudo ip netns exec ns2 ip link set dev ovs-port2 up
#sudo ip netns exec ns2 ip link set dev lo up
Note:
*Check the status of interfaces "lo" and "ovs-port2" in the namespace "ns2"
#sudo ip netns exec ns2 ifconfig -a
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
ovs-port2 Link encap:Ethernet HWaddr ce:ae:15:19:e2:16
inet6 addr: fe80::ccae:15ff:fe19:e216/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:3 errors:0 dropped:3 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:294 (294.0 B) TX bytes:1296 (1.2 KB)
7d)
Check the newly created ports in OpenDaylight Controller
Goto http://controller-ip:8080/#devices and find your switch/node and click on "Ports" link
7e)
Assign IP address to the interfaces "ovs-port1" in the namespace "ns1 and "ovs-port2" in the namespace "ns2" and ping from "ns1" to "ns2".
7e1)
Assign IP address to the interface "ovs-port1" in the namespace "ns1".
#sudo ip netns exec ns1 ip addr add 10.1.1.4/24 dev ovs-port1
7e2)
Assign IP address to the interface "ovs-port2" in the namespace "ns2".
#sudo ip netns exec ns2 ip addr add 10.1.1.5/24 dev ovs-port2
7e3)
Check the IP address of the interfaces "ovs-port1" and "ovs-port2"
#sudo ip netns exec ns1 ifconfig -a ovs-port1
#sudo ip netns exec ns2 ifconfig -a ovs-port2
#sudo ip netns exec ns1 ifconfig -a ovs-port1
ovs-port1 Link encap:Ethernet HWaddr b2:3c:e9:7c:cb:06
inet addr:10.1.1.4 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::b03c:e9ff:fe7c:cb06/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:16 errors:0 dropped:16 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1568 (1.5 KB) TX bytes:1296 (1.2 KB)
#sudo ip netns exec ns2 ifconfig -a ovs-port2
ovs-port2 Link encap:Ethernet HWaddr ce:ae:15:19:e2:16
inet addr:10.1.1.5 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::ccae:15ff:fe19:e216/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:3 errors:0 dropped:3 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:294 (294.0 B) TX bytes:1296 (1.2 KB)
* You should see the IP for the interfaces "ovs-port1" and "ovs-port2"
7f)
Ping from "ns1" to "ns2".
#sudo ip netns exec ns1 ping 10.1.1.5
PING 10.1.1.5 (10.1.1.5) 56(84) bytes of data.
From 10.1.1.4 icmp_seq=1 Destination Host Unreachable
From 10.1.1.4 icmp_seq=2 Destination Host Unreachable
* The ping does not work – the flow entries are missing.
* This ping will add a flow entry to OpenvSwitch "openflow" which tells that if any packet comes with "nw_dst=10.1.1.4" forward to the OpenvSwitch port "ovs-port1".You can see the MAC address on the OpenvSwitch port "ovs-port1" in the flow entry.
* Because of the entry, ping will work, if you ping from "ns2" to "ns1" like #sudo ip netns exec ns2 ping 10.1.1.4.
7f1)
Goto http://controller-ip:8080/#devices and check the Graph
* You can see the graph with OpenvSwitch "openflow" and interface "ovs-port1" from namespace "ns1" connected to it.
7f2)
Dump flows from OpenvSwitch "openflow"
#sudo ovs-ofctl dump-flows openflow
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=341.337s, table=0, n_packets=0, n_bytes=0, idle_age=341, priority=1,ip,nw_dst=10.1.1.4 actions=mod_dl_dst:da:cf:0d:90:c0:53,output:1
* This means that if any packet comes with "nw_dst=10.1.1.4" forward to the OpenvSwitch port "ovs-port1". You can see the MAC address on the OpenvSwitch port "ovs-port1" in the flow entry.
* Note nw_dst=10.1.1.4 and actions=mod_dl_dst:da:cf:0d:90:c0:53
http://www.opencloudblog.com/?p=207
ReplyDelete1)
##Create a OpenvSwitch named "openflow" and set controller
sudo ovs-vsctl add-br openflow
sudo ovs-vsctl set-controller openflow tcp:127.0.0.1:6633
##Create 2 Namespaces
sudo ip netns add ns1
sudo ip netns add ns2
##Create an OpenvSwitch port and attach to namespace "ns1" and set up and assign IP
sudo ovs-vsctl add-port openflow ovs-port1 -- set Interface ovs-port1 type=internal
sudo ip link set ovs-port1 netns ns1
sudo ip netns exec ns1 ip link set dev ovs-port1 up
sudo ip netns exec ns1 ip link set dev lo up
sudo ip netns exec ns1 ip addr add 10.1.1.4/24 dev ovs-port1
##Create another OpenvSwitch port and attach to namespace "ns2" and set up and assign IP
sudo ovs-vsctl add-port openflow ovs-port2 -- set Interface ovs-port2 type=internal
sudo ip link set ovs-port2 netns ns2
sudo ip netns exec ns2 ip link set dev ovs-port2 up
sudo ip netns exec ns2 ip link set dev lo up
sudo ip netns exec ns2 ip addr add 10.1.1.5/24 dev ovs-port2
##Goto http://controller-ip:8080/#devices and check the Nodes List and Graph
##Dump flows from the OpenvSwitch "openflow"
sudo ovs-ofctl dump-flows openflow
##Dump flows from datapath (kernal)
sudo ovs-dpctl dump-flows
##Ping from "ns1" to "ns2".
sudo ip netns exec ns1 ping 10.1.1.5
#OUTPUT: From 10.1.1.4 icmp_seq=1 Destination Host Unreachable
#* This will add a flow entry, Please check #sudo ovs-ofctl dump-flows openflow
##Ping from "ns2" to "ns1".
sudo ip netns exec ns2 ping 10.1.1.4
#OUTPUT: 64 bytes from 10.1.1.4: icmp_seq=1 ttl=64 time=1.20 ms
#* This will add another flow entry, Please check #sudo ovs-ofctl dump-flows openflow
##Ping from "ns1" to "ns2" again.
sudo ip netns exec ns1 ping 10.1.1.5
#OUTPUT: 64 bytes from 10.1.1.5: icmp_seq=1 ttl=64 time=6.27 ms
#* This time ping will work since flow table has entry for 2 ports
2)
#Delete Namespaces and OpenvSwitch
sudo ip netns del ns1
sudo ip netns del ns2
sudo ovs-vsctl del-br openflow
This comment has been removed by the author.
ReplyDeleteanyone has idea on how to install ovs switch on ns2. I want to implement aodv on top of ovs
ReplyDeleteIs Binance puzzle captcha not working properly in your Binance account? Are you looking for solutions to end all worries and carry on the process of Binance trading without any discontinuity? If you don’t know how to deal with such issues and looking for solution, you can always call on Binance customer care number which is functional all the time. The team is always ready to support you and helps you in every possible way that help in eliminating your trouble in no time. Save your time and get tested solutions from the skilled professionals who’re ready to support you.
ReplyDelete