You are on page 1of 26

A Simulation Framework for Sensor Networks in J-Sim

Ahmed Sobeih, Jennifer C. Hou Department of Computer Science University of Illinois at Urbana-Champaign Urbana, IL 61801 E-mail: {sobeih, jhou}@cs.uiuc.edu

Abstract Sensor networks have gained considerable importance and attention in the past few years. Hence, an inevitable need for developing simulation frameworks for sensor networks in existing network simulators arises. In this paper, we describe our work in incorporating wireless sensor networks simulation in J-Sim. We have built a simulation framework for sensor networks that builds upon the autonomous component architecture (ACA) and the extensible internetworking framework (INET) of J-Sim. The paper shows how each layer in the protocol stack of a sensor node can be implemented as a component and how ports and contracts enable different layers (components) to interact with each other in the initiator-reactor mechanism that is a fundamental concept of J-Sim.

1 Introduction
In a typical wireless sensor network, sensors monitor a specific environment (e.g., an airport, a battlefield, etc.) and upon detecting a relevant stimulus (signal), sensors send reports to a sink (user) node. There are different types of stimuli; for example, acoustic and seismic. Stimuli are generated by target nodes; for example, a moving tank may generate ground vibrations that can be detected by seismic sensors. Hence, a wireless sensor network simulation environment consists of three main types of nodes: sensor nodes, target nodes, and sink (user) nodes. Target nodes generate signals (stimuli). Sensor nodes detect the signals (stimuli) that are generated by a target node and forward the necessary data to the sink nodes. Finally, a sink node receives data collected by sensor nodes. Since the nature of signal propagation between target nodes and sensor nodes is inherently different from that between sensor nodes and sink nodes, two different models for channels and protocol stacks are needed. Namely, a sensor node is equipped with (1) a sensor protocol stack, which enables it to capture signals generated by target nodes through a sensor channel, and (2) a wireless protocol stack, which enables it to send reports to the sink nodes through a wireless channel. This operation is illustrated in Figure 1. The combination of the sensor protocol stack and the wireless protocol stack is usually called the sensor function model [1]. A sensor node also has a power model that embodies the energy-producing components (e.g., battery) and the energy-consuming components (e.g., radio and CPU) that enables a sensor to fulfill the functions of the sensor function model. Figure 2 shows an internal view of the three types of nodes [2].

Sensor Node 0

Wireless Channel

Sensor Node 1

Sensor Channel

Sink Node

Target Node

Sensor Node (n-2)

Sensor Node (n -1) Figure 1, A typical wireless sensor network environment Seeing that sensor networks have gained a considerable attention in the past few years, we have decided to build a simulation framework for sensor networks in J-Sim [3]. Our framework is based on a sensor network simulation framework [1, 2] that has been built in the network simulator ns-2 [4]; however, our approach makes extensive use of the autonomous component architecture (ACA) and the extensible internetworking framework (INET) [5] of J-Sim. The rest of the paper is organized as follows: Section 2 lists the components of the simulation framework for sensor networks. Section 3 describes, using block diagrams, the layers of the protocol stack of each type of node in a typical sensor network. Each layer in the protocol stack is a component. Section 4 gives a detailed description of the ports and contracts that enable different layers to interact in the initiator-reactor mechanism that is a fundamental concept of J-Sim. Finally, Section 5 provides a sample script of a wireless sensor network simulation; the script shows how layer (component) binding is deferred until a complete system is actually being built.

2 Components of Simulation Framework for Sensor Networks


In order to incorporate wireless sensor network simulation in J-Sim, we made a new package: drcl.inet.sensorsim. All of the implemented classes described below are defined inside this new package: Target Nodes: This includes the implementation of the following classes:

