Changes between Initial Version and Version 1 of GENIExperimenter/Tutorials/NFV/Ryu/LoadBalancePIwithRyu


Ignore:
Timestamp:
10/19/16 16:48:48 (8 years ago)
Author:
wyf@bu.edu
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GENIExperimenter/Tutorials/NFV/Ryu/LoadBalancePIwithRyu

    v1 v1  
     1= Experiment 2: Load Balancing using Proportional Integral (PI) Control with Ryu Controller =
     2
     3== Overview ==
     4
     5In this experiment, we will use a control theoretic approach to do load balancing. An overview of the system is shown in below figure.
     6
     7{{{
     8#!html
     9<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image060.gif" hspace=50>
     10 }}}
     11
     12In 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. We 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 Ryu 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 Ryu controller, which updates the !OpenFlow rules on the OVS switch to balance the load.
     13
     14'''Note: another version of this experiment using POX controller can be found at [wiki:GENIExperimenter/Tutorials/NFV/Execute/LoadBalancePI here].'''
     15
     16== (1) RINA Distributed Application ==
     17
     18First we will run a RINA distributed application to collect the VNF load information on the controller node.
     19
     20{{{
     21#!html
     22<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="10" >
     23 <tr>
     24<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image068.gif" > </td>
     25<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>
     26<b>(If the install fails, you may first run: sudo apt-get update)</b> 
     27 </td></tr></table>
     28}}} 
     29
     30
     31     1.  In the controller window, download the RINA controller code:
     32
     33      - ''' cd ~ '''
     34      - '''  wget !http://csr.bu.edu/rina/grw-bu2016/nfv_ryu/rina/Control.tar.gz '''
     35      - ''' tar -xvf Control.tar.gz '''
     36
     37
     38 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.
     39
     40 3.     In a new VNF1 window, download the RINA VNF1 code:
     41
     42
     43      - ''' cd ~ '''
     44      - '''  wget !http://csr.bu.edu/rina/grw-bu2016/nfv_ryu/rina/VNF1.tar.gz '''
     45      - ''' tar -xvf VNF1.tar.gz '''
     46
     47 4.     In a new VNF2 window, download RINA code using following commands to get RINA VNF2 code.
     48
     49
     50      - ''' cd ~ '''
     51      - '''  wget !http://csr.bu.edu/rina/grw-bu2016/nfv_ryu/rina/VNF2.tar.gz '''
     52      - ''' tar -xvf VNF2.tar.gz '''
     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      - ''' cd ~/VNF1'''
     58      - ''' nano ipcVNF1.properties '''
     59
     60 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.
     61
     62{{{
     63#!html
     64<img src="http://csr.bu.edu/rina/grw-bu2016/nfv_ryu/pics/DNSIDDConfig.png" hspace=50>
     65 }}}
     66
     67 In the VNF2 window, execute:
     68
     69      - ''' cd ~/VNF2'''
     70      - ''' nano ipcVNF2.properties '''
     71 
     72 At the bottom of the file, again change the '''''rina.dns.name''''' and '''''rina.idd.name''''' to the IP address of the controller.
     73
     74 6.     To run the RINA application, follow these steps (make sure you installed Java as noted above):
     75
     76  o   In the controller window, execute the following commands:
     77
     78      - ''' cd ~/Control/RINA/'''
     79      - ''' ./run_controller.sh '''
     80
     81  o   In the VNF1 window, execute the following commands:
     82
     83      - '''cd ~/VNF1/'''
     84      - ''' ./run_VNF1.sh '''
     85
     86
     87  o   In the VNF2 window, execute the following commands:
     88
     89      - '''cd ~/VNF2/'''
     90      - ''' ./run_VNF2.sh '''
     91
     92
     93 
     94  You should see output on the controller window as shown below:
     95{{{
     96#!html
     97<img src="http://csr.bu.edu/rina/grw-bu2016/nfv_ryu/pics/subInfo.png" hspace=2>
     98 }}}
     99
     100{{{
     101#!html
     102<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="10" >
     103 <tr>
     104<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image068.gif" > </td>
     105<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.   
     106 </td></tr></table>
     107}}} 
     108
     109
     110'''Note: the RINA distributed application also pass the intrusion detection results from VNFs to the Ryu controller, and this information is not used in this experiment, but will be used in [wiki:GENIExperimenter/Tutorials/NFV/Ryu/HandlingIntrusionwithRyu Experiment 3] when handling intrusion traffic.'''
     111
     112
     113
     114{{{
     115#!html
     116<table id="Table_02" width = "650" border="0" cellpadding="0" cellspacing="10" >
     117 <tr>
     118<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image022.gif" > </td>
     119<td>  <i> To stop all RINA processes running on a VM, run <b> killall -v java </b> </i>
     120 </td></tr></table>
     121}}} 
     122
     123
     124== (2) PI Controller ==
     125 The PI-controller gets the load information of VNF1 and VNF2 using RINA`s distributed application and makes the load balancing decision.
     126
     127 Below figure shows the block diagram of the Proportional Integral (PI) controlled NFV system.
     128
     129{{{
     130#!html
     131
     132<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="0" align="center" >
     133<tr>
     134<td><img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image074.gif" hspace=2/></td></tr>
     135
     136<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>
     137</table>
     138
     139 }}}
     140
     141 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:
     142
     143
     144{{{
     145#!html
     146<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image076.gif" hspace=70>
     147
     148 }}}
     149
     150 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.
     151
     152{{{
     153#!html
     154<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image078.gif" hspace=40>
     155
     156 }}}
     157
     158  1.     To run the PI-controller, open a new controller window and execute:
     159
     160         - ''' cd ~/Control/PI_controller '''
     161         - ''' python PI_controller.py ~/Control/RINA/NFV1.txt'''
     162
     163
     164
     165 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.
     166  2.     You should see the VNF state information printed on the screen. A sample output is shown below.
     167
     168{{{
     169#!html
     170<img src="http://csr.bu.edu/rina/grw-bu2016/nfv_ryu/pics/PIPic.png" hspace=40>
     171
     172 }}}
     173 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.
     174
     175 '''Do not close this window; leave the PI controller running.'''
     176
     177
     178
     179== (3) PI-based Ryu Controller ==
     180 Now we will run the Ryu controller that will get the load balancing decision from the PI-controller and direct the flows accordingly.
     181
     182 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:
     183
     184         - ''' nano ~/ryu/ryu/app/nfv.config'''
     185 
     186   o   Change the value of '''controller_type''' to '''PI''' [[BR]]
     187   o   Change the value of '''''file_path_pi''''' to the text file that has the PI controller`s  output.[[BR]]
     188    '''''/users/<!UserName>/Control/PI_controller /NFV_ratio_PI.txt'''''[[BR]]
     189    Change the '''''<!UserName>''''' to your user name.[[BR]]
     190
     191
     192 2.     Now we can run the Ryu controller. Execute
     193
     194        - ''' ~/ryu/bin/ryu-manager --verbose ~/ryu/ryu/app/nfv_controller.py'''
     195
     196 == (4) Run Snort and Generate Traffic ==
     197
     198 1.     First we will run Snort IDS on VNF1 and VNF2. In separate windows for VNF1 and VNF2, execute the following command:
     199
     200          - '''sudo /usr/local/bin/snort -A full -dev -i eth1'''
     201
     202
     203
     204 2.     We will use the iperf application to generate flows between a source and destination. If iperf is not installed on your nodes, execute:
     205
     206  - ''' sudo apt-get install iperf '''
     207
     208
     209 3.     Run iperf server on the destination node:
     210
     211  - ''' iperf -s '''
     212
     213
     214 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:
     215
     216  - ''' iperf -c destination -t 500 & '''
     217
     218{{{
     219#!html
     220<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="10" >
     221 <tr>
     222<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image068.gif" > </td>
     223<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>
     224 </td></tr></table>
     225}}}
     226
     227 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.
     228
     229{{{
     230#!html
     231<table id="Table_02" width = "700" border="0" cellpadding="0" cellspacing="10" >
     232 <tr>
     233<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image022.gif"> </td>
     234<td> <b>OPTIONAL: Review the PI Ryu Controller Code</b> </td> </tr></table>
     235}}}
     236
     237
     238The Ryu 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.
     239
     240
     241{{{
     242#!html
     243<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image092.gif" hspace=40>
     244
     245 }}}
     246
     247
     248==  (5) Real Time Graphs ==
     249
     250 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.
     251
     252 1.     Download the python script ''!RealTimeGraph.py'' to your laptop using the following link.
     253
     254{{{
     255#!html
     256    &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>
     257   
     258}}}
     259
     260 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:
     261
     262{{{
     263#!html
     264    &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; <br></b> </span>
     265   
     266}}}
     267
     268 Change '''''<username>''''' to your user name and '''''<controller IP address>''''' to the IP address of the controller.
     269 3.     You should see real-time CPU graphs as shown below:
     270
     271{{{
     272#!html
     273<img src="http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image096.gif" hspace=40>
     274
     275 }}}
     276
     277{{{
     278#!html
     279<table id="Table_02" width = "1150" border="0" cellpadding="0" cellspacing="10" >
     280 <tr>
     281<td> <img src = "http://csr.bu.edu/rina/grw-bu2016/tutorial_files/image068.gif" > </td>
     282<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>
     283 </td></tr></table>
     284}}}
     285
     286== Next Experiment ==
     287'''[wiki:GENIExperimenter/Tutorials/NFV/Ryu/HandlingIntrusionwithRyu Experiment 3: Handing Intrusion with Ryu Controller]'''[[BR]]
     288