NS3 的安装

摘自:NS  官网

在安装NS3的过程中你的系统应该首先安装下面提示的软件,否则会出现很多莫名的错误。

Installation

From Nsnam

Jump to: navigation, search

Main Page - Roadmap - Current Development - Developer FAQ - User FAQ - Tools

Installation - Troubleshooting - HOWTOs - Samples - Contributed Code - Papers

This is a detailed installation guide for ns-3. Basic installation instructions can be found at the Getting Started page or in the ns-3 tutorial.

Contents

[hide]
  • 1 Supported platforms
    • 1.1 ns-3 options
  • 2 Prerequisites
    • 2.1 Ubuntu/Debian
    • 2.2 Fedora/RedHat
    • 2.3 Gentoo
    • 2.4 Mac OS X (Snow Leopard)
  • 3 Installation
    • 3.1 Downloading ns-3 Using Mercurial
    • 3.2 Downloading ns-3 Using a Tarball
  • 4 Building ns-3 with ns-3-allinone
    • 4.1 Configuration with Waf
  • 5 Validating
  • 6 Using Python
  • 7 Troubleshooting

Supported platforms

ns-3 is primarily developed on GNU/Linux platforms, and the minimal requirements to run basic simulations are a gcc installation of gcc-3.4/g++-3.4 or greater, and python 2.4 or greater.

ns-3 is supported on the following primary platforms:

  1. Linux x86 gcc 4.4, 4.3, 4.2, 4.1, and, 3.4.6.
  2. Linux x86_64 gcc 4.4.0, 4.3.2, 4.2.3, 4.2.1, 4.1.3, 3.4.6
  3. MacOS X ppc and x86 (gcc 4.0.x and 4.2.x)
  4. Cygwin gcc 3.4.4 (debug only), gcc 4.3.2 (debug and optimized).See also the experimental project: Ns3 on Windows using Visual Studio 2010 here

By supported, we mean that the project tries to support most or all of the build options on these platforms unless there is a good reason to exclude the option; and at least the debug build will compile. If you intend to do serious work using ns-3, and are forced by circumstances to use a Windows platform, consider virtualization of a popular Linux platform. This may be more time-consuming than installing a minimal Cygwin, for example, but you end up with a fully functional Linux system and ns-3 distribution. Some quick performance comparisons between Cygwin and VirtualBoxed Fedora 11 indicate that examples can actually run faster under VirtualBox.

We provide HOWTO documents describing the process for installing Linux support and getting ns-3 running using two popular virtualization products: VirtualBox (HOWTO use VirtualBox to run simulations on Windows machines) and VMware (HOWTO use VMware to set up virtual networks (Windows)).

ns-3 may also run on currently unsupported platforms. For example, an alternative Windows platform is MinGW. There are maintainers who attempt to keep a subset of ns-3 running on MinGW, but it is not "officially" suppported. This means that bugs filed against MinGW will be addressed as time permits. Additionally, the Eclipse IDE is used by some developers, but the project does not actively support this environment.

Additional maintainers are invited to make more platforms, compilers and environments supported.

ns-3 options

There are a few options that are not enabled by default and are not available on all platforms. At the end of the configuration process (explained below), the status of these options are shown as detected by a waf script:

---- Summary of optional NS-3 features:
Threading Primitives          : enabled
Real Time Simulator           : enabled
Emulated Net Device           : enabled
Tap Bridge                    : enabled
GtkConfigStore                : enabled
XmlIo                         : enabled
SQlite stats data output      : enabled
Network Simulation Cradle     : enabled
Python Bindings               : enabled
Python API Scanning Support   : not enabled (Missing 'pygccxml' Python module)
MPI Support                   : not enabled (option --enable-mpi not selected)
Use sudo to set suid bit      : not enabled (option --enable-sudo not selected)
Build examples and samples    : enabled
Static build                  : not enabled (option --enable-static not selected)
GNU Scientific Library (GSL)  : enabled

Generally if the platform is missing some requirement for an option it is marked as "not enabled." Note that "disabled by user request" will be shown when the user explicitly disables a feature (such as "--disable-python"); and if a feature defaults to disabled this will also be noted (e.g., option --enable-sudo not selected).

The table below is meant to help sort out the different features and on which platforms they are supported. This table reflects the status of the most recent release version (ns-3.9):

Option status
Option Linux gcc-4.x,gcc-3.4.x OS X Cygwin
Optimized build     X 1
Python bindings     X 2
Threading      
Real-time simulator   X X
Emulated Net Device   X X
Tap Bridge   X X
Network simulation cradle note3 X X
Static builds      

Key: ( )(empty space) = supported; X = not supported; ? = unknown; dev = support in ns-3-dev (next release)

