【问题标题】:Execution of xgraph to compute throughput and packet delay using NS2使用 NS2 执行 xgraph 以计算吞吐量和数据包延迟
【发布时间】:2018-04-01 10:33:49
【问题描述】:

我已经在 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

【问题讨论】:

    标签: networking ns2


    【解决方案1】:

    “VIII. 为 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 示例”。

    DV-examples-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 不是有效的“注释字符”。第 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
    

    【讨论】:

    • 先生,这是真的,但是由于我使用的是 cygwin 并且无法使用应用程序工具进行分析,因此无法在此代码中集成吞吐量和延迟吗?
    • APP-Tool easy : 将“VirtualBox”安装到 Windows©,然后将 Ubuntu 16.04 安装到 VirtualBox。 ...并在 Ubuntu / app-tool 中分析您的跟踪文件。也很简单:使用 app-tool 中的 awk 文件分析 thro.tr(无图表)。 ... ... 艰难的方法:学习如何编写/编码您的 file.tcl 来为 xgraph 创建文件。
    猜你喜欢
    • 2012-07-02
    • 2022-12-25
    • 2015-04-16
    • 2018-12-14
    • 2021-04-16
    • 1970-01-01
    • 2019-08-27
    • 2017-11-19
    • 2017-03-05
    相关资源
    最近更新 更多