2017-01-19 2 views
0

私はns2を使用してアドホックネットワークをシミュレートし、NAMトレースファイルを生成しました。 NAMを使用してこのファイルを開くと、番号の付いた円でノードが表示されますが、アニメーションを再生すると何も起こりません。また、速度を減らしたり、上げたりしても、動作は変わりません。NAMのワイヤレスアドホックネットワークアニメーション

ここで問題となるのは、NAMにアニメーションのノード間の伝送を表示させるにはどうすればよいですか?

答えて

0

私はこの問題は、このコード記録アニメーションevent.Tryの設定ミスによって引き起こされていることを考える:

set val(chan)   Channel/WirelessChannel ;# channel type 
set val(prop)   Propagation/Nakagami  ;# radio-propagation model 
set val(netif)   Phy/WirelessPhy   ;# network interface type 
set val(mac)   Mac/802_11    ;# MAC type 
set val(ifq)   Queue/DropTail/PriQueue ;# interface queue type 
set val(ll)    LL       ;# link layer type 
set val(ant)   Antenna/OmniAntenna  ;# antenna model 
set val(ifqlen)   50       ;# max packet in ifq 
set val(nn)    5      ;# number of mobilenodes 
set val(rp)    AODV      ;# routing protocol 
set val(x)  200 
set val(y)  200 
# ====================================================================== 
# Main Program 
# ====================================================================== 
set ns_  [new Simulator] 
set tracefd  [open simple-udp.tr w] 
$ns_ trace-all $tracefd 

set namtrace [open simple-udp.nam w] 
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y) 
######################################### 
# set up topography object 
set topo  [new Topography] 

$topo load_flatgrid $val(x) $val(y) 

# 
# Create God 
# 
create-god $val(nn) 
# configure node 

    $ns_ node-config -adhocRouting $val(rp) \ 
      -llType $val(ll) \ 
      -macType $val(mac) \ 
      -ifqType $val(ifq) \ 
      -ifqLen $val(ifqlen) \ 
      -antType $val(ant) \ 
      -propType $val(prop) \ 
      -phyType $val(netif) \ 
      -channelType $val(chan) \ 
      -topoInstance $topo \ 
      -agentTrace ON \ 
      -routerTrace ON \ 
      -macTrace ON \ 
      -movementTrace OFF\ 
      # -OutgoingErrProc UniformErr 
set node_(0) [$ns_ node]  
$node_(0) random-motion 0 

set node_(1) [$ns_ node]  
$node_(1) random-motion 0 

set node_(2) [$ns_ node]  
$node_(2) random-motion 0 

set node_(3) [$ns_ node]  
$node_(3) random-motion 0 

set node_(4) [$ns_ node]  
$node_(4) random-motion 0 


# 
# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes 
# 

$node_(0) set X_ 0 
$node_(0) set Y_ 0 
$node_(0) set Z_ 0.0 

$node_(1) set X_ 70 
$node_(1) set Y_ 50 
$node_(1) set Z_ 0.0 

$node_(2) set X_ 70 
$node_(2) set Y_ 0 
$node_(2) set Z_ 0.0 

$node_(3) set X_ 70 
$node_(3) set Y_ -50 
$node_(3) set Z_ 0.0 

$node_(4) set X_ 400 
$node_(4) set Y_ 0 
$node_(4) set Z_ 0.0 
for {set i 0} {$i < $val(nn)} {incr i} { 
$ns_ initial_node_pos $node_($i) 30 
} 

#Setup first UDP connection 
set udp [new Agent/UDP] 
$ns_ attach-agent $node_(0) $udp 
set null [new Agent/LossMonitor] 
$ns_ attach-agent $node_(4) $null 
$ns_ connect $udp $null 
$udp set fid_ 5 


#Setup first CBR over first UDP connection 
set cbr [new Application/Traffic/CBR] 
$cbr attach-agent $udp 
$cbr set type_ CBR 
$cbr set packet_size_ 500 
$cbr set rate_ 100kb 
$cbr set random_ false 
$ns_ at 0.0 "$cbr start" 
$ns_ at 10.0 "$cbr stop" 
# Tell nodes when the simulation ends 
# 
for {set i 0} {$i < $val(nn) } {incr i} { 
    $ns_ at 10.01 "$node_($i) reset"; 
} 
$ns_ at 10.0 "stop" 
$ns_ at 10.01 "puts \"NS EXITING...\" ; $ns_ halt" 
proc stop {} { 
    global ns_ tracefd namtrace 
    $ns_ flush-trace 
    close $tracefd 
    close $namtrace 
} 

puts "Starting Simulation..." 
$ns_ run 
+0

私はこのような何かをやった、スクリプトが.namファイルを作成しますが、私はそれを開いたときNAMでは、ノードの位置に何も表示されず、送信も行われません。 – Ahmad

+0

すべてのns2プロトコルがnamをサポートするわけではありません。 ?どのプロトコルを使用していますか? ... namについて:基本的な "namコマンド"がここに表示されています。http://www.isi.edu/nsnam/ns/tutorial/nsscript1.html –

+0

私の回答を編集し、アドホックネットワークのサンプルコードを挿入しました上記のコードを試して、結果を知らせてください –

関連する問題