Notes:

  1. Works with gcc4
  2. Cygwin limitation explained here
  3. NSC works best with gcc-3.4 or gcc-4.2 or greater series. Try to avoid gcc-4.0 and gcc-4.1 series; some build problems have been found with these versions of compilers.

Prerequisites

The core of ns-3 requires a gcc/g++ installation of 3.4 or greater, and python 2.4 or greater. As mentioned above, different options require additional support. This is a list of packages (for Debian/Ubuntu systems) that are needed to support different ns-3 options. Note that other distributions (e.g., Fedora, FreeBSD) may have different package names or capitalization (e.g. ImageMagik). Installation should be similar for Red Hat/Fedora based systems, with "yum" replacing "apt-get", but some differences exist, so below is a guide for both Ubuntu (should generally apply to Debian) and Fedora/RedHat-based systems:

Ubuntu/Debian

The following list of packages should be accurate for Ubuntu 9.10 release; other releases or other Debian-based systems may slightly vary.

  • minimal requirements for C++ (release): This is the minimal set of packages needed to run ns-3 from a released tarball.
 sudo apt-get install gcc g++ python
  • minimal requirements for Python (release): This is the minimal set of packages needed to work with Python bindings from a released tarball.
 sudo apt-get install gcc g++ python python-dev
  • Mercurial is needed to work with ns-3 development repositories.
 sudo apt-get install mercurial
  • Running python bindings from the ns-3 development tree (ns-3-dev) requires bazaar
 sudo apt-get install bzr
  • Debugging:
 sudo apt-get install gdb valgrind 
  • GNU Scientific Library (GSL) support for more accurate WiFi error models
 sudo apt-get install gsl-bin libgsl0-dev libgsl0ldbl
  • The Network Simulation Cradle (nsc) requires the flex lexical analyzer and bison parser generator:
 sudo apt-get install flex bison
  • To install gcc-3.4 for some Network Simulation Cradle (nsc) stacks:
 sudo apt-get install g++-3.4 gcc-3.4
  • To read pcap packet traces
sudo apt-get install tcpdump
  • Database support for statistics framework
sudo apt-get install sqlite sqlite3 libsqlite3-dev
  • Xml-based version of the config store (requires libxml2 >= version 2.7)
sudo apt-get install libxml2 libxml2-dev
  • A GTK-based configuration system
 sudo apt-get install libgtk2.0-0 libgtk2.0-dev
  • To experiment with virtual machines and ns-3
 sudo apt-get install vtun lxc
  • Support for utils/check-style.py code style check program
sudo apt-get install uncrustify
  • Doxygen and related inline documentation:
 sudo apt-get install doxygen graphviz imagemagick
 sudo apt-get install texlive texlive-pdf texlive-latex-extra texlive-generic-extra texlive-generic-recommended
  • The ns-3 manual and tutorial are written in Texinfo (doc/tutorial or doc/manual):
 sudo apt-get install texinfo dia texlive texlive-pdf texlive-latex-extra texlive-extra-utils texlive-generic-recommended texi2html
  • Support for Gustavo Carneiro's ns-3-pyviz visualizer
sudo apt-get install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev

Fedora/RedHat

The following list of packages should be accurate for Fedora 12/CentOS 5.4 release; other releases may slightly vary.

  • minimal requirements for C++ (release): This is the minimal set of packages needed to run ns-3 from a released tarball.
 yum install gcc gcc-c++ python
  • Note: If you are using CentOS 5.4 or RHEL 5, you may want to also get and use the gcc44 packages; see the Troubleshooting page.


  • minimal requirements for Python (release): This is the minimal set of packages needed to work with Python bindings from a released tarball.
 yum install gcc gcc-c++ python python-devel
  • Mercurial is needed to work with ns-3 development repositories.
 You may want to install mercurial from rpmforge repository (instructions here) or EPEL.
 yum install mercurial
  • Running python bindings from the ns-3 development tree (ns-3-dev) requires bazaar. You may need EPEL repository for this.
 yum install bzr
  • An optional but recommended package (for improving some wireless model fidelity) is GNU scientific library:
 yum install gsl gsl-devel
  • A GTK-based configuration system
 yum install gtk2 gtk2-devel
  • Debugging:
 yum install gdb valgrind 
  • Doxygen and related inline documentation:
 yum install doxygen graphviz ImageMagick
 yum install texinfo texinfo-tex
  • The ns-3 manual and tutorial are written in Texinfo (doc/tutorial or doc/manual):
 yum install texinfo dia texinfo-tex texi2html
  • The Network Simulation Cradle (nsc) requires the flex lexical analyzer and bison parser generator:
 yum install flex bison
  • To install gcc-3.4 for some Network Simulation Cradle (nsc) stacks:
 yum install compat-gcc-34
  • To read pcap packet traces
 yum install tcpdump
  • Database support for statistics framework
 yum install sqlite sqlite-devel
  • Xml-based version of the config store (requires libxml2 >= version 2.7)
 yum install libxml2 libxml2-devel
  • Support for utils/check-style.py style check program
 yum install uncrustify

