Make the mobile nodes static in tcl.

set val(chan)   Channel/WirelessChannel
set val(prop)   Propagation/TwoRayGround
set val(ant)    Antenna/OmniAntenna
set val(ll)     LL
set val(ifq)    Queue/DropTail/PriQueue
set val(ifqlen) 50
set val(netif)  Phy/WirelessPhy
set val(mac)    Mac/802_11
set val(rp)     DSDV
set val(nn)     15
set val(x)      700
set val(y)      500
set val(stop)   130

set ns [new Simulator]
set tracefd       [open w]
set windowVsTime2 [open w]
set namtrace      [open trust.nam w]

$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
set topo       [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god (1)
#create-god (3)

 $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) \
                  -channelType $val(chan) \
                  -topoInstance $topo \
                  -agentTrace ON \
                  -routerTrace ON \
                  -macTrace OFF \
                  -movementTrace OFF\
                   -energyModel "EnergyModel" \
-initialEnergy 50

# Energy model
     $ns node-config  -energyModel EnergyModel \
                       -initialEnergy 50 \
                       -txPower 0.75
                       #-rxPower 0.25 \
                       #idlePower 0.0 \
                       #sensePower 0.0
for {set i 0} {$i < $val(nn) } { incr i } {
           set node_($i) [$ns node]
for {set i 0} {$i < $val(nn) } { incr i } {
                 set xx [expr rand()*600]
                 set yy [expr rand()*500]
                 $node_($i) set X_ $xx
                 $node_($i) set Y_ $yy
                 $node_($i) set Z_ 0.0

$ns at 0.0 "$ns trace-annotate \"MOBILE NODE MOVEMENTS\""
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(1) $tcp
$ns attach-agent $node_(3) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"

#setting initial position:
for {set i 0} {$i < $val(nn)} { incr i } {
$ns initial_node_pos $node_($i) 30

#$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 130.01 "puts \"end simulation\" ; $ns halt"
proc stop {} {
   global ns tracefd namtrace
   $ns flush-trace
   close $tracefd
   close $namtrace
exec nam trust.nam &

$ns run

this code run but the mobile nodes are dynamic each time how to make the dynamic mobile nodes to static? how to make it static mobile nodes and need to do randomized overhearing in the ns2 tcl code


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s