WikiStart: DataPathElementConfig.html

File DataPathElementConfig.html, 9.1 KB (added by andy, 5 years ago)
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5  <meta http-equiv="Content-Style-Type" content="text/css" />
6  <meta name="generator" content="pandoc" />
7  <title>SDN / OpenFlow tutorial</title>
8  <style type="text/css">code{white-space: pre;}</style>
9  <link rel="stylesheet" href="./style.css" type="text/css" />
10</head>
11<body>
12<div id="header">
13<h1 class="title">SDN / OpenFlow tutorial</h1>
14<h3 class="date">DataPath Element Config</h3>
15</div>
16<h1 id="introduction">Introduction</h1>
17<p>In 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.</p>
18<h1 id="goals">Goals</h1>
19<ul>
20<li>Connect to Datapath Element</li>
21<li>Start Open vSwitch</li>
22<li>Connect to Controller</li>
23</ul>
24<h1 id="notes">Notes</h1>
25<ul>
26<li>Commands preceded with &quot;$&quot; imply that you should execute the command as a general user - not as root.</li>
27<li>Commands preceded with &quot;#&quot; imply that you should be working as root.</li>
28<li>Commands with more specific command lines (e.g. &quot;RTR-GW&gt;&quot; or &quot;mysql&gt;&quot;) imply that you are executing commands on remote equipment, or within another program.</li>
29</ul>
30<h1 id="installation">Installation</h1>
31<h2 id="installing-telnet">Installing telnet</h2>
32<p>To 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</p>
33<pre><code>$ sudo apt-get install telnet</code></pre>
34<h2 id="telnet-to-your-datapath-element">Telnet to your datapath element</h2>
35<pre><code>$ telnet 10.10.0.1XX
36Trying 10.10.0.1XX...
37Connected to 10.10.0.1XX.
38Escape character is &#39;^]&#39;.
39 === IMPORTANT ============================
40  Use &#39;passwd&#39; to set your login password
41  this will disable telnet and enable SSH
42 ------------------------------------------
43
44
45BusyBox v1.15.3 (2013-12-28 17:47:54 NZDT) built-in shell (ash)
46Enter &#39;help&#39; for a list of built-in commands.
47
48  _______                     ________        __
49 |       |.-----.-----.-----.|  |  |  |.----.|  |_
50 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
51 |_______||   __|_____|__|__||________||__|  |____|
52          |__| W I R E L E S S   F R E E D O M
53 ---------------------------------------------------
54 Backfire (10.03.x Snapshot, r33081)
55 ---------------------------------------------------
56  * 1/3 shot Kahlua    In a shot glass, layer Kahlua
57  * 1/3 shot Bailey&#39;s  on the bottom, then Bailey&#39;s,
58  * 1/3 shot Vodka     then Vodka.
59 ---------------------------------------------------
60root@SDNX:/# </code></pre>
61<h2 id="creating-a-boot-script">Creating a boot script</h2>
62<p>Change to the root users home directory</p>
63<pre><code># cd</code></pre>
64<p>Start editing the following file</p>
65<pre><code># vi bootovs-rb532.sh</code></pre>
66<p>Enter in the following information being careful to change the top three variables to suit your number in class</p>
67<pre><code>#Setup variables
68#My IP address is required for the ovsdb server.
69MYIP=10.10.0.1XX 
70
71# This is the OpenFlow controller ID which we&#39;re going to load into the OVS
72CTLIP=10.10.0.X
73
74# This is our DataPath ID
75DPID=00000000000000XX
76
77# This is the name of the bridge that we&#39;re going to be creating
78SW=br0
79
80#What ports are we going to put in the OVS?
81DPPORTS=&quot;eth0 eth1&quot;
82
83#Alias some variables
84VSCTL=&quot;ovs-vsctl --db=tcp:$MYIP:9999&quot;
85OVSDB=/tmp/ovs-vswitchd.conf.db
86
87# Subroutine to wait until a port is ready
88wait_port_listen() {
89    port=$1
90    while ! `netstat -na | grep $port` ; do
91        echo -n .
92        sleep 1
93    done
94}
95
96# Kill off the servers and remove any stale lockfiles
97/usr/bin/killall ovsdb-server
98/usr/bin/killall ovs-vswitchd
99rm /tmp/.ovs-vswitchd.conf.db.~lock~
100
101# Remove the OVS Database and then recreate.
102rm -f $OVSDB
103ovsdb-tool create $OVSDB /usr/share/openvswitch/vswitch.ovsschema
104
105# Start the OVSDB server and wait until it starts
106ovsdb-server $OVSDB --remote=ptcp:9999:$MYIP &amp;
107#wait_port_listen 9999
108sleep 5
109
110# Start vSwitchd
111ovs-vswitchd tcp:$MYIP:9999 --pidfile=ovs-vswitchd.pid --overwrite-pidfile -- &amp;
112
113# Create the bridge and pass in some configuration options
114$VSCTL add-br $SW -- set bridge $SW datapath_type=netdev
115$VSCTL set bridge $SW datapath_type=netdev
116$VSCTL set bridge $SW protocols=OpenFlow13
117
118#Cycle through the DataPath ports adding them to the switch
119for i in $DPPORTS ; do
120    PORT=$i
121        ifconfig $PORT up
122    $VSCTL add-port $SW $PORT
123done
124
125#Ensure that the switch has the correct DataPath ID
126$VSCTL set bridge $SW other-config:datapath-id=$DPID
127
128#Configure the switch to have an OpenFlow Controller.  This will contact the controller.
129$VSCTL set-controller $SW tcp:$CTLIP:6633</code></pre>
130<p>Make the file executable</p>
131<pre><code># chmod 755 /root/bootovs-rb532.sh</code></pre>
132<p>Edit the startup script to start this by default</p>
133<pre><code># vi /etc/rc.local</code></pre>
134<p>Change the file to look like this.</p>
135<pre><code># Put your custom commands here that should be executed once
136# the system init finished. By default this file does nothing.
137/root/bootovs-rb532.sh
138exit 0</code></pre>
139<h2 id="creating-a-flow-monitor-script">Creating a flow monitor script</h2>
140<p>Start editing the following file</p>
141<pre><code># cd
142# vi monitor_flows.sh</code></pre>
143<p>Put the following information into that file</p>
144<pre><code>#!/bin/ash
145
146clear
147while true
148do
149        date
150        ovs-ofctl -O OpenFlow13 dump-flows br0
151        sleep 5
152        clear
153done</code></pre>
154<p>Make the file executable</p>
155<pre><code>    # chmod 755 /root/monitor_flows.sh</code></pre>
156<h1 id="running-the-bootscript">Running the bootscript</h1>
157<p>Even 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.</p>
158<p>Here is an example below</p>
159<pre><code># /root/bootovs-rb532.sh
1602014-01-28T03:05:18Z|00001|ovsdb_server|INFO|ovsdb-server (Open vSwitch) 2.0.0
1612014-01-28T03:05:23Z|00001|reconnect|INFO|tcp:10.10.0.101:9999: connecting...
1622014-01-28T03:05:23Z|00002|reconnect|INFO|tcp:10.10.0.101:9999: connected
1632014-01-28T03:05:23Z|00003|bridge|INFO|bridge br0: added interface br0 on port 65534
1642014-01-28T03:05:23Z|00004|dpif_linux|ERR|Generic Netlink family &#39;ovs_datapath&#39; does not exist. The Open vSwitch kernel module is probably not loaded.
1652014-01-28T03:05:23Z|00005|bridge|INFO|bridge br0: using datapath ID 0000ee25de8f4343
1662014-01-28T03:05:23Z|00006|connmgr|INFO|br0: added service controller &quot;punix:/var/run/br0.mgmt&quot;
1672014-01-28T03:05:23Z|00007|bridge|INFO|ovs-vswitchd (Open vSwitch) 2.0.0
1682014-01-28T03:05:24Z|00008|connmgr|INFO|br0: re-added service controller &quot;punix:/var/run/br0.mgmt&quot;
1692014-01-28T03:05:24Z|00009|bridge|INFO|bridge br0: added interface eth0 on port 1
1702014-01-28T03:05:24Z|00010|bridge|INFO|bridge br0: using datapath ID 0000000c42065803
1712014-01-28T03:05:25Z|00011|bridge|INFO|bridge br0: added interface eth1 on port 2
1722014-01-28T03:05:25Z|00012|bridge|INFO|bridge br0: using datapath ID 0000000000000001
1732014-01-28T03:05:25Z|00013|connmgr|INFO|br0: added primary controller &quot;tcp:10.10.0.4:6633&quot;
1742014-01-28T03:05:25Z|00014|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: connecting...
1752014-01-28T03:05:26Z|00015|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: connection timed out
1762014-01-28T03:05:26Z|00016|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: waiting 1 seconds before reconnect
1772014-01-28T03:05:27Z|00017|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: connecting...
1782014-01-28T03:05:28Z|00018|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: connection timed out
1792014-01-28T03:05:28Z|00019|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: waiting 2 seconds before reconnect
1802014-01-28T03:05:28Z|00002|memory|INFO|1440 kB peak resident set size after 10.2 seconds
1812014-01-28T03:05:28Z|00003|memory|INFO|cells:200 monitors:1 sessions:1
1822014-01-28T03:05:30Z|00020|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: connecting...
1832014-01-28T03:05:32Z|00021|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: connection timed out
1842014-01-28T03:05:32Z|00022|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: waiting 4 seconds before reconnect
1852014-01-28T03:05:33Z|00023|memory|INFO|1720 kB peak resident set size after 10.2 seconds
1862014-01-28T03:05:33Z|00024|memory|INFO|facets:2 ofconns:1 ports:3 rules:10 subfacets:2
1872014-01-28T03:05:36Z|00025|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: connecting...
1882014-01-28T03:05:39Z|00026|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: connection failed (No route to host)
1892014-01-28T03:05:39Z|00027|rconn|INFO|br0&lt;-&gt;tcp:10.10.0.4:6633: continuing to retry connections in the background but suppressing further logging
1902014-01-28T03:05:40Z|00028|fail_open|WARN|Could not connect to controller (or switch failed controller&#39;s post-connection admission control policy) for 15 seconds, failing open</code></pre>
191<p>You can see that in this case OVS is trying and failing to contact the OpenFlow controller. We will fix this in a later lab.</p>
192<p>--End</p>
193</body>
194</html>