[問題] 抱歉又有問題了 請各位大大給點提示

看板Network_Sim作者 (大棵)時間15年前 (2009/07/06 11:47), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
tcl如下: # Creating New Simulator set num_wired_nodes 7 set num_mobile_nodes 1 set num_bs_nodes 1 ;# number of base stations set num_nodes [expr $num_wired_nodes + $num_mobile_nodes + $num_bs_nodes] set bs_id $num_wired_nodes set ns [new Simulator -multicast on] set group0 [Node allocaddr] set group1 [Node allocaddr] # Setting up the traces set f [open out.tr w] set nf [open out.nam w] $ns namtrace-all $nf $ns trace-all $f proc finish {} { global ns nf f $ns flush-trace puts "Simulation completed." close $nf close $f exit 0 } #設定mobile node的個數 set opt(nnn) 1 set topo [new Topography] $topo load_flatgrid 100 100 #create god set god_ [create-god [expr $opt(nnn)+1]] # Parameter for wireless nodes set opt(chan) Channel/WirelessChannel ;# channel type set opt(prop) Propagation/TwoRayGround ;# radio-propagation model set opt(netif) Phy/WirelessPhy ;# network interface type set opt(mac) Mac/802_11 ;# MAC type set opt(ifq) Queue/DropTail/PriQueue set opt(ifqlen) 50 set opt(ll) LL ;# link layer type set opt(ant) Antenna/OmniAntenna ;# antenna model set opt(adhocRouting) NOAH ;# routing protocol set opt(x) 500 ;# X dimension of the topography set opt(y) 500 ;# Y dimension of the topography Mac/802_11 set SlotTime_ 0.000020 ;# 20us Mac/802_11 set SIFS_ 0.000010 ;# 10us Mac/802_11 set PreambleLength_ 144 ;# 144 bit Mac/802_11 set PLCPHeaderLength_ 48 ;# 48 bits Mac/802_11 set PLCPDataRate_ 1.0e6 ;# 1Mbps Mac/802_11 set dataRate_ 11.0e6 ;# 11Mbps Mac/802_11 set basicRate_ 1.0e6 ;# 1Mbps Mac/802_11 set RTSThreshold_ 3000 Mac/802_11 set ShortRetryLimit_ 7 ;# retransmittions Mac/802_11 set LongRetryLimit_ 4 ;# retransmissions #set up for hierarchical routing #(needed for routing over a basestation) $ns node-config -addressType hierarchical AddrParams set domain_num_ 2 ;# domain number lappend cluster_num 1 1 ;# cluster number for each domain AddrParams set cluster_num_ $cluster_num lappend eilastlevel $num_wired_nodes [expr $num_mobile_nodes + $num_bs_nodes] ;# number of nodes for each cluster AddrParams set nodes_num_ $eilastlevel # #wired Nodes # set n0 [$ns node 0.0.2] puts "n0: [$n0 id]" set n1 [$ns node 0.0.3] puts "n1: [$n1 id]" set n2 [$ns node 0.0.4] puts "n2: [$n2 id]" set n3 [$ns node 0.0.4] puts "n3: [$n3 id]" set n4 [$ns node 0.0.5] puts "n4: [$n4 id]" set n5 [$ns node 0.0.6] puts "n5: [$n5 id]" set n6 [$ns node 0.0.7] puts "n6: [$n6 id]" #設定節點參數 $ns node-config -adhocRouting $opt(adhocRouting) \ -llType $opt(ll) \ -macType $opt(mac) \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqlen) \ -antType $opt(ant) \ -propType $opt(prop) \ -phyType $opt(netif) \ -channel $opt(chan) \ -topoInstance $topo \ -wiredRouting ON \ -agentTrace OFF \ -routerTrace OFF \ -macTrace OFF \ -movementTrace OFF # creating base station set BS(0) [$ns node 1.0.0] $BS(0) random-motion 0 puts "Base-Station node $bs_id created" #provide some co-ord (fixed) to base station node $BS(0) set X_ 100.0 $BS(0) set Y_ 100.0 $BS(0) set Z_ 0.0 #設定mobile node的參數 set MH(0) [$ns_ node 1.0.1] set MHnetif_(0) [$MH(0) set netif_(0)] $MHnetif_(0) set-error-level $pGG $pBB $pG $pB $loss_model #把此mobile node跟前面的base station節點做連結 [$MH(0) set regagent_] set home_agent_ [AddrParams addr2id [$BS(0) node-addr]] #設定mobile node的位置在(80.0, 80.0) $MH(0) set X_ 80.0 $MH(0) set Y_ 80.0 $MH(0) set Z_ 0.0 # #Setup Connections # $ns duplex-link $n0 $BS(0) 100Mb 1ms DropTail $ns duplex-link $n2 $BS(0) 100Mb 1ms DropTail $ns duplex-link $n5 $n1 30Mb 10ms DropTail $ns queue-limit $n5 $n1 500 $ns duplex-link $n5 $n3 20Mb 10ms DropTail $ns queue-limit $n5 $n3 500 $ns duplex-link $n6 $n5 6Mb 10ms DropTail $ns duplex-link $n5 $n4 10Mb 10ms DropTail $ns queue-limit $n5 $n4 500 $ns duplex-link $n2 $n6 6Mb 10ms DropTail $ns duplex-link $n2 $n5 6Mb 10ms DropTail $ns queue-limit $n2 $n5 500 $ns duplex-link $n0 $n6 12Mb 10ms DropTail $ns duplex-link $n0 $n5 12Mb 10ms DropTail $ns queue-limit $n0 $n5 500 # #Set up Transportation Level Connections # set lossMonitor0 [new Agent/LossMonitor] $ns attach-agent $n1 $lossMonitor0 set lossMonitor2 [new Agent/LossMonitor] $ns attach-agent $n3 $lossMonitor2 set lossMonitor1 [new Agent/LossMonitor] $ns attach-agent $n4 $lossMonitor1 set lossMonitor3 [new Agent/LossMonitor] $ns attach-agent $n0 $lossMonitor3 set udp0 [new Agent/UDP] $udp0 set dst_addr_ $group1 $udp0 set packetSize_ 1500 $ns attach-agent $n0 $udp0 set udp1 [new Agent/UDP] $udp1 set dst_addr_ $group0 $udp1 set packetSize_ 1500 $ns attach-agent $n2 $udp1 # #Setup traffic sources # set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 1500 $cbr0 set interval_ 2ms $cbr0 attach-agent $udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 1500 $cbr1 set interval_ 2ms $cbr1 attach-agent $udp0 set mproto DM set mrthandle [$ns mrtproto $mproto] # #Start up the sources # $ns at 0 "$cbr0 start" $ns at 0 "$cbr1 start" $ns at 0 "$n1 join-group $lossMonitor0 $group0" $ns at 0 "$MH(0) join-group $lossMonitor0 $group0" $ns at 0 "$MH(0) join-group $lossMonitor0 $group1" $ns at 0 "$n1 join-group $lossMonitor0 $group1" $ns at 0 "$n4 join-group $lossMonitor1 $group0" $ns at 0 "$n4 join-group $lossMonitor1 $group1" $ns at 0 "$n3 join-group $lossMonitor2 $group0" $ns at 0 "$n3 join-group $lossMonitor2 $group1" $ns at 0 "$n0 join-group $lossMonitor3 $group0" $ns at 10 "$cbr0 stop" $ns at 10 "$cbr1 stop" $ns at 10 "$MH(0) leave-group $lossMonitor0 $group0" $ns at 10 "$MH(0) leave-group $lossMonitor0 $group1" $ns at 10 "$n1 leave-group $lossMonitor0 $group0" $ns at 10 "$n1 leave-group $lossMonitor0 $group1" $ns at 10 "$n4 leave-group $lossMonitor1 $group0" $ns at 10 "$n4 leave-group $lossMonitor1 $group1" $ns at 10 "$n3 leave-group $lossMonitor2 $group0" $ns at 10 "$n3 leave-group $lossMonitor2 $group1" $ns at 10 "$n0 leave-group $lossMonitor3 $group0" $ns at 10.0 "finish" $ns run 錯誤訊息如下: http://www.wretch.cc/album/show.php?i=nesk&b=4&f=1660761736&p=6 對了我是在柯老師第二本書的myns2下跑的 接著上網找了之後發現有人說把 $ns_ node-config-channel $opt(chan) \改成 $ns_ node-config -channel [new $val(chan)] 然後我也把這一行set opt(chan) Channel/WirelessChannel ;# channel type 去掉出現了另一種錯誤訊息 http://www.wretch.cc/album/show.php?i=nesk&b=4&f=1660761735&p=5 我知道第二個錯誤訊息是檢查TclParseNestedCmd時有問題的錯誤訊息 $ns_ node-config-channel $opt(chan) \改成 $ns_ node-config -channel [new $opt(chan)] 出現了這個問題 http://www.wretch.cc/album/show.php?i=nesk&b=4&f=1660761737&p=7 不知那位大大能給我點提示 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.118.122.88
文章代碼(AID): #1AKNFR82 (Network_Sim)
文章代碼(AID): #1AKNFR82 (Network_Sim)