Friday, January 31, 2014

Installing CPqD switch, invoke using Mininet and OpenFlow 1.3 for Communication

Installing CPqD switch on Mininet instead of OVSK.

If OVSK is already installed remove it using below commands


sudo kill `cd /usr/local/var/run/openvswitch && cat ovsdb-server.pid ovs-vswitchd.pid`
sudo /etc/init.d/openvswitch-switch stop
sudo apt-get remove openvswitch-common openvswitch-datapath-dkms openvswitch-controller openvswitch-pki openvswitch-switch


Git clone mininet
Below git command will check out the latest Mininet
git clone git://github.com/mininet/mininet.git

If you want to run the last tagged/released version of Mininet, use
git clone git://github.com/mininet/mininet
git checkout -b 2.1.0 2.1.0

Install CPqD
cd mininet/util
sudo ./install.sh -n3fx

Start CPqD Switch
sudo mn --topo single,2 --controller remote,ip=192.168.1.8 --switch user,protocols=OpenFlow13

CPqD works in User space and OVS works in kernel space.

To get the dpid of CPqD switch
sudo dpctl tcp:127.0.0.1:6634 features

To get the stats and flow rule for CPqD switch:
dpctl tcp:127.0.0.1:6634 stats-flow

dpctl doc
https://github.com/CPqD/ofsoftswitch13/wiki/Dpctl-Documentation

Wednesday, January 29, 2014

ovs-ofctl OVS action commands for OpenFlow 1.3

Add flows to Open vSwitch (OVSK)
Modify VLAN ID on a packet.
mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 "dl_type=0x0800,metadata=12345,cookie=8,table=2,actions=mod_vlan_vid:101"
mininet@mininet-vm104:~$

To list flows added to vSwitch
mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2):
 cookie=0x8, duration=20.959s, table=2, n_packets=0, n_bytes=0, ip,metadata=0x3039 actions=mod_vlan_vid:101
mininet@mininet-vm104:~$

To delete flows
mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 del-flows s1
mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2):
mininet@mininet-vm104:~$

Modify VLAN priority on a packet. Valid values are between 0 (lowest) and 7 (highest).
mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 "dl_type=0x0800,metadata=12345,cookie=8,table=2,priority=100,actions=mod_vlan_pcp:7"
mininet@mininet-vm104:~$
mininet@mininet-vm104:~$
mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1       
OFPST_FLOW reply (OF1.3) (xid=0x2):
 cookie=0x8, duration=4.512s, table=2, n_packets=0, n_bytes=0, priority=100,ip,metadata=0x3039 actions=mod_vlan_pcp:7
mininet@mininet-vm104:~$

mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 "dl_type=0x0800,metadata=12345,cookie=8,table=2,priority=100,actions=push_mpls:0x8847"
mininet@mininet-vm104:~$
mininet@mininet-vm104:~$
mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1       
OFPST_FLOW reply (OF1.3) (xid=0x2):
 cookie=0x8, duration=4.49s, table=2, n_packets=0, n_bytes=0, priority=100,ip,metadata=0x3039 actions=push_mpls:0x8847
mininet@mininet-vm104:~$

IPv4 ToS/DSCP must be a multiple of 4 between 0 and 255.
mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 add-flow s1 "dl_type=0x0800,metadata=12345,cookie=8,table=2,priority=100,actions=mod_dl_src:11:11:11:11:11:11,mod_dl_dst:22:22:22:22:22:22,mod_nw_src=1.1.1.1,mod_nw_dst=2.2.2.2,mod_nw_tos:16"
mininet@mininet-vm104:~$

mininet@mininet-vm104:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1       
OFPST_FLOW reply (OF1.3) (xid=0x2):
 cookie=0x8, duration=3.884s, table=2, n_packets=0, n_bytes=0, priority=100,ip,metadata=0x3039 actions=mod_dl_src:11:11:11:11:11:11,mod_dl_dst:22:22:22:22:22:22,mod_nw_src:1.1.1.1,mod_nw_dst:2.2.2.2,mod_nw_tos:16
mininet@mininet-vm104:~$

For manpage you can refer below link

Thursday, January 23, 2014

ovs-ofctl commands on OpenFlow 1.3 Mininet switch (ovsk)

ovs−ofctl program is a command line tool for monitoring and administering OpenFlow switches. It can also show the current state of an OpenFlow switch, including features, configuration, and table entries. It should work with any OpenFlow switch, not just Open vSwitch.

Before pushing the flows we need to start mininet switch. using below command(also shown in snapshot).
sudo mn --topo single,2 --controller remote,ip=192.168.56.103:6653 --switch ovsk,protocols=OpenFlow13
where,
192.168.56.103 is openflowplugin Controllers IP Address and protocols=OpenFlow13 states that we need to use OpenFlow protocol version 1.3, tcp/6653 is used for OF1.3 communication and 6633 for OF1.0.
Point to note here, Mininet and Controller are running on different Virtual Machines.


 If the above command is successfully executed we should see OF1.3 communication between OVSK(switch s1 here) and SDN Controller.
Flows can be added as
sudo ovs-ofctl -O Openflow13 add-flow s1 in_port=1,actions=nw_ttl:2,output:2

sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=11,dl_type=0x0800,nw_src=10.0.0.1,action=mod_tp_dst:8888

If the above command is successfully configured on OVSK we should successfully dump flows.
mininet@mininet-vm:~$ sudo ovs-ofctl -O OpenFlow13 dump-flows s1
OFPST_FLOW reply (OF1.3) (xid=0x2):
 cookie=0x0, duration=7.443s, table=0, n_packets=0, n_bytes=0, priority=11,ip,nw_src=10.0.0.1 actions=mod_tp_dst:8888


ovs-ofctl connects to an OpenFlow switch using ssl, tcp(ip and port), socket file, unix file etc. ovs-ofctl talks to ovs-vswitchd, and ovs-vsctl talks to ovsdb-server.

Detailed options can be found at
http://openvswitch.org/cgi-bin/ovsman.cgi?page=utilities%2Fovs-ofctl.8