📄 tcl1dsr.tcl
字号:
# wrls1.tcl
# A 35-node example for ad-hoc simulation with DSDV
# Define options
set val(chan) Channel/WirelessChannel ;# type de canal
set val(prop) Propagation/TwoRayGround ;# model de propagation radio
set val(netif) Phy/WirelessPhy ;# type d'interface
set val(mac) Mac/802_11 ;# type MAC
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# type link layer
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 10 ;# Nombre des noueds mobiles
set val(rp) DSR ;# protocole de routage
set val(x) 2200 ;# X dimension de topography
set val(y) 950 ;# Y dimension de topography
set val(stop) 1200 ;# le temps de simulation
#programme principal
#initialisation des variables globaux
set ns [new Simulator]
set tracefd [open dsr_all.tr w]
set windowVsTime2 [open dsr_emi_tcp10.tr w]
set namtrace [open dsr_tcp_10.nam w]
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
# creer l'objet de topography
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
#
# creation des noeud (nn) mobile.
#
# configurer les noeuds
$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 OFF \
-movementTrace ON
# positionnement des noeud aleatoirement // location
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
$node_($i) set X_ [expr int(rand()*600.0*rand())+100.0]
$node_($i) set Y_ [expr int(rand()*600.0*rand())+100.0]
$node_($i) set Z_ 3000.0
$node_($i) random-motion 0;
}
# etablir la connection TCP connection entre node_(0) et node_(2)
for {set i 0} {$i < $val(nn) } {incr i} {
set tcp [new Agent/TCP/Reno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
}
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(2) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 0.5 "$ftp start"
$ns at 1150.0 "$ftp stop"
# Printing the window size
proc plotWindow {tcpSource file} {
global ns
set time 0.4
set now [$ns now]
set cwnd [$tcpSource set cwnd_]
puts $file "$now $cwnd"
$ns at [expr $now+$time] "plotWindow $tcpSource $file" }
$ns at 0.5 "plotWindow $tcp $windowVsTime2"
# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 50
}
# met en fin les noued quant la simulation terminers
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "$node_($i) reset";
}
# la fin de simulation et de nam
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 1200.0 "puts \"end simulation\" ; $ns halt"
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $tracefd
close $namtrace
exec xgraph dsr_emi_tcp10.tr &
exec nam dsr_tcp_10.nam &
exit 0
} $ns run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -