Changes between Initial Version and Version 1 of GENIExperimenter/Tutorials/OpenFlowNFVNAT


Ignore:
Timestamp:
11/20/15 14:05:45 (7 years ago)
Author:
nriga@bbn.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GENIExperimenter/Tutorials/OpenFlowNFVNAT

    v1 v1  
     1[[PageOutline]]
     2= OpenFlow NAT Router =
     3
     4{{{
     5#!html
     6<table border="0" >
     7 <tr>
     8    <td width="350" valign="top">
     9<h3 align="left"> <u>Overview: </u> </h3>
     10In this tutorial you will learn <b> how to build a router for a network with a private address space that needs a one-to-many NAT </b> (IP Masquerade) using OpenFlow. We will use the following network topology for this experiment. You will also learn how to <b> take advantage of kernel L3 routing while using OVS </b>. 
     11<img border="0" src="http://www.gpolab.bbn.com/experiment-support/NFVApps/GENI-NFV-NAT.png" alt="route topology"  align="center" width="350" title="nat topology" />
     12
     13</td>
     14 <td> <pre>   </pre> </td>
     15    <td width="350" valign="top">
     16<h3 align="left"> <u>Prerequisites: </u></h3>
     17 For this tutorial you need :
     18   <ul>
     19       <li> <b> access to the <a href="https://portal.geni.net"> GENI Experimenter Portal </a></b> and be a <b> member of a GENI project </b>. <br/>Please see the <a href="http://groups.geni.net/geni/wiki/SignMeUp"> Sign Me Up page for more information. </a></li>
     20       <li> <b>be familiar with reserving resources in GENI based on an rspec</b>. <br/>If you are not familiar you should first do the <a href="http://groups.geni.net/geni/wiki/GENIExperimenter/Tutorials/RunHelloGENI"> Hello GENI </a> or <a href="http://groups.geni.net/geni/wiki/GENIEducation/SampleAssignments/LabZero/Procedure"> Lab Zero </a> </li>
     21       <li>  be familiar with <b><a href="http://groups.geni.net/geni/wiki/HowTo/LoginToNodes" > logging in to GENI resources </a> </b> </li>
     22       <li> be familiar with <b> OpenFlow concepts </b> </li>
     23   </ul>
     24
     25    </td>
     26  </tr>
     27  <tr>
     28    <td width="350" valign="top">
     29<h3 align="left"> <u>Tools: </u></h3>
     30All the tools will already be installed at your nodes. For your reference we are going to use <b>a Ryu controller</b>.
     31     </td>
     32 <td> <pre>   </pre> </td>
     33    <td width="350" valign="top">
     34    <h3 align="left"> <u>Where to get help: </u></h3>
     35      For any questions or problem with the tutorial please email <a href="mailto:geni-users@googlegroups.com?Subject=Help%20with%20HelloGENI%20tutorial"> geni-users@googlegroups.com </a>
     36    </td>
     37  </tr>
     38</table>
     39}}}
     40----
     41
     42{{{
     43#!html
     44<table  border="0" cellpadding="0" cellspacing="0">
     45  <tr>
     46     <td valign="top" align="left">
     47        <img src="http://groups.geni.net/geni/attachment/wiki/GENIExperimenter/Tutorials/Graphics/design.png?format=raw" width="150" alt="Design/Setup"></a>
     48      </td>
     49      <td>
     50         <h3> If you have already reserved the topology from a previous tutorial you can move to Execute. </h3>
     51         <h3><u>1. Verify your Environment Setup: </u></h3>
     52   This exercise assumes you have already setup your account at the GENI Portal. In particular ensure that:
     53   <ol>
     54      <li> You can login to the <a href="https://portal.geni.net"> GENI Portal </a></li>
     55      <li> You are a member of a GENI Project (there is at least one project listed under the <a href="https://portal.geni.net/secure/projects.php">''Projects''</a> tab) </li>
     56      <li> You have setup your ssh keys (there is at least one key listed under the <a href="https://portal.geni.net/secure/profile.php#ssh">''Profile->SSH Keys''</a> tab) </li>
     57    </ol>
     58<h3><u> 2. Setup the Topology: </u></h3>
     59   <ol>
     60      <li> Login to the <a href="https://portal.geni.net"> GENI Portal </a> </li>
     61       <li> Reserve:
     62           <ol type='a'>
     63            <li>  the topology from an InstaGENI rack using the <a href="http://www.gpolab.bbn.com/experiment-support/OpenFlowOVS/openflowovs-all-xen.rspec.xml"> OpenFlow OVS all XEN </a> RSpec (In Portal: "OpenFlow OVS all XEN"; URL: http://www.gpolab.bbn.com/experiment-support/OpenFlowOVS/openflowovs-all-xen.rspec.xml)</li>
     64            <li> at a <b>different InstaGENI rack</b> reserve a <a href="http://www.gpolab.bbn.com/experiment-support/OpenFlowOVS/xen-openflow-controller-rspec.xml"> XEN OpenFlow Controller</a> RSpec (In Portal: "XEN OpenFlow Controller"; URL: http://www.gpolab.bbn.com/experiment-support/OpenFlowOVS/xen-openflow-controller-rspec.xml)</li>
     65    </ol>         
     66          </td>
     67       </tr>
     68</table>
     69}}}
     70
     71[[BR]]
     72
     73{{{
     74#!html
     75<table  border="0" cellpadding="0" cellspacing="0">
     76  <tr>
     77     <td valign="top" align="left">
     78        <img src="http://groups.geni.net/geni/attachment/wiki/GENIExperimenter/Tutorials/Graphics/execute.png?format=raw" height="150" alt="Execute"></a>
     79      </td>
     80      <td>
     81 </tr>
     82</table>
     83}}}
     84== 3. Test reachability before starting controller ==
     85=== 3.1 Login to your hosts ===
     86
     87To start our experiment we need to ssh into all the hosts (controller, ovs, host1, host2, host3). 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.
     88
     89=== 3.1a Configure OVS ===
     90 i. Write down the interface names that correspond to the connections to your hosts (use ifconfig). The correspondence is:
     91       * '''h1_if''': Interface with IP ''10.10.1.11'' to host1  - ethX
     92       * '''h2_if''': Interface with IP ''10.10.1.12'' to host2 - ethY
     93       *  '''h3_if''': Interface with IP ''10.10.1.13'' to host3 - ethZ
     94 ii. In the OVS node run:
     95 {{{
     96wget http://www.gpolab.bbn.com/experiment-support/NFVApps/ovs-nat-conf.sh ; chmod +x ovs-nat-conf.sh
     97sudo ./ovs-nat-conf.sh <h1_if> <h2_if> <h3_if> <controller_ip>
     98}}}
     99
     100=== 3.1b Configure hosts ===
     101The hosts in your topology are all in the same subnet, 10.10.1.0/24. We will move host3 to a different subnet:
     102  i. '''host3''': Assign 128.128.128.128 to host3.
     103  {{{
     104   sudo ifconfig eth1 128.128.128.128/24
     105}}}
     106
     107  ii. '''host1, host2''': Setup routes at `host1` and `host1` to 128.128.128.0/24 subnet:
     108  {{{
     109   sudo route add -net 128.128.128.0 netmask 255.255.255.0 gw 10.10.1.100
     110}}}
     111
     112=== 3.2 Test reachability ===
     113
     114a. First we start a ping from `inside1` to `inside2`, which should work since they are both inside the same LAN.
     115{{{
     116host1:~$ ping 10.10.1.2 -c 10
     117}}}
     118
     119b. Then we start a ping from `outside` to `inside1`, which should timeout as there is no routing information in its routing table. You can use `route -n` to verify that.
     120{{{
     121host3:~$ ping 10.10.1.2 -c 10
     122}}}
     123
     124c. Similarly, we cannot ping from `insideX` to `outside`.
     125
     126d. You can also use Netcat (`nc`) to test reachability of TCP and UDP. The behavior should be the same.
     127
     128== 2 Start controller to enable NAT ==
     129
     130=== 2.1 Access a server from behind the NAT ===
     131
     132You can try to write your own controller to implement NAT. However, we a provide you a functional controller.
     133  i. Download the NAT Ryu module. At your controller node run:
     134     {{{
     135cd /tmp/ryu/
     136wget http://www.gpolab.bbn.com/experiment-support/NFVApps/ryu-nat.tar.gz
     137tar xvfz ryu-nat.tar.gz
     138}}}
     139
     140  ii. Start the controller on `NAT` host:
     141  {{{
     142nat:~$ cd /tmp/ryu/; ./bin/ryu-manager ryu-nat.py
     143}}}
     144You should see output similar to following log after the switch is connected to the controller
     145{{{
     146loading app ryu-nat.py
     147loading app ryu.controller.dpset
     148loading app ryu.controller.ofp_handler
     149instantiating app ryu.controller.dpset of DPSet
     150instantiating app ryu.controller.ofp_handler of OFPHandler
     151instantiating app ryu-nat.py of NAT
     152switch connected <ryu.controller.controller.Datapath object at 0x2185210>
     153}}}
     154
     155
     156b. On `outside`, we start a nc server:
     157{{{
     158host3:~$ nc -l 6666
     159}}}
     160and we start a nc client on `inside1` to connect it:
     161{{{
     162host1:~$ nc 128.128.128.2 6666
     163}}}
     164
     165c. Now send message between each other and try the same thing between `host3` and `host2`.
     166
     167d. On the terminal of `controller`, in which you started your controller, you should see a log similar to:
     168{{{
     169Created mapping 192.168.0.3 31596 to 128.128.128.100 59997
     170}}}
     171Note that there should be only one log per connection, because the rest of the communication will re-use the mapping.
     172
     173{{{
     174#!comment
     175=== 2.2 Outside source ===
     176
     177You may be wondering whether it will behave the same if we use `insideX` hosts to be the nc server. You can try it and the answer is no. That's due to the nature of dynamic NAT.
     178
     179However, it will work if we can access the translation table on the switch.
     180
     181a. Look back into the log we got previously:
     182{{{
     183Created mapping 192.168.0.3 31596 to 128.128.128.100 59997
     184}}}
     185Now we know there is mapping between these two pairs.
     186
     187b. Now we start a nc server on `inside2` (`inside1` if your mapping shows 192.168.0.2) on the according port:
     188{{{
     189inside2:~$ nc -l 31596
     190}}}
     191
     192c. Then on `outside`, we start a nc client:
     193{{{
     194outside:~$ nc 128.128.128.1 59997
     195}}}
     196
     197d. `outside` and `inside2` should be able to send messages to each other.
     198
     199e. Common solution of handling outside source is providing some way to manually create mapping in advance. We will leave it as an exercise for you to implement it.
     200}}}
     201
     202== 3 Handle ARP and ICMP ==
     203One of very common mistakes that people make, when writing OF controller, is forgetting to handle ARP and ICMP message and finding their controller does not work as expected.
     204
     205=== 3.1 ARP ===
     206As we mentioned before, we should insert rules into the OF switch that allow ARP packets to go through, probably after the switch is connected.
     207
     208=== 3.2 ICMP ===
     209Handling ARP is trivial as NAT does not involve ARP. However, it's not the case for ICMP. If you only process translation for TCP/UDP, you will find you cannot ping between `outside` and `insideX` while nc is working properly. Handling ICMP is even not as straightforward as for TCP/UDP. Because for ICMP, you cannot get port information to bind with. Our provided solution makes use of ICMP echo identifier. You may come up with different approach involves ICMP sequence number or others.
     210
     211a. On `inside1`, start a ping to `outside`.
     212{{{
     213host1:~$ ping 128.128.128.128
     214}}}
     215
     216b. Do the same thing on `host2`.
     217{{{
     218host2:~$ ping 128.128.128.128
     219}}}
     220
     221You should see both pinging are working.
     222
     223c. On `host3`, use `tcpdump` to check the packets it receives.
     224{{{
     225host3:~$ sudo tcpdump -i eth1 -n icmp
     226}}}
     227
     228You should see it's receiving two groups of icmp packets, differentiated by id.
     229[[BR]]
     230{{{
     231#!html
     232<table  border="0" cellpadding="0" cellspacing="0">
     233  <tr>
     234     <td valign="top" align="left">
     235        <img src="http://groups.geni.net/geni/attachment/wiki/GENIExperimenter/Tutorials/Graphics/finish.png?format=raw"  width="150" alt="Finish"></a>
     236      </td>
     237       <td>
     238             
     239               <h3><u> 4. Cleanup </u></h3>
     240           After you are done with the exercise and you have captured everything requested for the writeup, you should release your resources so that other experimenters can use
     241them. In order to cleanup your slice :
     242              <ol type="a">
     243                 <li>In Flack, press the <b>Delete</b> button in the bottom of your canvas </li>
     244                 <li> Select <b>Delete at used managers</b> and <b>confirm</b> your selection. </li>
     245              </ol>
     246Wait and after a few moments all the resources will have been released and you will have an empty canvas again. Notice that your slice is still there. There is no way to delete a slice, it will be removed automatically after its expiration date, but remember that a slice is just an empty container so it doesn't take up any resources.
     247                             
     248          </td>
     249       </tr>
     250</table>
     251}}}
     252----
     253
     254[[Image(GENIExperimenter/Tutorials/Graphics:tip.png, 40, left)]]
     255= Tips =
     256  * Remember that you can use “ifconfig” to determine which Ethernet interface (e.g., eth0) is bound to what IP address at each of the nodes.
     257  * In order to enable IP forwarding of packets on a node you have to execute the following command:
     258  {{{
     259sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
     260}}}
     261
     262
     263= [.. Return to the main page] =