[心得] Ns2 MOVE SUMO一些錯誤訊息解決方案

作者: kaibaemon (海馬衛門)   2012-07-23 20:36:57
回首向來一路跌跌撞撞
終於將論文從無到有生出來
關於ns2的知識幾乎得知於網路
花很多時間自己去搜尋而來
因此將筆記整理整理po上來以供各位參考
減少碰壁的時間
我使用ns2.34版本
模擬VANET
如有錯誤歡迎指正~~
問題一、讓節點擁有廣播的功能出現錯誤
Ns2.34有內建廣播的功能
位置在apps資料夾裡的pbc.cc
在tcl裡面創造節點時並將agent添加到node上之後
要run tcl出現以下錯誤(藍色字是原本tcl程式碼)
(_o14 cmd line 1)
invoked from within
"_o14 cmd random-motion 0 #disable random motion"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o14" line 2)
(SplitObject unknown line 2)
invoked from within
"$node_($i) random-motion 0 #disable random motion"
("for" body line 4)
invoked from within
"for {set i 0} {$i < $val(nn)} {incr i} {
set ID_($i) $i
set node_($i) [$ns_ node]
$node_($i) random-motion 0 #disable random motion
$..."
(file "practice.tcl" line 106)
解決方法:
將程式碼改成以下即可執行tcl檔案了
for {set i 0} {$i < $val(nn)} {incr i} {
set ID_($i) $i
set node_($i) [$ns_ node]
$node_($i) set id_ $ID_($i)
$node_($i) set address_ $ID_($i)
$node_($i) nodeid $ID_($i)
set agent_($i) [new Agent/PBC]
$ns_ attach-agent $node_($i) $agent_($i)//將每個agent加到每個node上
$agent_($i) set Pt_ 2.0e-4
$agent_($i) set payloadSize 1000
$agent_($i) set modulationScheme 0
$agent_($i) PeriodicBroadcast OFF
$node_($i) random-motion 0; //要將牠放到for loop最後一行
}
問題二、(可承上問題)出現node is not defined錯誤訊息
問題一解決之後可以跑了但跑很慢
用nam秀出結果時候電腦也跑很慢
且一直出現 node is not defined
解決的方法:
在tcl裡面加上
for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 2
}//初始化nam節點的位置及大小
解決之後執行速度變快了
而且本來有些節點弧形的移動
變回直線移動樣式了
原來是沒有將節點位置初始化的關係
問題三、出現invalid command name "Agent/XXX" wile executing "Agent/XXX"
在ns2.34版添加新協定Agent/CLUSTER之後
在terminal執行ns practice.tcl
出現invalid command name "Agent/CLUSTER"
while executing
"Agent/CLUSTER"
解決方法:
../ns practice.tcl
再命令前加上 ../ 即可執行tcl檔案
問題四、 Segmentation Fault錯誤訊息
Segmentation Fault錯誤訊息最常發生的原因是
指標所指的物件已經不存在了
後面code仍去使用不存在的物件
例如:
我曾經將event物件(Timeouthandler)用指標delete掉了
所以再次進入條件判斷後event指向的物件已經不存在
因此出現segementation fault訊息
解決方法:
檢查程式有沒有將物件釋放掉仍去使用他的狀況
問題五、編譯ns2程式時候,顯示makefile.in is newer than makefile訊息
當要執行make編譯程式的時候,終端機顯示如下
makefile.in is newer than makefile
you need to re-run configure...
解決方法:
先修改makefile.in文件內容
接著修改makefile文件
也就是要兩個文件補補丁上XXXX.o檔案
(XXXX.o就是使用者自己寫的XXXX.cc以及XXXX.h的程式碼)
問題六、 修改agent接收tcl參數的個數出現global errorInfo訊息
原本tcl程式碼是
$agent_($i) PeriodicBoradcast OFF
改成如下
$agent_($i) PeriodicBroadcast OFF 0
也就是說我本來丟三個參數給.cc
現在改丟四個參數給.cc
出現以下錯誤
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
解決方法:
原來是.cc的tcl command那邊沒有接收四個參數的條件判斷
或者將接收四個參數的條件判斷寫在其他條件判斷下了
也就是說我將if(argc == 4)寫在if(argc == 3)裏頭了
因為漏掉大括號的關係
也因此tcl丟四個參數給.cc時候
.cc不會認識這四個參數
因此出現此問題好好檢查大括號有沒有漏掉或多寫
或者是沒有寫if(argc == 4)
問題七、 floating point exception
解決方法:
1.對數的真數不可為零
2.除數不可為零
問題八、MOVE產生的移動劇本無法給SUMO執行
解決方法:
請注意MOVE與SUMO版本相容性
MOVE2.9版的無法與SUMO-0.11.X以及以前版本相容
我用MOVE 2.9版跟SUMO-0.12.3版
MOVE產生的移動劇本檔可以給SUMO執行模擬
作者: tuner123 (健康的腳踝)   2012-01-29 18:41:00
感謝分享

Links booklink

Contact Us: admin [ a t ] ucptt.com