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 complex as it seems to be. In this article, the installation process in the official Wiki is slightly combed, hoping to bring some convenience to those who have just started learning.

At the same time, the descriptive narrative in the official Wiki is sufficiently specific. Therefore, there will be a large section of references in this article and no translation is intended. I hope you'll forgive me.

1. Install the ns-31.1 environment configuration

This section refer to the Prerequisites-ubuntu/debian section of the installation page in the examiner's wiki, please jump to the wiki page for query.

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 animation demonstration tool Netanim, which is a tool that is used very often by ns-3, so I think it belongs to the required tool). In the official Wiki, there are many other optional tools in the Prerequisites-ubuntu/debian section of the Installation page, which allows you to choose what you need to install later in the actual use.

Since the author is also a novice for programming under Linux, an excellent IDE seems indispensable to 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 the Eclipse for debugging (which is explained in the latter part of this article), so I chose it for debugging. The same IDE tools with official instructions are NetBeans and qtcreator.
Assuming that you intend 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).

The downloaded Ns-3 project should then be placed directly in the workspace folder for Eclipse identification.

1.2 Installing 1.2.1 Using the Bake tool

This tool is a tool for installing, compiling, and querying missing tools in the new version number of ns-3, but I have always used manual installation methods (described in the next section) and never tried such an installation. So. In this direct copy of the official wiki of the relevant information, please refer to the Examiner's wiki in the installation page of the installation-installation with Bake subsection.

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 number management tool), install the developer version number with the source code (with the latest features but not stable enough), Use the source code to install the published version (that is, the release version, the latest stable version number). The first way is officially recommended. However, the author did not use mercurial, and the manual installation method is relatively simple, so the author chose the third Way to install. So. This section describes the third way of installing. Two other installation options please visit the installation-manual Installation section of the official Wiki installation page for details.

    • Download Ns-3 source code compression package
      Download from the official. or perform the following instruction to copy directly from server to Local:
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 folder in the terminal (the folder where build.py is located, typically its folder name is "ns-allinone-3.25") and execute the compilation script:

./build.py

Wait patiently for a while (depending on the computer configuration different compile-time length, I compile time about 40 minutes), after the successful compilation will see such as 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 WAF configuration. WAF is a python-based, open-source compilation system, please search the relevant information by yourself.
      There are many parts of the official Wiki about WAF configuration, but it is not necessary for me to develop at the moment. So it's not listed here. See the Official Wiki Installation page on the Building ns-3 with Build.py-configuration with WAF section for details
      The author suggests, however, that the following instruction be executed to agree to compile the sample program (Src/examples, src/module/examples program) and test program (src/module/ns-3) in the source code. Tests in the program)
./wafconfigure--enable-examples--enable-tests

The sample program and test program are compiled and executed at the next compile time after the configuration is successful. This is done with WAF (the author is also less aware of the relationship between build.py compilation and WAF compilation):

./waf

After compiling, you can use ns-3 to simulate or develop

At this point, Ns-3 has been successfully installed on your computer.

Now go into the Ns-3 project folder (the WAF folder) and execute the instructions to execute 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

At the same time this verifies that your ns-3 was successfully installed.

2. Configure Eclipse

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

2.1 Configuring the WAF compiler (WAF Builder)
    • Right-click on the Project-> Property (properties), click 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

The italic section should be replaced with the corresponding folder name for your ns-3 project.

    • Cancel the check box before you actively generate the compiled script file (Generate makefiles automatically). and change the compilation folder (build directory) to

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

The italic section should be replaced with the corresponding folder name for your ns-3 project.

And you can choose by clicking on working folder (Workspace ... button to browse and select the compilation folder.



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

2.2 Configuring the Debugger (Debugger)
    • On the menu bar click Execute (Run) Debug Configuration (Debug configurations)
    • Double-clicking on the C + + application in the left-hand list (C + + application) project 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 C/s + + applications (application) and select the file (usually the. cc file that contains the main function) that you want to debug.

      The file is the one you want to debug when you click the Debug button, so you need to modify it every time you need to debug a different file.

    • Under Project (Project), click Browse (Browse ... ) button, 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" (no quotes)
    • Fill in values (value)

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

The italic section should be replaced with the corresponding folder name for your ns-3 project.

    • Select the "Attach to local environment (Append environment to native environment)" Radio box
    • Click Apply button to apply the change and exit
2.3 Configuring the External Execution tool (External Runner)
    • Click on the menu bar (run), external tools (External tools) and external tools configuration (External tools configurations)
    • Select the main (Main) tab
    • Click Browse Workspace under Location (browse Workspace ... button and select the WAF script file in Ns-3 project.

      At this point in the text box should show the sample example:

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

The italic section should be replaced with the corresponding folder name for your ns-3 project.

    • Click Browse Workspace under Working folders (working Directory) (Browse Workspace ... ) button and select the Ns-3 project folder.

      At this point in the text box should show the sample example:

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

The italic section should be replaced with the corresponding folder name for your ns-3 project.
-Enter an execution parameter in the text box under parameters (Arguments)

–run "${string_prompt}"

This allows execution of the script by executing the ns-3 script through an external execution tool (the name does not contain a suffix) by entering the file name of the ns-3 script that needs to be executed in the pop-up text box.

So far. All of the configuration work in Eclipse is complete. The ability to try out compile, debug, and execute functions correctly. You can also view many other configuration information in the HOWTO configure Eclipse with ns-3 article in the official Wiki.

End The installation and configuration section of ns-3 is completely complete and you have been able to use ns-3 for simulation or development. For the development of ns-3, official sites and official documents are important reference materials. In particular, the official online API documentation, official Wiki pages and three important official reference materials--tutorial, Manual, Models, three of which can be downloaded through the official website.

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

3. Installing the Netanim Animation Demo tool

Updated on 2016/04/28

This chapter is mainly based on the article "Netanim 3.107" in the official Wiki. To introduce how to download, compile, and simply use the Netanim Animation demo tool. The Netanim is able to read the contents of the log files recorded and generated during the ns-3 simulation. To show the simulation process in the form of animations. The following is a Netanim use (from the NS-3 official Wiki):

For more specific installation and usage please refer to "Netanim 3.107" of the official Wiki of Ns-3.

1. Environment configuration

Execute the following instruction to install the necessary tools to execute Netanim (actually these two tools we should have installed before):

apt-get install mercurialapt-get install qt4-dev-tools
2. Download Netanim Source code

If the Mercurial tool is installed. Can be downloaded directly to the folder by following the instructions below. If not installed, you can click on the following instructions in the link, through the browser download (if previously downloaded from the official website ns-allinone-3.xx source code package, the inside has brought the Netanim source code, the path is ns-allinone-3.xx/ NETANIM-3.XXX):

clone http://code.nsnam.org/netanim
3. Compiling

Enter the Netanim source code folder and execute the following command to compile it:

make cleanqmake NetAnim.pro  (For MAC Users: qmake -spec macx-g++ NetAnim.pro)make

After compiling, the executable file named "Netanim" is generated in the Netanim folder and can be executed by double-clicking it.

4. Use

The use of Netanim is simple. A total of 3 steps:

    • Add a header file to the. cc file (which I generally call the scene script) that has the main function written:
include"ns3/netanim-module.h"
    • Declare a Animationinterface object before the Simulator::run () function in the scene script:
AnimationInterface anim ("AnimFileName.xml");
    • After performing the simulation, double-click the Netanim executable to execute the program and click on the "Open" button to select the previously generated Animfilename.xml file.

      Finally, click on the "Play" button to see the animated presentation.

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.