Communication and Computer Networks Simulator (NS2) : January 2014
Communication and Computer Networks Simulator (NS2) : January 2014
net/publication/264166764
CITATIONS READS
0 807
1 author:
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
High Altitude Platform Stations in Design Wireless Communication System View project
All content following this page was uploaded by Yousif Mohsin Hasan on 11 August 2016.
1.0 INTRODUCTION
NS meaning Network Simulation is an open source network simulation tool or software, which
was first, developed Steve McCanne in 1995-1997. NS (Version 2) is an object oriented, discrete
event driven simulator written in C++ (core) and Otcl (python). NS was mainly developed in
order for researchers to simulate various kinds of wired or wireless LAN and WAN thus
implementing network protocols such as TCP and UDP. In addition NS enables researchers to
study and understand traffic source behavior of FTP, VBR, CBR, Web and Telnet, not only that
but also router queue management mechanism such as DropTail, RED and CBQ, routing
algorithms such as Dijkstra, and many more.
NS2 was written in C++ and Otcl in order to differentiate the control and data path
implementations. The simulator supports a class hierarchy in C++ (the compiled hierarchy) and a
corresponding hierarchy within the Otcl interpreter (interpreted hierarchy). To understand more
about the control and data path, take for instance; basically simulation of protocols requires
efficient manipulation of bytes and packet headers thus making run-time speed very essential. On
the other hand, in network studies where the aim is to vary some parameters and to quickly
examine a number of scenarios the time to change the model and run it again is more important.
In NS2 for detailed protocol implementation (new queuing discipline), C++ is the best choice
this is because every packet flowing must be processed and C++ is quiet fast. On the other hand
Otcl is suitable for configuration and setup. Otcl runs a bit slow compared to C++, but it can be
changed very quickly making the construction of simulations easier. Another important aspect is
availability of the compiled C++ objects to the Otcl interpreter; this enables the objects to be
controlled from the OTcl level.
A network simulation performance for a network topology that consist of 3 sources, a gateway
and a receiver is analyzed using FTP and CBR applications connected over TCP and UDP agent
respectively. The benchmark for the simulation is done using the following queuing mechanisms
namely; Droptail, Stochastic Fair Queuing (SFQ) and Random Early Detection (RED) in which
the performance of this topology is analyzed. The report is organized as follows;
First, an introduction is carried out to give an overview on Network Simulation software (NS2)
and the aim of this simulation; this is followed by the methodology which gives an insight on the
steps carried out in developing the code script for the simulation, this is then followed by the
source code and NAM trace file for TCP Scenario. Afterwards the results of the simulation are
analyzed and a conclusion on the overall simulation is performed.
2.0 METHODOLOGY
This section will cover detail description on various sections of the code and their functions. The
various code sections are organized as follows;
b. Trace file
c. Source creation
g. Topology layout
agents used in creating a network topology for the simulation in determining network
performance . The class Simulator has all the basic functions to perform this task. Functions
belonging to the simulator class can be used by appending “$ns” at the beginning of the
command since the simulator object are design to be handled by ns. This is show below.
Trace file is use in collecting data for calculating of simulation results. With the aid of NS2 trace
file, drop or arrival of packet that occurs in queue or in a link are recorded. Below is the code
that is use in creating a trace file and the nam trace file for the simulation.
to be handle s0, s1, s2, G, r. The handles are used when referring to those nodes. Traffic sources
(FTP and CBR) are attached to the traffic agents (TCP and UDP) and these traffic agents are
attached to the nodes if a node is not a router but an end system. Below is the code for creating
#G acts as a gateway.
set G [$ns node]
#r acts as a receiver.
set r [$ns node]
one another by assigning color to each. The color assigning is done using the calling the color
It could be seen that the packet sent from node s0 and s1 have the assigned color red because
they use the same TCP traffic agent and that of node s2 has green color which uses a UDP traffic
agent.
together. When creating a link in NS2, the output queue and the queue type of a node are
implemented as part of the link. There are two types of links namely: simplex and duplex but in
this simulation all links are design to be duplex. The command for creating a duplex or simplex
The code section below shows a duplex link connection between all the sources (S0, S1 and S2)
and the gateway and from the gateway to the receiver using Drop tail queuing mechanism.
From the code section above, it could be seen that the duplex link connection the sources to the
gateway have a bandwidth of 6Mb and a delay of 5ms. The duplex link between the gateway and
There are several queue management algorithms implemented in ns2, but in this exercise only
The command above sets the queue limit of the two duplex links that connect node1 and node2
to the number specified. In this report, a queuing size of 5 is used between the gateway and the
$ns queue-limit $G $r 5
For the simulation scenario in ns2 to run successfully, there is need to set up the layout of the
network topology. This topology comprises of a collections of links and nodes. The code
fragment for creating the topology using 5 nodes is shown below:
includes number of arrived packets in the queue or number of packets drops, this therefore make
it possible to track the statistics of arrivals, departures and drops which can represented either in
bytes or packets . Similarly, queue size overtime can be tracked by the queue monitor.
The code fragment above shows the queue for monitoring the links.
The command used for setting up a TCP agent that uses Reno and attaching to a node s0 with a
window size of 8 byte which is the maximum amount of received data that can be buffered at any
given time on the receiving side of the connection.
The command used to create an FTP application and attaching it to a TCP/Reno agent is shown
below;
Similarly, the command use to create a CBR application and attaching it to a UDP agent is
shown by the code fragment below;
To terminate the flow of information without any processing, a UDP and TCP sources have to be
connected with traffic sinks.
While Class Agent/Null is use to define a UDP sink also shown below;
set null [new Agent/Null]
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exit 0
Figure 2: traffic flow for packet from source to receiver TCP = Yellow, UDP = Seagreen
5.0 Conclusion
The codes has been compiled and run based on the network simulation software of NS2 using
three queuing mechanism (Droptail, RED and SFQ queuing mechanism), as stated earlier from
the discussion of the result SFQ provide the best result among the three in terms of average
packet drop, and the number of packet drop per simulation time with less congestion in the
network as well as high throughput this is achieved duet to fact that SFQ does not actually assign
a queue for every session rather it uses an algorithm that divides the traffic over a restricted
number of queues. The result obtained from RED queuing mechanism as well agree with it
concept that it preserves high throughput which make it suitable mechanism to stop congestion
collapses, on the other side Droptail produce less performance as its treat each packet identically
and loss of packet causes the sender to enter slow start which decreases the throughput there by
increasing the congestion window. The aim and objectives of the project has been achieved
through learning the basic on how to use NS2 software and Ubuntu operating system, which
helped in clarifying and identifying different queuing mechanism as a basic of understanding the
basis for more complicated network simulation, and give more light towards understanding
network performance like queuing delay and packet loss where various session of queuing
mechanism behavior where observed and analyzed. The nam (NS2 network animator or GUI)
that receive some of the NS2 command to display the result help a lot in our discussion and
analysis
REFERENCE
5. Kalav, Dolly, and Sudha Gupta. "Congestion Control Communication Network Using RED,
SFQ and REM Algorithm."