实验中可能出现的错误及其解决方法

转载自:http://peilie-coolboy.blog.163.com/blog/static/23952371201241710531592/

参考文献:

[1]马崇霄,吴长奇.基于网络仿真器NS2的Adhoc网络路由协议仿真[J].电子测量技术,2008(5):75-79

 

按照参考文献[1]所给的代码运行的时候可能出现的错误及其对应的解决方法

出现以下错误提示:

错误1:参考文章[1]中没有设置路由协议变量rp的值。

 

can't read "val(rp)": no such element in array

   while executing

"$ns_ node-config -adhocRouting $val(rp) \

-llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen $val(ifqlen) \

-antType $val(ant) \

-pr..."

   (file "aodv.tcl" line 30)

 

错误2:参考文章[1]中set val(prop) Propagation/TwoRayGrond;这句写错了,应该是set val(prop)  Propagation/TwoRayGround;

 

invalid command name "Propagation/TwoRayGrond"

   while executing

"Propagation/TwoRayGrond create _o12 "

   invoked from within

"catch "$className create $o $args" msg"

   invoked from within

"if [catch "$className create $o $args" msg] {

if [string match "__FAILED_SHADOW_OBJECT_" $msg] {

delete $o

return ""

}

global errorInfo

error "class $..."

   (procedure "new" line 3)

   invoked from within

"new $propType_"

   (procedure "_o3" line 34)

   (Simulator node-config line 34)

   invoked from within

"$ns_ node-config -adhocRouting $val(rp) \

-llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen $val(ifqlen) \

-antType $val(ant) \

-pr..."

   (file "aodv.tcl" line 31)

 

错误3:参考文章[1]中set val(chan) Channel/wireless;这句写错了,应该是set val(chan)  Channel/WirelessChannel; 。

 

warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl

invalid command name "Channel/wireless"

   while executing

"Channel/wireless create _o13 "

   invoked from within

"catch "$className create $o $args" msg"

   invoked from within

"if [catch "$className create $o $args" msg] {

if [string match "__FAILED_SHADOW_OBJECT_" $msg] {

delete $o

return ""

}

global errorInfo

error "class $..."

   (procedure "new" line 3)

   invoked from within

"new $channelType_"

   (procedure "_o3" line 44)

   (Simulator node-config line 44)

   invoked from within

"$ns_ node-config -adhocRouting $val(rp) \

-llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen $val(ifqlen) \

-antType $val(ant) \

-pr..."

(file "aodv.tcl" line 31)

 

错误4:代码{$ i

 

warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl

extra characters after close-brace

   while executing

"for {set i 0}{$i < val(nn)}{incr i}{

set node_($i) [$ns_ node]

$node_($i) random-motion 0

}

source $opt(cp)

source $opt(sc)

for {set i 0}{$i <$val(nn)}..."

   (file "aodv.tcl" line 46)

 

错误5:"for {set i 0} {$i  这句代码中val(nn)前面应该加上$,即改为

"for {set i 0} {$i <$val(nn)} {incr i} {  。

 

syntax error in expression "$i < val(nn)": variable references require preceding $

   while executing

"for {set i 0} {$i < val(nn)} {incr i} {

set node_($i) [$ns_ node]

$node_($i) random-motion 0

}"

   (file "aodv.tcl" line 46)

你可能感兴趣的:(NS2学习)