18 | | |
19 | | == Step 2. Configure and Initialize == |
20 | | |
21 | | Although OVS is installed and initialized on the host that is meant to act as a software switch, it has not been configured yet. |
22 | | There are two main things that need to be configured: ''(1) configure your software switch with the interfaces as ports'' and '' (2) point the switch to an !OpenFlow controller''. |
23 | | |
24 | | In order to configure our switch, we first need to login to the host that will be used as an !OpenFlow switch. |
| 18 | == Step 3. Execute Experiment == |
| 19 | |
| 20 | Now that the switch is up and running we are ready to start working on the controller. For this tutorial we are going to use the [http://www.noxrepo.org/pox/about-pox/ POX controller]. The software is already installed in the controller host for running POX and can also be found [http://www.gpolab.bbn.com/experiment-support/OpenFlowOVS/of-ovs.tar.gz here]. |
| 21 | |
| 22 | === 3a. Login to your hosts === |
| 23 | |
| 24 | To start our experiment we need to ssh all of our hosts. |
33 | | Depending on which tool and OS you are using there is a slightly different process for logging in. If you don't know how to SSH to your reserved hosts take a look in [wiki:HowTo/LoginToNodes this page.] |
34 | | |
35 | | === 2a. Configure the Software Switch (OVS Window) === |
36 | | |
37 | | Now that you are logged in, we need first to configure OVS. To save time in this tutorial, we have already started OVS and we have added an Ethernet bridge that will act as our software switch. Try the following to show the configure bridge: |
38 | | {{{ |
39 | | sudo ovs-vsctl list-br |
40 | | }}} |
41 | | You should see only on bridge `br0`. Now we need to add the interfaces to this bridge that will act as ports of our software switch. |
42 | | |
43 | | {{{ |
44 | | #!html |
45 | | <table border="0"> |
46 | | <tr > |
47 | | <td width = "500"> |
48 | | <ol> |
49 | | <li>List all the interfaces of the node |
50 | | <ul> <li> <code>ifconfig</code> </ul><br/> |
51 | | Write down the interface names that correspond to the connections to your hosts. The correspondence is: |
52 | | <ul> |
53 | | <li> Interface with IP 10.10.1.11 to host1 - ethX</li> |
54 | | <li> Interface with IP 10.10.1.12 to host2 - ethY</li> |
55 | | <li> Interface with IP 10.10.1.13 to host3 - ethZ</li> |
56 | | </ul></li> |
57 | | </li> <br/> |
58 | | <li> Be careful <b> not to bring down eth0</b>. This is your control interface, if you bring that interface down you <b> won't be able to login</b> to your host!. For all interfaces other than <code>eth0</code> and <code> l0</code>, remove the IP from the interfaces (your interface names may vary): <br/> |
59 | | <ul><li> <code> sudo ifconfig ethX 0 </code> </li></ul> |
60 | | <ul><li> <code> sudo ifconfig ethY 0 </code> </li></ul> |
61 | | <ul><li> <code> sudo ifconfig ethZ 0 </code> </li></ul> |
62 | | <li> Add all the data interfaces to your switch (bridge):Be careful <b> not to add interface eth0</b>. This is your control interface. You should see three interfaces that start with VLAN, these are your data interfaces. (Use the same interfaces as you used in the previous step.) |
63 | | <ul><li> <code> sudo ovs-vsctl add-port br0 ethX </code> </li></ul> |
64 | | <ul><li> <code> sudo ovs-vsctl add-port br0 ethY </code> </li></ul> |
65 | | <ul><li> <code> sudo ovs-vsctl add-port br0 ethZ </code> </li></ul> |
66 | | </li> |
67 | | </ol> |
68 | | </td> |
69 | | <td> |
70 | | <img border="0" src="http://groups.geni.net/geni/attachment/wiki/GENIExperimenter/Tutorials/OpenflowOVS/Graphics/ovs-interfaces.jpg?format=raw" alt="Login information for a VM" height="250" title="Login information for a VM" /> </a> |
71 | | </td> |
72 | | </tr> |
73 | | </table> |
74 | | }}} |
| 33 | Depending on which tool and OS you are using there is a slightly different process for logging in. If you don't know how to SSH to your reserved hosts learn [wiki:HowTo/LoginToNodes how to login.] Once you have logged in follow the rest of the instructions. |
| 34 | |
| 35 | === 3b. Use a Learning Switch Controller === |
| 36 | |
| 37 | In this example we are going to run a very simple learning switch controller to forward traffic between `host1` and `host2`. |
76 | | Congratulations! You have configured your software switch. To verify the three ports configured run: |
77 | | {{{ |
78 | | sudo ovs-vsctl list-ports br0 |
79 | | }}} |
80 | | |
81 | | === 2c. Point your switch to a controller === |
82 | | |
83 | | In the controller window, find the control interface IP of your controller, use ifconfig and note down the IP of `eth0`. |
84 | | |
85 | | An !OpenFlow switch will not forward any packet, unless instructed by a controller. Basically the forwarding table is empty, until an external controller inserts forwarding rules. The !OpenFlow controller communicates with the switch over the control network and it can be anywhere in the Internet as long as it is reachable by the OVS host. For the purpose of this tutorial and in order to minimize the resources we have reserved we are going to run !OpenFlow controller at the same host as the OVS switch. This is '''merely''' for convenience reasons, the controller could have been anywhere on the Internet. |
86 | | |
87 | | In order to point our software !OpenFlow switch to the controller, in the ovs window, run: |
88 | | {{{ |
89 | | sudo ovs-vsctl set-controller br0 tcp:<controller_ip>:6633 |
90 | | }}} |
91 | | |
92 | | ==== `standalone` vs `secure` mode ==== |
93 | | |
94 | | The !OpenFlow controller is responsible for setting up all flows on the switch, which means that when the controller is not running there should be no packet switching at all. Depending on the setup of your network, such a behavior might not be desired. It might be best that when the controller is down, the switch should default back in being a learning layer 2 switch. In other circumstances however this might be undesirable. In OVS this is a tunable parameter, called `fail-safe-mode` which can be set to the following parameters: |
95 | | * `standalone` [default]: in which case OVS will take responsibility for forwarding the packets if the controller fails |
96 | | * `secure`: in which case only the controller is responsible for forwarding packets, and if the controller is down all packets are going to be dropped. |
97 | | |
98 | | In OVS when the parameter is not set it falls back to the `standalone` mode. For the purpose of this tutorial we will set the `fail-safe-mode` to `secure`, since we want to be the ones controlling the forwarding. Run: |
99 | | {{{ |
100 | | sudo ovs-vsctl set-fail-mode br0 secure |
101 | | }}} |
102 | | You can verify your OVS settings by issuing the following: |
103 | | |
104 | | {{{ |
105 | | sudo ovs-vsctl show |
106 | | }}} |
107 | | |
108 | | == Step 3. Execute Experiment == |
109 | | |
110 | | Now that our switch is up and running we are ready to start working on our controller. For this tutorial we are going to use the [http://www.noxrepo.org/pox/about-pox/ POX controller]. The software is already installed in the controller host for running POX and can also be found [http://www.gpolab.bbn.com/experiment-support/OpenFlowOVS/of-ovs.tar.gz here]. |
111 | | |
112 | | === 3a. Login to your hosts === |
113 | | |
114 | | To start our experiment we need to ssh all of our hosts. Depending on which tool and OS you are using there is a slightly different process for logging in. If you don't know how to SSH to your reserved hosts take a look in [wiki:HowTo/LoginToNodes this page.] Once you have logged in follow the rest of the instructions. |
115 | | |
116 | | === 3b. Use a Learning Switch Controller === |
117 | | |
118 | | In this example we going to run a very simple learning switch controller to forward traffic between host1 and host2. |
119 | | |
120 | | 1. First we are going to start a ping from `host1` to `host2`, which should timeout, since there is no controller running. |
121 | | {{{ |
122 | | ping host2 -c 10 |
123 | | }}} |
124 | | |
125 | | 2. We have installed the POX controller under `/tmp/pox` on the controller host. POX comes with a set of example modules that you can use out of the box. One of the modules is a learning switch. Let's start the learning switch controller which is already available: |
126 | | {{{ |
127 | | cd /tmp/pox |
128 | | ./pox.py --verbose forwarding.l2_learning |
129 | | |
| 39 | 1. First start a ping from `host1` to `host2`, which should timeout, since there is no controller running. |
| 40 | |
| 41 | {{{ |
| 42 | ping host2 -c 10 |
| 43 | }}} |
| 44 | |
| 45 | 2. We have installed the POX controller under `/tmp/pox` on the controller host. POX comes with a set of example modules that you can use out of the box. One of the modules is a learning switch. Start the learning switch controller which is already available by running the following two commands: |
| 46 | |
| 47 | {{{ |
| 48 | cd /tmp/pox |
| 49 | ./pox.py --verbose forwarding.l2_learning |
| 50 | }}} |
| 51 | |
| 52 | The output should look like this: |
| 53 | {{{ |
141 | | '' Note: "l2" above uses the letter `l` as in level and is not the number one. And you should wait for the '''INFO ... connected''' line to ensure that the switch and the controller are communicating.''[[BR]] |
142 | | |
143 | | '' Note: In the event that you need to move the port of your controller, this is the command - sudo ./pox.py --verbose openflow.of_01 --port=443 forwarding.l2_learning - Do not forget to tell the ovs switch that the controller will be listening on this new port, i.e change 6633 to 443 in Step 2c.'' |
144 | | |
145 | | 3. Now go to terminal of `host1` and ping `host2`: |
| 65 | {{{ |
| 66 | #!html |
| 67 | |
| 68 | <table id="Table_01" border="0" cellpadding="5" cellspacing="0"> |
| 69 | <tr> |
| 70 | <td> |
| 71 | <img src="http://trac.gpolab.bbn.com/gcf/raw-attachment/wiki/Graphics/4NotesIcon_512x512.png" width="50" height="50" alt="Note"> |
| 72 | </td> |
| 73 | <td>"l2" above uses the letter `l` as in level and is not the number one. And you should wait for the '''INFO ... connected''' line to ensure that the switch and the controller are communicating. |
| 74 | </td> |
| 75 | </tr> |
| 76 | </table> |
| 77 | }}} |
| 78 | |
| 79 | |
| 80 | {{{ |
| 81 | #!html |
| 82 | |
| 83 | <table id="Table_01" border="0" cellpadding="5" cellspacing="0"> |
| 84 | <tr> |
| 85 | <td> |
| 86 | <img src="http://trac.gpolab.bbn.com/gcf/raw-attachment/wiki/Graphics/4NotesIcon_512x512.png" width="50" height="50" alt="Note"> |
| 87 | </td> |
| 88 | <td>In the event that you need to move the port of your controller, this is the command - |
| 89 | <pre> |
| 90 | sudo ./pox.py --verbose openflow.of_01 --port=443 forwarding.l2_learning |
| 91 | </pre> |
| 92 | Do not forget to tell the ovs switch that the controller will be listening on this new port, i.e change 6633 to 443 in Step 2c. |
| 93 | </td> |
| 94 | </tr> |
| 95 | </table> |
| 96 | }}} |
| 97 | |
| 98 | 3. In the terminal of `host1`, ping `host2`: |
161 | | 4. Go back to your OVS host and take a look at the print outs. You should see that your controller installed flows based on the mac addresses of your packets. |
162 | | |
163 | | 5. To see the flow table entries on your OVS switch: |
164 | | {{{ |
165 | | sudo ovs-ofctl dump-flows br0 |
| 114 | 4. If you are using OVS, go back to your OVS host and take a look at the print outs. You should see that your controller installed flows based on the mac addresses of your packets. |
| 115 | |
| 116 | {{{ |
| 117 | #!html |
| 118 | |
| 119 | <table id="Table_01" border="0" cellpadding="5" cellspacing="0"> |
| 120 | <tr> |
| 121 | <td> |
| 122 | <img src="http://trac.gpolab.bbn.com/gcf/raw-attachment/wiki/Graphics/4NotesIcon_512x512.png" width="50" height="50" alt="Note"> |
| 123 | </td> |
| 124 | <td>There is no way to get this information from the OpenFlow-capable hardware switch. |
| 125 | </td> |
| 126 | </tr> |
| 127 | </table> |
| 128 | }}} |
| 129 | |
| 130 | 5. If you are using OVS, to see the flow table entries on your OVS switch: |
| 131 | {{{ |
| 132 | sudo ovs-ofctl dump-flows br0 |
259 | | When the wireshark window pops up, you might still have to choose eth0 for a live capture. And you will want to use a filter to cut down on the chatter in the wireshark window. One such filter might be just seeing what shows up on port 6633, so to do that type ''tcp.port eq 6633'' in the filter window, assuming that 6633 is the port that the controller is |
260 | | listening on. And once you have lines, you can choose one of the lines and choose "Decode as ...." and choose the OFP protocol. |
| 226 | When the wireshark window pops up, you might still have to choose eth0 for a live capture. And you will want to use a filter to cut down on the chatter in the wireshark window. One such filter might be just seeing what shows up on port 6633. To do that type ''tcp.port eq 6633'' in the filter window, assuming that 6633 is the port that the controller is |
| 227 | listening on. And once you have lines, you can choose one of the lines and choose "Decode as ...." and choose the ''OFP protocol''. |
267 | | * Software Switch (OVS): If you haven't note them down you can use the manifest and the MAC address of the interfaces (ovs:if1 and ovs:if2) to figure this out. Run tcpdump on these interfaces; one in each of the two ovs terminals you opened. This will allow you to see all traffic going out the interfaces. |
268 | | * Hardware Switch: Refer to this Section to figure out ports: [http://groups.geni.net/geni/wiki/GENIExperimenter/Tutorials/OpenFlowOVS/Appendix#Usefultips UsefulTips]. If you are using a hardware switch, you may not see the traffic on host3, but if you observe your controller output, you will notice that flows are being installed for forwarding to host2 and host3.[[BR]] |
269 | | To see that duplication is happening, on host3, run: |
270 | | {{{ |
271 | | sudo tcpdump -i <data_interface_name> |
| 234 | * Software Switch (OVS): If you have not noted them down you can use the manifest and the MAC address of the interfaces (ovs:if1 and ovs:if2) to figure this out. But you should have noted down the interfaces in Section 2 when you were configuring the software switch. Run tcpdump on these interfaces; one in each of the two ovs terminals you opened. This will allow you to see all traffic going out the interfaces. |
| 235 | * Hardware Switch: Refer to this Section to figure out ports: [http://groups.geni.net/geni/wiki/GENIExperimenter/Tutorials/OpenFlowHW/DesignSetup#a2a.ConfiguretheControllerfortheHardwareSwitch:UsefulTips UsefulTips]. If you are using a hardware switch, you may not see the traffic on host3, but if you observe your controller output, you will notice that flows are being installed for forwarding to host2 and host3.[[BR]] |
| 236 | |
| 237 | To see that duplication is happening, on host3, run: |
| 238 | {{{ |
| 239 | sudo tcpdump -i <data_interface_name> |