Gentoo

The following list of packages should be accurate for Gentoo as of 04/22/2010; due to possible changes in USE-flags or package names the list may slightly vary.First of all, become root as usual.

  • minimal requirements for C++ or Python (release): This is the minimal set of packages needed to run ns-3 or to work with Python bindings from a released tarball.
 USE="threads -nocxx nptl" emerge -uavN gcc python
  • Mercurial is needed to work with ns-3 development repositories.
 emerge -av --noreplace mercurial
  • Running python bindings from the ns-3 development tree (ns-3-dev) requires bazaar
 USE="curl" emerge -uavN bzr
  • A GTK-based configuration system
 emerge -av --noreplace gtk+:2
  • Debugging:
 emerge -av --noreplace gdb valgrind 
  • Doxygen and related inline documentation; also ns-3 manual and tutorial (written in Texinfo):
 USE="extra graphics png" emerge -uavN texlive
 USE="cairo graphviz latex png svg" emerge -uavN doxygen imagemagick dia
  • The Network Simulation Cradle (nsc) requires the flex lexical analyzer and bison parser generator:
 emerge -av --noreplace flex bison
  • Some basic mobility visualization tests require goocanvas:
 emerge -av --noreplace goocanvas
  • To install gcc-3.4 for some Network Simulation Cradle (nsc) stacks:
 USE="-nocxx nptl" emerge -uavN gcc:3.4
  • To read pcap packet traces
 emerge -av --noreplace tcpdump

or you may prefer

 emerge -av --noreplace wireshark
  • Database support for statistics framework
 USE="threadsafe" emerge -uavN sqlite:3
  • Xml-based version of the config store (requires libxml2 >= version 2.7)
 emerge -av --noreplace libxml2
  • Support for Gustavo's ns-3-pyviz visualizer (following packages have no stable version as of day of writing, so ~arch for ACCEPT_KEYWORDS)
 ACCEPT_KEYWORDS="~x86" emerge -av --noreplace pygraphviz kiwi pygoocanvas
  • Support for utils/check-style.py style check program
 ACCEPT_KEYWORDS="~x86" emerge -av --noreplace uncrustify
  • To summarize all of above up (without not yet stable pygraphviz, kiwi, pygoocanvas, uncrustify):
 USE="cairo curl extra graphics graphviz latex -nocxx nptl png svg threads threadsafe" emerge -uavN bison bzr dia doxygen flex gcc gcc:3.4 goocanvas gtk+:2 imagemagick libxml2 mercurial python sqlite:3 tcpdump texlive valgrind wireshark

Mac OS X (Snow Leopard)

Please see HOWTO_get_ns-3_running_on_Mac_OS_X_(10.6.2_Intel) and follow steps 1 and 2 (prerequisites) and continue reading below if you want to work with a released version, and follow all steps if you want to work with a development version of ns-3.

Installation

The ns-3 code is available in Mercurial repositories on the server http://code.nsnam.org (look for the latest release e.g., "ns-3.4"). You can download a tarball of the latest release at http://www.nsnam.org/releases or you can work with our repositories using Mercurial. We recommend using Mercurial unless there's a good reason not to (See the end of this section for instructions on how to get a tarball release).

The simplest way to get started using Mercurial repositories is to use the ns-3-allinone environment. This is a set of scripts that manages the downloading and building of various subystems of ns-3 for you. We recommend that you begin your ns-3 adventures in this environment as it can really simplify your life at this point.

Downloading ns-3 Using Mercurial

One practice is to create a directory called repos in one's home directory under which one can keep local Mercurial repositories. If you adopt that approach, you can get a copy of ns-3-allinone by typing the following into your Linux shell (assuming you have installed Mercurial):

 cd
 mkdir repos
 cd repos
 hg clone http://code.nsnam.org/ns-3-allinone

As the hg (Mercurial) command executes, you should see something like the following displayed,

 destination directory: ns-3-allinone
 requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 26 changesets with 40 changes to 7 files
 7 files updated, 0 files merged, 0 files removed, 0 files unresolved

After the clone command completes, you should have a directory called ns-3-allinone under your ~/repos directory, the contents of which should look something like the following:

 build.py*  constants.py  dist.py*  download.py*  README  util.py

Notice that you really just downloaded some Python scripts. The next step will be to use those scripts to download and build the ns-3 distribution of your choice.

If you go to the following link: http://code.nsnam.org/ you will see a number of repositories. Many are the private repositories of the ns-3 development team. The repositories of interest to you will be prefixed with ns-3. Official releases of ns-3 will be numbered as ns-3.release.hotfix. For example, a second hotfix to a still hypothetical release nine of ns-3 would be numbered as ns-3.9.2 on this page.

