ns-3 download, compile, and Eclipse-related configuration

Source: Internet
Author: User
Tags mercurial

0. Write in front

For the first contact with the Linux system, the installation of ns-3 seems unfriendly. But in fact, the installation process is not as complicated as it seems to be in a methodical way. In this paper, the installation process in the official Wiki is slightly combed, hoping to bring some convenience for beginners. As the description in the official Wiki is sufficiently detailed, there will be a large citation in this article and no intention to translate it, please forgive me.

1. Install the ns-31.1 environment configuration

This section refers to the Prerequisites-ubuntu/debian section of the installation page in the official wiki, which is explained in detail by jumping to the wiki page for queries.

Execute the following instructions to install the necessary tools to properly compile and use ns-3:

  • Minimal requirements for C + + (release): This was the minimal set of packages needed to run NS -3 from a released tarball.

    apt-get  install gcc g++ python   
  • Minimal requirements for Python (release): The minimal set of packages needed With Python bindings from a released tarball.

    apt-get install gcc g++ python  Span class= "Hljs-keyword" >python -dev  
  • Qt4 development tools (NOTE:QT4, not qt5) needed For Netanim animator

    apt-get  install Qt4-dev  -tools  Libqt4-dev   

These are the tools that must be installed to install ns-3 (in fact, the third QT development package is not necessary for ns-3 itself, but it is necessary for the animated presentation tool Netanim, and the tool is a very common tool for ns-3, so I think it belongs to the mandatory tool). There are a number of other optional tools in the Prerequisites-ubuntu/debian section of the installation page in the official Wiki, which you can choose to install in a later practical use.

Because the author is also a novice for programming under Linux, an excellent IDE is essential for me, and I chose Eclipse as my tool for debugging ns-3 because it is a powerful and stable IDE tool, and Ns-3 's official Wiki has information on how to use The description of Eclipse for debugging (explained in detail in the latter part of this article), so I chose it for debugging. IDE Tools with official instructions also include NetBeans and Qtcreator.
If you plan to use Eclipse for ns-3 development, you can install Eclipse and the CDT plug-in first (enabling Eclipse to support C + + development), and open Eclipse and create a new workspace (workspace). Subsequent downloads of the Ns-3 project should be placed directly in the workspace directory for Eclipse identification.

1.2 Installing 1.2.1 Using the Bake tool

This tool is a tool for installing, compiling, and querying a missing tool in the new version of Ns-3, but I have been using manual installation methods (described in the next section) and never tried this installation. So, in this direct copy of the official wiki of the relevant introduction, details, please refer to the official Wiki installation page installation-installation with Bake.

Bake is a new tool for installing, building and finding out of the missing requirements for ns-3 in your own environment.

To use Bake-need to has at least Python (preferably 2.6 and above) and mercurial in your Requisites above to see how to install these).

First need to download Bake using Mercurial, go to where you want Bake to be installed and call

clone http://code.nsnam.org/bake

It is advisable to add bake to your path.

