Wireless Sensor Network Simulation and Analysis

Verified

Added on  2023/01/23

|37
|5073
|94
AI Summary
This document provides an analysis of the simulation of wireless sensor networks using DSDV and AODV routing protocols. It discusses the behavior of nodes, energy consumption, and packet transfer. The advantages and disadvantages of each protocol are also explored.
tabler-icon-diamond-filled.svg

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Wireless Sensor Network
Student Name
College
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Introduction
A wireless network is named so because of its unguided medium. This is a computer network which
makes use of wireless connection of data in between the nodes of its network. By the use of wireless
network, most of the telecommunication network companies, homes as well as business reduces the
cost of cable installations into the buildings for the connections between two network locations due to
the introduction of wireless networks. Wireless network as be designed and simulated just like the wired
network before it is deployed into real world scenario by the use of the Network Simulation -2 software
alias NetSim-2 or NS-2 which runs on both Linux and windows operating systems [1].
Network Design
The Network Animation tool alias NAM, is a tool which is used by the network Simulator software for
the core purpose of viewing the simulation of the network traces which were designed and its related
real world traces of packets. The NAM supports the layout topology, the animation of the packet level as
well as tools for data inspection and analysis [2].
The network simulation was done in NAM for both the DSDV and AODV routing protocol. Before the
network is simulated in the NAM tool, it is first designed in the NetSim software as shown in the
screenshot below.
Document Page
The screenshots below shows topology designs as depicted by the NAM tool just after the design from
the NetSim software.
The below screenshot shows topology with a circle which indicates packets which are being sent to the
destined node at the start of simulation.
Document Page
The below screenshot shows how packets are being transferred to the destined nodes from several
nodes as designed. At this point when the packets are being transferred, energy is being consumed
slows from the nodes affected.
Simulation
When the simulation begins, packets are sent from one node to another, energy is consumed at this
point. The behavior of the nodes during simulation depends on the routing protocol chosen. For this
case, protocol chosen are DSDV and AODV [3].
In a nutshell, the design consists of 20 nodes with two agents of type UDP and CBR traffic attached to
the UDP. The simulation is designed to run for 300 seconds.
For the simulation of DSDV at 50 seconds, 150 seconds and 250 seconds, the screenshots explain as
below.
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
DSDV routing protocol Simulation
The screenshot below is the representation of the behavior of DSDV routing protocol at 50 seconds.
From the beginning of simulation at zero seconds to 50 seconds, there was some relation of nodes from
one point to another and transfer of packets from one node to another. Node 20 which was attached to
the udp0 moved to its destination at null4 which. This is because node udp0 which was connected to
node 20 was pointed to null 4 [4]. Energy is lost during the process. There was also some movement and
collision of nodes; node 03 and node 11 collided since they were positioned on the same x axis at 499.
From 0-50, the energy of nodes was at the pick hence the transfer of packets was very high and faster.
Document Page
The screenshot below is the representation of the behavior of DSDV routing protocol at 150 seconds.
From 50 seconds all along to 150 seconds, there was decrease in the rate at which packets are being
transferred. The decrease in packet transfer is a result of increase in energy consumption from one node
to another. The consumption of energy is dependable in the initial total energy and power allocated to
each node. There was no movement of nodes at this stage since the all the nodes which were moving
from one position to another had already reached their respective destination [5].
Document Page
The screenshot below is the representation of the behavior of DSDV routing protocol at 250 seconds.
From 150 seconds to 250 seconds, the transfer of protocol reduced more further and there were also
some changes in the color of the nodes which was an indication of the decrease in the energy which is
used for protocol transfer. Almost all the nodes had given energy depletion warning that once turned
red, there would be no energy transfer at all [6].
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
AODV routing protocol simulation
The screenshot below is the representation of the behavior of DSDV routing protocol at 50 seconds.
From 0 towards 50, there was massive packet transfer in the first 5 seconds of simulation, the transfer
stopped after 5 seconds of transfer and then relocation of nodes began, node 20 moved towards null3
and node 1 moved towards node 14 since those are the positions at which the nodes were pointed
during design. Node 16 and node 11 moved towards node 3 since that is where they were pointed to.
From 5 seconds to 50, there was no single packet which was being transferred [7].
Document Page
The screenshot below is the representation of the behavior of DSDV routing protocol at 50 seconds.
From 50 seconds to 150 seconds, there was no process of packet transfer taking place, the nodes were
not moving to any position to, though energy was being consumed at this point. This is because in the
AODV routing protocol, transfer of packets is massive in the first 5 seconds of simulation and the process
is not evenly distributed all through the simulation process as the transfer of packets taken only 5
seconds before the relocation of nodes begins to take place [8].
Document Page
The screenshot below is the representation of the behavior of DSDV routing protocol at 50 seconds.
At 250 seconds, still no packet is being transferred, no sign of energy loss is witnessed here since all the
nodes are still with original color. This is because the transmission of packets which consumes a lot of
energy has taken place in the first 5 seconds then the process was halted. From that time there was no
energy consumption from the nodes as they were at idle state hence being the very main reason as to
why the energy loss did not happen even at 250 seconds [9].
Trace file analysis
Trace file for DSDV routing Protocol
From the trace file, at 0.004166565 seconds, packet is sent from node 0 containing no message, at this
point the energy is not consumed and remains at 60 joules. At 0.004262 seconds, all the nodes started
losing energy from 60 joules to 59.999358 joules. The drop of energy is due to the activities of sending
and receiving packets had already started [10].
From 0.004981773 to 0.005007365 packets were received to their respective destinations. Energy was
also consumed at this point and dropped to 59.999358 joules from all the nodes which were being used.
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
The process of sending and receiving packets continued from 0.005007365 seconds with consecutive
reduction of energy due to the packets sending and receiving activities [11].
The first two data packets send were dropped at 0.087875710 seconds from node 13, at 0.088595998
Seconds, all the data packets received were dropped while forwarding.
The simulation ended at 300 seconds with the energy consumed from 60 joules to 29.900644 joules at
the end. Only 4 nodes were still having more energy with other nodes dropped its energy below 30
joules. There was no node which had finished its energy. A total of 846 packets of data had been sent
and received in 300 seconds of simulation [12].
Trace file for AODV routing Protocol
For this routing protocol, packet sending began at 1.000000000 seconds which each node having initial
energy which was 60 joules. In the first 5 seconds of simulation, it is seen that there was massive packet
sending and receiving which attracted further massive data dropping within this time period.
Energy dropped from 60 joules to 58.809064 within 5 seconds. After words all packets had already been
send hence there was no data packet sending at this from this point [12].
M 6.00000 11 (449.00, 260.00, 0.00), (499.00, 400.00), 40.00
M 6.00000 16 (693.00, 526.00, 0.00), (499.00, 400.00), 40.00
From the 6th second to 10th, node 11 and node 16 relocated and collided with node 3 at 499 position as
seen in the above trace lines.
There was packet dropping at 1.009455238 seconds , which was packet forwarded by node 19 to node
12. This was due to the collision by node 0 forwarding AODV MAC level 106. All packet dropping have
been happening at node 0.
Simulation ended at 300 seconds when all nodes had their energy still 58.809064 there very little energy
was consumed in the process.
Document Page
Results
The below Graph is a representation of the DSDV routing protocol packets sent, packets received, the
packets dropped and the energy consumption
The below Graph is a representation of the AODV routing protocol packets sent, packets received, the
packets dropped and the energy consumption
Document Page
Conclusion
From the simulation analysis and results of the two routing protocols, that is DSDV and AODV, the
following can be concluded.
The rate at which packet are transferred using the DSDV routing protocol, with energy of 60 joules, is
evenly done from the time simulation starts to the end. The use of DSDV routing protocol in simulation
of networks is very essential as the protocol facilitate the even transfer of data packets with reduction of
energy in each node. Though this is very disadvantageous as the energy consumption might end up
being exhausted hence hindering the transfer of packets from one node to another [13].
For the routing protocol AODV, this is a routing protocol which limits energy consumption as much as
possible, its best for use where the energy given to each node is limited hence the protocol will ensure
that the process is very vigorous at the beginning of the simulation to send all data packets before
energy is exhausted. It is therefore recommended that AODV be used in network designs where limited
energy is granted to each node as it will limit the extinction of energy in the nodes.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
References
[1]Q. Mao, F. Hu and S. Kumar, "Simulation methodology and performance analysis of network coding
based transport protocol in wireless big data networks", Simulation Modelling Practice and Theory, vol.
84, pp. 38-49, 2018. Available: 10.1016/j.simpat.2018.01.005.
[2]K. P. and S. Dr.G., "Simulation of Efficient Life-Time in Clustering Approaches for New Approach in
Wireless Sensor Network", Bonfring International Journal of Networking Technologies and Applications,
vol. 5, no. 1, pp. 01-02, 2018. Available: 10.9756/bijnta.8366.
[3]H. Karatza, "Introduction to the Special Issue: On Internet and Wireless Network Performance",
SIMULATION, vol. 82, no. 5, pp. 277-278, 2006. Available: 10.1177/0037549706068694.
[4]Y. Xiao and H. Guo, "Coverage Model of Wireless Network Based on Computer Virtual Simulation",
Applied Mechanics and Materials, vol. 539, pp. 378-381, 2014. Available:
10.4028/www.scientific.net/amm.539.378.
[5]L. Zhang and L. Wang, "Industrial Monitoring Wireless Sensor Network Routing Algorithm and
Simulation", Advanced Materials Research, vol. 457-458, pp. 1149-1154, 2012. Available:
10.4028/scientific5/amr.457-458.1149.
[6]M. Wójcikowski, "Transmission Protocol Simulation Framework For The Resource-Constrained
Wireless Sensor Network", Metrology and Measurement Systems, vol. 22, no. 2, pp. 221-228, 2015.
Available: 10.1515/mms-2015-0019.
[7]G. Gautam and B. Sen, "Design and Simulation of Wireless Sensor Network in NS2", International
Journal of Computer Applications, vol. 113, no. 16, pp. 14-16, 2015. Available: 10.5120/19910-2018.
[8]Q. Li, "Wireless Sensor Network Fault Diagnosis Method of Optimization Research and Simulation",
Applied Mechanics and Materials, vol. 347-350, pp. 955-959, 2013. Available:
10.4028/www.scientific.net/amm.347-350.955.
[9]"Wireless Sensor Networks | LORD Sensing Systems". [Online]. Available:
https://www.microstrain.com/wireless. [Accessed: 2019].
[10]"Global Energy Harvesting System for Wireless Sensor ...". [Online]. Available:
https://www.marketwatch.com/press-release/global-energy-harvesting-system-for-wireless-sensor-
network-market-growth-with-latest-innovation-rising-trends-and-applications-2019-2028-2019-04-26/.
[Accessed: 2019].
[11]"Wireless Sensor Networks - UTA". [Online]. Available:
http://www.uta.edu/utari/acs/networks/WirelessSensorNetChap04.pdf. [Accessed: 2019].
[12]"Internet of Things: Wireless Sensor Networks - iec.ch". [Online]. Available:
https://www.iec.ch/whitepaper/pdf/iecWP-internetofthings-LR-en.pdf. [Accessed: 2019].
Document Page
[13]"Wireless Sensor Network Research Papers - Academia.edu". [Online]. Available:
http://www.academia.edu/Documents/in/Wireless_Sensor_Network. [Accessed: 2019].
Document Page
Appendix
SimDSDV.tcl File
# This script is created by NSG2 beta1
# <http://wushoupong.googlepages.com/nsg>
#===================================
# Simulation parameters setup
#===================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 21 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 1000 ;# X dimension of topography
set val(y) 678 ;# Y dimension of topography
set val(stop) 300.0 ;# time of simulation end
#===================================
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#Open the NS trace file
set tracefile [open SimDSDV.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open SimDSDV.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel
#===================================
# Mobile node parameter setup
#===================================
Document Page
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channel $chan \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON
#Energy Moddel
$ns node-config -energyModel EnergyModel \
-rxPower .3 \
-txPower .3 \
-initialEnergy 60 \
-sleepPower .5 \
-idlePower .1
#===================================
# Nodes Definition
Document Page
#===================================
#Create 21 nodes
set n0 [$ns node]
$n0 set X_ 359
$n0 set Y_ 429
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 420
$n1 set Y_ 443
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20
set n2 [$ns node]
$n2 set X_ 467
$n2 set Y_ 486
$n2 set Z_ 0.0
$ns initial_node_pos $n2 20
set n3 [$ns node]
$n3 set X_ 499
$n3 set Y_ 406
$n3 set Z_ 0.0
$ns initial_node_pos $n3 20
set n4 [$ns node]
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
$n4 set X_ 537
$n4 set Y_ 468
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20
set n5 [$ns node]
$n5 set X_ 609
$n5 set Y_ 499
$n5 set Z_ 0.0
$ns initial_node_pos $n5 20
set n6 [$ns node]
$n6 set X_ 682
$n6 set Y_ 410
$n6 set Z_ 0.0
$ns initial_node_pos $n6 20
set n7 [$ns node]
$n7 set X_ 599
$n7 set Y_ 420
$n7 set Z_ 0.0
$ns initial_node_pos $n7 20
set n8 [$ns node]
$n8 set X_ 622
$n8 set Y_ 347
$n8 set Z_ 0.0
Document Page
$ns initial_node_pos $n8 20
set n9 [$ns node]
$n9 set X_ 522
$n9 set Y_ 330
$n9 set Z_ 0.0
$ns initial_node_pos $n9 20
set n10 [$ns node]
$n10 set X_ 423
$n10 set Y_ 347
$n10 set Z_ 0.0
$ns initial_node_pos $n10 20
set n11 [$ns node]
$n11 set X_ 449
$n11 set Y_ 260
$n11 set Z_ 0.0
$ns initial_node_pos $n11 20
set n12 [$ns node]
$n12 set X_ 595
$n12 set Y_ 218
$n12 set Z_ 0.0
$ns initial_node_pos $n12 20
set n13 [$ns node]
$n13 set X_ 675
Document Page
$n13 set Y_ 272
$n13 set Z_ 0.0
$ns initial_node_pos $n13 20
set n14 [$ns node]
$n14 set X_ 724
$n14 set Y_ 343
$n14 set Z_ 0.0
$ns initial_node_pos $n14 20
set n15 [$ns node]
$n15 set X_ 754
$n15 set Y_ 445
$n15 set Z_ 0.0
$ns initial_node_pos $n15 20
set n16 [$ns node]
$n16 set X_ 693
$n16 set Y_ 526
$n16 set Z_ 0.0
$ns initial_node_pos $n16 20
set n17 [$ns node]
$n17 set X_ 605
$n17 set Y_ 578
$n17 set Z_ 0.0
$ns initial_node_pos $n17 20
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
set n18 [$ns node]
$n18 set X_ 504
$n18 set Y_ 565
$n18 set Z_ 0.0
$ns initial_node_pos $n18 20
set n19 [$ns node]
$n19 set X_ 399
$n19 set Y_ 560
$n19 set Z_ 0.0
$ns initial_node_pos $n19 20
set n20 [$ns node]
$n20 set X_ 305
$n20 set Y_ 519
$n20 set Z_ 0.0
$ns initial_node_pos $n20 20
#===================================
# Generate movement
#===================================
$ns at 4 " $n1 setdest 822 341 50 "
$ns at 6 " $n11 setdest 499 400 40 "
$ns at 6 " $n16 setdest 499 400 40 "
$ns at 2 " $n20 setdest 900 420 20 "
Document Page
#===================================
# Agents Definition
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$ns attach-agent $n20 $udp0
set null2 [new Agent/Null]
$ns attach-agent $n15 $null2
$ns connect $udp0 $null2
$udp0 set packetSize_ 1500
#Setup a UDP connection
set udp1 [new Agent/UDP]
$ns attach-agent $n0 $udp1
set null3 [new Agent/Null]
$ns attach-agent $n14 $null3
$ns connect $udp1 $null3
$udp1 set packetSize_ 1500
#===================================
# Applications Definition
Document Page
#===================================
#Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 1000
$cbr0 set rate_ 1.0Mb
$cbr0 set random_ null
$ns at 1.0 "$cbr0 start"
$ns at 2.0 "$cbr0 stop"
#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 1000
$cbr1 set rate_ 1.0Mb
$cbr1 set random_ null
$ns at 1.0 "$cbr1 start"
$ns at 2.0 "$cbr1 stop"
#===================================
# Termination
#===================================
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam SimDSDV.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
Document Page
SimAODV.tcl File
# This script is created by NSG2 beta1
# <http://wushoupong.googlepages.com/nsg>
#===================================
# Simulation parameters setup
#===================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 21 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 1000 ;# X dimension of topography
set val(y) 678 ;# Y dimension of topography
set val(stop) 300.0 ;# time of simulation end
#===================================
# Initialization
Document Page
#===================================
#Create a ns simulator
set ns [new Simulator]
#Setup topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#Open the NS trace file
set tracefile [open SimAODV.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open SimAODV.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel
#===================================
# Mobile node parameter setup
#===================================
$ns node-config -adhocRouting $val(rp) \
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channel $chan \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON
#Energy Moddel
$ns node-config -energyModel EnergyModel \
-rxPower .3 \
-txPower .3 \
-initialEnergy 60 \
-sleepPower .5 \
-idlePower .1
#===================================
# Nodes Definition
#===================================
Document Page
#Create 21 nodes
set n0 [$ns node]
$n0 set X_ 359
$n0 set Y_ 429
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 420
$n1 set Y_ 443
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20
set n2 [$ns node]
$n2 set X_ 467
$n2 set Y_ 486
$n2 set Z_ 0.0
$ns initial_node_pos $n2 20
set n3 [$ns node]
$n3 set X_ 499
$n3 set Y_ 406
$n3 set Z_ 0.0
$ns initial_node_pos $n3 20
set n4 [$ns node]
$n4 set X_ 537
Document Page
$n4 set Y_ 468
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20
set n5 [$ns node]
$n5 set X_ 609
$n5 set Y_ 499
$n5 set Z_ 0.0
$ns initial_node_pos $n5 20
set n6 [$ns node]
$n6 set X_ 682
$n6 set Y_ 410
$n6 set Z_ 0.0
$ns initial_node_pos $n6 20
set n7 [$ns node]
$n7 set X_ 599
$n7 set Y_ 420
$n7 set Z_ 0.0
$ns initial_node_pos $n7 20
set n8 [$ns node]
$n8 set X_ 622
$n8 set Y_ 347
$n8 set Z_ 0.0
$ns initial_node_pos $n8 20
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
set n9 [$ns node]
$n9 set X_ 522
$n9 set Y_ 330
$n9 set Z_ 0.0
$ns initial_node_pos $n9 20
set n10 [$ns node]
$n10 set X_ 423
$n10 set Y_ 347
$n10 set Z_ 0.0
$ns initial_node_pos $n10 20
set n11 [$ns node]
$n11 set X_ 449
$n11 set Y_ 260
$n11 set Z_ 0.0
$ns initial_node_pos $n11 20
set n12 [$ns node]
$n12 set X_ 595
$n12 set Y_ 218
$n12 set Z_ 0.0
$ns initial_node_pos $n12 20
set n13 [$ns node]
$n13 set X_ 675
$n13 set Y_ 272
Document Page
$n13 set Z_ 0.0
$ns initial_node_pos $n13 20
set n14 [$ns node]
$n14 set X_ 724
$n14 set Y_ 343
$n14 set Z_ 0.0
$ns initial_node_pos $n14 20
set n15 [$ns node]
$n15 set X_ 754
$n15 set Y_ 445
$n15 set Z_ 0.0
$ns initial_node_pos $n15 20
set n16 [$ns node]
$n16 set X_ 693
$n16 set Y_ 526
$n16 set Z_ 0.0
$ns initial_node_pos $n16 20
set n17 [$ns node]
$n17 set X_ 605
$n17 set Y_ 578
$n17 set Z_ 0.0
$ns initial_node_pos $n17 20
set n18 [$ns node]
Document Page
$n18 set X_ 504
$n18 set Y_ 565
$n18 set Z_ 0.0
$ns initial_node_pos $n18 20
set n19 [$ns node]
$n19 set X_ 399
$n19 set Y_ 560
$n19 set Z_ 0.0
$ns initial_node_pos $n19 20
set n20 [$ns node]
$n20 set X_ 305
$n20 set Y_ 519
$n20 set Z_ 0.0
$ns initial_node_pos $n20 20
#===================================
# Generate movement
#===================================
$ns at 4 " $n1 setdest 822 341 50 "
$ns at 6 " $n11 setdest 499 400 40 "
$ns at 6 " $n16 setdest 499 400 40 "
$ns at 2 " $n20 setdest 900 420 20 "
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
#===================================
# Agents Definition
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$ns attach-agent $n20 $udp0
set null2 [new Agent/Null]
$ns attach-agent $n15 $null2
$ns connect $udp0 $null2
$udp0 set packetSize_ 1500
#Setup a UDP connection
set udp1 [new Agent/UDP]
$ns attach-agent $n0 $udp1
set null3 [new Agent/Null]
$ns attach-agent $n14 $null3
$ns connect $udp1 $null3
$udp1 set packetSize_ 1500
#===================================
# Applications Definition
#===================================
Document Page
#Setup a CBR Application over UDP connection
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
$cbr0 set packetSize_ 1000
$cbr0 set rate_ 1.0Mb
$cbr0 set random_ null
$ns at 1.0 "$cbr0 start"
$ns at 2.0 "$cbr0 stop"
#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 1000
$cbr1 set rate_ 1.0Mb
$cbr1 set random_ null
$ns at 1.0 "$cbr1 start"
$ns at 2.0 "$cbr1 stop"
#===================================
# Termination
#===================================
#Define a 'finish' procedure
Document Page
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam SimAODV.nam &
exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
chevron_up_icon
1 out of 37
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]