Hie

 

Can anyone help me why my tcl script is not showing the packets movement but
its showing nodes range and movement in the nam window.

This is my tcl script.

 

 

 

set opt(chan)        Channel/WirelessChannel

set opt(prop)        Propagation/TwoRayGround

set opt(netif)        Phy/WirelessPhy

#set opt(mac)            Mac/802_11                   ;# MAC type

set opt(mac)            Mac/SMAC                   ;# MAC type

set opt(ifq)        Queue/DropTail/PriQueue

set opt(ll)        LL

set opt(ant)            Antenna/OmniAntenna

 

set opt(x)        800    ;# X dimension of the topography

set opt(y)        800        ;# Y dimension of the topography

set opt(ifqlen)        50        ;# max packet in ifq

set opt(nn)              2        ;# number of nodes

set opt(seed)        0.0

set opt(stop)        700.0        ;# simulation time

set opt(tr)        try.tr      ;# trace file

set opt(nam)        try.nam     ;# animation file

set opt(rp)            DumbAgent       ;# routing protocol script

set opt(lm)             "off"           ;# log movement

set opt(agent)          Agent/DSDV

set opt(energymodel)    EnergyModel     ;

set opt(radiomodel)        RadioModel     ;

set opt(initialenergy)  1000            ;# Initial energy in Joules

 

Mac/SMAC set syncFlag_ 1

 

Mac/SMAC set dutyCycle_ 10

 

set ns_  [new Simulator]

 

 

 

set prop    [new $opt(prop)]

 

 

# For model 'TwoRayGround'

set dist(5m)  7.69113e-06

set dist(9m)  2.37381e-06

set dist(10m) 1.92278e-06

set dist(11m) 1.58908e-06

set dist(12m) 1.33527e-06

set dist(13m) 1.13774e-06

set dist(14m) 9.81011e-07

set dist(15m) 8.54570e-07

set dist(16m) 7.51087e-07

set dist(20m) 4.80696e-07

set dist(25m) 3.07645e-07

set dist(30m) 2.13643e-07

set dist(35m) 1.56962e-07

set dist(40m) 1.20174e-07

 

Phy/WirelessPhy set CSThresh_ $dist(15m)

Phy/WirelessPhy set RXThresh_ $dist(15m)

 

set topo    [new Topography]

$topo load_flatgrid $opt(x) $opt(y)

#ns-random 1.0

 

#

# Create god

#

set god_ [create-god $opt(nn)]

 

 

#global node setting

 

        $ns_ node-config -adhocRouting DumbAgent \

             -llType $opt(ll) \

             -macType $opt(mac) \

             -ifqType $opt(ifq) \

             -ifqLen $opt(ifqlen) \

             -antType $opt(ant) \

             -propType $opt(prop) \

             -phyType $opt(netif) \

             -channelType $opt(chan) \

             -topoInstance $topo \

             -agentTrace ON \

             -routerTrace ON \

             -macTrace ON \

             -energyModel $opt(energymodel) \

             -idlePower 1.0 \

             -rxPower 1.0 \

             -txPower 1.0 \

                   -sleepPower 0.001 \

                   -transitionPower 0.2 \

                   -transitionTime 0.005 \

             -initialEnergy $opt(initialenergy)

 

 

 

    $ns_ set WirelessNewTrace_ ON

       set tracefd    [open $opt(tr) w]

       $ns_ trace-all $tracefd

      set namtracefd    [open $opt(nam) w]

      $ns_ namtrace-all-wireless $namtracefd 500 500

 

 

                  #  Create the specified number of nodes [$opt(nn)] and
"attach" them

       #  to the channel.

    for {set i 0} {$i < $opt(nn) } {incr i} {

        set node_($i) [$ns_ node]

                                

        $node_($i) random-motion 0        ;# disable random motion

    }

                

                

 

                                

                                for {set i 0} {$i < $opt(nn)} {incr i} {

                # init agent

                set agent_($i) [new $opt(agent)]

}

    for {set i 0} {$i < $opt(nn)} {incr i} {                       

                # attach agent to node.

                $node_($i) attach $agent_($i)

} 

 

                                

    $node_(0) set X_ 5.0

    $node_(0) set Y_ 2.0

    $node_(0) set Z_ 0.0

 

    $node_(1) set X_ 15.0

    $node_(1) set Y_ 2.0

    $node_(1) set Z_ 0.0

                

# Generation of movements

$ns_ at 10.0 "$node_(1) setdest 250.0 250.0 3.0"

$ns_ at 15.0 "$node_(0) setdest 45.0 285.0 5.0"

$ns_ at 110.0 "$node_(1) setdest 48.0 300.0 5.0" 

 

set udp_(0) [new Agent/UDP]

$ns_ attach-agent $node_(0) $udp_(0)

set null_(0) [new Agent/Null]

$ns_ attach-agent $node_(1) $null_(0)

set cbr_(0) [new Application/Traffic/CBR]

$cbr_(0) set packetSize_ 512

$cbr_(0) set interval_ 0.05

$cbr_(0) set random_ 1

$cbr_(0) set maxpkts_ 0000

$cbr_(0) attach-agent $udp_(0)

$ns_ connect $udp_(0) $null_(0)

 

$ns_ at 40.00 "$cbr_(0) start"

 

# nodes: 5, max conn: 8, send rate: 0.0, seed: 1.0

#

# 1 connecting to 3 at time 80.557023746220864

#

set tcp_(0) [$ns_ create-connection  TCP $node_(0) TCPSink $node_(1) 0]

$tcp_(0) set window_ 32

$tcp_(0) set packetSize_ 512

set ftp_(0) [$tcp_(0) attach-source FTP]

$ns_ at 80.557023746220864 "$ftp_(0) start"

 

# defines the node size in Network Animator 

      for {set i 0} {$i < $opt(nn)} {incr i} { 

                  

                  # 20 defines the node size in nam, must adjust it
according to your scenario

      # The function must be called after mobility model is defined

       $ns_ initial_node_pos $node_($i) 20 

 

                    }

 

 

                                # Tell nodes when the simulation ends

for {set i 0} {$i < $opt(nn) } {incr i} {

    $ns_ at $opt(stop) "$node_($i) reset";

}

$ns_ at $opt(stop) "puts \"NS EXITING...\" ; $ns_ halt"

 

set b [$node_(0) set mac_(0)]

 

set d [Mac/SMAC set syncFlag_]

 

set c [Mac/SMAC set dutyCycle_]

 

$ns_ at $opt(stop) "finish"

 

puts "Starting Simulation..."

$ns_ run

Reply via email to