TargetAgent: implements a target node. This involves generating signals (stimuli) and passing them to the lower layers in order to be transmitted over the sensor channel. TargetPacket: implements the packet that represents the signal generated by a target node. SensorMobilityModel: a derived class of drcl.inet.mac.MobilityModel. Since the target nodes may move (e.g., moving tanks), their mobility pattern, speed and location are handled by SensorMobilityModel. SensorNodePositionTracker: keeps track of the locations of all the nodes. This location information is being reported by the SensorMobilityModel component of each node to the SensorNodePositionTracker. A major function done by this class is that it determines the sensor nodes that are within the transmission radius of a target node, and hence, should receive a copy of the signal generated by that target node. SensorPhy: This class plays two roles depending on whether an instance of it exists in the protocol stack of a target node or a sensor node. If it is defined in the protocol stack of a target node, its function is to receive a signal generated by the TargetAgent, query the SensorMobilityModel component to get the most up-to-date location of the target node, and forward the generated signal (together with the location information) to the sensor channel component. SensorPositionReportContract: defines the contract needed to define the interface between SensorPhy and SensorMobilityModel and also between SensorMobilityModel and SensorNodePositionTracker. Sensor Channel: This includes the implementation of the following classes: SensorChannel: implements the sensor channel. The function of the sensor channel is that it receives a signal (stimulus) from a target node, queries SensorNodePositionTracker to get the list of sensor nodes that are within the transmission radius of that target node, and hence, should receive a copy of the signal generated by that target node. The sensor channel then sends a copy of the generated signal to each sensor node that belongs to that list. SensorNodeChannelContract: defines the contract needed to define the interface between SensorChannel and SensorPhy. SensorNeighborQueryContract: defines the contract needed to define the interface between SensorChannel and SensorNodePositionTracker. Propagation model: This includes the implementation of the following classes: SensorRadioPropagationModel: abstract base class for different types of signal propagation models on the sensor channel. SeismicProp: derived class of SensorRadioPropagationModel. The major function of SeismicProp is to calculate the signal strength of a received signal based on the distance between the transmitter (target node) and receiver (sensor node) and also based on the attenuation factor.

Sensor Function Model Sensor Application Middleware Sensor Stack Sensor Layer

Power Model

CPU Model Battery Model

Network Stack Network Layer

Radio Model MAC Layer Sensor Physical Layer Physical Layer

Wireless Channel

Sensor Channel

Figure 2.a, Internal view of a sensor node (dashed line)

Sensor Stack Target Agent Layer

Sensor Physical Layer

Sensor Channel Figure 2.b, Internal view of a target node (dashed line)

Sensor Application Middleware

Network Stack Network Layer

MAC Layer

Physical Layer

Wireless Channel Figure 2.c, Internal view of a user (sink) node (dashed line) Battery model: This includes the implementation of the following classes: BatteryBase: abstract base class for different types of batteries. It defines the ports that are needed for all types of batteries (e.g., to interface with the CPU and the Radio models). BatteryTable: a class that defines a table that specifies the capacity of a battery as a function of its current. Capacities at values of current that do not exist in the table are calculated by interpolation. BatteryCoinCell: [6] a derived class of BatteryBase, which implements a coin cell battery. The implementation is based on the CR1220 coin cell datasheet. BatteryCoinCell defines a table (instance of BatteryTable) that specifies the capacity of the battery as a function of its current. BatteryLiNR: a derived class of BatteryBase, which implements a LiNR battery. Similar to BatteryCoinCell, BatteryLiNR defines a table (instance of BatteryTable) that specifies the capacity of the battery as a function of its current. BatterySimple: a derived class of BatteryBase, which implements a very simplistic battery model whose capacity is always assumed to be constant (i.e., not a function of the current). BatteryContract: defines the contract needed for the battery model to interface with the CPU and Radio models; for example, so that the CPU and Radio models can inform the battery about the current that they want to drain from it.

