Hands On Training in NS2
Hands On Training in NS2
ON
COURSE CONTENTS
MODULE -1
Durations Topics Resource Person
Introduction to NS2
Overview
Why TCL, Installation of NS-2
Week 1 Dr. C.Kotteeswaran
Network Component
Node and Routing
Packet Flow
Assignment-1
Overview of ns-2 simulation test bed
ns architecture
NS programming
Dr. C.Kotteeswaran
Week 2 TCL interpreter, characteristics, X Graph
Assignment-2
Basic Linux and Ns2
Node Commands
Dr. C.Kotteeswaran
WIRELESS NETWORK PROGRAMS
Week 3
Assignment-3
MODULE -2
Durations Topics Resource Person
WSN program
Creation of TCP
AODV routing protocol
Multicast
1
Week 4 Link Dr. C.Kotteeswaran
Assignment-4
MODULE -3
Durations Topics Resource Person
Channel – Wireless Channel
1 NS 2 INTRODUCTION
2
(Object Tool Command Language). Network Simulation is first and foremost used in the
simulation of LAN and WAN network.
1.1 Overview
As shown in Figure (Simplified user view of NS2), in a simplified user's view, Network
simulation is an Object-oriented tool script interpretered with simulation event scheduler and the
libraries of network component object, and the libraries of network setup (plumbing) module (in
fact it is the plumbing modules which are implemented as member functions of the base
simulator object). Otherwise to use NS, we have to program in OTcl script language.
To create and run a simulation, OTcl script should be written by the user that creates an
event, initiate the network topology set up using the objects of the network and comment the
traffic sources and fix the transmission time and stop time of transmitting packets through the
event scheduler.
NS Simulator Library
Network Animator
One more imporant component of NS beside network objects is the event scheduler. An
event in NS is a packet ID that is unique for a packet with scheduled time and the pointer to an
object that handles the event. In NS, an event scheduler continuously tracking of simulation time
period and fires all the simulation events in the event queue programmed for the present time by
invoking suitable network components, which more often than not are the ones who issued the
events in the simulation, and let them perform the suitable action connected with packet pointed
by the event.
Network components communicates with one another transitory packet, however this does
not devour real simulation time. Each and every network components that require spending a
little simulation time for handling a packet (i.e. essential delay) use the event scheduler by
providing an event for the packet and to come for the event to be fired to itself previous to doing
additional action handling the packet. For example, a network switch component that handles the
simulation which switch with 20 microseconds of switching delay issues an event for a data
packet to be switched to the scheduler as an event 20 microsecond afterward. The scheduler
following 20 microseconds handle the process of dequeue the event and fires it to the switch
component, which subsequently send the packet to a suitable output link component.
One more work of an event scheduler is timer. For example, Transmission Control
Protocol (TCP) needs to make use of a timer to keep tracking transmission time of a packet out
for further transmission (transmission of a packet with similar TCP packet number but dissimilar
network packet identication). Timers will make use of the event schedulers in a same manner
that delay does. The one and only difference in that timer is, it measures a time linked with a
4
packet and does a suitable action connected to that packet after a firm time goes by, and does not
simulate a time delay.
A user inscribe an OTcl script that’s creates an event scheduler, sets up the topology of the
network by make use of an objects of the network and the libraries plumbing functions, and
control the traffic sources when to initiate and finalize the transmission of the packets through
the event scheduler. Here plumbing is defined as a network setup, for the reason that setting up a
network is plumbing possible paths for data transfer between network objects by locating the
"neighbor" pointer of an object to the address of a suitable object. When a user needs to create a
new network object, he or she with no trouble can make an object either by creating a fresh
object or by constructing a compound object from the object library, and plumb the path of the
data through the object. This may resonance like difficult job, but the plumbing OTcl modules in
reality make the job trouble-free. The influence of NS comes from this plumbing.
NS is created not only in tool command language but in C++ also. For efficiency reason,
NS data path implementations are separated from control path implementations. Most
importantly the packet and event processing time has to be reduced, for that purpose the C++
language is used to write and compile the event scheduler and the component objects. These
compiled objects are ready accessible to the OTcl interpreter through an OTcl linkage that
creates a corresponding OTcl object for each and every C++ objects and makes the control
functions and the configurable variables specified by the C++ object take action as member
functions and member variables of the corresponding OTcl object. By the way, the controls of
the C++ objects are prearranged to OTcl. It is also probable to insert member functions and
variables to a C++ linked OTcl object.
TclObject
IN OUT DRP Edrp Drop RED TCP UDP Enq Deq Drop Recv
Tail
Reno SACK
Link
Unicast Node Multicast Node
Link
Figure Nodes (Unicast and Multicast)
A node of a network is one of a compound object composed by both the node entry object
and classifiers as shown in Figure (Unicast and Multicast). There are two important types of
nodes in network simulation. First is unicast node, it has an address classifier with it that does the
operation of unicast routing and a port classifier. Next is multicast node, in addition to routing
6
and port classification, it has a classifier which classify multicast packets from unicast packets
and a multicast classifier that performs multicast routing.
In network simulation, Unicast nodes are in default condition. In order to create Multicast
nodes once the user must clearly notify in the input of the OTcl script, after the exact creation of
scheduler object, the nodes which are created that will be in the form of multicast nodes. Next
process is specification, once it get done then specify the node type, the user can also select a
exact routing protocol other than using a predifined one.
Unicast
- $ns rtproto type
- type: Static, Session, DV, cost, multi-path
Multicast
- $ns multicast (right after set $ns [new Scheduler])
1.2.3 Link
n0 Simplex Link n1
Link Entry
Queue Delay TTL
Agent/Null
Figure Link
Drop
First notify that a node’s output queue is actually implemented in the form of simplex
link object. Once after completing the process of dequeued packets from a queue are passed to
the Delay object that again simulates the link delay, and the dropped packets at a queue are
transferred to a Null Agent and are made freed there. Finally, the TTL object calculates Time To
Live (TTL) parameters for each received packets and updates.
7
1.2.4 Tracing
In NS2, activities of the network are traced around simplex links. If the simulator is
intended for to the trace network activities (specifically make use of $ns trace-all file or $ns
namtrace-all file), the links created after this commands will be followed by the upcoming trace
objects inserted as shown in Figure (Inserting Trace Objects). Users creates a trace object of type
type between the given source and destination nodes using the create-trace {type file src dst}
command.
RecvT
DrpT Agent/Null
Figure Inserting Trace Objects
Drop
On the whole, tracing objects are intended to trace packet arrival time at which the
localization is done. Even though a user gets sufficient information from the trace files, he or she
might be concerned with what is going inside the output queue. For example, a user paying
attention in RED queue behavior may want to calculate the dynamics of average and current
queue size of a exact RED queue (i.e. need for queue monitoring). Queue monitoring can be
successfully achieved using queue monitor objects and snoop queue objects as shown in Figure
(Monitoring Queues).
8
Link with Snoop Queue Objects
Link Entry
SnoopQ/Drop Agent/Null
Drop
Queue Monitor
When a data packet arrives, the queue monitor object is notified by the snoop queue
object of this event. Using this information the queue is monitored by the queue monitor. RED
Queue Monitor Example section shows some examples for RED queue monitoring. Note that
snoop queue objects can be second-hand in parallel with tracing objects although it is not shown
in the above figure (Figure Monitoring Queues).
Until now, the examination of two most important network components (node and link) is
done. Figure (Packet Flow Examples) shows internals of an example simulation network setup
and packet flow. The number of nodes network is two which is node 0 (n0) and node 1 (n1) of
which the network addresses are 0 and 1 respectively. A TCP agent (sender agent) attached to n0
using port 0 communicates with a TCP sink object (destination agent) attached to n1 port 0.
Finally, an FTP application layer (or traffic source) is attached to the TCP agent (sender
application), asking to send some amount of data to the destination which is node 1.
9
Figure Packet Flow Examples
Features:
10
Simulation of various kinds of wireless networks
Terrestrial (cellular, Adhoc, GPRS, WLAN, BLUETOOTH), satellite network are used
IEEE 802.11 standard can be simulated, Mobile Internet Protocols and Ad hoc protocols
such as DSR, TORA, DSDV and AODV Routing are simulated
NAM(Network Animator)
xGraph
1.3.3 NS ARCHITECTURE
1.3.4 NS PROGRAMMING
11
1.3.5 TCL INTERPRETER
TclCL is the language used to provide a linkage between C++ and OTcl. Toolkit
Command Language(Tcl/OTcl) scripts are written to set up/configure network topologies. TclCL
provides linkage for class hierarchy,object instantiation, variable binding and command
dispatching. OTcl is used for periodic or triggered events
1. Events Scheduler
2. NAM- The Network Animator
3. Xgraph- For plotting
4. Pre Processing- Traffic & Topology generator
5. Post Processing- Simple Trace Analysis often used TCL and Pearl
1.3.6 CHARACTERISTICS
2. Multicasting
NAM provides a visual interpretation of the network topology created. The application was
developed as part of the VINT project. Its feature is as follows.
12
Controls include play; stop fast forward, rewind, pause, a display speed controller button
and a packet monitor facility.
Presented information such as throughput, number packets on each link
1.3.8 X Graph
Interactive plotting and graphing Animated and derivatives, to use Graph in NS-2 the
executable can be called within a TCL script. This will then load a graph displaying the
information visually displaying the information of the file produced from the simulation. The
output is a graph of size 800 x 400 displaying information on the traffic flow and time.
1.3.9 Simulation tool
NS2 are often growing to include new protocols. LANs need to be updated for new
wired/wireless support. ns are an object oriented simulator, written in C++, with an OTcl
interpreter as a front-end. The simulator supports a class hierarchy in C++ and a similar class
hierarchy within the OTcl interpreter (also called the interpreted hierarchy). The two hierarchies
13
are closely related to each other; from the user’s perspective, there is a one-to-one
correspondence between classes in the interpreted.
cd : change directory
Syntax: cd directoryname
Syntax: ls
Syntax: rm filename
Syntax: pwd
Syntax: ps
Syntax: clear
14
gedit: Create and open the file in text editor.
Syntax: ./ objectfilename
Go to ns-2.34 folder,
Do (./configure)
Do make all.
Do make install.
15
Open Terminal
gedit ~/.bashrc
Add the TCL library, LD library and ns library path in .bashrc file.
source ~/.bashrc
16
3 Scenarios
Simulation Script
17
18
Save the simulation script in specific folder.
Syntax: ns filename.tcl
e.g. ns First_script_wired.tcl
19
3.1.2 Flow of Simulation (Network Topology – Link)
20
3.1.4 Flow of Simulation (Transport)
21
3.1.6 Flow of Simulation (Packet Flow)
22
3.2.1 Simulation Script 2
23
24
3.3 Node Orientation
25
3.4 Node Commands
$node id
$node node-addr
$node reset
$node entry
$node neighbors
$node incr-rgtable-size
$link head
$link link
26
$link add-to-head <connector>
$link queue
$link cost?
$link if-lable?
$link up
$link down
$link up?
$ns halt
$ns run
$ns flush-trace
$ns clearMemTrace
$ns is-started
$ns dumpq
27
More functions
$ns flush-trace
More Functions,
28
3.9 Third Simulation Scenario
29
30
31
3.10 Wired file format
32
Event Time From- To- Pkt- Pkt- Fid Src- Dest- Seq- Pkt-
Node Node Type Size Flags addr addr num id
33
4 WIRELESS NETWORK PROGRAMS
34
35
36
OUTPUT
NETWORK FORMATION
DATA TRANSMISSION
37
4.2 UNICAST PROGRAM
38
OUTPUT
39
DATA TRANSFER
40
4.3 MULTICAST PROGRAM 1
41
42
OUTPUT
DATA TRANSMISSION
43
4.4 MULTICAST PROGRAM 2
44
45
OUTPUT
DATA TRANSMISSION
46
4.5 Mobile/Wireless Node Structure
47
4.6 WIRELESS PROGRAM 1
48
49
50
OUTPUT
DATA TRANSFER
51
4.7 WSN PROGRAM – 802.11
52
53
54
OUTPUT
DATA TRANSFER
55
4.8 WSN PROGRAM – 802.15.4
56
57
OUTPUT
58
5 Protocol Works
bool malicious;
2. Add the following statement to the aodv.cc file in the "if(argc==2)" statement.
if(strcmp(argv[1], "malicious") == 0) {
desyn = true;
return TCL_OK;
}
3. Implement the behavior of the malicious node by setting the following code in the
rt_resolve(Packet *p) function. The malicious s node will simply drop the packet as indicated
below.
59
if(malicious ==true)
{
drop(p,DROP_RTR_ROUTE_LOOP);
}
Once the compilation is done, Check the malicious behavior using the Tcl Script by setting any
four node as malicious node. The command to set the malicious node is
$ns at 2.0 "[$n0 set ragent_] malicious "
60
./setdest –v 2 –n 10 –s 1 –m 10 –M 50 –t 30 –P 1 –p 1 –x 500 –y 500
./setdest –v 2 –n 10 –s 1 –m 10 –M 50 –t 30 –P 1 –p 1 –x 500 –y 500 >usersetdest.tcl
gedit usersetdest.tcl
6. PROGRAMS
Program Description
Basic wirless construction with number of nodes contained is three. The procedure to
create nam file and trace file is given in this program. Topology is created by giving the position
to the nodes and is specified by X, Y and Z coordinates. Here initial size of each and every nodes
are built using initial_node_pos.The routing protocol which is used in this program is AODV
(Adhoc On-demand Vector Routing Protocol). And simulation end time is 10ms.
61
62
Procedure to run the program in the terminal window - $ns program1.tcl
OUTPUT
63
6.2 PROGRAM 2 – Code for the construction of wireless nodes with fixed colors
Program Description:
Number of nodes in the network is eight which are created and configured as mobile
wireless nodes. Procedure for the creation of nam file and trace file is given and is followed by
the topology creation. Localization of the network is specified by using the X, Y and Z
coordinates and the Z coordinates are always remains zero. Routing protocol is AODV and the
stop time of the simulation is 10ms. Here all the nodes are created in cyan color.
64
65
66
Procedure to run the program in the terminal window - $ns program2.tcl
OUTPUT
6.3 PROGRAM 3 – Dynamic node creation program using AODV protocol TCL script
Program Discription
Number of nodes in the network is not static in this program. Number of nodes
construction is given during the run time of the program. The user should give the number of
nodes in the terminal window during the execution of the program. Procedure for the creation of
nam file and trace file is given and is followed by the topology creation. Localization of the
network is specified by using the X, Y and Z coordinates and the Z coordinates are always
remains zero. Routing protocol is AODV and the stop time of the simulation is 10ms. Here all
the nodes are created in yellow color.
if {$argc != 1} {
error "\nCommand: ns wireless1.tcl <no.of.mobile-nodes>\n\n "
}
67
68
69
Procedure to run the program in the terminal window - $ns program3.tcl
OUTPUT
70
6.4 PROGRAM 4 – Dynamic node creation program and its initial location using AODV
protocol TCL script
Program Discription
Number of nodes in the network is not static in this program. Number of nodes
construction is given during the run time of the program. The user should give the number of
nodes in the terminal window during the execution of the program. Procedure for the creation of
nam file and trace file is given and is followed by the topology creation. Localization of the
network is specified by using the X, Y and Z coordinates and the Z coordinates are always
remains zero. Here initial size of each and every node is created by the use of the command
(initial_node_pos). Routing protocol is AODV and the stop time of the simulation is 10ms. Here
all the nodes are created in yellow color.
X dimension – 600
Y dimension – 600
Stop time – 10ms
Color – Yellow color
Initial Node Position - 30
if {$argc != 1} {
error "\nCommand: ns wireless3.tcl <no.of.mobile-nodes>\n\n "
}
71
72
Procedure to run the program in the terminal window - $ns program4.tcl
OUTPUT
73
6.5 PROGRAM 5 – Dynamic color creation program and its initial location of nodes using
AODV routing protocol TCL script
Program Discription
Number of nodes in the network is static in this program. Nodes are configured in the
mobile wireless node format. Procedure for the creation of nam file and trace file is given and is
followed by the topology creation. Localization of the network is not static. X and Y coordinates
are randomly selected and the Z coordinates are always remains zero. Here initial size of each
and every node is created by the use of the command (initial_node_pos). Routing protocol is
AODV and the stop time of the simulation is 10ms. Here all the nodes colors will get modified
dynamically according to the time period
Number of nodes - 4
X dimension – 750
Y dimension – 550
Stop time – 3.0ms
Color – Yellow color
Initial Node Position - 30
74
75
76
Procedure to run the program in the terminal window - $ns program5.tcl
OUTPUT
77
6.6 PROGRAM 6 – Node mobility construction program using DSR routing protocol TCL
script
Program Discription
Number of nodes in the network is static. Nodes are configured in the mobile wireless
node format. Procedure for the creation of nam file and trace file is given and is followed by the
topology creation. Localization of the network is static. X and Y coordinates values are given in
the program and the Z coordinates are always remains zero. Movement for each and every node
is built with static speed and spectifed receiver address which is randomly generated and also the
mobility will get change accoding to the time period. Here initial size of each and every node is
created by the use of the command (initial_node_pos). Routing protocol is DSR and the stop
time of the simulation is 10ms.
X dimension – 750
Y dimension – 550
Stop time – 3.0ms
Color – Yellow color
Initial Node Position - 30
if {$argc != 1} {
error "\nCommand: ns program6.tcl <no.of.mobile-nodes>\n\n "
}
78
79
80
81
Procedure to run the program in the terminal window - $ns program6.tcl
OUTPUT
82
6.7 PROGRAM 7 – Creation of TCP (Transmission Control Protocol) communication
between the nodes using AODV routing protocol TCL script
Program Discription
Number of nodes in the network is static and is declared as three in the network. Nodes
are configured in the mobile wireless node format. Procedure for the creation of nam file and
trace file is given and is followed by the topology creation. Localization of the network is static.
X and Y coordinates values are given in the program and the Z coordinates are always remains
zero. Movement for each and every node is built with static speed and spectifed receiver address
which is randomly generated and also the mobility will get change accoding to the time period.
Here initial size of each and every node is created by the use of the command (initial_node_pos).
Routing protocol is AODV and the stop time of the simulation is 150ms. Three nodes are created
which are node0, node 1 and node 2. Send TCP agent is created and attached to node0,
destination TCPsink agent is created and attached to node1. Then the TCP agent and the
TCPsink agent are connected. In the next level, FTP application is created and attached to the
sender TCP agent. Now the communication is initiated.
X dimension – 500
Y dimension – 400
Stop time – 150 ms
83
84
85
Procedure to run the program in the terminal window - $ns program7.tcl
OUTPUT
86
6.8 PROGRAM 8 – Creation of TCP (Transmission Control Protocol) communication
between the nodes using DSR routing protocol TCL script
Program Discription
Number of nodes in the network is static and is declared as three in the network. Nodes
are configured in the mobile wireless node format. Procedure for the creation of nam file and
trace file is given and is followed by the topology creation. Localization of the network is static.
X and Y coordinates values are given in the program and the Z coordinates are always remains
zero. Movement for each and every node is built with static speed and spectifed receiver address
which is randomly generated and also the mobility will get change accoding to the time period.
Here initial size of each and every node is created by the use of the command (initial_node_pos).
Routing protocol is DSR and the stop time of the simulation is 150ms. Three nodes are created
which are node0, node 1 and node 2. Send TCP agent is created and attached to node0,
destination TCPsink agent is created and attached to node1. Then the TCP agent and the
TCPsink agent are connected. In the next level, FTP application is created and attached to the
sender TCP agent. Now the communication is initiated.
X dimension – 500
Y dimension – 400
Stop time – 150 ms
87
88
89
Procedure to run the program in the terminal window - $ns program8.tcl
OUTPUT
90
6.9 PROGRAM 9 – Creation of UDP (User Datagram Protocol) communication between
nodes with CBR traffic using AODV routing protocol TCL script
Program Discription
Number of nodes in the network is static and is declared as 22 in the network. Nodes are
configured in the mobile wireless node format. Procedure for the creation of nam file and trace
file is given and is followed by the topology creation. Localization of the network is static. X and
Y coordinates values are given in the program and the Z coordinates are always remains zero.
Movement for each and every node is built with static speed and spectifed receiver address
which is randomly generated and also the mobility will get change accoding to the time period.
Here initial size of each and every node is created by the use of the command (initial_node_pos).
Routing protocol is AODV and the stop time of the simulation is 150ms. Send UDP agent is
created and attached to sender node, destination UDPNull agent is created and attached to
destination node. Then the UDP agent and the UDPNull agent are connected. In the next level,
CBR application is created and attached to the sender UDP agent. Now the communication is
initiated.
Number or nodes - 22
X dimension – 1800
Y dimension – 840
Stop time – 150 ms
91
92
93
94
95
96
97
98
99
Procedure to run the program in the terminal window - $ns program9.tcl
OUTPUT
100
6.10 PROGRAM 10 – Creation of TCP (Transmission Control Protocol) communication
between the nodes using DSDV routing protocol TCL script
Program Discription
Number of nodes in the network is static and is declared as three in the network. Nodes
are configured in the mobile wireless node format. Procedure for the creation of nam file and
trace file is given and is followed by the topology creation. Localization of the network is static.
X and Y coordinates values are given in the program and the Z coordinates are always remains
zero. Movement for each and every node is built with static speed and spectifed receiver address
which is randomly generated and also the mobility will get change accoding to the time period.
Here initial size of each and every node is created by the use of the command
(initial_node_pos). Routing protocol is DSDV and the stop time of the simulation is 150ms.
Three nodes are created which are node0, node 1 and node 2. Send TCP agent is created and
attached to node0, destination TCPsink agent is created and attached to node1. Then the TCP
agent and the TCPsink agent are connected. In the next level, FTP application is created and
attached to the sender TCP agent. Now the communication is initiated.
101
102
103
Procedure to run the program in the terminal window - $ns program10.tcl
OUTPUT
104
6.11 PROGRAM 11 – Mobile node energy model construction TCL script
Program Discription
Number of nodes in the network is static and is declared as six in the network. Nodes are
configured in the mobile wireless node format. Procedure for the creation of nam file and trace
file is given and is followed by the topology creation. Localization of the network is static. X and
Y coordinates values are given in the program and the Z coordinates are always remains zero.
Movement for each and every node is built with static speed and spectifed receiver
address which is randomly generated and also the mobility will get change accoding to the time
period. Here initial size of each and every node is created by the use of the command
(initial_node_pos). Routing protocol is DSR and the stop time of the simulation is 18ms.
105
106
107
108
109
Procedure to run the program in the terminal window - $ns program11.tcl
OUTPUT
110
6.12 PROGRAM 12 – Creation of nodes at random destination at particular time interval
using AODV routing protocol TCL script
Program Discription
Number of nodes in the network is not static and is declared as six in the network. Nodes
are configured in the mobile wireless node format. Number of nodes construction is given during
the run time of the program. The user should give the number of nodes in the terminal window
during the execution of the program. Procedure for the creation of nam file and trace file is given
and is followed by the topology creation. Localization of the network is static. X and Y
coordinates values are given in the program and the Z coordinates are always remains zero.
Movement for each and every node is built with static speed and spectifed receiver address
which is randomly generated and also the detination location will get change accoding to the
time period.
111
112
113
Procedure to run the program in the terminal window - $ns program12.tcl
OUTPUT
6.13 PROGRAM 13 – Creation of nodes destination and random coloring using AODV
routing protocol TCL script
Program Discription
Number of nodes in the network is not static and is declared as eight in the network.
Nodes are configured in the mobile wireless node format. Number of nodes construction is given
during the run time of the program. The user should give the number of nodes in the terminal
window during the execution of the program. Procedure for the creation of nam file and trace file
is given and is followed by the topology creation. Localization of the network is static. X and Y
coordinates values are given in the program and the Z coordinates are always remains zero.
Movement for each and every node is built with static speed and spectifed receiver address
which is randomly generated and also the detination location will get change accoding to the
time period. Here initial size of each and every node is created by the use of the command
(initial_node_pos). Routing protocol is AODV and the stop time of the simulation is 10ms. Here
each and every group of the nodes is constructed with different type of colors.
114
115
116
Procedure to run the program in the terminal window - $ns program13.tcl
OUTPUT
117
6.14 PROGRAM 14 – Creation of nodes with the initial and destination position in random
manner using AODV routing protocol TCL script
Program Discription
Number of nodes in the network is not static and is declared as eight in the network.
Nodes are configured in the mobile wireless node format. Procedure for the creation of nam file
and trace file is given and is followed by the topology creation. Localization of the network is
static. X and Y coordinates values are given in the program and the Z coordinates are always
remains zero.
Movement for each and every node is built with static speed and spectifed receiver
address which is randomly generated and also the detination location will get change accoding to
the time period. Here initial size of each and every node is created by the use of the command
(initial_node_pos). Routing protocol is AODV and the stop time of the simulation is 10ms. Here
each and every group of the nodes is constructed with different type of colors.
118
119
120
Procedure to run the program in the terminal window - $ns program14.tcl
OUTPUT
121
6.15 PROGRAM 15 – Creation of graphs with X dimension and Y Dimension constructed
randomly using AODV routing protocol TCL script
Program Discription
Number of nodes in the network is static and is declared as three in the network.
Procedure for the creation of nam file and trace file is given and is followed by the topology
creation. Localization of the network is static. X and Y coordinates values are given in the
program and the Z coordinates are always remains zero. Graph is randomly generated using the
X and Y dimensions and is programmed to generate the trace file accordingly. Here the trace file
acts as a input file to plot the graph in the format of trace file. Routing protocol is AODV and the
stop time of the simulation is 10ms.
122
123
124
Procedure to run the program in the terminal window - $ns program15.tcl
OUTPUT
6.16 PROGRAM 16 – Creation of graphs with two parameters as inputs using AODV
routing protocol TCL script
Program Discription
Number of nodes in the network is static and is declared as three in the network.
Procedure for the creation of nam file and trace file is given and is followed by the topology
creation. Localization of the network is static. X and Y coordinates values are given in the
program and the Z coordinates are always remains zero. Graph is randomly generated using the
X and Y dimensions and is programmed to generate the trace file accordingly. The trace file acts
as input file to plot the graph in the format of trace file. Here single plotted graph consist of two
trace file values. Different colors are given to each trace file during plotting. Routing protocol is
AODV and the stop time of the simulation is 10ms.
125
126
127
Procedure to run the program in the terminal window - $ns program16.tcl
OUTPUT
6.17 PROGRAM 17 – Creation of graphs with more than two parameter files as inputs
using AODV routing protocol TCL script
Program Discription
Number of nodes in the network is static and is declared as three in the network.
Procedure for the creation of nam file and trace file is given and is followed by the topology
creation. Localization of the network is static. X and Y coordinates values are given in the
program and the Z coordinates are always remains zero. Graph is randomly generated using the
X and Y dimensions and is programmed to generate the trace file accordingly. The trace file acts
as input file to plot the graph in the format of trace file. Here single plotted graph consist of more
than two trace file values. Different colors are given to each trace file during plotting. Routing
protocol is AODV and the stop time of the simulation is 10ms.
128
129
130
Procedure to run the program in the terminal window - $ns program17.tcl
OUTPUT
131