Hi,

I have encountered a problem while using Ping protocol. While the protocol 
works file when used in wired simulation, for some reason, it fails for 
wireless. In case of wireless, the recv() function of the protocol is not 
called at all.

Can somebody point out the reason for this. 

I have included the TCL scripts for both wired and wireless case.
__________________________________________________________________________
Wireless case:

#Define a 'recv' function for the class 'Agent/Ping'
Agent/Ping instproc recv {from rtt} {
    $self instvar node_
    puts "node [$node_ id] received ping answer from \
              $from with round-trip-time $rtt ms."
}
# ====================================================================== 
# Define options 
# ====================================================================== 
 
set val(chan)       Channel/WirelessChannel 
set val(prop)       Propagation/FreeSpace 
set val(netif)      Phy/WirelessPhy 
 
set val(mac)        Mac/802_11 
 
set val(ifq)        Queue/DropTail/PriQueue 
set val(ll)         LL 
set val(ant)        Antenna/OmniAntenna 
set val(x)              670   ;# X dimension of the topography 
set val(y)              670   ;# Y dimension of the topography 
set val(ifqlen)         50            ;# max packet in ifq 
set val(seed)           0.0 
 
set val(adhocRouting)   FLOODING 
# when set to flooding, only one node is accounted for.... 
 
set val(nn)             3           ;# how many nodes are simulated 
set val(stop)           200.0           ;# simulation time 
 
# ===================================================================== 
# Main Program 
# ====================================================================== 
# ====================================================================== 
 
# 
# Initialize Global Variables 
# 
 
# create simulator instance 
set ns        [new Simulator] 
 
# setup topography object 
set topo    [new Topography] 
 
#use new trace format 
$ns use-newtrace 
 
# create trace object for ns and nam 
set tracefd    [open ping_wl.tr w] 
$ns trace-all $tracefd 
 
set namtrace [open ping_wl.nam w] 
$ns namtrace-all-wireless $namtrace $val(x) $val(y) 
 
 
# define topology 
$topo load_flatgrid $val(x) $val(y) 
 
# 
# Create God 
# 
set god_ [create-god $val(nn)] 
 
#$god_ on 
# when god turned on, ns segfaults 
 
# 
# define how node should be created 
# 
 
# Create channel #1 
set chan_1_ [new $val(chan)] 
 
#global node setting 
$ns node-config -adhocRouting $val(adhocRouting) \ 
                  -llType $val(ll) \ 
                  -macType $val(mac) \ 
                  -ifqType $val(ifq) \ 
                  -ifqLen $val(ifqlen) \ 
                  -antType $val(ant) \ 
                  -propType $val(prop) \ 
                  -phyType $val(netif) \ 
          -topoInstance $topo \ 
          -agentTrace ON \ 
                  -routerTrace ON \ 
                  -macTrace OFF \ 
          -mobilityTrace OFF \ 
          -channel $chan_1_ 
 
# 
#  Create the specified number of nodes [$val(nn)] and "attach" them 
#  to the channel. 
 
for {set i 0} {$i < $val(nn) } {incr i} { 
     set node_($i) [$ns node $i] 
     $node_($i) random-motion 0        ;# disable random motion 
} 
 
$god_ set-dist 0 1 1 
 
#setting initial positions of the nodes 
#nodes are stationary for throughout the simulation 
$node_(0) set Z_ 0.000000000000 
$node_(0) set Y_ 0.00 
$node_(0) set X_ 0.00 
 
$node_(1) set Z_ 0.000000000000 
$node_(1) set Y_ 0.0 
$node_(1) set X_ 10.0

$node_(2) set Z_ 0.000000000000 
$node_(2) set Y_ 20.0 
$node_(2) set X_ 20.0

set p0 [new Agent/Ping]
$ns attach-agent $node_(0) $p0
set p1 [new Agent/Ping]
$ns attach-agent $node_(1) $p1
set p2 [new Agent/Ping]
$ns attach-agent $node_(2) $p2

#Connect the two agents
$ns connect $p0 $p2
$ns connect $p0 $p1
$ns connect $p2 $p1

#Schedule events
$ns at 0.2 "$p0 send"
$ns at 0.4 "$p1 send"
$ns at 0.6 "$p0 send"
$ns at 0.6 "$p1 send"
$ns at 1.0 "finish"

#Run the simulation
$ns run

__________________________________________________________________________

Wired Case:

#Define a 'recv' function for the class 'Agent/Ping'
Agent/Ping instproc recv {from rtt} {
    $self instvar node_
    puts "node [$node_ id] received ping answer from \
              $from with round-trip-time $rtt ms."
}

set ns [new Simulator]

set nf [open out.nam w]
$ns namtrace-all $nf

set tracefd    [open ping.tr w]
$ns trace-all $tracefd

#Create three nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
#Connect the nodes with one link
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n2 $n1 1Mb 10ms DropTail



#Create two ping agents and attach them to the nodes n0 and n1
set p0 [new Agent/Ping]
$ns attach-agent $n0 $p0
set p1 [new Agent/Ping]
$ns attach-agent $n1 $p1
set p2 [new Agent/Ping]
$ns attach-agent $n2 $p2

#Connect the two agents
$ns connect $p0 $p2
$ns connect $p0 $p1
$ns connect $p2 $p1

#Schedule events
$ns at 0.2 "$p0 send"
$ns at 0.4 "$p1 send"
$ns at 0.6 "$p0 send"
$ns at 0.6 "$p1 send"
$ns at 1.0 "finish"

#Run the simulation
$ns run



      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
http://in.yahoo.com/

Reply via email to