CPU model: This includes the implementation of the following classes: CPUBase: abstract base class for different types of CPUs. It defines the ports that are needed for all types of CPUs (e.g., ports are needed to interface with the battery model and other ports are needed to interface with the sensor function model). CPUAvr: derived class of CPUBase, which provides reasonable values for active, idle, sleep and off currents. Radio model: This includes the implementation of the following classes: RadioBase: abstract base class for different types of Radio models. It defines the ports that are needed for all types of Radio models (e.g., ports are needed to interface with the battery model and other ports are needed to interface with the sensor function model). RadioSimple: derived class of RadioBase, which provides reasonable values for transmit mode, receiver mode, and sleep mode current draws. In the current implementation, the CPU and Radio models can report their operation mode to the sensor function model and the sensor function model can also change the operation mode of both the CPU and Radio models. However, we let the sensor function model decide what action to take when being informed of a change in the operation mode of either the CPU or Radio model. Sensor Protocol Stack: This includes the implementation of the following classes: SensorPhy: As mentioned above, this class plays two roles depending on whether an instance of it exists in the protocol stack of a target node or a sensor node. If it is defined in the protocol stack of a sensor node, its function is to get from the sensor channel a copy of a signal (stimulus) generated by a target node. Based on the location of the target node at the time of generating this signal and the current location of the sensor node, SensorPhy queries the propagation model to compute the received signal strength; if it is below a certain receiving threshold (which is one of the member variables of SensorPhy), the signal is discarded, otherwise, it is forwarded (after being attenuated) up to the sensor layer. SensorAgent: implements the sensor layer. It gets from the sensor physical layer the signal (stimulus), compiles it and forwards the relevant data up to the sensor application layer. In the current implementation, the relevant data is: number of bytes received, the signal-to-noise ratio and the target node ID. SensorAgentPhyContract: defines the contract needed to define the interface between SensorPhy and SensorAgent. SensorRadioPropagationQueryContract: defines the contract needed to define the interface between SensorPhy and SeismicProp. Sensor Application Layer: This includes the implementation of the following classes:

SensorApp: This class plays two roles depending on whether an instance of it exists in the protocol stack of a sensor node or a sink node. If it is defined in the protocol stack of a sensor node, it gets the relevant data from SensorAgent and forwards it to the middleware layer between the sensor protocol stack and the wireless protocol stack so as to go through the wireless protocol stack and then eventually go through the wireless channel to the sink node. SensorPacket: defines the packet that is to be sent to the sink node. It includes the number of bytes received, the signal-to-noise ratio and the target node ID. SensorAppAgentContract: defines the contract needed to define the interface between SensorAgent and SensorApp. Middleware between sensor protocol stack and wireless protocol stack: This includes the implementation of the following classes: WirelessAgent: This class plays two roles depending on whether an instance of it exists in the protocol stack of a sensor node or a sink node. If it is defined in the protocol stack of a sensor node, its function is to get from SensorApp the relevant data that is to be sent to the sink node (e.g., number of bytes received, the signal-to-noise ratio and the target node ID) and enclose this data in a SensorPacket and forward it to the wireless protocol stack so that the SensorPacket (carrying the necessary information) can go through the wireless protocol stack and then eventually go through the wireless channel to the sink node. SensorAppWirelessAgentContract: defines the contract needed to define the interface between WirelessAgent and SensorApp. Integrating the sensor protocol stack with the wireless protocol stack: To build the sensor functional model, we had to integrate the sensor protocol stack with the wireless protocol stack. This integration was done, in part, by implementing the SensorApp and the WirelessAgent classes as described above. We also used the following protocols in the wireless protocol stack: - Network Layer: AODV protocol (drcl.inet.protocol.aodv.AODV) - MAC Layer: MAC 802.11 (drcl.inet.mac.Mac_802_11) - Physical Layer: drcl.inet.mac.WirelessPhy - Wireless Channel: drcl.inet.mac.Channel Sink nodes: As shown in Figure 2.c, a sink node is built in a plug-and-play fashion using a sensor application layer (SensorApp), an interface layer (WirelessAgent) with the wireless protocol stack: network layer (AODV protocol (drcl.inet.protocol.aodv.AODV)), MAC layer (MAC 802.11 (drcl.inet.mac.Mac_802_11)), and physical layer (drcl.inet.mac.WirelessPhy)

3 Protocol stacks
In this section, we present the layers of the protocol stack of the three types of nodes mentioned above; namely, target nodes, sensor nodes and sink nodes. We also present how each node connects to other components in the simulation; e.g. sensor channel, wireless channel, node position tracker, propagation model, etc. A more detailed description, that also includes ports and contracts, will be given in Section 4. Figure 3 shows the architecture of a target node. Figure 4 shows the architecture of a sensor node. Figure 5 shows the architecture of a sink node.

