Wireless Sensor Network
VerifiedAdded on  2023/01/19
|30
|4934
|46
AI Summary
This document provides an introduction to wireless sensor networks and their simulation using the NS-2 tool. It discusses network design, routing protocols (DSDV and AODV), and energy consumption. The document also includes analysis of trace files and presents the results of the simulation.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Wireless Sensor Network
Student Name
College
Student Name
College
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Introduction
Wireless computer networking is the most recent technology which was introduced in order to take
away the old wired networking. This is because wired networking was not able to transfer data over a
long distance in a cost effective manner. That is why many organizations replaced there wired
technology of networking to wireless especially to organizations and companies which had different
branches in different locations [1]. The simulation of the wireless network can be done by the use of the
network simulation tools which are software tools that design and simulate network. In this paper, the
NS-2 tool is used for the network design and simulations. The NS-2 which is also called the NetSim-2 or
the network simulator version 2 is best suited for wireless design on both the MacOS, linux and windows
platforms [2].
Network Design
In windows operating systems, the design of the network is well achieved by the use of the NSG2.1 tool,
Cygwin command line and the NAM tool. The NAM tool is used for the animation of the network tracing
the transfer of packets from one point to another. Network design by the use of the NSG tool offered a
wide range of the protocols which are to be used for routing. This includes the AODV, DSDV, DSR and
TORA. Therefore, for the design of the network in this paper, the AODV and the DSDV routing protocols
are used [3]. After the design is made, and all configurations are made in terms of the time which can
take for the simulation to be done, the agent and the parameters, it is then saved to a file called the tcl
file. The nam and the tr files are generated by the use of the Cygwin command line tool. After that, then
the NAM tool is used for the simulation of the packets and the wireless networks.
The below figure shows the initial stage of wireless network design in the NS-2 software where the nodes
are arranged, and connected with each other before simulation is done.
Wireless computer networking is the most recent technology which was introduced in order to take
away the old wired networking. This is because wired networking was not able to transfer data over a
long distance in a cost effective manner. That is why many organizations replaced there wired
technology of networking to wireless especially to organizations and companies which had different
branches in different locations [1]. The simulation of the wireless network can be done by the use of the
network simulation tools which are software tools that design and simulate network. In this paper, the
NS-2 tool is used for the network design and simulations. The NS-2 which is also called the NetSim-2 or
the network simulator version 2 is best suited for wireless design on both the MacOS, linux and windows
platforms [2].
Network Design
In windows operating systems, the design of the network is well achieved by the use of the NSG2.1 tool,
Cygwin command line and the NAM tool. The NAM tool is used for the animation of the network tracing
the transfer of packets from one point to another. Network design by the use of the NSG tool offered a
wide range of the protocols which are to be used for routing. This includes the AODV, DSDV, DSR and
TORA. Therefore, for the design of the network in this paper, the AODV and the DSDV routing protocols
are used [3]. After the design is made, and all configurations are made in terms of the time which can
take for the simulation to be done, the agent and the parameters, it is then saved to a file called the tcl
file. The nam and the tr files are generated by the use of the Cygwin command line tool. After that, then
the NAM tool is used for the simulation of the packets and the wireless networks.
The below figure shows the initial stage of wireless network design in the NS-2 software where the nodes
are arranged, and connected with each other before simulation is done.
Just after the design of the network, then the tcl file is saved and the nam file is generated from the tcl
file by the use of Cygwin command line tool. Then nam tool will then be able to open the nam file and
the design is shown as below [4].
There is packet transfer from one node to another which is the beginning of the simulation process as
shown below.
file by the use of Cygwin command line tool. Then nam tool will then be able to open the nam file and
the design is shown as below [4].
There is packet transfer from one node to another which is the beginning of the simulation process as
shown below.
As shown below, it is also seen that the receiver is in a position to receive data from more than one node
depending with the routing protocol and the agent used.
depending with the routing protocol and the agent used.
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Simulation
When data packets are being transferred from one point to another, energy is consumed. The
consumption of energy takes place since the design is created with the energy model. The initial energy
was 60 joules. The rate and the method at which energy is consumed is deeply in dependence of the
routing protocol which has been chosen during the design of the wireless network. In the design, there
are 20 nodes which are so be simulated in 300 seconds of time before stopping. The records are taken at
50 seconds, 150 seconds and 250 seconds of time [5].
Simulation for DSDV routing protocol
This is the display at 50 seconds by a DSDV protocol
At the 50 seconds of time, the below is the screenshots which shows the simulation.
At indicated and seen above, there is evidence of packets transfer from one point to another point.
There is movement of nodes too from one point to the other. As seen on the node 20 which is moving
from its position to the position of null4 agent. This is because the waypoint for node 20 was directed at
null 4. At this point energy is also consumed since data packets are being transferred from one point to
another [6].
When data packets are being transferred from one point to another, energy is consumed. The
consumption of energy takes place since the design is created with the energy model. The initial energy
was 60 joules. The rate and the method at which energy is consumed is deeply in dependence of the
routing protocol which has been chosen during the design of the wireless network. In the design, there
are 20 nodes which are so be simulated in 300 seconds of time before stopping. The records are taken at
50 seconds, 150 seconds and 250 seconds of time [5].
Simulation for DSDV routing protocol
This is the display at 50 seconds by a DSDV protocol
At the 50 seconds of time, the below is the screenshots which shows the simulation.
At indicated and seen above, there is evidence of packets transfer from one point to another point.
There is movement of nodes too from one point to the other. As seen on the node 20 which is moving
from its position to the position of null4 agent. This is because the waypoint for node 20 was directed at
null 4. At this point energy is also consumed since data packets are being transferred from one point to
another [6].
The screenshot captured below shows the behavior of the simulation at after 150seconds of simulation
by the use of the DSDV routing protocol.
From the evidence obtained in the above captured screenshot at 150 seconds of time. It is evident that
the rate at which packets are being transferred from one node to another have decreased as compared
to the packets which were being transferred at 50seconds of time. There is no movement of nodes at
this time.
by the use of the DSDV routing protocol.
From the evidence obtained in the above captured screenshot at 150 seconds of time. It is evident that
the rate at which packets are being transferred from one node to another have decreased as compared
to the packets which were being transferred at 50seconds of time. There is no movement of nodes at
this time.
At 250 seconds of time, the below is the screenshot which shows the simulation trait
There is further decrease in the rate of data packets transfer at this time. Most of the nodes have energy
depletion warnings which are seen by there colors changing to yellow from green. This shows that the
energy level has reduced from 60 joules to below 30 joules. Though none of the nodes has its energy
level completely depleted.
There is further decrease in the rate of data packets transfer at this time. Most of the nodes have energy
depletion warnings which are seen by there colors changing to yellow from green. This shows that the
energy level has reduced from 60 joules to below 30 joules. Though none of the nodes has its energy
level completely depleted.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Simulation of AODV routing protocol
For the AODV routing protocol, the below is the screenshot which shows how the simulation is at 50
seconds of simulation.
From the screenshot above, there is evidence of massive data packets transfer which was seen during
the first 5 seconds of wireless network simulation. The rate of data packets transfer decreases then stops
after 5 seconds. Nodes movements begins to be seen after 5 seconds of time with node 20 moving
towards node null 4 and there is also movement of node 16 and node 11 towards node 3. This is brought
about by the waypoints in the nodes which were being pointed at the nodes where they are moving to
[7].
For the AODV routing protocol, the below is the screenshot which shows how the simulation is at 50
seconds of simulation.
From the screenshot above, there is evidence of massive data packets transfer which was seen during
the first 5 seconds of wireless network simulation. The rate of data packets transfer decreases then stops
after 5 seconds. Nodes movements begins to be seen after 5 seconds of time with node 20 moving
towards node null 4 and there is also movement of node 16 and node 11 towards node 3. This is brought
about by the waypoints in the nodes which were being pointed at the nodes where they are moving to
[7].
The screenshot captured below shows 150 seconds simulation of the AODV touring protocol.
There is a unique observation which is during this time. There is no data transfer at this point. This simply
means that no energy is consumed at this point since the rate at which energy is consumed depends on
the rate at which data packets are sent from one point to another.
There is a unique observation which is during this time. There is no data transfer at this point. This simply
means that no energy is consumed at this point since the rate at which energy is consumed depends on
the rate at which data packets are sent from one point to another.
At 250 seconds of simulating AODV routing protocol, the below is the screenshot.
Also, here there is no trace of data packets transfer. This is because in AODV routing protocol, data was
transferred in the first 5 seconds. there is not energy level change at this stage as all the nodes are still
green in color. This simply means that energy is still above 30 joules.
Also, here there is no trace of data packets transfer. This is because in AODV routing protocol, data was
transferred in the first 5 seconds. there is not energy level change at this stage as all the nodes are still
green in color. This simply means that energy is still above 30 joules.
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Analysis of Trace file
DSDV routing Protocol Trace file
As seen from the trace file for the simulation of the DSDV routing protocol, data packets are being send
from approximately 0.00416 seconds of time. At this point the energy in every node is still 60 joules.
There is energy loss at 0. 004262 seconds of time at the very same time. This is an indication that the
nodes have begun sending and receiving data packets. From the overall checkout from the trace file,
there is uniform data packets sending and receiving in this protocol. This sending data is done every
second of the time hence subsequent energy loss [7]. The rate at which energy is being lost is abit
uniform all through the simulation process though it decreases slightly from 0 to 300 seconds. The
increase in the rate of nodes movement and collision is what resulted to the increase in the rate at which
data packets are dropped from the 5th second to 10th seconds. Though, throughout the simulation as
seen from the trace files, there is still uniform but minimal rate of data packets dropping [8].
AODV routing Protocol Trace file
On this routing protocol, data packets sending on happens during the first 5 seconds of simulation. After
which there was no trace of data packets sending. Packets of data send was massive during this first 5
seconds only.
Data packets reception was only done during the first 5 seconds of data transfer. This is because data
sending was only during the first 5 seconds also. Data sending and receiving always takes place at the
very same time. There was no trace of data packets being received after 5 seconds of massive data
reception ended [9].
Data packets dropping was very massive within the first 5 seconds. this is because, at this time, data
sending and receiving was very massive therefore the rate at which data packets collides and drops also
increased. After 5 seconds, only few drops were traced till 10th second since there was movement of
nodes from one place to another.
Energy consumption was only traced during the first 5 seconds of simulation since this was the time
when data packets transfer was very much high. The reduction of energy was done from 60 joules to 58
joules. Only 2 joules were consumed [10].
DSDV routing Protocol Trace file
As seen from the trace file for the simulation of the DSDV routing protocol, data packets are being send
from approximately 0.00416 seconds of time. At this point the energy in every node is still 60 joules.
There is energy loss at 0. 004262 seconds of time at the very same time. This is an indication that the
nodes have begun sending and receiving data packets. From the overall checkout from the trace file,
there is uniform data packets sending and receiving in this protocol. This sending data is done every
second of the time hence subsequent energy loss [7]. The rate at which energy is being lost is abit
uniform all through the simulation process though it decreases slightly from 0 to 300 seconds. The
increase in the rate of nodes movement and collision is what resulted to the increase in the rate at which
data packets are dropped from the 5th second to 10th seconds. Though, throughout the simulation as
seen from the trace files, there is still uniform but minimal rate of data packets dropping [8].
AODV routing Protocol Trace file
On this routing protocol, data packets sending on happens during the first 5 seconds of simulation. After
which there was no trace of data packets sending. Packets of data send was massive during this first 5
seconds only.
Data packets reception was only done during the first 5 seconds of data transfer. This is because data
sending was only during the first 5 seconds also. Data sending and receiving always takes place at the
very same time. There was no trace of data packets being received after 5 seconds of massive data
reception ended [9].
Data packets dropping was very massive within the first 5 seconds. this is because, at this time, data
sending and receiving was very massive therefore the rate at which data packets collides and drops also
increased. After 5 seconds, only few drops were traced till 10th second since there was movement of
nodes from one place to another.
Energy consumption was only traced during the first 5 seconds of simulation since this was the time
when data packets transfer was very much high. The reduction of energy was done from 60 joules to 58
joules. Only 2 joules were consumed [10].
Results
The graph below shows the analysis on the DSDV routing protocol in terms of data send, receiving,
dropping and energy consumption.
The graph below shows the analysis on the AODV routing protocol in terms of data send, receiving,
dropping and energy consumption.
The graph below shows the analysis on the DSDV routing protocol in terms of data send, receiving,
dropping and energy consumption.
The graph below shows the analysis on the AODV routing protocol in terms of data send, receiving,
dropping and energy consumption.
Conclusion
In conclusion, it is evident that the simulation using the DSDV routing protocol a uniform sending and
reception of data packets is done. This leads to uniform rate of data packets dropping throughout the
simulation and also high consumption of energy in every node. Therefore, DSDV is suitable for
transferring data with minimal data dropping and maximum energy consumption hence best for
accurate results.
AODV routing protocol has more data packets dropping, faster rate of data transfer and reception. Can
transfer high amount of data in a very short period of time with less energy being consumed. Therefore,
it is best suited for transferring large amount of data in a short time period. Accuracy of this routing
protocol is poor since the rate at which data packets are being dropped is very high compared to DSDV.
In conclusion, it is evident that the simulation using the DSDV routing protocol a uniform sending and
reception of data packets is done. This leads to uniform rate of data packets dropping throughout the
simulation and also high consumption of energy in every node. Therefore, DSDV is suitable for
transferring data with minimal data dropping and maximum energy consumption hence best for
accurate results.
AODV routing protocol has more data packets dropping, faster rate of data transfer and reception. Can
transfer high amount of data in a very short period of time with less energy being consumed. Therefore,
it is best suited for transferring large amount of data in a short time period. Accuracy of this routing
protocol is poor since the rate at which data packets are being dropped is very high compared to DSDV.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
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].
[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].
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
#===================================
# 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)
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
#===================================
# 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
#===================================
$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 \
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
#===================================
$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 \
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
-initialEnergy 60 \
-sleepPower .5 \
-idlePower .1
#===================================
# Nodes Definition
#===================================
#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
$n4 set Y_ 468
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20
-sleepPower .5 \
-idlePower .1
#===================================
# Nodes Definition
#===================================
#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
$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
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
$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
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
$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
$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
$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
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
$ns initial_node_pos $n17 20
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 "
#===================================
# Agents Definition
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$ns attach-agent $n20 $udp0
set null2 [new Agent/Null]
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 "
#===================================
# 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
#===================================
#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 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
#===================================
#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
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
#===================================
# Termination
#===================================
#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
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
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
#===================================
#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)
# 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
#===================================
#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) \
-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 \
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) \
-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
#===================================
#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
$n4 set Y_ 468
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20
set n5 [$ns node]
-idlePower .1
#===================================
# Nodes Definition
#===================================
#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
$n4 set Y_ 468
$n4 set Z_ 0.0
$ns initial_node_pos $n4 20
set n5 [$ns node]
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
$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
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
$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
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
$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
$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
$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]
$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 "
#===================================
# 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
$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 "
#===================================
# 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
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
$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
#===================================
#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"
$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
#===================================
#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
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
# Termination
#===================================
#Define a 'finish' procedure
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
1 out of 30
Related Documents
Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024  |  Zucol Services PVT LTD  |  All rights reserved.