Changes between Initial Version and Version 1 of GENIExperimenter/Tutorials/NFV/Pox/Execute/LoadBalancePI


Ignore:
Timestamp:
05/31/17 14:17:18 (7 years ago)
Author:
Nabeel Akhtar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GENIExperimenter/Tutorials/NFV/Pox/Execute/LoadBalancePI

    v1 v1  
     1= [wiki:GENIExperimenter/Tutorials/NFV/Execute NFV Tutorial Part II: Execute] =
     2== Experiment 2:  Load Balancing using Proportional Integral (PI) Control ==
     3In this experiment, we will use a control theoretic approach to do load balancing. An overview of the system is shown in below figure.
     4
     5{{{
     6#!html
     7<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image060.gif" hspace=50>
     8 }}}
     9
     10In this control theoretic approach, the load on VNF1 and VNF2 is monitored, and flow-forwarding decisions are made based on the load information retrieved from the hosting VMs.
     11
     12We will run a [http://www.geni.net/?p=3133 RINA] distributed application to get the state (load) of the VNFs to the controller VM. Once the controller has the IDS load information, it will use the Proportional Integral (PI) load balancer to balance the load across the VNF instances based on the load information. This load balancing information is then provided to the OVS controller, which updates the OpenFlow rules on the OVS switch to balance the load.
     13
     14=== RINA Distributed Application: ===
     15First we will run a RINA distributed application to collect the VNF load information on the controller node.
     16{{{
     17#!html
     18<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="10" >
     19 <tr>
     20<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image068.gif" > </td>
     21<td>  We need Java installed on the nodes to run the RINA application. Install java on <i> VNF1, VNF2 </i> and <i> controller </i> nodes (Type Ctrl-C to exit netcat). To install Java, execute: &nbsp;<span style="background:#c0c0c0; font-size: 10pt"><b>sudo apt-get install openjdk-7-jdk </b> </span> <br>
     22<b>(If the install fails, you may first run: sudo apt-get update. In some cases, you may need to first run: sudo add-apt-repository ppa:openjdk-r/ppa followed by: sudo apt-get update.)</b> 
     23 </td></tr></table>
     24}}} 
     25
     26 1.     In the controller window, download the RINA controller code:
     27
     28{{{
     29#!html
     30    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~ <br></b> </span>
     31    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>wget http://csr.bu.edu/rina/grw-bu2016/nfv/Control.tar.gz<br></b> </span>
     32    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>tar -xvf Control.tar.gz<br></b> </span>
     33}}}
     34
     35 2.     Type ''ifconfig'' to get the IP address of the controller. Save this address as we will need this address to direct the RINA processes on the VNFs to the RINA process on the controller.
     36 3.     In a new VNF1 window, download the RINA VNF1 code:
     37
     38{{{
     39#!html
     40    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~ <br></b> </span>
     41    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>wget http://csr.bu.edu/rina/grw-bu2016/nfv/VNF1.tar.gz<br></b> </span>
     42    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>tar -xvf VNF1.tar.gz<br></b> </span>
     43}}}
     44
     45 4.     In a new VNF2 window, download RINA code using following commands to get RINA VNF2 code.
     46
     47{{{
     48#!html
     49    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~ <br></b> </span>
     50    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>wget http://csr.bu.edu/rina/grw-bu2016/nfv/VNF2.tar.gz<br></b> </span>
     51    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>tar -xvf VNF2.tar.gz<br></b> </span>
     52}}}
     53
     54 5.     Now we will change the IP address in the RINA configuration files for VNF1, VNF2 and controller, so these RINA processes can talk to each other.
     55 In the VNF1 window, execute:
     56
     57{{{
     58#!html
     59    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~/VNF1 <br></b> </span>
     60    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>nano ipcVNF1.properties<br></b> </span>
     61}}}
     62
     63
     64 At the bottom of the file, change the '''''rina.dns.name''''' and '''''rina.idd.name''''' to the IP address of the controller. The following screenshot shows an example.
     65
     66{{{
     67#!html
     68<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image064.gif" hspace=50>
     69 }}}
     70 In the VNF2 window, execute:
     71
     72{{{
     73#!html
     74    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~/VNF2 <br></b> </span>
     75    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>nano ipcVNF2.properties<br></b> </span>
     76}}}
     77 
     78 At the bottom of the file, again change the '''''rina.dns.name''''' and '''''rina.idd.name''''' to the IP address of the controller.
     79
     80 In the controller window, execute:
     81
     82{{{
     83#!html
     84    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~/Control/RINA/  <br></b> </span>
     85    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>nano ipcControl.properties<br></b> </span>
     86}}}
     87 
     88
     89 At the bottom of the file, again change the rina.dns.name and rina.idd.name to the IP address of the controller.
     90
     91 6.     To run the RINA application, follow these steps (make sure you installed Java as noted above):
     92
     93  o   In the controller window, execute the following commands:
     94{{{
     95#!html
     96    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~/Control/RINA/ <br></b> </span>
     97    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>./run_controller.sh<br></b> </span>
     98}}}
     99
     100  o   In the VNF1 window, execute the following commands:
     101{{{
     102#!html
     103    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~/VNF1/ <br></b> </span>
     104    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>./run_VNF1.sh<br></b> </span>
     105}}}
     106
     107  o   In the VNF2 window, execute the following commands:
     108{{{
     109#!html
     110    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~/VNF2/ <br></b> </span>
     111    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>./run_VNF2.sh<br></b> </span>
     112}}}
     113 
     114  After waiting for sometime, you should see output on the controller window as shown below:
     115{{{
     116#!html
     117<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image066.gif" hspace=2>
     118 }}}
     119
     120{{{
     121#!html
     122<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="10" >
     123 <tr>
     124<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image068.gif" > </td>
     125<td>  <i> The RINA application on VNF1 and VNF2 should be run as soon as possible after the RINA application on the controller  is started. If you wait for too long, you will get <b> null</b> values for CPU usage, as the controller`s RINA app is not able to subscribe to the CPU load of the VNFs. </i> If this is the case, you should restart all RINA processes. The sample output below shows a case where the controller RINA app is not able to subscribe to the CPU load of VNF2 .
     126 </td></tr></table>
     127}}} 
     128
     129{{{
     130#!html
     131<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image070.gif" hspace=2>
     132 }}}
     133
     134{{{
     135#!html
     136<table id="Table_02" width = "650" border="0" cellpadding="0" cellspacing="10" >
     137 <tr>
     138<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image022.gif" > </td>
     139<td>  <i> To stop all RINA processes running on a VM, run <b> killall -v java </b> </i>
     140 </td></tr></table>
     141}}} 
     142
     143[[BR]][[BR]] [[BR]]
     144
     145'''PI controller'''
     146 The PI-controller gets the load information of VNF1 and VNF2 using RINA`s distributed application and makes the load balancing decision.
     147
     148 Below figure shows the block diagram of the Proportional Integral (PI) controlled NFV system.
     149
     150{{{
     151#!html
     152
     153<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="0" align="center" >
     154<tr>
     155<td><img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image074.gif" hspace=2/></td></tr>
     156
     157<tr><td> <i style="font-size:9px">Block diagram of the PI-controller NFV system. System load L and target load T(s)=T/s of VNF1 is used to compute X, i.e. ratio of traffic diverted to VNF2. K` = K/T.</i></td></tr>
     158</table>
     159
     160 }}}
     161
     162 The RINA-based distributed monitoring application provides the VNF1 state (average CPU load) information L(t) to the PI controller. The maximum capacity of a VNF instance is T. If the load on VNF1 exceeds T, new traffic flows are forwarded to a second VNF instance, VNF2. Assuming instantaneous feedback / measured load L(t), the PI control equation is given by:
     163
     164
     165{{{
     166#!html
     167<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image076.gif" hspace=70>
     168
     169 }}}
     170
     171 The code for the PI controller is based on following algorithm. Input ''IDS,,load,,.txt'' is the file generated by the RINA distributed application. This file has load information of the VNFs.
     172
     173{{{
     174#!html
     175<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image078.gif" hspace=40>
     176
     177 }}}
     178
     179  1.     To run the PI-controller, open a new controller window and execute:
     180
     181{{{
     182#!html
     183    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd ~/Control/PI_controller <br></b> </span>
     184    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>python PI_controller.py ~/Control/RINA/NFV1.txt<br></b> </span>
     185}}}
     186
     187
     188 Note that here we are directing ''PI_controller.py'' to the ''NFV1.txt'' file that is constantly updated by the RINA distributed application with the load information of VNFs.
     189  2.     You should see the VNF state information printed on the screen. A sample output is shown below.
     190
     191{{{
     192#!html
     193<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image080.gif" hspace=40>
     194
     195 }}}
     196 Here the target load on VNF1 is 30.0% of CPU usage, i.e. if the CPU load on VNF1 is more than 30.0%, traffic flows will be diverted to VNF2. The `current CPU load` shows the load on VNF1. The next line of the output shows the percentage of flows that will be directed to VNF2 and the last line shows the flows that were being directed to VNF2 before the current control update.
     197
     198 '''Do not close this window; leave the PI controller running.'''
     199
     200
     201'''PI-based OVS controller:'''
     202 Now we will run the OVS controller that will get the load balancing decision from the PI-controller and direct the flows accordingly.
     203
     204 1.     First we will update the ''port.config'' file to direct the controller to the ''NFV_ratio_PI.txt'' file generated by the PI-controller, which has the load balancing decision information. In a new controller window, execute:
     205
     206{{{
     207#!html
     208    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>cd /tmp/pox/ext <br></b> </span>
     209    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>nano port.config<br></b> </span>
     210}}}
     211 
     212   o   Change the value of '''controller_type''' to '''PI''' [[BR]]
     213   o   Change the value of '''''file_path_pi''''' to the text file that has the PI controller`s  output.[[BR]]
     214    '''''/users/<!UserName>/Control/PI_controller/NFV_ratio_PI.txt'''''[[BR]]
     215    Change the '''''<!UserName>''''' to your user name.[[BR]]
     216  Sample values are shown below.
     217
     218{{{
     219#!html
     220<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image082.gif" hspace=40>
     221
     222 }}}
     223
     224 2.     Now we can run the OVS controller. Execute
     225
     226{{{
     227#!html
     228    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b> cd /tmp/pox <br></b> </span>
     229    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b>python pox.py --verbose NFV_controller<br></b> </span>
     230}}}
     231
     232
     233 ''' Run Snort and Generate Traffic: '''
     234 1.     First we will run Snort IDS on VNF1 and VNF2. In separate windows for VNF1 and VNF2, execute the following command:
     235
     236{{{
     237#!html
     238    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b> sudo /usr/local/bin/snort -A console -v -c / -i eth1<br></b> </span>
     239   
     240}}}
     241
     242 You should see the window as shown below in the ''VNF1'' and ''VNF2'' windows:
     243{{{
     244#!html
     245<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image084.gif" hspace=40>
     246
     247 }}}
     248
     249 2.     We will use the iperf application to generate flows between a source and destination. If iperf is not installed on your nodes, execute:
     250
     251{{{
     252#!html
     253    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b> sudo apt-get install iperf<br></b> </span>
     254   
     255}}}
     256
     257 3.     Run iperf server on the destination node:
     258
     259{{{
     260#!html
     261    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b> iperf -u -s <br></b> </span>
     262   
     263}}}
     264
     265
     266 4.     Now we will generate traffic from the sources (s1 and s2) to the destination node using ''iperf'' and see how it effects the CPU utilization at VNF1 and VNF2 running Snort IDS. Note that if we run multiple instances of ''iperf'', we can generate significant load on the VNF instances. To run ''iperf'' client on a source, execute:
     267
     268{{{
     269#!html
     270    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b> iperf -u -c destination -t 500 & <br></b> </span>
     271   
     272}}}
     273
     274{{{
     275#!html
     276<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="10" >
     277 <tr>
     278<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image068.gif" > </td>
     279<td>  <i>Note that you can run multiple instances of iperf by running <span style="background:#c0c0c0"> iperf -c destination -t 500 & </span> multiple time in s1 and s2 nodes. This flow lasts for 500 seconds. To kill all the flows generated at a node, run <span style="background:#c0c0c0"> killall –v iperf </span> </i>
     280 </td></tr></table>
     281}}}
     282
     283 5.     Now if you look at the controller window, which is running the PI-controller, you can see the load on VNF1 has significantly increased. If the load is more than 30%, some percentage of the traffic flows will be diverted to VNF2. A sample output is shown below:
     284
     285{{{
     286#!html
     287<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image088.gif" hspace=40>
     288
     289 }}}
     290
     291{{{
     292#!html
     293<table id="Table_02" width = "500" border="0" cellpadding="0" cellspacing="10" >
     294 <tr>
     295<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image022.gif" > </td>
     296<td>   <b> OPTIONAL: Review the PI Controller Code: </b> 
     297 </td></tr></table>
     298}}} 
     299
     300
     301{{{
     302#!html
     303<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="10" >
     304 <tr>
     305<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image068.gif" > </td>
     306<td>  <i>Optional: Code Review: The OVS controller gets the load balancing information from the output text file generated by the PI-controller. Based on the  value of the control variable  (variable X), it sends each new flow to either VNF1 or VNF2. The algorithm for the PI-based OVS controller is shown below: </i>
     307 </td></tr></table>
     308}}}
     309 
     310{{{
     311#!html
     312<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image092.gif" hspace=40>
     313
     314 }}}
     315''The corresponding code can be found in  '''/tmp/pox/ext/NFV_controller.py''' as shown below:''
     316
     317{{{
     318#!html
     319<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image094.gif" hspace=40>
     320
     321 }}}
     322
     323''' Real Time Graphs: '''
     324
     325On any Linux machine (including MAC OS), you can draw real-time CPU usage graphs for both VNF1 and VNF2 nodes. A Python script is provided to produce these real-time graphs. The script periodically retrieves the CPU usage file from the Controller node and plots the graph for it.
     326
     327 1.     Download the python script ''!RealTimeGraph.py'' to your laptop using the following link.
     328
     329{{{
     330#!html
     331    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b> http://csr.bu.edu/rina/grw-bu2016/nfv/RealTimeGraph.py <br></b> </span>
     332   
     333}}}
     334
     335 2.     Run the script and direct it to the CPU usage files (''NFV1.txt'' and ''NFV2.txt'') present at the controller. To run the Python script, type the following in the folder where you saved the ''!RealTimeGraph.py'' file:
     336
     337{{{
     338#!html
     339    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="background:#c0c0c0; font-size: 9pt"><b> python RealTimeGraph.py -n &lt;username&gt;@&lt;controller IP address&gt -k &lt;Path to your ssh key&gt;   ; <br></b> </span>
     340   
     341}}}
     342
     343 Change '''''<username>''''' to your user name,  '''''<controller IP address>''''' to the IP address of the controller and '''''<Path to your ssh key>''''' is the path to your ssh key that you use to log into GENI nodes. 
     344 3.     You should see real-time CPU graphs as shown below:
     345
     346{{{
     347#!html
     348<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image096.gif" hspace=40>
     349
     350 }}}
     351
     352{{{
     353#!html
     354<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="10" >
     355 <tr>
     356<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image068.gif" > </td>
     357<td>  <i>To run the Python script to plot graphs, you need the python plotting library <b>matplotlib</b>. If you do not have this library on your laptop, you can use the following link to download it to your computer: <a href = "http://matplotlib.org/users/installing.html">http://matplotlib.org/users/installing.html</a>  </i>
     358 </td></tr></table>
     359}}}
     360
     361'''[wiki:GENIExperimenter/Tutorials/NFV/Execute Back to Part II: Execute]'''[[BR]]
     362== [wiki:GENIExperimenter/Tutorials/NFV/Finish Next: Finish] ==
     363
     364----
     365Author: Nabeel Akhtar
     366
     367Supervised by: Ibrahim Matta
     368
     369Boston University