Saturday, August 25, 2012

What is ns-3

ns-3 is a discrete-event network simulator, targeted primarily for research and educational use. ns-3 is free software, licensed under the GNU GPLv2 license, and is publicly available for research, development, and use.
The goal of the ns-3 project is to develop a preferred, open simulation environment for networking research: it should be aligned with the simulation needs of modern networking research and should encourage community contribution, peer review, and validation of the software.

Simulation models

The ns-3 project is committed to building a solid simulation core that is well documented, easy to use and debug, and that caters to the needs of the entire simulation workflow, from simulation configuration to trace collection and analysis.
Furthermore, the ns-3 software infrastructure encourages the development of simulation models which are sufficiently realistic to allow ns-3 to be used as a realtime network emulator, interconnected with the real world and which allows many existing real-world protocol implementations to be reused within ns-3.
The ns-3 simulation core supports research on both IP and non-IP based networks. However, the large majority of its users focuses on wireless/IP simulations which involve models for Wi-Fi, WiMAX, or LTE for layers 1 and 2 and and a variety of static or dynamic routing protocols such as OLSR and AODV for IP-based applications.
ns-3 also supports a real-time scheduler that facilitates a number of "simulation-in-the-loop" use cases for interacting with real systems.  For instance, users can emit and receive ns-3-generated packets on real network devices, and ns-3 can serve as an interconnection framework to add link effects between virtual machines.
Another emphasis of the simulator is on the reuse of real application and kernel code.  Frameworks for running unmodified applications or the entire Linux kernel networking stack within ns-3 are presently being tested and evaluated.

Community involvement

Because creating a network simulator that sports a sufficient number of high-quality validated, and maintained models requires a lot of work, ns-3 attempts to spread this workload over a large community of users and developers.
Every three months, we ship a new stable version of ns-3 with new models developed, documented, validated, and maintained by enthusiastic researchers. We encourage the open validation of these models by third parties on our mailing-lists to ensure that the models we ship are and stay of the highest quality possible.

 

ns-2 & ns-3

The difference between ns-2 and ns-3

ns-2 is a popular discrete-event network simulator developed under several previous research grants and activities. It remains in active use and will continue to be maintained.
ns-3 is a new software development effort focused on improving upon the core architecture, software integration, models, and educational components of ns-2. The project commenced in July 2006 and the first release was made on June 30, 2008.

ns-2 scripts in ns-3

ns-2 scripts will not run within ns-3. ns-2 uses OTcl as its scripting environment. ns-3 uses C++ programs or python scripts to define simulations.

ns-2 models in ns-3

Some ns-2 models that are mostly written in C++ have already been ported to ns-3: OLSR and Error Model were originally written for ns-2. OTcl-based models have not been and will not be ported since this would be equivalent to a complete rewrite.

Running scripts

Running C++ scripts

Once the build is done and all tests pass, one generally wants to run a couple of examples as per the tutorial. The easiest way to do this is to run:
./waf --run progname
To find out the list of available programs, you can do:
./waf --run non-existent-program-name.

Running python scripts

The method to run a python script is fairly similar to that of a C++ script except that you need to specify a complete path to the script file. For example:
./waf --run examples/wireless/mixed-wireless.py

Running scripts in a shell

Another way to run ns-3 programs that does not require using the ./waf –run command is to use the ns-3 shell which takes care of setting up all the environment variables necessary to do so:
./waf shell
And, then:
./build/debug/examples/csma-broadcast

Running C++ scripts with gdb

If you do not use the ns-3 shell, and if you want to run your simulation under a special tool (valgrind or gdb), you need to use a command template:
./waf --run csma-cd-one-subnet --command-template="gdb %s"
or:
./waf --run csma-cd-one-subnet --command-template="valgrind %s"
 

Writing scripts

Starting from an existing script

While experienced users of ns-3 often write new simulation scripts from scratch, most users merely copy/paste an existing script which incorporates the simulation models they need and modify it until it matches what they want. Consult the extensive example scripts that ship with every module.

Building a new C++ script

Once you have identified which simulation script you would like to start from, building a modified version of this script is a matter of dropping it in the scratch directory and running waf again:
cp examples/csma/csma-broadcast.cc scratch/csma-modified.cc
./waf
Running a new script which was dropped in the scratch directory is similar to running other examples.

Building many C++ files

If your simulation script becomes complex and if you split it in more than one C++ source file, you need to create a new sub-directory in the scratch directory:
mkdir scratch/modified
cp x.cc scratch/modified
cp y.cc scratch/modified
./waf
This will build a new program named after the name of your sub-directory (modified here) and you can run it just like any other example:
./waf --run modified
 

No comments:

Post a Comment