使用 NS2 执行 xgraph 计算吞吐量和数据包延迟

Execution of xgraph to compute throughput and packet delay using NS2

我已经在 NS2 中实现了距离矢量协议,现在我想执行 xgraph 以获取吞吐量和数据包延迟。我知道我必须插入吞吐量和延迟等式以及 exec xgraph 命令,但我无法将其集成到我的代码中。有人可以帮帮我吗。

    set ns [new Simulator]  
set nr [open thro.tr w]
$ns trace-all $nr
set nf [open thro.nam w]

$ns namtrace-all $nf
        proc finish { } { // finish procedure   
        global ns nr nf
        $ns flush-trace
        close $nf
        close $nr
        exec nam thro.nam &
    exit 0
        }

for { set i 0 } { $i < 12} { incr i 1 } { // Number of nodes
set n($i) [$ns node]}

for {set i 0} {$i < 8} {incr i} {
$ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail } // Link bandwidth and delay
$ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail
$ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail
$ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail

set udp0 [new Agent/UDP] // Traffic UDP 
$ns attach-agent $n(0) $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set  interval_ 0.005
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp0 $null0

set udp1 [new Agent/UDP]
$ns attach-agent $n(1) $udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set  interval_ 0.005
$cbr1 attach-agent $udp1
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp1 $null0

$ns rtproto DV // routing protocol used

$ns rtmodel-at 10.0 down $n(11) $n(5)
$ns rtmodel-at 15.0 down $n(7) $n(6)
$ns rtmodel-at 30.0 up $n(11) $n(5)
$ns rtmodel-at 20.0 up $n(7) $n(6)

$udp0 set fid_ 1
$udp1 set fid_ 2

$ns color 1 Green
$ns color 2 Blue

$ns at 1.0 "$cbr0 start"
$ns at 2.0 "$cbr1 start"

$ns at 45 "finish"
$ns run

"VIII. Creating Output Files for Xgraph" http://www.isi.edu/nsnam/ns/tutorial/nsscript4.html

Xgraph 示例:xgraph_ns2-files-tcl_09.17.tar.gz https://drive.google.com/file/d/0B7S255p3kFXNczFLV0ZnNWdVY2s/view?usp=sharing → → 文件 n-code.tcl 是一个 "DV example".

DV-示例-3.tar.gz https://drive.google.com/file/d/0B7S255p3kFXNRzBzOGdRODNwcVU/view?usp=sharing

部分APP-Tool结果,"QasimCool-DV.tcl" https://www.dropbox.com/s/qfij7vhpo49t0r1/DV-QuasimCool.tar.gz?dl=0 → → Delay-figure_3.png, Thr-figure_1.png, 1-Instantaneous-throughput_thro.tr.txt, Instantaneous -delay_thro.tr.txt

关于您的文件:“//”不是 ns2 file.tcl 的有效 "comment character"。第 7、16、20、28、48 行已编辑:

7        proc finish { } {             ;# finish procedure

16 for { set i 0 } { $i < 12} { incr i 1 } {    ;# Number of nodes

20 $ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail } ;# Link bandwidth and delay

28 set udp0 [new Agent/UDP]            ;# Traffic UDP

48 $ns rtproto DV                       ;# routing protocol used