The current development snapshot (unreleased) of ns-3 may be found at http://code.nsnam.org/ns-3-dev/. The developers attempt to keep these repository in consistent, working states but they are in a development area with unreleased code present, so you may want to consider staying with an official release if you do not need newly-introduced features.

Since the release numbers are going to be changing, we will stick with the more constant ns-3-dev here, but you can replace the string ns-3-dev with your choice of release (e.g., ns-3.4) in the text below. You can find the latest version of the code either by inspection of the repository list or by going to the Getting Started web page and looking for the latest release identifier.

To download the most common options type the following into your shell (remember you can substitute the name of your chosen release number instead of ns-3-dev)

 ./download.py -n ns-3-dev

After download process completes, you should have several new directories under ~/repos/ns-3-allinone:

 build.py*     constants.pyc  download.py*  nsc/        README      util.pyc
 constants.py  dist.py*       ns-3-dev/     pybindgen/  util.py

Go ahead and change into ns-3-dev under your ~/repos/ns-3-allinone directory. You should see something like the following there:

 AUTHORS       examples/  RELEASE_NOTES  utils/   wscript
 bindings/     LICENSE    samples/       VERSION  wutils.py
 CHANGES.html  ns3/       scratch/       waf*
 doc/          README     src/           waf.bat*

You are now ready to build the ns-3 distribution.

Downloading ns-3 Using a Tarball

The process for downloading ns-3 via tarball is simpler than the Mercurial process since all of the pieces are pre-packaged for you. You just have to pick a release, download it and decompress it.

As mentioned above, one practice is to create a directory called repos in one's home directory under which one can keep local Mercurial repositories. One could also keep a tarballs directory. If you adopt the tarballs directory approach, you can get a copy of a release by typing the following into your Linux shell (substitute the appropriate version numbers, of course):

 cd
 mkdir tarballs
 cd tarballs
 wget http://www.nsnam.org/releases/ns-allinone-3.6.tar.bz2
 tar xjf ns-allinone-3.6.tar.bz2

If you change into the directory ns-allinone-3.6 you should see a number of files:

 build.py*     dist.py*      ns-3-dev/   pybindgen/  util.py
 constants.py  download.py*  nsc/        README

You are now ready to build the ns-3 distribution.

Building ns-3 with ns-3-allinone

The first time you build the ns-3 project you should build using the allinone environment. This will get the project configured for youin the most commonly useful way.

Change into the directory you created in the download section above. If you downloaded using Mercurial you should have a directory called ns-3-allinone under your ~/repos directory. If you downloaded using a tarball you should have a directory called something like ns-3-allinone-3.4 under your ~/tarballs directory. Type the following:

 ./build.py

You will see lots of typical compiler output messages displayed as the build script builds the various pieces you downloaded. Eventually you should see the following magic words:

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

Once the project has built you typically will not use ns-3-allinone scripts. You will now interact directly with Waf and we do it in the ns-3-dev directory and not in the ns-3-allinone directory.

Configuration with Waf

To see valid configure options, type ./waf --help. The most important option is -d . Valid debug levels (which are listed in waf --help) are: "debug" or "optimized". It is also possible to change the flags used for compilation with (e.g.):

 CXXFLAGS="-O3" ./waf configure 

or, alternately, the gcc compiler

 CXX=g++-3.4 ./waf configure

Note: Unlike some other build tools, to change the build target, the option must be supplied during the configure stage rather thanthe build stage (i.e., "./waf -d optimized" will not work; instead, do

 ./waf -d optimized configure; ./waf 

The resulting binaries are placed in build//srcpath. For example, in a debug build you can find the executable for the first.cc example as build/debug/examples/first. You can debug the executable directly by:

 ./waf --shell
 cd build/debug/examples
 gdb first

Of course, you can run gdb in emacs, or use your favorite debugger such as ddd or insight just as easily. In an optimized build you can find the executable for the first.cc example as build/optimized/examples/first.

In order to forcibly disable python bindings, you can provide the following option:

 ./waf --disable-python configure

In order to tell the build system to use the sudo program to set the suid bit if required, you can provide the following option:

 ./waf --enable-sudo configure

To start over a configuration from scratch, type:

 ./waf distclean

Or if you get stuck and all else fails:

 rm -rf build

followed by changing back into ns-3-allinone and doing:

 ./build.py

will basically reset your build state.

To see all waf options:

 ./waf --help

Validating

ns-3 has unit tests that can be run to verify the installation:

 ./test.py

which should produce output like:

PASS: TestSuite histogram
PASS: TestSuite ns3-wifi-interference
PASS: TestSuite ns3-tcp-cwnd
PASS: TestSuite ns3-tcp-interoperability
PASS: TestSuite sample
...


你可能感兴趣的:(NS3)