export BAKE_HOME=`pwdexport PATH=$PATH:$BAKE_HOMEexport PYTHONPATH=$PYTHONPATH:$BAKE_HOME

After so you can use Bake to find the missing packages, download build and install ns-3 and its modules.

To find out what's missing in your system and may be needed for installing ns-3 The can call Bake check:

check

You should has seen something like:

> Python-ok
> GNU C + + Compiler-ok
> Mercurial-ok
> Cvs-ok
> Git-ok
> Bazaar-ok
> Tar Tool-ok
> Unzip Tool-ok
> Unrar Tool-ok
> 7z Data compression Utility-ok
> XZ Data compression Utility-ok
> Make-ok
> Cmake-ok
> Patch Tool-ok
> autoreconf Tool-ok
> Path searched for tools:/usr/lib64/qt-3.3/bin
/usr/lib64/ccache/usr/local/bin/usr/bin/bin/usr/local/sbin/usr/sbin
/sbin/user/dcamara/home/scripts/user/dcamara/home/inria/programs/bin
/user/dcamara/home/inria/repos/llvm/build/debug+asserts/bin

Before downloading and building ns-3 you need to configure bake to inform it which is the modules you want added to Ns-3, The standard distribution for example.

-e ns-3.17

Then the modules it have added, and the specific system requirements for this configuration, you can call Bake show:

show   

To download the modules, build and install your can call bake Deploy

bake.py deploy

This would download the selected modules, all their dependencies and build ns-3 with all these independent modules. You can also perform this installation step by step, i.e. by calling download and build in different steps.

bake.py downloadbake.py build
1.2.2 Manual Installation

Three manual installation options are described in the official Wiki installation page-install using Mercurial (a version management tool), install the developer version with the source code (with the latest features but not stable), install the release version using the source code (i.e. release version, The latest stable version). The first method is officially recommended, but the author does not use mercurial, and the manual installation method is relatively simpler, so the author chooses the third way to install it. Therefore, this section describes the third installation method, the other two installation methods, please visit the Official Wiki Installation page installation-manual installation section to see the details.

    • Download Ns-3 Source Compression Package
      Download from the official, or copy directly from the server to local by executing the following instructions:
cdmkdir tarballscd tarballswget http://www.nsnam.org/release/ns-allinone-3.13.tar.bz2tar xjf ns-allinone-3.13.tar.bz2
1.3 Compiling

Enter the NS-3 project directory in the terminal (the directory where the build.py is located, typically its folder name is "ns-allinone-3.25") and execute the compilation script:

./build.py

Wait patiently for a period of time (depending on the computer configuration different compile-time length, I compile time about 40 minutes), after the successful compilation will see the following prompt:

Build finished successfully (00:02:37)
Leaving directory './ns-3.25 '

    • Configure WAF
      Next go to the ns-3.25 folder for the WAF configuration. WAF is a python-based, open-source compilation system, please search the relevant information by yourself.
      There are a lot of things about WAF configuration in the official wiki, but it's not necessary for my current development, so it's not listed here, so you can see the official Wiki Installation page Building ns-3 with Build.py-config Uration with WAF section
      The authors suggest, however, that the following directives be executed to allow the compilation of the example programs (Src/examples, src/module/examples programs) and test programs (src/module/ns-3) in the source code. Tests in the program)
./wafconfigure--enable-examples--enable-tests

The example program and the test program will be compiled and executed at the next compile time after the configuration is successful.

At this point, Ns-3 has been successfully installed in your computer. Now go to the NS-3 project directory (the WAF directory) and run the instructions to run your first ns-3 program (the program Path is/ns-allinone-3.25/ns-3.25/scratch/scratch-simulator.cc):

./waf--runscratch-simulator

The output is:

Scratch Simulator

It also verifies that your ns-3 installation was successful.

2. Configure Eclipse

This chapter, based on the article "HOWTO Configure Eclipse with Ns-3" in the official Wiki, describes how to configure the parameters of Eclipse, making it easy to complete the development of ns-3 projects through eclipse. As before, please visit HOWTO configure Eclipse with ns-3 in the official Wiki.

2.1 Configuring the WAF compiler (WAF Builder)
    • Right-click Engineering--Properties--click/C + + compile (c + + build)
    • Select compiler settings (builder Settings) tab
    • Cancel the Use default build command check box to change the build command to

${workspace_loc:/ns-allinone-3.25/ns-3.25}/waf

Where the italic part should be replaced by the corresponding directory name of your ns-3 project.

    • Cancel the check box before automatically generating the compiled script file (Generate makefiles automatically) and change the compiled directory (build directory) to

${workspace_loc:/ns-allinone-3.25/ns-3.25}

Where the italic part should be replaced by the corresponding directory name of your ns-3 project. And you can choose by clicking on the working directory (Workspace ... ) button to browse and select the compiled directory.

-Selection behavior (behaviour) tab
-Change the "all" command to "build" after compiling (build (incremental build))
-click the Apply or Confirm (OK) button to save the settings and exit

2.2 Configuring the Debugger (Debugger)
    • On the menu bar, click Run (Running), Debug configuration (Debug configurations)
    • Double-clicking on the C/C + + application (c + + application) project in the list on the left generates a new configuration file and names it (my name is ns-allinone-3.25 Debug)
    • Select the main (Main) tab
    • Click the Search Project button under the C/s + + application (application) and select the file you want to debug (typically a. cc file that contains the main function). The file is the one you want to debug when you click the Debug button, so you need to change it every time you need to debug a different file.
    • Click Browse under Project (Project) (Browse ... ) button to select your Ns-3 project

    • Select Environment (Environment) tab

    • Stand-alone new (new) button, create a new environment variable
    • Fill in the name with "Ld_library_path" (without quotation marks)
    • Fill in values (value)

${workspace_loc:ns-allinone-3.25/ns-3.25}/build

Where the italic part should be replaced by the corresponding directory name of your ns-3 project.

    • Select the "Attach to local environment (Append environment to native environment)" Radio box
    • Click the Apply button to apply the changes and exit
2.3 Configuring the External Run tool (External Runner)
    • Click the External tool configuration (External tools), external tools (External tools configurations), which runs (run) in the menu bar
    • Select the main (Main) tab
    • Click Browse Workspace under Location (browse Workspace ... ) button and select the WAF script file in the Ns-3 project. This should appear in the text box as follows:

${workspace_loc:/ns-allinone-3.25/ns-3.25/waf}

Where the italic part should be replaced by the corresponding directory name of your ns-3 project.

    • Click Browse Workspace under working directory (working directory) (Browse Workspace ... ) button and select the NS-3 Project catalog. This should appear in the text box as follows:

${workspace_loc:/ns-allinone-3.25/ns-3.25}

Where the italic part should be replaced by the corresponding directory name of your ns-3 project.
-Enter the run parameters in the text box under parameters (Arguments)

–run "${string_prompt}"

This allows you to execute the script by entering the name of the ns-3 script file that needs to be executed in the pop-up text box (the name does not include the suffix) when executing the ns-3 script from the external run tool.

Now that the configuration work in Eclipse is complete, you can try the compile, debug, and run functions correctly. You can also view more configuration information in the HOWTO configure Eclipse with ns-3 article in the official Wiki.

At this end, the installation and configuration section of ns-3 is completely complete and you can already use NS-3 for simulation or development. For the development of Ns-3, official website and official documents are very important reference materials, especially the official online API document, official Wiki page and three important official references--tutorial, Manual, Models, these three materials can be downloaded through the official website.

Thank you very much for your reading, I hope I write these words can give you the help you want.

ns-3 download, compile, and Eclipse-related configuration

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.