Skip to content

Installing OFSwitch13 and doing SDN Simulation under ns-3  

Generally, the procedures that you find on the internet for installing OpenFlow 1.3 support module (OFSwitch13) may fail on latest Linux Operating systems because of the new conventions and standards that are found in the default versions of compilers found in them. This article provides a way to successfully compile ns-3 with  OFSwitch13 module.

Procedure for installing  OpenFlow 1.3

Before installing OpenFlow,  first, we should install a suitable version of ns-3.  One may follow the installation procedure presented in the following link, or follow any other installation procedure for installing the preferred version of ns-3. 

Installing ns3.35 in Debian 11 (Bullseye)

For a chroot-jail based installation procedure, one may follow this link[1].

 

The following step-by-step procedure explains the way of installing OpenFlow 1.3.

 

Step 1:  Installing dependencies.

$ sudo apt-get install build-essential gcc g++ python git mercurial unzip cmake pkg-config autoconf libtool libboost-dev

Step 2:  Clone the original ns-3.29 repository.

$  cd /home/your-home
$  hg clone http://code.nsnam.org/ns-3.29

Step 3:  Downloading OFSwitch13 code.

We can download the OFSwitch13 source code into the /src folder or /contrib folder of the ns-3.29.

$  cd /home/your-home/ns-3.29/src
$ git clone –recurse-submodules https://github.com/ljerezchaves/ofswitch13.git
In my chroot-jail based debian  10 installation, I am keeping ns-3.29 under the folder /home. The following screenshot shows the successful cloning of the OFSwitch13 source code.

Step 4:  Update the code to the desired release version of OFSwitch13 code.

We can download the OFSwitch13 source code into the /src folder or /contrib folder of the ns-3.29.

$  cd /home/your-home/ns-3.29/src/ofswitch13
$ git checkout 4.0.0 && git submodule update –recursive
The following screenshot shows the successful operation of the above command.
 

 

Step 5:  Compiling OFSwitch13 Code.

We have to issue the following commands to compile OFSwitch13 code.

$  cd /home/your-home/ns-3.29/src/ofswitch13/lib/ofsoftswitch13
$  ./boot.sh
$  ./configure –enable-ns3-lib
$  make -j8
But, keep in mind that, even though, the above steps may compile correctly and end up with the final binary libns3ofswitch13.a , while compiling ns-3 with this libns3ofswitch13.a, you may face waf compilation failure while using the latest version of GCC compiler that was commonly found on the latest Linux distributions.  

 
The following section explains an important technique to compile libns3ofswitch13.a in such a way to make it get working along with ns-3 while using the latest gcc compilers.
The following steps are more important steps – they are the very secrets of compiling ns-3 with OFSwitch13 support on the latest Linux OS Varients.
 

Hidden Section! Contact Charles  

The key/passphrase will be given once you have been approved for getting paid research support/assistance from Charles. To get paid support, you may start a 'free' research discussion.  

WhatsApp chatDiscuss Through WhatsApp
 

 

If you are doing all the above steps correctly, then at the end of successful compile, you will see a screen similar to the following:

 

Once everything gets compiled, the static library libns3ofswitch13.a file will be available under the lib/ofsoftswitch13/udatapath directory.
But keep in mind, if you are compiling libns3ofswitch13.a with correct options, then only this compiled binary will be compatible with ns-3 compile process. Otherwise, the “waf” compile process of ns-3 will just end with strange errors that are previously shown in the restricted section of the article.

 

Step 6: Patching the ns-3 code

This OFSwitch ns-3 module code will need some patching operation in some other module code -then only we can compile and use this ns-3 extension in our simulations.  Go back to the ns-3 root directory and patch the ns-3 code with the appropriated patches available under the ofswitch13/utils directory.  The ofswitch13/utils directory may contain patches for some other versions of ns3-also.

The src patch creates the new OpenFlow receive a callback at CsmaNetDevice and VirtualNetDevice, allowing OpenFlow switch to get raw packets from these devices. These are the only required changes in the ns-3 code for OFSwitch13 integration. Running the second patch (the doc patch) is optional, and it will only instruct the simulator to include the module in the ns-3 model library and source code API documentation, which can be helpful to compile the documentation using Doxygen and Sphinx.

We have to issue the following commands to do the automated patch operation.

$  cd /home/your-home/ns-3.29/
$  patch -p1 < src/ofswitch13/utils/ofswitch13-src-3_29.patch
$  patch -p1 < src/ofswitch13/utils/ofswitch13-doc-3_29.patch
The following screenshot shows the successful completion of the two patch operations.
 
 
(Note: If you are trying to install OFSwitch on a different version of ns-3, then this patch operation may fail.)
 

Step 7:  Configuring ns-3

Now, we are ready to configure the ns-3. By default, the configuration script will look for the ofsoftswitch13 library in the lib/ofsoftswitch13/ directory.

Now we can configure the ns-3 make as follows :
 
$ ./waf configure   
If we face some errors while compiling in the next step, then we may need to reconfigure the make as follows:
 

Hidden Section! Contact Charles  

The key/passphrase will be given once you have been approved for getting paid research support/assistance from Charles. To get paid support, you may start a 'free' research discussion.  

WhatsApp chatDiscuss Through WhatsApp
 

 
Now check for the enabled NS-3 OpenFlow 1.3 integration feature after configuration.
The following screenshot shows the successful configuration of ns-3 with OpenFlow 1.3.

Step 8:  Compiling ns-3 with OpenFlow Module

Finally, compile the simulator as follows:
 
$  ./waf 
(Note:  Keep in mind that, even if we configured the OFSwitch13 correctly in the previous step, still the waf compile may fail because of the reasons mentioned in Step 5 and Step  7.)

The following screenshot shows the successful compile operation. In the final screen output, we can see the newly added module OFSwitch in the list of modules, as shown below:
 
 
Finally, we have compiled ns-3 with OFSwitch13 support. Now, the newly compiled ns-3 contains the new OpenFlow 1.3 capabilities.
 

Step 9:  Testing the installation of OFSwitch13 ns-3 module 

Now we can run an example simulation to test the good working of our installation.

Run an example simulation as follows:
 
$  ./waf  –run ofswitch13-first
If you did the OFSwitch13 installation correctly and your ns-3 is really having installed with that extension, then the example simulation will run successfully and will produce the following output.

Now our ns-3 is ready to do with some excellent SDN simulations. We may explore a simple SDN simulation. 
 
The following article presents a simple SDN simulation.

Doing Software-Defined Networking(SDN) Simulation under ns-3

References

  1. https://www.projectguideline.com/installing-ns3-35-in-debian-10-chroot-jail-under-debian-11-host-os-or-any-version-of-linux-

    Hidden Section! Contact Charles  

    The key/passphrase will be given once you have been approved for getting paid research support/assistance from Charles. To get paid support, you may start a 'free' research discussion.  

    WhatsApp chatDiscuss Through WhatsApp
     

 

 

 

WhatsApp Discuss Through WhatsApp