Hi all,
I have written a simulation script as given below. Now when I try to calculate 
no of data packets sent, the result comes out to be zero. Can anyone tell me 
the problem in my script. 
  
set ns_ [new Simulator]

#number of nodes
set num_mobile_nodes 10

# Parameter for wireless nodes
set opt(chan)           Channel/WirelessChannel    ;# channel type
set opt(prop)           Propagation/TwoRayGround   ;# radio-propagation model
set opt(netif)          Phy/WirelessPhy            ;# network interface type
set opt(mac)            Mac/802_11                 ;# MAC type
set opt(ifq)            Queue/DropTail/PriQueue    ;# interface queue type
set opt(ifqlen)         30                         ;# max packet in ifq
set opt(ll)             LL                         ;# link layer type
set opt(ant)            Antenna/OmniAntenna        ;# antenna model
set opt(adhocRouting)   AODV                       ;# routing protocol
set opt(x)              1500                       ;# X dimension of the 
topography
set opt(y)              300                        ;# Y dimension of the 
topography

$ns_ use-newtrace

set ntr [open out_pq.tr w] 
$ns_ trace-all $ntr

set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)

# Create God
set god_ [create-god $num_mobile_nodes]

set chan_1 [new $opt(chan)]

# config node
$ns_ node-config -adhocRouting $opt(adhocRouting) \
                 -llType $opt(ll) \
                 -macType $opt(mac) \
                 -ifqType $opt(ifq) \
                 -ifqLen $opt(ifqlen) \
                 -antType $opt(ant) \
                 -propType $opt(prop)    \
                 -phyType $opt(netif) \
                 -channel $chan_1      \
                 -topoInstance $topo \
                 -wiredRouting OFF \
                 -agentTrace ON \
                 -routerTrace OFF \
                 -macTrace OFF    \
                 -movementTrace OFF


# creating mobile nodes
for {set i 0} {$i < $num_mobile_nodes} {incr i} {
    set node_($i) [$ns_ node]         
    $node_($i) random-motion 0               ;# disable random motion
    puts "wireless node $i created ..."
    $node_($i) set X_ [expr $i * 10.0]
    $node_($i) set Y_ [expr $i * 5.0]
    $node_($i) set Z_ 0.0
}


for {set i 0} {$i < $num_mobile_nodes} {incr i} {
    set src_tcp_($i) [new Agent/TCP]
    $src_tcp_($i) set class_ $i
    set sink_($i) [new Agent/TCPSink]
    $ns_ attach-agent $node_($i) $src_tcp_($i)
    $ns_ attach-agent $node_([expr ($i+3)%($num_mobile_nodes)]) $sink_($i)
    set ftp_($i) [new Application/FTP]
    $ftp_($i) set packetSize_ 1025
    $ftp_($i) set interval_ 0.005
    $ftp_($i) attach-agent $src_tcp_($i)
    $ns_ connect $src_tcp_($i) $sink_($i)
    #$ns_ set fid_ $i
    $ns_ at 0.1 "$ftp_($i) start"
}

# Define node initial position in nam
for {set i 0} {$i < $num_mobile_nodes} {incr i} {
    $ns_ initial_node_pos $node_($i) 20
   }

#source $opt(cp)
#source $opt(sc)

# Tell nodes when the simulation ends
for {set i 0} {$i < $num_mobile_nodes } {incr i} {
    $ns_ at 299.0 "$node_($i) reset";
}

for {set i 0} {$i < $num_mobile_nodes} {incr i} {
    $ns_ at 300.0 "stop"
}

$ns_ at 300.00 "puts \"NS EXITING...\" ; $ns_ halt"

proc stop {} {
    global ns_ ntr queuechan
    $ns_ flush-trace    
    close $ntr
  #  close $queuechan
    exit 0
}

# run the simulation
$ns_ run

Reply via email to