2013-12-15 30 views
3

我是NS2的新手,嘗試設置基本的啞鈴形網絡模擬;我有一個節點n TCP代理(網關或「gw」)通過鏈接發送到遠程節點(遠程網關,「rgw」),它連接到n TCP接收器(每個代理都連接到一個水槽)。NS2 NAM不顯示傳輸

enter image description here

下面是其中n = 5。節點0與帕累託流量發生器5個TCP代理的圖片;每個連接到連接到右側節點之一的TCPSink代理。

我有以下TCL腳本來設置和測試網絡;它運行成功,但是當我在NAM中查看跟蹤時,我看不到移動的數據包。我用NAM運行了一個類似的教程,它看起來很好,所以在我自己的代碼中一定有一個錯誤。任何人都可以幫我找到我的錯誤?

謝謝。

set ns [new Simulator] 

# Set up trace 
set trc [open out.trc w] 
set namtrc [open out.nam w] 
$ns trace-all $trc 
$ns namtrace-all $namtrc 

proc finish {} { 
    global ns trc 
    global ns namtrc 
    $ns flush-trace 
    close $trc 
    close $namtrc 
    exec nam out.nam & 
    exit 0 
} 

# Simulation parameters 
set n 5 
set bw 150000000 # 150 Mb/s 

# Set up bottleneck link 
set gw [$ns node] 
set rgw [$ns node] 
$ns duplex-link $gw $rgw $bw .30 DropTail 

set snd {} # TCP senders sitting on the gateway node 
set trf {} # Traffic generators for the senders 
set dst {} # Destination nodes hosting the receivers 
set rcv {} # TCP receivers sitting on the destination 

for {set i 0} {$i<$n} {incr i} { 
    # Create the objects needed for a new connection 
    lappend snd [new Agent/TCP] 
    lappend rcv [new Agent/TCPSink] 
    lappend trf [new Application/Traffic/Pareto]  
    lappend srv [$ns node] 

    # set up source and destination nodes 
    $ns attach-agent $gw [lindex $snd $i] 
    $ns attach-agent [lindex $srv $i] [lindex $rcv $i] 
    [lindex $trf $i] attach-agent [lindex $snd $i] 

    # Connect nodes 
    $ns duplex-link $rgw [lindex $srv $i] 1000000000000 .100 DropTail 
    # Connect agents 
    $ns connect [lindex $snd $i] [lindex $rcv $i] 
} 

foreach traffic $trf { 
    $ns at 0.0 "$traffic start" 
} 
$ns at 10.0 "finish" 

$ns run 

下面是從使用此代碼生成一個跟蹤的摘錄:

+ 0.214008 0 1 pareto 40 ------- 0 0.0 2.0 0 0 
- 0.214008 0 1 pareto 40 ------- 0 0.0 2.0 0 0 
+ 0.321715 0 1 pareto 40 ------- 0 0.3 5.0 0 1 
- 0.321715 0 1 pareto 40 ------- 0 0.3 5.0 0 1 
r 0.51401 0 1 pareto 40 ------- 0 0.0 2.0 0 0 
+ 0.51401 1 2 pareto 40 ------- 0 0.0 2.0 0 0 
- 0.51401 1 2 pareto 40 ------- 0 0.0 2.0 0 0 
r 0.61401 1 2 pareto 40 ------- 0 0.0 2.0 0 0 
+ 0.61401 2 1 ack 40 ------- 0 2.0 0.0 0 2 
- 0.61401 2 1 ack 40 ------- 0 2.0 0.0 0 2 
r 0.621717 0 1 pareto 40 ------- 0 0.3 5.0 0 1 
+ 0.621717 1 5 pareto 40 ------- 0 0.3 5.0 0 1 
- 0.621717 1 5 pareto 40 ------- 0 0.3 5.0 0 1 
r 0.71401 2 1 ack 40 ------- 0 2.0 0.0 0 2 
+ 0.71401 1 0 ack 40 ------- 0 2.0 0.0 0 2 
- 0.71401 1 0 ack 40 ------- 0 2.0 0.0 0 2 
r 0.721717 1 5 pareto 40 ------- 0 0.3 5.0 0 1 
+ 0.721717 5 1 ack 40 ------- 0 5.0 0.3 0 3 
- 0.721717 5 1 ack 40 ------- 0 5.0 0.3 0 3 
+ 0.735936 0 1 pareto 40 ------- 0 0.2 4.0 0 4 
- 0.735936 0 1 pareto 40 ------- 0 0.2 4.0 0 4 
r 0.821717 5 1 ack 40 ------- 0 5.0 0.3 0 3 
+ 0.821717 1 0 ack 40 ------- 0 5.0 0.3 0 3 
- 0.821717 1 0 ack 40 ------- 0 5.0 0.3 0 3 
+ 0.831634 0 1 pareto 40 ------- 0 0.4 6.0 0 5 
- 0.831634 0 1 pareto 40 ------- 0 0.4 6.0 0 5 
r 1.014013 1 0 ack 40 ------- 0 2.0 0.0 0 2 
+ 1.014013 0 1 pareto 1040 ------- 0 0.0 2.0 0 6 
- 1.014013 0 1 pareto 1040 ------- 0 0.0 2.0 0 6 
+ 1.014013 0 1 pareto 1040 ------- 0 0.0 2.0 0 7 
- 1.014068 0 1 pareto 1040 ------- 0 0.0 2.0 0 7 
r 1.035938 0 1 pareto 40 ------- 0 0.2 4.0 0 4 
+ 1.035938 1 4 pareto 40 ------- 0 0.2 4.0 0 4 
- 1.035938 1 4 pareto 40 ------- 0 0.2 4.0 0 4 
r 1.121719 1 0 ack 40 ------- 0 5.0 0.3 0 3 
+ 1.121719 0 1 pareto 1040 ------- 0 0.3 5.0 0 8 
- 1.121719 0 1 pareto 1040 ------- 0 0.3 5.0 0 8 
+ 1.121719 0 1 pareto 1040 ------- 0 0.3 5.0 0 9 
- 1.121775 0 1 pareto 1040 ------- 0 0.3 5.0 0 9 
r 1.131636 0 1 pareto 40 ------- 0 0.4 6.0 0 5 

看起來是工作的罰款。

回答

1

嘗試下面的代碼是用於回覆正常工作

set ns [new Simulator] 

# Set up trace 
set trc [open out.trc w] 
set namtrc [open out.nam w] 
$ns trace-all $trc 
$ns namtrace-all $namtrc 

proc finish {} { 
    global ns trc 
    global ns namtrc 
    $ns flush-trace 
    close $trc 
    close $namtrc 
    exec nam out.nam & 
    exit 0 
} 

# Simulation parameters 
set n 5 
set bw 150000000; # 150 Mb/s 

# Set up bottleneck link 
set gw [$ns node] 
set rgw [$ns node] 
$ns duplex-link $gw $rgw $bw .3000 DropTail 

set snd {} 
# TCP senders sitting on the gateway node 
set trf {} 
# Traffic generators for the senders 
set dst {} 
# Destination nodes hosting the receivers 
set rcv {} 
# TCP receivers sitting on the destination 

for {set i 0} {$i<$n} {incr i} { 
    # Create the objects needed for a new connection 
    lappend snd [new Agent/TCP] 
    lappend rcv [new Agent/TCPSink] 
    lappend trf [new Application/Traffic/Pareto]  
    lappend srv [$ns node] 

    # set up source and destination nodes 
    $ns attach-agent $gw [lindex $snd $i] 
    $ns attach-agent [lindex $srv $i] [lindex $rcv $i] 
    [lindex $trf $i] attach-agent [lindex $snd $i] 

    # Connect nodes 
    $ns duplex-link $rgw [lindex $srv $i] 10000 .10000 DropTail 
    # Connect agents 
    $ns connect [lindex $snd $i] [lindex $rcv $i] 
} 

foreach traffic $trf { 
    $ns at 0.0 "$traffic start" 
} 
$ns at 10.0 "finish" 

$ns run 
+1

喜納文,謝謝。它看起來像我使用的帶寬值太高,無法使nam可靠地呈現。謝謝你的幫助。 – ILikeFood