TargetAgent

SensorPhy

Sensor Propagation Model

SensorMobilityModel

SensorChannel

SensorNodePositionTracker

Figure 3, Architecture of a target node (dashed line) with its connections to other components

SensorApp ID RT

CPU Model Battery Model Radio Model SensorAgent

WirelessAgent

Ad Hoc Routing

PktDispatcher

ARP

LL

Queue

SensorPhy

Sensor Propagation Model

Mac_802_11

Wireless Propagation Model

WirelessPhy

SensorMobilityModel

SensorChannel

SensorNodePosition Tracker

Channel

NodePositionTracker

Figure 4, Architecture of a sensor node (dashed line) with its connections to other components

SensorApp ID RT

WirelessAgent

Ad Hoc Routing

PktDispatcher

ARP

LL

Queue

Mac_802_11

Wireless Propagation Model

WirelessPhy

MobilityModel

Channel

NodePositionTracker

Figure 5, Architecture of a sink node (dashed line) with its connections to other components

10

4 Ports and Contracts


In this section, we present the ports and contracts that enable the different layers, which are in the protocol stacks presented in Section 3, to interact. The following figures show this information. Whenever a Contract name is shown in a figure, the Contract.Message is actually what is meant.

Figure 6, Ports and Contracts for sensor nodes

11

Figure 6, Ports and Contracts for sensor nodes (cont.)

12

Figure 6, Ports and Contracts for sensor nodes (cont.)

13

Figure 6, Ports and Contracts for sensor nodes (cont.)

14

Figure 7, Ports and Contracts for target nodes

15

Figure 8, Ports and Contracts for sink nodes

16

Figure 8, Ports and Contracts for sink nodes (cont.) 17

5 Sample Script
In this section, we give a sample script of a wireless sensor network simulation that has 4 sensor nodes, 2 target nodes and 1 sink node. The nodes are placed in a 500*400 m2 terrain as shown in Figure 9. The sensor and sink nodes are stationary, but the two target nodes are moving with a maximum speed of 30 m/sec.

Figure 9, A Wireless Sensor Network. Target Nodes are moving with a maximum speed of 30 m/sec.
cd [mkdir -q drcl.comp.Component /aodvtest] # TOTAL number of nodes (sensor nodes + target nodes) set node_num 7 # Number of TARGET nodes ONLY set target_node_num 2 # Hence, number of SENSORS = node_num - target_node_num set sink_id 0 # create the sensor channel mkdir drcl.inet.sensorsim.SensorChannel chan # Capacity of the sensor channel is total number of nodes (sensors + targets)

18

# make simulation for $node_num nodes ! chan setCapacity $node_num # create the propagation model mkdir drcl.inet.sensorsim.SeismicProp seismic_Prop ! seismic_Prop setD0 0.2 # create the sensor node position tracker mkdir drcl.inet.sensorsim.SensorNodePositionTracker nodetracker ! nodetracker setGrid 600.0 100.0 500.0 100.0 # connect the sensor channel to the sensor node position tracker connect chan/.tracker@ -and nodetracker/.channel@ # create the wireless channel mkdir drcl.inet.mac.Channel channel # Capacity of the wireless channel is number of sensors and sinks ONLY # which is equal to $node_num - $target_node_num ! channel setCapacity [expr $node_num - $target_node_num] # create the node position tracker mkdir drcl.inet.mac.NodePositionTracker tracker # maxX minX maxY minY dX dY ! tracker setGrid 600.0 100.0 500.0 100.0 60.0 60.0 connect channel/.tracker@ -and tracker/.channel@ # FOR THE SINKs ONLY, do the following # SINKs have only a network protocol stack for {set i 0} {$i < [expr $sink_id + 1]} {incr i} { puts "create sink $i" set node$i [mkdir drcl.comp.Component n$i] cd n$i mkdir ! app ! app ! app drcl.inet.sensorsim.SensorApp app setNid $i setSinkNid $sink_id setCoherentThreshold 1000.0

