[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] target_->recv(p,0) calls the recv(p,0) of the same object
I have designed a new protocol header LWP and two agents LWP/SENA and
LWP/AP . I have followed all the guidelines of ns tutorial on ping
protocol design. (please see my tcl script at the end). I wish to send
packets from SENA Agent to AP Agent. My "send size" command takes the
packet size from the tcl script. In the C++ code, it creates a packet of
that size and calls target_->recv(p,0). But instead of calling the
target's recv() function, it calls its own. This I verified from the
debugging statements. The print statements in the tcl script shows the
addresses and ports as below:
for SENA Agent
agent_addr_ = 0 , agent_port_ =0 , dst_addr_ = 1 , dst_port_ = 0
for AP Agent
agent_addr_ = 1 , agent_port_ =0 , dst_addr_ = 0 , dst_port_ = 0
This seems to be correct to me but doesn't work.
But when in the tcl script I have
#p0 and p1 are the agents
$p0 target $p1
$p1 target $p0
it works. However, It doesn't generate any trace.
Can anybody help me out?
Thanks in advance....
Here is the tcl script
-------------------------------------------------
remove-all-packet-headers
add-packet-header LWP
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
set p0 [new Agent/LWP/SENA]
$ns attach-agent $n0 $p0
set p1 [new Agent/LWP/AP]
$ns attach-agent $n1 $p1
#Connect the two agents
$ns connect $p0 $p1
$ns at 0.05 "$p1 startme"
$ns at 0.1 "$p0 startme"
$ns at 0.55 "$p0 send 40"
$ns at 0.60 "$p0 send 40"
$ns at 1.5 "finish"
$ns run