Hi,
I have project on mobile tracking in sensor network in which i have to
simulate in ns2, but i stuck at some place in ns2 please look on
it......
I made three nodes in the scenario and one node is moving towards the
other two node,so in normal situation when moving node
come in the range of any one of the other two node then there should
be the data transfer between them.
My problem is that when i change the position of sensor node then it does
not work. That is it does not communicate with mobile node when it comes
in range (after changing sensor location). The same thing happen if i
change initial location of mobile node (from where it starts). i am
attaching my code with this mail, it is very short code.
Please see it, please i am stuck up badly.
# ======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
#set val(prop) Propagation/Shadowing ;# 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) 500 ;# max packet in ifq
set val(nn) 3 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
1st attempt dsdv 2nd attempt aodv 3rd attempt dsr
set val(x) 670 ;
set val(y) 670 ;
Phy/WirelessPhy set RXThresh_ 7.51087e-07 ;#for range 15 m and
for tworayground model 8.5457e-07
#Phy/WirelessPhy set RXThresh_ 4.9364e-07 ;# fro shadowing model
with path loss 2 and accuracy .5 and distance 15m
#Phy/WirelessPhy set Tx 8.5457e-07 ;#for range 15 m
# ======================================================================
# Main Program
# ======================================================================
#
# Initialize Global Variables
#
set ns_ [new Simulator]
#$ns_ use-newtrace
set tracefd [open simple.tr w]
$ns_ trace-all $tracefd
set namtrace [open simple-out.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid 500 500
#
# Create God
#
create-god $val(nn)
set chan_1_ [new $val(chan)]
#
# Create the specified number of mobilenodes [$val(nn)] and "attach" them
# to the channel.
# Here two nodes are created : node(0) and node(1)
# configure node
$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_1_ \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON
set node_(0) [$ns_ node]
set node_(1) [$ns_ node]
set node_(2) [$ns_ node]
#
# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
#
$node_(0) set X_ 20.0 # if i change this 20 value to anything say 50
it wont work
$node_(0) set Y_ 10.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 300.0
$node_(1) set Y_ 20.0
$node_(1) set Z_ 0.0
$node_(2) set X_ 200.0 # if i change this 200 value to anything say
100 it wont work
$node_(2) set Y_ 20.0
$node_(2) set Z_ 0.0
for {set i 0} {$i < $val(nn)} { incr i } {
# defines the node size for nam here 30 means diameter
$ns_ initial_node_pos $node_($i) 30
}
#
# Now produce some simple node movements
#
$ns_ at 20.0 "$node_(0) setdest 400.0 10.0 2.0"
# Setup traffic flow between nodes
set tcp_(0) [new Agent/TCP]
$tcp_(0) set class_ 2
$ns_ attach-agent $node_(0) $tcp_(0)
set sink_(0) [new Agent/TCPSink]
$ns_ attach-agent $node_(1) $sink_(0)
$ns_ connect $tcp_(0) $sink_(0)
set ftp_(0) [new Application/FTP]
$ftp_(0) set interval_ 0.01
$ftp_(0) attach-agent $tcp_(0)
$ns_ at 1.0 "$ftp_(0) start"
set tcp_(1) [new Agent/TCP]
$tcp_(1) set class_ 2
$ns_ attach-agent $node_(0) $tcp_(1)
set sink_(1) [new Agent/TCPSink]
$ns_ attach-agent $node_(2) $sink_(1)
$ns_ connect $tcp_(1) $sink_(1)
set ftp_(1) [new Application/FTP]
$ftp_(1) set interval_ 0.01
$ftp_(1) attach-agent $tcp_(1)
$ns_ at 1.0 "$ftp_(1) start"
#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
$ns_ at 300.0 "$node_($i) reset";
}
$ns_ at 300.0 "stop"
$ns_ at 300.01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
global ns_ tracefd
$ns_ flush-trace
close $tracefd
exec nam simple-out.nam
}
puts "Starting Simulation..."
$ns_ run
Or you can give me if you have some sample code of target tracking in WSN
in NS2 in which i can specify range of sensor node.
Thanks!!!
with regards
Ankit Kesharwani
M.Tech
IIT Kanpur ,India