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

11/20/15 14:05:45 (7 years ago)



  • GENIExperimenter/Tutorials/OpenFlowNFVNAT

    v1 v1  
     2= OpenFlow NAT Router =
     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="" alt="route topology"  align="center" width="350" title="nat topology" />
     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=""> GENI Experimenter Portal </a></b> and be a <b> member of a GENI project </b>. <br/>Please see the <a href=""> 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=""> Hello GENI </a> or <a href=""> Lab Zero </a> </li>
     21       <li>  be familiar with <b><a href="" > logging in to GENI resources </a> </b> </li>
     22       <li> be familiar with <b> OpenFlow concepts </b> </li>
     23   </ul>
     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=""> </a>
     36    </td>
     37  </tr>
     44<table  border="0" cellpadding="0" cellspacing="0">
     45  <tr>
     46     <td valign="top" align="left">
     47        <img src="" 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=""> 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="">''Projects''</a> tab) </li>
     56      <li> You have setup your ssh keys (there is at least one key listed under the <a href="">''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=""> GENI Portal </a> </li>
     61       <li> Reserve:
     62           <ol type='a'>
     63            <li>  the topology from an InstaGENI rack using the <a href=""> OpenFlow OVS all XEN </a> RSpec (In Portal: "OpenFlow OVS all XEN"; URL:</li>
     64            <li> at a <b>different InstaGENI rack</b> reserve a <a href=""> XEN OpenFlow Controller</a> RSpec (In Portal: "XEN OpenFlow Controller"; URL:</li>
     65    </ol>         
     66          </td>
     67       </tr>
     75<table  border="0" cellpadding="0" cellspacing="0">
     76  <tr>
     77     <td valign="top" align="left">
     78        <img src="" height="150" alt="Execute"></a>
     79      </td>
     80      <td>
     81 </tr>
     84== 3. Test reachability before starting controller ==
     85=== 3.1 Login to your hosts ===
     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.
     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 '''' to host1  - ethX
     92       * '''h2_if''': Interface with IP '''' to host2 - ethY
     93       *  '''h3_if''': Interface with IP '''' to host3 - ethZ
     94 ii. In the OVS node run:
     95 {{{
     96wget ; chmod +x
     97sudo ./ <h1_if> <h2_if> <h3_if> <controller_ip>
     100=== 3.1b Configure hosts ===
     101The hosts in your topology are all in the same subnet, We will move host3 to a different subnet:
     102  i. '''host3''': Assign to host3.
     103  {{{
     104   sudo ifconfig eth1
     107  ii. '''host1, host2''': Setup routes at `host1` and `host1` to subnet:
     108  {{{
     109   sudo route add -net netmask gw
     112=== 3.2 Test reachability ===
     114a. First we start a ping from `inside1` to `inside2`, which should work since they are both inside the same LAN.
     116host1:~$ ping -c 10
     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.
     121host3:~$ ping -c 10
     124c. Similarly, we cannot ping from `insideX` to `outside`.
     126d. You can also use Netcat (`nc`) to test reachability of TCP and UDP. The behavior should be the same.
     128== 2 Start controller to enable NAT ==
     130=== 2.1 Access a server from behind the NAT ===
     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/
     137tar xvfz ryu-nat.tar.gz
     140  ii. Start the controller on `NAT` host:
     141  {{{
     142nat:~$ cd /tmp/ryu/; ./bin/ryu-manager
     144You should see output similar to following log after the switch is connected to the controller
     146loading app
     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 of NAT
     152switch connected <ryu.controller.controller.Datapath object at 0x2185210>
     156b. On `outside`, we start a nc server:
     158host3:~$ nc -l 6666
     160and we start a nc client on `inside1` to connect it:
     162host1:~$ nc 6666
     165c. Now send message between each other and try the same thing between `host3` and `host2`.
     167d. On the terminal of `controller`, in which you started your controller, you should see a log similar to:
     169Created mapping 31596 to 59997
     171Note that there should be only one log per connection, because the rest of the communication will re-use the mapping.
     175=== 2.2 Outside source ===
     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.
     179However, it will work if we can access the translation table on the switch.
     181a. Look back into the log we got previously:
     183Created mapping 31596 to 59997
     185Now we know there is mapping between these two pairs.
     187b. Now we start a nc server on `inside2` (`inside1` if your mapping shows on the according port:
     189inside2:~$ nc -l 31596
     192c. Then on `outside`, we start a nc client:
     194outside:~$ nc 59997
     197d. `outside` and `inside2` should be able to send messages to each other.
     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.
     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.
     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.
     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.
     211a. On `inside1`, start a ping to `outside`.
     213host1:~$ ping
     216b. Do the same thing on `host2`.
     218host2:~$ ping
     221You should see both pinging are working.
     223c. On `host3`, use `tcpdump` to check the packets it receives.
     225host3:~$ sudo tcpdump -i eth1 -n icmp
     228You should see it's receiving two groups of icmp packets, differentiated by id.
     232<table  border="0" cellpadding="0" cellspacing="0">
     233  <tr>
     234     <td valign="top" align="left">
     235        <img src=""  width="150" alt="Finish"></a>
     236      </td>
     237       <td>
     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.
     248          </td>
     249       </tr>
     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'
     263= [.. Return to the main page] =