NS3 Series--eclipse + NS3 Environment construction

Source: Internet
Author: User
Tags gtk

1. Installing NS3 (1) Install ns3.20 in ubuntu12.04, first install a variety of dependent software:

sudo apt-get install gcc g++ python
sudo apt-get install Python-dev
sudo apt-get install mercurial
sudo apt-get install BZR
sudo apt-get install gdb valgrind
sudo apt-get install gsl-bin libgsl0-dev libgsl0ldbl
sudo apt-get install Flex Bison Libfl-dev
sudo apt-get install tcpdump
sudo apt-get install SQLite sqlite3 Libsqlite3-dev
sudo apt-get install libxml2 Libxml2-dev
sudo apt-get install libgtk2.0-0 Libgtk2.0-dev
sudo apt-get install Vtun LXC
sudo apt-get install uncrustify
sudo apt-get install Doxygen graphviz ImageMagick
sudo apt-get install texlive texlive-extra-utils Texlive-latex-extra
sudo apt-get install Python-sphinx dia
sudo apt-get install Python-pygraphviz python-kiwi
sudo apt-get install Python-pygoocanvas Libgoocanvas-dev
sudo apt-get install Libboost1.46-dev
sudo apt-get install Libboost-filesystem1.46-dev
sudo apt-get install Libboost-signals-dev Libboost-filesystem-dev
sudo apt-get install openmpi-bin openmpi-doc Libopenmpi-dev

(2) Download NS3.20

mkdir tarballs
CD Tarballs
wget http://www.nsnam.org/release/ns-allinone-3.20.tar.bz2
Tar xjf ns-allinone-3.20.tar.bz2

(3) Compiling

CD ns-allinone-3.20
./build.py
CD ns-3.20
./waf Distclean
./waf Configure--enable-examples--enable-tests
./WAF Build

(4) test

./test.py

2. Install Eclipse (1) Download install JDK

1. Download the installation file

On the JDK's official website www.Oracle.com, after entering the download page, select Accept license Agreement, then select the corresponding file download. This article installs the practice to choose LinuxX86 corresponding jdk-7u17-linux-i586.tar.gz, as for the jdk-7u17-linux-i586.rpm installation may refer to other literature.

For the download method, you can use the command, or manually download, tastes, no need to insist.

2. Unzip to the destination folder

If the destination folder exists, skip this step, or enter the following command to create the destination folder:

sudo MKDIR/USR/LIB/JVM

Enter the following command to extract jdk-7u17-linux-i586.tar.gz to the destination folder:

sudo tar-zxvf./jdk-7u17-linux-i586.tar.gz-c/USR/LIB/JVM

Note that this article installs in practice jdk-7u17-linux-i586.tar.gz in the current user's root directory, the tar command the second parameter is./jdk-7u17-linux-i586.tar.gz, of course, can use absolute path, no longer repeat.

3. Add Environment variables

Enter the following command to open the file:

Gedit ~/.BASHRC

At the end of the. bashrc file, if the following statement:

#java JDK Configuration
Export JAVA_HOME=/USR/LIB/JVM/JDK1.7.0_17
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH

Enter the following command to run to make it effective immediately:

SOURCE ~/.BASHRC

The modification of environment variables in the installation of this article is in ~/.BASHRC, only for the current user, if modifying/etc/profile is for all users.

4. Test the JDK

Enter the following command to view the JDK version:

Java-version

If the installation succeeds, the following is displayed:

Java Version "1.7.0_17"
Java (TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot (TM) Server VM (build 23.7-b01, Mixed mode)

5. Configuring the default JDK version

If there is only one JDK in the system, the above steps have been installed accordingly. However, if there are multiple JDK systems, such as OPENJDK and SUNJDK, you need to configure the default JDK with the following steps.

1) Execute the following command:

sudo update-alternatives--install/usr/lib/java Java/usr/lib/jvm/jdk1.7.0_17/bin/java 300
sudo update-alternatives--install/usr/lib/javac Javac/usr/lib/jvm/jdk1.7.0_17/bin/javac 300

2) Execute the following command:

sudo update-alternatives--config java

Information about the various JDK versions is listed, which is labeled "*" as the default JDK. If you want to maintain the current default JDK, press ENTER, otherwise enter the number of the corresponding JDK to set it as the default version.

(2) Download eclipse

1. Download the installation file

On the Eclipse's official website www.eclipse.org, after entering the download page, select Accept license Agreement, then select the corresponding file download. This article installs the practice to choose LinuxX86 corresponding eclipse-cpp-luna-r-linux-gtk.tar.gz, as for the eclipse-cpp-luna-r-linux-gtk.tar.gz installation may refer to other literature.

For the download method, you can use the command, or manually download, tastes, no need to insist.


2. Unzip to the destination folder

Enter the following command to extract eclipse-cpp-luna-r-linux-gtk.tar.gz to the destination folder:

sudo tar-zxvf./eclipse-cpp-luna-r-linux-gtk.tar.gz-c/usr/local/

It is important to note that this article installs in practice eclipse-cpp-luna-r-linux-gtk.tar.gz the second parameter of the TAR command under the current user's root directory. Eclipse-cpp-luna-r-linux-gtk.tar.gz, of course, can use absolute path, no longer repeat.

Enter the directory where Eclipse is located after successful decompression

Cd/usr/local/eclipse

Perform

./eclipse

3. Test:

Create C + + project after entering eclipse

Test code:

1 #include <iostream>23usingnamespace  std; 4 5 int Main () 6 {7     " Hello world! " << Endl; 8     return 0 ; 9 }

Here's a point to note:

A small bug in Eclipse itself, if the test is unsuccessful may be due to the following conditions:

1) No CTRL + S to save a bit

2) do not compile first

3) JDK configuration problem java-version query

4) version of Eclipse issue

3. Configure NS3 (1) in Eclipse to create a new NS3 empty project.

The initial entry into eclipse will prompt you where to put the workspace, where I put the "/home/xbb/ns3"

file->new->c++ project,project name with NS3, select Empty Project, click Finish.

(2) Import the ns-3.20 file into Eclipse's NS3 project.

Unzip the downloaded ns-3.20 compressed package and copy all the files from the extracted ns-3.20 folder to the new working directory you just created.
cd/home/xbb/tarballs/ns-allinone-3.20/ns-3.20
Cp-r./*/home/xbb/ns3/ns3/

Enter NS3

Cd/home/xbb/ns3/ns3

./waf-d Debug--enable-examples--enable-tests Configure

After the configuration is successful, you can click "Refresh" on the NS3 project you built in eclipse to see all the files you have imported

(3) Setting the NS3 compiler in Eclipse as a WAF

Right-click on the NS3 in Project Explorer and select Properties to do the following: In the Build Settings tab in C + + build, remove the hook in the Use default build command check box ,

Enter ${WORKSPACE_LOC:/NS3/WAF} in the build command, remove the hook from the Generate makefiles automatically check box, and enter ${in build directory Workspace_loc:/ns3/build}


Then, in the Behavior tab of the C + + Build, the check boxes in Workbench Buildbehavior are selected, the first 2 values are empty, and the last is clean.

(4) Setting up Eclipse execution program using external tools

Select Run->external tools->external Tools Configuration, right-click New in Program,
, set ${workspace_loc:/ns3/waf} in location, set ${workspace_loc:/ns3},argument in working directory to--run "${string_ Prompt} "

Click Run, enter Scratch-simulator, click OK

After successful execution,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.