[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Help for ns-2



Dear sir:
I am a doctorate candidate of Electronics and Information Engineering department,Huazhong university of Science and Technology,Wuhan,China.
My name is Niqiang.My research interest is cooperative congestion control for shared flows,Multicast.It is well known that ns-2 
is one of the best simulaton softwares.I get it from the ns homepage.
I write a sample TCl file(attachment),but I don't know how to output
each packet's delay and loss reate in the TRACE file.Would you mind 
telling me how to record the detailed packet information and output?
Your reply will be sincerely appreciated.Thank you very much.

Best wishes to you

Yours Ever:
niqiang
[email protected]
Electronics and Information Engineering department,Huazhong university of Science and Technology,Wuhan,China


_____________________________________________
�׶�����--�й��˵����ϼ�԰ http://www.263.net
@263.net�й����������ʾ� http://freemail.263.net
#Create a simulator object
set ns [new Simulator]

#Open the nam trace file
set nf [open out.nam w]
set f [open out.tr w]
$ns namtrace-all $nf
$ns trace-all $f

#Define a 'finish' procedure
proc finish {} {
        global ns f nf
        $ns flush-trace
	#Close the trace file
        close $nf
	close $f
	#Execute nam on the trace file
        exec nam out.nam &
        exit 0
}

#Create seven nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]

#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 2Mb 30ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 1000Mb 30ms DropTail
$ns duplex-link $n3 $n4 1000Mb 20ms DropTail
$ns duplex-link $n4 $n5 1000Mb 30ms DropTail
$ns duplex-link $n2 $n6 1000Mb 20ms DropTail
$ns duplex-link $n6 $n7 1000Mb 20ms DropTail

#Create a CBR agent and attach it to node n0
set cbr0 [new Agent/CBR]
set cbr1 [new Agent/CBR]
set cbrb [new Agent/CBR]

$ns attach-agent $n0 $cbr0
$ns attach-agent $n0 $cbr1
$ns attach-agent $n0 $cbrb

$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005

$cbr1 set packetSize_ 1000
$cbr1 set interval_ 0.005

$cbrb set packetSize_ 10000
$cbrb set interval_ 0.02

#Create a Null agent (a traffic sink) and attach it to node n5,n7,n2
set null0 [new Agent/Null]
set null1 [new Agent/Null]
set nullb [new Agent/Null]


$ns attach-agent $n5 $null0
$ns attach-agent $n7 $null1
$ns attach-agent $n2 $nullb

#Connect the traffic source with the traffic sink
$ns connect $cbr0 $null0  
$ns connect $cbr1 $null1  
$ns connect $cbrb $nullb  

#Schedule events for the CBR agent
$ns at 0.0 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"

$ns at 0.0 "$cbr1 start"
$ns at 4.5 "$cbr1 stop"

$ns at 0.0 "$cbrb start"
$ns at 4.5 "$cbrb stop"

#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"

#Run the simulation
$ns run