WikiStart: DataPathElementConfig.md

File DataPathElementConfig.md, 7.8 KB (added by andy, 5 years ago)
Line 
1% SDN / OpenFlow tutorial
2%
3% DataPath Element Config
4
5# Introduction
6
7In this lab we will connect to our datapath element and perform the necessary steps to ensure that it is running Open vSwitch and can connect to our controller.
8
9# Goals
10
11* Connect to Datapath Element
12* Start Open vSwitch
13* Connect to Controller
14
15# Notes
16
17* Commands preceded with "$" imply that you should execute the command as
18  a general user - not as root.
19* Commands preceded with "#" imply that you should be working as root.
20* Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>")
21  imply that you are executing commands on remote equipment, or within
22  another program.
23
24# Installation
25
26## Installing telnet
27
28To connect to the datapath element from your controller you will need to install telnet on your VM.  Alternatively you can telnet directly from your laptop
29
30    $ sudo apt-get install telnet
31
32
33## Telnet to your datapath element
34
35
36
37        $ telnet 10.10.0.1XX
38        Trying 10.10.0.1XX...
39        Connected to 10.10.0.1XX.
40        Escape character is '^]'.
41         === IMPORTANT ============================
42          Use 'passwd' to set your login password
43          this will disable telnet and enable SSH
44         ------------------------------------------
45   
46   
47        BusyBox v1.15.3 (2013-12-28 17:47:54 NZDT) built-in shell (ash)
48        Enter 'help' for a list of built-in commands.
49   
50          _______                     ________        __
51         |       |.-----.-----.-----.|  |  |  |.----.|  |_
52         |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
53         |_______||   __|_____|__|__||________||__|  |____|
54                  |__| W I R E L E S S   F R E E D O M
55         ---------------------------------------------------
56         Backfire (10.03.x Snapshot, r33081)
57         ---------------------------------------------------
58          * 1/3 shot Kahlua    In a shot glass, layer Kahlua
59          * 1/3 shot Bailey's  on the bottom, then Bailey's,
60          * 1/3 shot Vodka     then Vodka.
61         ---------------------------------------------------
62        root@SDNX:/#
63
64
65## Creating a boot script
66
67Change to the root users home directory
68
69    # cd
70
71Start editing the following file
72
73    # vi bootovs-rb532.sh
74
75Enter in the following information being careful to change the top three variables to suit your number in class
76
77
78        #Setup variables
79        #My IP address is required for the ovsdb server.
80        MYIP=10.10.0.1XX 
81   
82        # This is the OpenFlow controller ID which we're going to load into the OVS
83        CTLIP=10.10.0.X
84   
85        # This is our DataPath ID
86        DPID=00000000000000XX
87   
88        # This is the name of the bridge that we're going to be creating
89        SW=br0
90   
91        #What ports are we going to put in the OVS?
92        DPPORTS="eth0 eth1"
93   
94        #Alias some variables
95        VSCTL="ovs-vsctl --db=tcp:$MYIP:9999"
96        OVSDB=/tmp/ovs-vswitchd.conf.db
97   
98        # Subroutine to wait until a port is ready
99        wait_port_listen() {
100            port=$1
101            while ! `netstat -na | grep $port` ; do
102                echo -n .
103                sleep 1
104            done
105        }
106   
107        # Kill off the servers and remove any stale lockfiles
108        /usr/bin/killall ovsdb-server
109        /usr/bin/killall ovs-vswitchd
110        rm /tmp/.ovs-vswitchd.conf.db.~lock~
111   
112        # Remove the OVS Database and then recreate.
113        rm -f $OVSDB
114        ovsdb-tool create $OVSDB /usr/share/openvswitch/vswitch.ovsschema
115   
116        # Start the OVSDB server and wait until it starts
117        ovsdb-server $OVSDB --remote=ptcp:9999:$MYIP &
118        #wait_port_listen 9999
119        sleep 5
120   
121        # Start vSwitchd
122        ovs-vswitchd tcp:$MYIP:9999 --pidfile=ovs-vswitchd.pid --overwrite-pidfile -- &
123   
124        # Create the bridge and pass in some configuration options
125        $VSCTL add-br $SW -- set bridge $SW datapath_type=netdev
126        $VSCTL set bridge $SW datapath_type=netdev
127        $VSCTL set bridge $SW protocols=OpenFlow13
128   
129        #Cycle through the DataPath ports adding them to the switch
130        for i in $DPPORTS ; do
131            PORT=$i
132                ifconfig $PORT up
133            $VSCTL add-port $SW $PORT
134        done
135   
136        #Ensure that the switch has the correct DataPath ID
137        $VSCTL set bridge $SW other-config:datapath-id=$DPID
138   
139        #Configure the switch to have an OpenFlow Controller.  This will contact the controller.
140        $VSCTL set-controller $SW tcp:$CTLIP:6633
141
142Make the file executable
143
144        # chmod 755 /root/bootovs-rb532.sh
145
146Edit the startup script to start this by default       
147
148        # vi /etc/rc.local
149
150Change the file to look like this.
151
152        # Put your custom commands here that should be executed once
153        # the system init finished. By default this file does nothing.
154        /root/bootovs-rb532.sh
155        exit 0
156
157
158##  Creating a flow monitor script
159
160Start editing the following file
161
162    # cd
163        # vi monitor_flows.sh
164
165Put the following information into that file
166
167        #!/bin/ash
168   
169        clear
170        while true
171        do
172                date
173                ovs-ofctl -O OpenFlow13 dump-flows br0
174                sleep 5
175                clear
176        done
177
178
179Make the file executable
180
181                # chmod 755 /root/monitor_flows.sh
182
183
184
185# Running the bootscript
186
187Even if the script has been started at boot time it's ok to start it from the command line.  The script will kill any existing instances of the daemons.
188
189Here is an example below
190
191        # /root/bootovs-rb532.sh
192        2014-01-28T03:05:18Z|00001|ovsdb_server|INFO|ovsdb-server (Open vSwitch) 2.0.0
193        2014-01-28T03:05:23Z|00001|reconnect|INFO|tcp:10.10.0.101:9999: connecting...
194        2014-01-28T03:05:23Z|00002|reconnect|INFO|tcp:10.10.0.101:9999: connected
195        2014-01-28T03:05:23Z|00003|bridge|INFO|bridge br0: added interface br0 on port 65534
196        2014-01-28T03:05:23Z|00004|dpif_linux|ERR|Generic Netlink family 'ovs_datapath' does not exist. The Open vSwitch kernel module is probably not loaded.
197        2014-01-28T03:05:23Z|00005|bridge|INFO|bridge br0: using datapath ID 0000ee25de8f4343
198        2014-01-28T03:05:23Z|00006|connmgr|INFO|br0: added service controller "punix:/var/run/br0.mgmt"
199        2014-01-28T03:05:23Z|00007|bridge|INFO|ovs-vswitchd (Open vSwitch) 2.0.0
200        2014-01-28T03:05:24Z|00008|connmgr|INFO|br0: re-added service controller "punix:/var/run/br0.mgmt"
201        2014-01-28T03:05:24Z|00009|bridge|INFO|bridge br0: added interface eth0 on port 1
202        2014-01-28T03:05:24Z|00010|bridge|INFO|bridge br0: using datapath ID 0000000c42065803
203        2014-01-28T03:05:25Z|00011|bridge|INFO|bridge br0: added interface eth1 on port 2
204        2014-01-28T03:05:25Z|00012|bridge|INFO|bridge br0: using datapath ID 0000000000000001
205        2014-01-28T03:05:25Z|00013|connmgr|INFO|br0: added primary controller "tcp:10.10.0.4:6633"
206        2014-01-28T03:05:25Z|00014|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting...
207        2014-01-28T03:05:26Z|00015|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection timed out
208        2014-01-28T03:05:26Z|00016|rconn|INFO|br0<->tcp:10.10.0.4:6633: waiting 1 seconds before reconnect
209        2014-01-28T03:05:27Z|00017|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting...
210        2014-01-28T03:05:28Z|00018|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection timed out
211        2014-01-28T03:05:28Z|00019|rconn|INFO|br0<->tcp:10.10.0.4:6633: waiting 2 seconds before reconnect
212        2014-01-28T03:05:28Z|00002|memory|INFO|1440 kB peak resident set size after 10.2 seconds
213        2014-01-28T03:05:28Z|00003|memory|INFO|cells:200 monitors:1 sessions:1
214        2014-01-28T03:05:30Z|00020|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting...
215        2014-01-28T03:05:32Z|00021|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection timed out
216        2014-01-28T03:05:32Z|00022|rconn|INFO|br0<->tcp:10.10.0.4:6633: waiting 4 seconds before reconnect
217        2014-01-28T03:05:33Z|00023|memory|INFO|1720 kB peak resident set size after 10.2 seconds
218        2014-01-28T03:05:33Z|00024|memory|INFO|facets:2 ofconns:1 ports:3 rules:10 subfacets:2
219        2014-01-28T03:05:36Z|00025|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting...
220        2014-01-28T03:05:39Z|00026|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection failed (No route to host)
221        2014-01-28T03:05:39Z|00027|rconn|INFO|br0<->tcp:10.10.0.4:6633: continuing to retry connections in the background but suppressing further logging
222        2014-01-28T03:05:40Z|00028|fail_open|WARN|Could not connect to controller (or switch failed controller's post-connection admission control policy) for 15 seconds, failing open
223
224You can see that in this case OVS is trying and failing to contact the OpenFlow controller.  We will fix this in a later lab.
225
226--End