NS2跨层设计传输层 - > mac

时间:2016-09-09 14:27:35

标签: ns2

如下,tcl运行遇到了问题,我该如何解决? 非常感谢!!!!!!

问题: 无法读取“mac_(0)”:没有这样的变量     执行时 “subst $ [subst $ var]”     (程序“ o10”第5行)     (SplitObject设置第5行)     从内部调用 “$ node ($ i)设置mac_(0)”     从内部调用 “$ bop0 bop-get-mac [$ node _($ i)set mac_(0)]”     (档案“test.tcl”第47行)

代码:

set ns [new Simulator]    

set val(ifq)        Queue
set val(ll)         LL
set val(ifqlen)         50 
set val(mac)        Mac

$ns node-config -llType $val(ll) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
                -macType $val(mac) \

set tracef [open test.tr w]
$ns trace-all $tracef
set namtf [open test.nam w]
$ns namtrace-all $namtf

proc finish {} {
    global ns tracef namtf
    $ns flush-trace
    close $tracef
    close $namtf
    exec nam test.nam &
    exit 0
}
set i 0
set node_($i) [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]

$ns duplex-link $node_($i) $n1 10Mb 10ms DropTail
$ns duplex-link $n1 $n2 10Mb 10ms DropTail
$ns duplex-link $n2 $n3 10Mb 10ms DropTail
$ns duplex-link $n3 $n4 10Mb 10ms DropTail

$ns duplex-link-op $node_($i) $n1 orient right
$ns duplex-link-op $n1 $n2 orient right
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n3 $n4 orient right

set bop0 [new Agent/BOP]
#bop: a new transport layer protocol
$ns attach-agent $node_($i) $bop0  
$bop0 bop-get-mac [$node_($i) set mac_(0)]

set bop4 [new Agent/BOPSink]
$ns attach-agent $n4 $bop4

$ns connect $bop0 $bop4

set ftp [new Application/FTP]
$ftp attach-agent $bop0
$ftp set type_ FTP

$ns at 1.0 "$ftp start"
$ns at 4.0 "$ftp stop"

$ns at 5.0 "finish"

$ns run 

0 个答案:

没有答案