# create wireless agent layers mkdir drcl.inet.sensorsim.WirelessAgent wireless_agent # connect the sensor application to the wireless agent # so that sinks can send through the wireless network protocol stack connect app/down@ -to wireless_agent/up@ # connect the wireless agent to the sensor application # so that sinks can receive thru the wireless network protocol stack connect wireless_agent/.toSensorApp@ -to app/.fromWirelessAgent@ mkdir drcl.inet.mac.LL ll mkdir drcl.inet.mac.ARP arp mkdir drcl.inet.core.queue.FIFO queue

19

mkdir drcl.inet.mac.Mac_802_11 mac mkdir drcl.inet.mac.WirelessPhy wphy ! wphy setRxThresh 0.0 ! wphy setCSThresh 0.0 mkdir drcl.inet.mac.FreeSpaceModel propagation mkdir drcl.inet.mac.MobilityModel mobility set PD [mkdir drcl.inet.core.PktDispatcher set RT [mkdir drcl.inet.core.RT set ID [mkdir drcl.inet.core.Identity $PD bind $RT $PD bind $ID mkdir drcl.inet.protocol.aodv.AODV aodv connect -c aodv/down@ -and pktdispatcher/103@up connect aodv/.service_rt@ -and rt/.service_rt@ connect aodv/.service_id@ -and id/.service_id@ connect aodv/.ucastquery@ -and pktdispatcher/.ucastquery@ connect mac/.linkbroken@ -and aodv/.linkbroken@ # present if using 802.11 power-saving mode connect mac/.energy@ -and wphy/.energy@ connect wphy/.mobility@ -and mobility/.query@ connect wphy/.propagation@ -and propagation/.query@ connect mac/down@ -and wphy/up@ connect mac/up@ -and queue/output@ connect ll/.mac@ -and mac/.linklayer@ connect ll/down@ -and queue/up@ connect ll/.arp@ -and arp/.arp@ connect -c pktdispatcher/0@down -and ll/up@ set nid $i ! ! ! ! ! ! arp setAddresses ll setAddresses mac setMacAddress wphy setNid mobility setNid id setDefaultID $nid $nid $nid $nid $nid $nid $nid $nid "packet" 40 pktdispatcher] rt] id]

! queue setMode ! queue setCapacity # disable ARP ! arp setBypassARP

[ expr 2>1]

! mac setRTSThreshold 0

20

connect mobility/.report@ -and /aodvtest/tracker/.node@ connect wphy/down@ -to /aodvtest/channel/.node@ ! /aodvtest/channel attachPort $i [! wphy getPort .channel] # maxX maxY maxZ minX minY minZ dX dY dZ ! mobility setTopologyParameters 600.0 500.0 0.0 100.0 100.0 0.0 60.0 60.0 0.0 ! mac disable_MAC_TRACE_ALL wireless_agent/down@ -and pktdispatcher/1111@up

connect -c cd .. }

# FOR THE SENSORS ONLY , do the following # create sensor application, battery, CPU, Radio models, etc. for {set i [expr $sink_id + 1]} {$i < [expr $node_num - $target_node_num]} {incr i} { puts "create sensor $i" set node$i [mkdir drcl.comp.Component n$i] cd n$i mkdir ! app ! app ! app drcl.inet.sensorsim.SensorApp app setNid $i setSinkNid $sink_id setCoherentThreshold 1000.0

# Energy Model set cc($i) [java::new drcl.inet.sensorsim.BatteryCoinCell 1.00] java::call drcl.comp.Util setRuntime $cc($i) [java::new drcl.comp.ARuntime] set cpu($i) [java::new drcl.inet.sensorsim.CPUAvr] java::call drcl.comp.Util setRuntime $cpu($i) [java::new drcl.comp.ARuntime] set radio($i) [java::new drcl.inet.sensorsim.RadioSimple] java::call drcl.comp.Util setRuntime $radio($i) [java::new drcl.comp.ARuntime] connect $cc($i)/batteryOut@ -to $cpu($i)/batteryIn@ connect $cc($i)/battery@ -and $cpu($i)/battery@ $cpu($i) setCPUMode 2 connect $cc($i)/batteryOut@ -to $radio($i)/batteryIn@ connect $cc($i)/battery@ -and $radio($i)/battery@ $radio($i) setRadioMode 4 $cpu($i) attachApp [! app getPort .cpu] $radio($i) attachApp [! app getPort .radio] # End Energy Model

21

# create nodes mkdir drcl.inet.sensorsim.SensorAgent agent # create sensor physical layers mkdir drcl.inet.sensorsim.SensorPhy phy ! phy setRxThresh 0.0 # create mobility models mkdir drcl.inet.sensorsim.SensorMobilityModel mobility ! phy setNid $i ! phy setRadius 250.0 # connect phyiscal layers to sensor agents so that nodes can receive connect phy/.toAgent@ -to agent/.fromPhy@ # connect sensor agent and sensor application connect agent/.toSensorApp@ -to app/.fromSensorAgent@ # connect the sensor channel to the nodes so that they can receive ! /aodvtest/chan attachPort $i [! phy getPort .channel] # connect the nodes to the propagation model connect phy/.propagation@ -and /aodvtest/seismic_Prop/.query@ ! mobility setNid $i # create wireless agent layers mkdir drcl.inet.sensorsim.WirelessAgent wireless_agent # connect the sensor application to the wireless agent # so that sensors can send through the wireless network protocol stack connect app/down@ -to wireless_agent/up@ # connect the wireless agent to the sensor application # so that sensors can receive thru the wireless network protocol stack connect wireless_agent/.toSensorApp@ -to app/.fromWirelessAgent@ mkdir drcl.inet.mac.LL ll mkdir drcl.inet.mac.ARP arp mkdir drcl.inet.core.queue.FIFO queue mkdir drcl.inet.mac.Mac_802_11 mac mkdir drcl.inet.mac.WirelessPhy wphy ! wphy setRxThresh 0.0 ! wphy setCSThresh 0.0 mkdir drcl.inet.mac.FreeSpaceModel propagation set PD [mkdir drcl.inet.core.PktDispatcher set RT [mkdir drcl.inet.core.RT set ID [mkdir drcl.inet.core.Identity $PD bind $RT pktdispatcher] rt] id]

22

$PD bind $ID mkdir drcl.inet.protocol.aodv.AODV aodv connect -c aodv/down@ -and pktdispatcher/103@up connect aodv/.service_rt@ -and rt/.service_rt@ connect aodv/.service_id@ -and id/.service_id@ connect aodv/.ucastquery@ -and pktdispatcher/.ucastquery@ connect mac/.linkbroken@ -and aodv/.linkbroken@ # present if using 802.11 power-saving mode connect mac/.energy@ -and wphy/.energy@ connect wphy/.mobility@ -and mobility/.query@ connect wphy/.propagation@ -and propagation/.query@ connect mac/down@ -and wphy/up@ connect mac/up@ -and queue/output@ connect ll/.mac@ -and mac/.linklayer@ connect ll/down@ -and queue/up@ connect ll/.arp@ -and arp/.arp@ connect -c pktdispatcher/0@down -and ll/up@ set nid $i ! ! ! ! ! arp setAddresses ll setAddresses mac setMacAddress wphy setNid id setDefaultID $nid $nid $nid $nid $nid $nid $nid "packet" 40

! queue setMode ! queue setCapacity # disable ARP ! arp setBypassARP

[ expr 2>1]

! mac setRTSThreshold 0 connect mobility/.report@ -and /aodvtest/tracker/.node@ connect wphy/down@ -to /aodvtest/channel/.node@ ! /aodvtest/channel attachPort $i [! wphy getPort .channel] # maxX maxY maxZ minX minY minZ dX dY dZ ! mobility setTopologyParameters 600.0 500.0 0.0 100.0 100.0 0.0 60.0 60.0 0.0 ! mac disable_MAC_TRACE_ALL wireless_agent/down@ -and pktdispatcher/1111@up

connect -c cd .. }

23

# FOR THE TARGET NODES ONLY , do the following if { $target_node_num == 0 } { puts "No target agents .... " } else { for {set i [expr $node_num - $target_node_num]} {$i < $node_num} {incr i} { puts "create target $i" set node$i [mkdir drcl.comp.Component n$i] cd n$i # create target agents mkdir drcl.inet.sensorsim.TargetAgent agent ! agent setBcastRate 20.0 ! agent setSampleRate 1.0 # create sensor physical layers mkdir drcl.inet.sensorsim.SensorPhy phy ! phy setRxThresh 0.0 ! phy setNid $i ! phy setRadius 250.0 # create mobility models mkdir drcl.inet.sensorsim.SensorMobilityModel mobility # connect target agents to phy layers so that nodes can send connect agent/down@ -to phy/up@ # connect phy layers to sensor channel so that nodes can send connect phy/down@ -to /aodvtest/chan/.node@ # connect the nodes to the propagation model connect phy/.propagation@ -and /aodvtest/seismic_Prop/.query@ ! mobility setNid $i # set the topology parameters ! mobility setTopologyParameters 600.0 500.0 0.0 100.0 100.0 0.0 cd .. } } # for SENSORs and TARGETs only. Not SINKs for {set i [expr $sink_id + 1]} {$i < $node_num} {incr i} { # connect the mobility model of each node to the node position tracker connect n$i/mobility/.report_sensor@ -and /aodvtest/nodetracker/.node@ connect n$i/phy/.mobility@ -and n$i/mobility/.query@ } ! n$sink_id/app createSnrPorts $node_num $target_node_num set plot_ [mkdir drcl.comp.tool.Plotter .plot] for {set i 0} {$i < $target_node_num} {incr i} { connect -c n$sink_id/app/.snr$i@ -to $plot_/$i@$i }

24

# set the position of sink nodes ! n0/mobility setPosition 0.0 300.0 250.0 0.0 # set the position of target nodes ! n5/mobility setPosition 30.0 550.0 250.0 0.0 ! n6/mobility setPosition 30.0 400.0 450.0 0.0 # # ! ! ! ! set the position of sensor nodes should be made to read from a scenario file n1/mobility setPosition 0.0 350.0 250.0 0.0 n2/mobility setPosition 0.0 400.0 250.0 0.0 n3/mobility setPosition 0.0 450.0 250.0 0.0 n4/mobility setPosition 0.0 500.0 250.0 0.0

puts "simulation begins..." set sim [attach_simulator .] $sim stop # need to start different nodes at different time # in order to avoid route request collision script {run n0} -at 0.3 -on $sim script {run n1} -at 0.4 -on $sim script {run n2} -at 0.5 -on $sim script {run n3} -at 0.6 -on $sim script {run n4} -at 0.7 -on $sim script {run n5} -at 0.8 -on $sim script {run n6} -at 0.9 -on $sim $sim resumeTo 5000.0

Figure 10 shows the signal-to-noise ratio (SNR) collected at the sink node for the two target nodes.

Figure 10.a, SNR collected at the sink node for the target node at (550, 250) 25

Figure 10.b, SNR collected at the sink node for the target node at (400, 450)

References
[1] Sung Park, Andreas Savvides, and Mani B. Srivastava, SensorSim: A Simulation Framework for Sensor Networks, Proceedings of the 3rd ACM international workshop on Modeling, analysis and simulation of wireless and mobile systems, Boston, MA, 2000. [2] Sung Park, Andreas Savvides, and Mani B. Srivastava, Simulating Networks of Wireless Sensors, Proceedings of the 2001 Winter Simulation Conference, 2001. [3] J-Sim - http://www.j-sim.org/ [4] The Network Simulator ns-2 - http://www.isi.edu/nsnam/ns/ [5] Hung-ying Tyan, Design, Realization and Evaluation of a Component-based Compositional Software Architecture for Network Simulation, PhD thesis, Department of Electrical Engineering, The Ohio State University, 2002. [6] Sung Park, Andreas Savvides, and Mani B. Srivastava, Battery Capacity Measurement And Analysis Using Lithium Coin Cell Battery, Proceedings of ISLPED 2001, Huntington Beach, CA, 2001.

26

You might also like