2008年3月19日 星期三

實驗二 nsBench

準備工具JVM,到目錄C:\cygwin\home\Administrator\ns-allinone-2.29\ns-2.29\book2\lab2
執行jre-1_5_0_03-windows-i586-p.exe進行安裝


安裝結束後,打開cygwin,執行nsBench


產生如下視窗


點選Node,建立節點


建立4個節點,如下圖所示


建立連線


在連線上連點2次,出現參數設定,如下圖所示


先點選n0一下,在選TCP Tahoe


產生如下結果


在n3上建立一個TCP Sink


先點選tcp0,在選FTP
.

將tcp0宇sink0建立連線,在n1上建立UDP agent,在n3上建立Null,並建立CBR


連點cbr02次,設定參數


點選Scenario


按Add Row,如下圖設定


點選Trace


如下圖設定


儲存


選擇儲存路徑


產生TCL檔


觀看TCL程式


------------------------------------------------------------------
產生的TCL檔

# Creating New Simulator
set ns [new Simulator]

# 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
}


#
#Create Nodes
#

set n0 [$ns node]
puts "n0: [$n0 id]"
set n1 [$ns node]
puts "n1: [$n1 id]"
set n2 [$ns node]
puts "n2: [$n2 id]"
set n3 [$ns node]
puts "n3: [$n3 id]"


#
#Setup Connections
#

$ns duplex-link $n0 $n2 2Mb 10ms DropTail

$ns duplex-link $n2 $n3 1.7Mb 10ms DropTail

$ns duplex-link $n1 $n2 2Mb 10ms DropTail



#
#Set up Transportation Level Connections
#

set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0

set sink0 [new Agent/TCPSink]
$ns attach-agent $n3 $sink0

set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1

set null0 [new Agent/Null]
$ns attach-agent $n3 $null0



#
#Setup traffic sources
#

set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0

set cbr0 [new Application/Traffic/CBR]
$cbr0 set rate_ 1Mb
$cbr0 set packetSize_ 1000
$cbr0 attach-agent $udp1

$ns connect $tcp0 $sink0
$tcp0 set fid_ 0
$ns connect $udp1 $null0
$udp1 set fid_ 1

#
#Start up the sources
#

$ns at 0.1 "$cbr0 start"
$ns at 1 "$ftp0 start"
$ns at 4 "$ftp0 stop"
$ns at 4.5 "$cbr0 stop"
$ns at 5.0 "finish"
$ns run

------------------------------------------------------------------

開啟xwin


執行模擬







沒有留言: