Personal Notes On The Network Simulator NS-3: Mubashir Husain Rehmani
Personal Notes On The Network Simulator NS-3: Mubashir Husain Rehmani
Personal Notes On The Network Simulator NS-3: Mubashir Husain Rehmani
Version 1
H. Rehmani is a PhD studnet at Lip6/Universti Pierre et Marie Curie (UPMC) e Paris-6, France, e-mail: [email protected]; The author would like to thanks Aline Carneiro Viana, who is with INRIA, France, e-mail: [email protected]
M.
Contents
1 Introduction 2 NS-3 Installation Procedure on Ubuntu (Linux) 2.1 NS-3 validation . . . . . . . . . . . . . . . . . . . . . . 2.2 Running rst program on NS-3 . . . . . . . . . . . . . 2.3 Running AODV Protocol . . . . . . . . . . . . . . . . 2.4 How changes taken into aect in NS-3? Recompilation . . . . . . . . . . . . . . . of NS-3 . . . . 3 3 4 4 5 5 6 6
Introduction
The Network Simulator (NS-3) [1] is a discrete-event network simulator. NS-3 is not backward compatible with NS-2, instead, it is built from the scratch. It is written in C++ and Python Programming Language can be optionally used as an interface. It has extensive doxygen documentation [2], which is available on the Internet. NS-3 is trying to tackle problems present in NS-2 such as lack of memory management, coupling between dierent models (C++ weak base class problem) etc,. When we talk about NS-2, it has the strongest asset in terms of contributed code (cf. Fig. 1).
Figure 1: NS-2 contributed code. Since NS-3 is under development, there is very limited number of models and contributed codes compared to NS-2 (cf. Fig. 2), which is mentioned on the ocial site of NS-3 [1]. Therefore, NS-3 requires strong community participation to add the contributed codes as well as to improve the simulation credibility. One interesting feature of NS-3 is that the publication list will be maintained by the maintainers of NS-3 on the NS-3 ocial site. We now describe step-by-step procedure to install NS-3.
We consider NS-3 version 3.8 and the Ubuntu (Linux) distribution version 9.04. To install NS-3, we need to install some packages like gcc, g++, python, and mercurial (optional). Download the all-in-one copy of NS-3 from the ocial 3
site [1]. Then, go to the directory /ns-3-allinone/, and use the following commands to build and congure: ./build.py cd ns-3.8 // change your directory ./waf congure ./waf This will successfully install the NS-3.
2.1
NS-3 validation
In order to validate NS-3, run the following command: ./test.py -c core If NS-3 is installed correctly, it will give the message: 65 test out of 65 passed.
2.2
To run the rst program on NS-3, waf is required. Waf is a Python-based framework for conguring, compiling and installing applications. It is already included in the ubuntu repository. The syntax to run any NS-3 script is: ./waf - -run lename Now, we are ready to run our rst program on NS-3. We run the following command: ./waf - -run hello-simulator 4
2.3
Now, lets try to use AODV protocol. A simple example regarding aodv protocol is present in the following directory of NS-3: ns-allinone-3.8/ns-3.8/examples/routing/aodv.cc copy the le aodv.cc from the examples/routing directory and rename it myaodv.cc and put it in the scratch directory ns-allinone-3.8/ns-3.8/scratch Now, run the aodv example by the following command: ./waf - -run myadov AODV has run successfully and the output is present in the Fig 3.
2.4
Unlike NS-2, making changes in NS-3 is simpler and does not require to run the commands like make clean, make and sudo make install. Instead, user can simply make the changes in the appropriate le and just run the following command and this will recompile the whole NS-3 and user can see the changes taken into aect. ./waf - -run lename
Lets take a simple example. A user want to print the message whenever AODV process the Hello packets. To do this, user need to make changes in the le aodv-routing-protocol.cc, present in the following location: /ns-allinone-3.8/ns-3.8/src/routing/aodv/aodv-routing-protocol.cc User just need to put the following cout statement in the function: void RoutingProtocol::ProcessHello(RrepHeader const & rrepHeader, Ipv4Address receiver ) { std::cout Now Processing Hello Packet std::endl ; }
3.1
Tracing in NS-3
NS-3 generates pcap packet trace les. pcap les can be read and display through Wireshark.
References
[1] [Online]. Available: http://www.nsnam.org/ [2] [Online]. Available: http://www.nsnam.org/doxygen-release/index.html