Wednesday, October 28, 2015

installing ns3.16 in opensuse 12 using vmware

Install and configure Eclipse IDE on ns-3

In this article, I want to review my video about install and configure Eclipse for ns-3.
In articles install ns-3 on OpenSuse Part 1, Part 2 and Part 3, we sow that how we can install ns-3. So I already have installed ns-3.17 on OpenSuse 12.2.

You can find my videos about installing ns-3 on OpenSuse Linux in: 
Part1: Install OpenSuse 12.2 On VM-Ware
Part2: Install Pre-requirements Package for ns-3 (ns3.16)
Part3: Install ns-3 and Run Example (ns-3.16)
And now we want to install and configure Eclipse IDE on ns-3.



Please notice that I installed ns-3.17 on OpenSuse Linux from ns-allinone-3.17.tar.bz2 in Documentspath in OpenSuse Linux. We need this path later. (/home/ns3user/ Documents/ns-allinone-3.17/)

I suppose, you already have Mercurial installed on your machine. You can find how to install Mercurialat "Part2: Install Pre-requirements Package for ns-3"

What we need:
1. Eclipse IDE for C/C++ Developers. You can download it from http://www.eclipse.org/downloads/
Depend on your CPU which is 32-bit or 64-bit, you can download eclipse-cpp-juno-SR2-linux-gtk-x86_64.tar.gz or eclipse-cpp-juno-SR2-linux-gtk.tar.gz. In this video, I downloaded "eclipse-cpp-juno-SR2-linux-gtk-x86_64.tar.gz".
Eclipse IDE for C/C++ Developers version in this video is: Version: Juno Service Release 2 - Build id: 20130225-0426

2. An Internet Connection.

In this tutorial, we have 4 parts:
• Part A: Install Eclipse and Configure Mercurial
• Part B: Configure Waf Builder
• Part C: Configure Debugger
• Part D: Create new source code, and run it.
   o D-1: Use Eclipse for running source code
   o D-2: Use Eclipse for creating new source code, but use ns-3 for running it (I Recommend)


Part A: Install Eclipse and Configure Mercurial 

1. Open Terminal and go to Eclipse path by cd command. Then use tar command to extract Eclipse
 tar -xvf eclipse-cpp-juno-SR2-linux-gtk-x86_64.tar.gz

2. Open Eclipse and choose a path for your projects.
You can choose whatever you want but it is advised to use a directory just for the Eclipse projects.

3. Be sure your Internet is connected.

4. In Eclipse, go to Help → Install New Software.
You should insert http://cbes.javaforge.com/update and mercurialeclipse in the form. It is simple, just follow the video. (After this step, the Internet is no longer needed)

 5. Create new C++ Project and with your preferred name. (I choose NS-3 Projects as project name)
You should choose the installed ns-3 path for the project. As I told you before, I installed ns-3 in Documents. The path is:  /home/ns3user/Documents/ns-allinone-3.17/ns-3.17/

6. Right Click on the project and go to Team→ Share Project. Then click on Next and select local Mercurial.


B: Configure Waf Builder 

1. Right Click on the project and click on Properties. Then, click on C/C++ build. After that uncheck the boxes: "Use default build command" and "Generate make file automatically"

2. Insert this path as Build command: /home/ns3user/Documents/ns-allinone-3.17/ns-3.17/waf

3. Insert this path as Build directory: /home/ns3user/Documents/ns-allinone-3.17/ns-3.17/build

4. Click on the Behaviour tab and remove the `all` option in front of the Build (Incremental build) check-box and then write build


Part C: Configure Debugger

1. Go to Run → Debug Configurations and create a new configuration and choose a name for it.
2. Click on the "Browse" button under the "Project" section and select your project.
3. Click on the "Search Project" button under the "C/C++ Application" section and type scratch-simulator
4. Go to Environment tab and click on New button to create a new variable. You will need these:LD_LIBRARY_PATH  and /home/ns3user/Documents/ns-allinone-3.17/ns-3.17/build
5. Be sure the "Append environment to native environment" is selected. Now, let run an example


Part D: Create new source code, and run it.
There are two different ways for compiling source codes:
 • D-1: Use Eclipse for running source codes
 • D-2: Use Eclipse for creating new source code, but use waf for running it (I recommend this one)

D-1: Use Eclipse for running source code

1. Create your source code, in scratch directory. As you will watch in the video, I create reza.cc file and copy the third.cc content into reza.cc. (The third.cc is one of the ns-3.17 example.) You can suppose it is a new code. The path is:  /home/ns3user/Documents/ns-allinone-3.17/ns-3.17/scratch/
2. Click on Run button to compile all the source codes in scratch directory. So your source code is compiled too.
3. Go to Run Configurations and in Search Project option, select your project. Then click again on Run button and wait until compile complete. You will see your source code output

D-2: Use Eclipse for creating new source code, but use waf for running it (I Recommend) 

 1. Create your source code, in scratch directory. As you will watch in the video, I create reza.cc file and copy the third.cc content into reza.cc. (The third.cc is one of the ns-3.17 example.) You can suppose it is a new code. The path is: • /home/ns3user/Documents/ns-allinone-3.17/ns-3.17/scratch/
2. Open terminal, go to ns-3 path by cd command, and run the source code by waf command.:   ./waf  or ./waf --run scratch/reza

You see D-1 and D-2 ways have same output. but when you use way D-2 you can use --visualize for visualizing.for example: ./waf --run scratch/reza --visualize


References:
http://www.nsnam.org
http://www.nsnam.org/documentation/videos/
http://www.nsnam.org/documentation/presentations/
http://www.nsnam.org/wiki/index.php/HOWTO_configure_Eclipse_with_ns-3

No comments:

Post a Comment