Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
NETWORKSIMULATOR-2
USING JAVA
Contents
Abstract
1. Introduction
1.1 Purpose
1.2 Abbreviations
1.3 Definitions
2. Project Description
3. Requirements
4. Design aspects
5. Coding
6. Results
7. Conclusions
8. Future work
9. References
ABSTRACT
effective. The performance of the network may not be as good as the one estimated
before the installation and this may sometimes lead to changing of the peripherals.
Therefore it is always better to have a simulation of the network using a computer than
network without the cost involvement. After having simulated the network, it can be
analyzed for its performance. This approach directs us to take a proper decision about
One of the foremost problems with the beginners of ns2 is what to do with the
enormous data provided by the trace files. Very little documentation is available which
will help the users of ns2 in extracting the required data and thus calculating parameters
like one-way delay, throughput etc. Besides calculating parameters, one is more
NANS is the utility which brings all these features into one and from now onwards,
1.1 Purpose
created the need for tools that could monitor network transmissions and analyse them.
We have many simulators like NS2, GLOMOSIM, SWANS etc. meant exclusively for
network simulations which helps us in estimating the performance of network without the
cost involvement. After having simulated the network, it can be analyzed for its
One of the foremost problems with the beginners of ns2 is what to do with the enormous
data provided by the trace files. Very little documentation is available which will help the
users of ns2 in extracting the required data and thus calculating parameters like one-way
delay, throughput etc. Besides calculating parameters, one is more interested in observing
This paper describes Trace graph a data presentation system for Network Simulator -2
Trace graph system provides many options for analysis, has capabilities to calculate
many parameters characterizing network simulation. The NS2 simulator leaves lot of
statistical data as the output of a particular simulation. Using this data that particular
network can be analyzed for its performance. This analysis may include the capturing of
1.2 Abbreviations
NS - Network Simulator
ACK - Acknowledgement
Wired Networks: A Wired network is a network with physical cables connecting each
system together.
Wireless Networks: The term wireless networking refers to technology that enables two
network cabling.
Adhoc Networks: Adhoc networks are mobile wireless networks that have no fixed
infrastructure. There are no fixed routers instead each node acts as a router and forwards
MANETS are wireless network formed by a collection of mobile nodes without any pre
established infrastructure
Simulator: A device that enables the operator to reproduce or represent under test
NS: The Network Simulator ns-2 is a discrete event simulator, which means it simulates
such events as sending, receiving, forwarding and dropping packets. The events are
TCP: A protocol developed for the internet to get data from one network device to
another; "TCP uses a retransmission strategy to insure that data will not be lost in
sessions over IP networks. TCP offers reliability by providing reliable packet delivery.
compared with variable bit rate. CBR is useful for streaming multimedia content on
limited capacity channels since it is the maximum bit rate that matters, not the average, so
ACK: ACK is a message sent to acknowledge the receipt of an error free data packet
from a remote machine. Acknowledgment is service that is used by TCP, to transmit data
reliably in an IP environment.
TCL: TCL is an interpreted language that operates, like Perl, within its own shell.
Establishing the computer networks in the different peripherals is cost effective. The
performance of the network may not be as good as the one estimated before the
installation and this may sometimes lead to changing of the peripherals. Therefore it is
always better to have a simulation of the network using simulators likes NS2,
GLOMOSIM, SWANS etc. meant exclusively for network simulations which helps us in
estimating the performance of network without the cost involvement. Here we are using
NS2. After having simulated the network with NS2, it can be analyzed for its
The main problem is that NS-2 doesnt provide any visualization options for simulation
results (trace files) analysis. Because of this reason trace graph NS-2 data presentation
system was created. This paper describes Trace graph a data presentation system for
Network Simulator NS-2. The simulator doesnt have any options implemented to
analyse simulations results so its hard to use it. Trace graph system provides many
network simulation, and statistical reports, saves calculation results to text files and to
developed, especially the largest one the Internet. Nowadays networks have more and
more workstations, the transmission speed increases and the connections capabilities rise.
created the need for tools that could monitor network transmissions and analyse them.
There have been developed network simulators, which help to design and test various
project. It fast became a property of the entire research community, where everyone can
add its own modules, and contributes to the development of the simulator. The first
version of NS was experimental. Now we are working with the second version called NS-
2.The simulator works under UNIX and Windows system platforms and is mainly used
for network research. It is widely used all over the world The main advantage of
experimental tests in real environment. The main problem is that ns-2 doesnt provide
any visualization options for simulation results (trace files) analysis. Because of this
reason Trace graph ns-2 data presentation system was created in year 2001 and has
been developed for a year and a half. This paper describes Trace graph a data
presentation system for Network Simulator ns-2. The simulator doesnt have any options
implemented to analyse simulations results so its hard to use it. Trace graph system
provides many options for analysis, has capabilities to calculate many parameters
processing time, to plot 250 various graphs, and statistical reports, to save calculations
results to text files and to process its own script files to do all the calculations
automatically. Trace graph has become very popular and is used by many ns-2 users.
The Network Simulator ns-2 is a discrete event simulator, which means it simulates
such events as sending, receiving, forwarding and dropping packets. The events are
sorted by time (seconds) in ascending order. The NS project is now a part of the
VINT PROJECT that develops tools for simulation results display, analysis and
NS formats. Currently, NS (version 2) written in C++ and OTcl (Tcl script language
C++. For simulation scenario and network topology creation it uses OTcl (Object
interpreter that has a simulation event scheduler and network component object libraries,
and network setup (plumbing) module libraries (actually, plumbing modules are
implemented as member functions of the base simulator object). In other words, to use
NS, you program in OTcl script language. To setup and run a simulation network, a user
should write an OTcl script that initiates an event scheduler, sets up the network topology
using the network objects and the plumbing functions in the library, and tells traffic
sources when to start and stop transmitting packets through the event scheduler. The term
"plumbing" is used for a network setup, because setting up a network is plumbing
possible data paths among network objects by setting the "neighbor" pointer of an object
to the address of an appropriate object. When a user wants to make a new network object,
he or she can easily make an object either by writing a new object or by making a
compound object from the object library, and plumb the data path through the object.
This may sound like complicated job, but the plumbing OTcl modules actually make the
job very easy. The power of NS comes from this plumbing. Another major component of
unique for a packet with scheduled time and the pointer to an object that handles the
event. In NS, an event scheduler keeps track of simulation time and fires all the events in
the event queue scheduled for the current time by invoking appropriate network
components, which usually are the ones who issued the events, and let them do the
appropriate action associated with packet pointed by the event. Network components
communicate with one another passing packet; however this does not consume actual
simulation time. All the network components that need to spend some simulation time
handling a packet (i.e. need a delay) use the event scheduler by issuing an event for the
packet and waiting for the event to be fired to itself before doing further action handling
the packet. For example, a network switch component that simulates a switch with 20
dequeues the event and fires it to the switch component, which then passes the packet to
an appropriate output link component. Another use of an event scheduler is timer. For
example, TCP needs a timer to keep track of a packet transmission time out for
retransmission (transmission of a packet with the same TCP packet number but different
NS packet ID). Timers use event schedulers in a similar manner that delay does. The only
difference is that timer measures a time value associated with a packet and does an
appropriate action related to that packet after a certain time goes by, and does not
simulate a delay.
Figure 2 shows the general architecture of NS. In this figure a general user (not an NS
developer) can be thought of standing at the left bottom corner, designing and running
simulations in Tcl using the simulator objects in the OTcl library. The event schedulers
and most of the network components are implemented in C++ and available to OTcl
through an OTcl linkage that is implemented using tclcl. The whole thing together makes
NS, which is a OO extended Tcl interpreter with network simulator libraries. This section
briefly examined the general structure and architecture of NS. At this point, one might be
simulation is finished, NS produces one or more text-based output files that contain
detailed simulation data, if specified to do so in the input Tcl (or more specifically, OTcl)
script. The data can be used for simulation analysis ( simulation result analysis examples
are presented in later sections)or as an input to a graphical simulation display tool called
Network Animator (NAM) that is developed as a part of VINT project. NAM has a nice
graphical user interface similar to that of a CD player (play, fast forward, rewind, pause
and so on), and also has a display speed controller.} Furthermore, it can graphically
present information such as throughput and number of packet drops at each link, although
space (see Figure 3). A packet header format is initialized when a Simulator object is
created, where a stack of all registered (or possibly useable) headers, such as the common
header that is commonly used by any objects as needed, IP header, TCP header, RTP
header (UDP uses RTP header) and trace header, is defined, and the offset of each header
in the stack is recorded. What this means is that whether or not a specific header is used,
agent, and a network object can access any header in the stack of a packet it processes
Usually, a packet only has the header stack (and a data space pointer that is null).
Although a packet can carry actual data (from an application) by allocating a data space,
very few application and agent implementations support this. This is because it is
implement an application that talks to another application cross the network, you might
want to use this feature with a little modification in the underlying agent implementation
Another possible approach would be creating a new header for the application and
modifying the underlying agent to write data received from the application to the new
header.
Simple ns script:
EXAMPLE:
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exit 0
$ns run
First two lines will create and open network simulator and nam.
There are number of ways of collecting output or trace data on a simulation. Generally,
trace data is either displayed directly during execution of the simulation, or (more
simulator. The first, called traces, record each individual packet as it arrives, departs,
them, representing the destination of collected data (typically a trace file in the
current directory). The other types of objects, called monitors, record counts
associated with all packets. To support traces, there is a special common header
The various traces begin with a single character or abbreviation that indicates the type of
trace, followed by a fixed or variable trace format. The tables listing the trace formats
For fixed trace formats, the table lists the event the triggers the trace under the
Event heading and the characters that start the trace under the Abbreviation
heading. The format is listed across the last two columns, and the type and value
for each element of the format are listed beneath under the Type and Value
For variable trace formats, the table lists the event the triggers the trace under the Event
heading and the characters that start the trace under the Abbreviation heading. The
last three columns list the possible flags, types, and values for the event under the
Depending on the packet type, the trace may log additional information:
Each trace line starts with an event (+, -, d, r) descriptor followed by the simulation time
(in seconds) of that event, and from and to node, which identify the link on which the
event occurred. The next information in the line before flags (appeared as "------" since
no flag is set) is packet type and size (in Bytes). Currently, NS implements only the
Explicit Congestion Notification (ECN) bit, and the remaining bits are not used. The next
field is flow id (fid) of IPv6 that a user can set for each flow at the input OTcl script.
Even though fid field may not used in a simulation, users can use this field for analysis
purposes. The next two fields are source and destination address in forms of "node.port".
The next field shows the network layer protocol's packet sequence number. Note that
even though UDP implementations do not use sequence number, NS keeps track of UDP
packet sequence number for analysis purposes. The last field shows the unique id of the
packet.
Having simulation trace data at hand, all one has to do is to transform a subset of the data
of interest into a comprehensible information and analyze it.A tracefile called "out.tr"
will be produced.This out.tr will be used for our simulation analysis. Figure 4shows the
2.2.3.3.2:Sample Graph
This section showed an example of how to generate traces in NS, how to interpret them,
and how to get useful information out from the traces. In this example, the post
To create new objects, protocols, and routing algorithms or to modify them ns-2 C++
source code has to be changed. The simulator supports wired, wireless(new and old
trace),wired cum wireless. Figure 5shows the ns-2 system architecture on a simple block
diagram. One of the blocks represents Trace graph. With ns-2 comes Network Animator ,
a visualization tool for packets flows. It only shows generated packets movement
users have to create their own programs to process the results trace files [1]. The ns-2
output data contains a lot of complicated information about simulation. There are a few
trace file formats and each of them can have various versions, so it can be hard to find out
how to extract necessary data. This is the reason why Trace graph is so useful. It makes
1) wired,
Normal trace format
Simple wireless
New wireless
networks.
Wired networks are almost always faster and less expensive than wireless
networks. Once connected, there is little that can disrupt a good wired connection.
TCP, UDP, multicast are the transportation protocols used in wired networks.
Web, ftp, telnet, CBR, stochastic are the traffic sources used .
In wired networks firstly we create the event scheduler (simulator) and set
up the tracing and then create the network topology and set up the routing. We will
create connection in the transport layer and create the traffic in the application layer and
connections.
network.
network a wired network will limit the logical reason of purchasing a notebook in
the first place.
3.4 Constraints: The typical problems we face when trying to run large simulations in ns,
the main constraints being that of memory and cpu-time. Of the different performance
1) Start-up time or the time taken before the actual simulation can start,
Start-up time can be defined as the time overhead required before the actual
o time taken to parse thru nodelist and populate each classifier in each node
Thus we find that start-up times mainly consist of time taken to compute routes
follows:
a. Turn off all tracing like trace-all and namtrace-all if tracing on ALL links
large simulations.
One of the most common problem that people face while running large
Packet-headers in ns
Different types of packet headers are defined for different protocols in ns. And
Thus by default each packet-header in ns, by default becomes heavy-weight which will
continue to increase as more protocols are added in ns. One way to significantly reduce
The term wireless networking refers to technology that enables two or more
cabling. Strictly speaking, any technology that does this could be called wireless
networking. In wireless network nodes can move, no explicit links are used to
connect nodes. There are two kinds of wireless networks: There are two kinds of
wireless networks:
Wireless traces begin with one of four characters followed by one of two different trace
formats, depending on whether the trace logs the X and Y coordinates of the mobile node.
. Similar to the old format, in the new format wireless traces begin with one of four
characters. The first letter of flags with two letters designates the flag type:
N: Node Property
Note that the value for the -Hd flag may be -1 or -2. -1 means that the packet is a
broadcast packet, and -2 means that the destination node has not been set. -2 is typically
seen for packets that are passed between the agent (-Nl AGT) and routing (-Nl RTR)
levels
3. Requirements:
3.1 Hardware Requirements:
4. Design Aspects
later be built.
4.1 Basic Idea of Design:
There are two major phases to design any process. The first one is diversification
design are components, component solution, and knowledge all contained in catalos,
textbooks, and the mind. During convergence, the designer chooses and combines
requirements document and as agreed to by the customer. The second phase is the gradual
elimination of all but one particular configuration of components and thus the creation of
the final product. Using one of a number of design methods the design task produces
a data design, an architectural design, an interface design and a component design. The
data design transforms the information domain model created during analysis into data
structures that will be required to implement the software. The architectural design
defines the relationship between major structural elements of the software, the design
patterns that can be used to achieve the requirements that have been defined for the
system, and the constraints that effect the way in which architectural patterns can be
applied. The interface design describes how the software communicates within itself,
with systems that interoperate with it, and with humans who use it. The component level
Read file
Tokenize
Calculate
Collect
Display
Calculate Throughput
Collect Throughput Calculate
Find Calculate
different connections (one wayDisplayThroughput
Throughput (RTT)
sequence
Collect
Display sequence
Collect delay
Calculate
Display
data Collect
CallRTT (delay)
to collect
Display data
data RTT Throughput
RTT data (RTT)
data data
(RTT) data
number
sequencedata delay data data data Delay) data (RTT) data
Options explanation:
information in to tokens based on the number of fields present in the trace file
format specified
FINDDIFFDIELDS: Separates the trace file information and stores the required
CALL TO COLLECT DATA: This method calls the following methods based on
methods
data for calculation of sequence number data from the given trace
from temporary array and check the event field required of delay
data from the given trace file and stores in temporary file
DISPLAY DELAY DATA: The generated temporary file is used to
RTT data from the given trace file and stores in temporary file
CALC THRU PUT (ONE WAY): This method calls the following methods
COLLECT THRU PUT (ONE WAY): collects the required data for
calculation of thru put for one way delay data from the given trace
CALC THRU PUT (RTT): This method calls the following methods
COLLECT THRU PUT (RTT): collects the required data for
calculation of thru put for RTT data from the given trace file and
Observed outputs
This is the output obtained for the parameter one way delay Vs time
This is the output obtained for the parameter sequence number Vs time
This is the output obtained for the parameter RTT Vs time
This is the output obtained for the parameter Throughput (RTT) Vs time
This is the output obtained for the parameter Throughput(one way delay) Vs
time
DATA PRESENTATION
Trace graph architecture enables implementing new system functions very easy. For
example adding a new graph can take only 10 minutes. The system could be expanded to
read other trace file formats like real network traces, e.g. a trace format converter could
be created for conversion to Trace graph format. Nodes movements with packets flows
2D/3D visualization could be added. More parameters from trace files could be used for
new graphs implementation. MATLAB environment enables to develop the system very
easy and very fast.
Future Work: