Sunteți pe pagina 1din 6

Personal Notes on the Network Simulator NS-3

Mubashir Husain Rehmani

Version 1

26th July 2010

H. Rehmani is a PhD studnet at Lip6/Universti Pierre et Marie Curie (UPMC) e Paris-6, France, e-mail: mubashir.rehmani@lip6.fr; The author would like to thanks Aline Carneiro Viana, who is with INRIA, France, e-mail: aline.viana@inria.fr

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

3 Some Basic Components 3.1 Tracing in NS-3 . . . . . . . . . . . . . . . . . . . . . . . . . . . .

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.

NS-3 Installation Procedure on Ubuntu (Linux)

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

Figure 2: Comparison of NS-2 and NS-3 existing models.

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

Running rst program on NS-3

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

and it will print Hello Simulator on the console.

2.3

Running AODV Protocol

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.

Figure 3: Running a simple example of AODV Protocol in NS-3.

2.4

How changes taken into aect in NS-3? Recompilation of NS-3

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 ; }

Some Basic Components


Node: The basic computing device in NS-3 is node and it is dened through the class Node. Application: A user program that generates some activity is called as Application in NS-3. It is dened through the class Abstraction. For e.g. UdpEchoClientApplication and UdpEchoServerApplication. Channel: The medium over which the data ows is called channel and it is dened through the class Channel. In NS-3, we have CsmaChannel, PointToPointChannel and WiChannel. NetDevice: It is the network interface card and it is dened through the class NetDevice. For e.g. CsmaNetDevice, PointToPointNetDevice, and WiNetDevice. The CsmaNetDevice is designed to work with a CsmaChannel; the PointToPointNetDevice is designed to work with a PointToPointChannel and a WiNetNevice is designed to work with a WiChannel. Toplogy Helper: Topology helpers are designed to provide help in connecting NetDevices to Nodes, NetDevices to Channels, assigning IP addresses, etc., as they are common tasks in NS-3.

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

S-ar putea să vă placă și