Installing and Running ns-3|THE NS-3 NETWORK SIMULATOR
Installing and Running ns-3
We here outline the steps for installing ns-3 under Linux from the “allinone” tar file, assuming that all prerequisite packages (such as gcc) are already in place. Much more general installation instructions can be found at www.nsnam.org. In particular, serious users are likely to want to download the current Mercurial repository directly. Information is also available for Windows and Macintosh installation, although perhaps the simplest option for Windows users is to run ns-3 in a Linux virtual machine.
The first step is to unzip the tar file; this should leave a directory named ns-allinone-3.nn, where nn reflects the version number (20 in the author’s installation as of this 2014 writing). This directory is the root of the ns-3 system; it contains a build.py (python) script and the primary ns-3 directory ns-3.nn. All that is necessary is to run the build.py script:
Considerable configuration and then compiler output should ensue, hopefully terminating with a list of “Modules built” and “Modules not built”.
From this point on, most ns-3 work will take place in the subdirectory ns-3.nn, that is, in ns-allinone-3.nn/ns3.nn. This development directory contains the source directory src, the script directory scratch, and the execution script waf.
The development directory also contains a directory examples containing a rich set of example scripts. The scripts in examples/tutorial are described in depth in the ns-3 tutorial in doc/tutorial.
Running a Script
Let us now run a script, for example, the file first.cc included in the examples/tutorial directory. We first copy this file into the directory “scratch”, and then, in the parent development directory, enter the command
An Introduction to Computer Networks, Release 2.0.4
./waf --run first
The program is compiled and, if compilation is successful, is run.
In fact, every uncompiled program in the scratch directory is compiled, meaning that projects in progress that are not yet compilable must be kept elsewhere. One convenient strategy is to maintain multiple project directories, and link them symbolically to scratch as needed.
The ns-3 system includes support for command-line options; the following example illustrates the passing by command line of the value 3 for the variable nCsma:
./waf --run "second --nCsma=3"
By default, ns-3 enables the -Werror option to the compiler, meaning that all warnings are treated as errors. This is good practice for contributed or published scripts, but can be rather exasperating for beginners. To disable this, edit the file waf-tools/cflags.py (relative to the development directory). Change the line
|self.warnings_flags = [['-Wall'], ['-Werror'], ['-Wextra']]|
|self.warnings_flags = [['-Wall'], ['-Wextra']]|
Then, in the development directory, run
Frequently Asked Questions
- Uses of Computer Networks
- Network Hardware
- OpenFlow and the POX Controller|Mininet
- RSA|PUBLIC-KEY ENCRYPTION
- Forward Secrecy|Public-Key Encryption
- Trust and the Man in the Middle|Public-Key Encryption
- End-to-End Encryption|Public-Key Encryption
- SSH and TLS|Public-Key Encryption
- IPsec |Public-Key Encryption