📄 sctp-1-2k-s1p101.tcl~
字号:
Trace set show_sctphdr_ 1
#===============================================================
# Define options
#===============================================================
Mac/802_11 set dataRate_ 1Mbset val(chan) Channel/WirelessChannel ;# tipe channel
set val(prop) Propagation/TwoRayGround ;# model radio-propagation
set val(netif) Phy/WirelessPhy ;# tipe network interface
set val(mac) Mac/802_11 ;# tipe MAC
set val(ifq) Queue/DropTail/PriQueue ;# tipe interface queue
set val(ll) LL ;# tipe link layer
set val(ant) Antenna/OmniAntenna ;# model antenna
set val(ifqlen) 50 ;# max paket pada ifq
set val(nn) 50 ;# jumlah
set val(rp) AODV ;# routing protokol
set val(x) 1500
set val(y) 1500
set val(sc) "/home/tresna/ns-allinone-2.30/ns-2.30/indep-utils/cmu-scen-gen/setdest/scen-50-s1-p10"; # Lokasi file pergerakan node (hasil ./setdest)
#set val(cp) "/home/nana/program/tcl/sctp_1"; set val(stop) 900; set val(seed) 0.0;
#===============================================================
# Main Program
#===============================================================
# Inisialisasi vaiabel global
set ns_ [new Simulator]
set tracefd [open sctp-1-2K-s1p101.tr w ]
$ns_ trace-all $tracefd
set namtrace [open sctp-1-2K-s1p101.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)
# Membuat objek topograpi
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
# Membuat god
set god_ [create-god $val(nn)]
# Membuat channel
set chan_ [new $val(chan)]
# Konfigurasi 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)\
-channel $chan_\
-topoInstance $topo\
-agentTrace ON\
-routerTrace ON\
-macTrace ON\
-movementTrace OFF
# Membuat node
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0; # disable random motion $node_($i) radius 250m;
}
#$ns_ multihome-add-interface $node_(0) $node_(49)
# Load file pergerakan node
puts "Loading node-movement file...."
source $val(sc)
# Load file model trafik
set sctp0 [new Agent/SCTP]$ns_ attach-agent $node_(0) $sctp0 ;# refer to sctpDebug.h for mask mappings$sctp0 set debugMask_ 0x00303000$sctp0 set fid_ 0 $sctp0 set debugMask_ -1$sctp0 set debugFileIndex_ 0$sctp0 set mtu_ 1500$sctp0 set dataChunkSize_ 1340$sctp0 set initialCwnd_ 4380 $sctp0 set numOutStreams_ 1set trace_ch [open trace.sctp w] ;# do not trace all variables on one line$sctp0 set trace_all_ 0 ;# trace cwnd for all destinations$sctp0 trace cwnd_$sctp0 attach $trace_chset sctp1 [new Agent/SCTP]$ns_ attach-agent $node_(49) $sctp1 ;# use -1 to turn on all debugging$sctp1 set debugMask_ -1$sctp1 set debugFileIndex_ 1$sctp1 set mtu_ 1500$sctp1 set initialRwnd_ 2048#$sctp1 set useDelayedSacks_ 1$ns_ connect $sctp0 $sctp1set ftp0 [new Application/FTP]$ftp0 attach-agent $sctp0$ns_ at 10.0 "$ftp0 start"#$ns_ at 900.0 "$ftp0 stop"
# Definisi posisi awal node pada NAM
for {set i 0} {$i < $val(nn)} {incr i} {
# fungsi harus dipanggil setelah model pergerakan node sudah didefinisikan
$ns_ initial_node_pos $node_($i) 20
}
# Menghentikan simulasi
for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ at $val(stop) "$node_($i) reset";
}
$ns_ at $val(stop) "stop"
$ns_ at $val(stop) "puts \"NS EXITING...\"; $ns_ halt"
proc stop {} {
global ns_ tracefd namtrace
global ns_ tracefd
$ns_ flush-trace
close $tracefd
close $namtrace exec nam sctp-1-2K-s1p101.nam & exit 0
}
# Penjelasan di file .tra
puts $tracefd "M 0.0 nn $val(nn) x $val(x) y $val(y) rp $val(rp)"
puts $tracefd "M 0.0 sc $val(sc) seed $val(seed)"
puts $tracefd "M 0.0 prop $val(prop) ant $val(ant)"
# Start NS-2
puts "Starting simulation"
$ns_ run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -