[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] How to use "create-trace"? -- What's wrong with my program?
I wrote a program trying to trace the traffic between
two nodes. I want to use the method "create-trace" to
capture only the "Recv" trace. The program can run,
but nothing is written into the output file "out.tr".
Can anyone help me to find of what the problem is?
(BTW, I am using ns-allinone-2.1b8a under Red Hat
Linux 7.1).
This is my program:
#*******************************************
set ns [new Simulator]
set tracefd [open out.tr w]
# Create the nodes
set n1 [$ns node]
set n2 [$ns node]
# Setup connections between the nodes
$ns duplex-link $n1 $n2 10Mb 5ms DropTail
set newtrc [$ns create-trace Recv $tracefd $n1 $n2]
$newtrc set show_tcphdr_ 1
# Configure the nodes
set tcp1 [new Agent/TCP]
$ns attach-agent $n1 $tcp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set rate_ 64Kb
$cbr1 attach-agent $tcp1
set sink1 [new Agent/TCPSink]
$ns attach-agent $n2 $sink1
# Connect the agents.
$ns connect $tcp1 $sink1
$ns at 1.0 "$cbr1 start"
$ns at 2.0 "$cbr1 stop"
$ns at 10.0 "finish"
proc finish {} {
global ns tracefd newtrc
$newtrc flush
close $tracefd
exit 0
}
$ns run
#************************************************
Best Regards,
Lao Yu
__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Beat the crowds! Do your X'mas Shopping Online!
http://shopping.yahoo.com.sg/