📄 test-scenario.tcl
字号:
#
# A wireless lan scenario with 1 ftp stream and 2 phone
# traffic streams as the default case; passing in the
# num of nodes as an argument sets up half the nodes as
# phones into the AP, and the other half as ftp streams
# in pairs
#
#
# node_([0....max])
# node_(0) is AP
# number of mobilenodes in the scenario
# num_nodes is global
# overridden by $arg3 on cmd line
# $node_(foo) setMac CWMin value
# defaults
set num_nodes 5
proc create_scenario { } {
global ns_ node_
global num_nodes
#set num_phones [expr $num_nodes / 2]
set num_phones 0
# SET
set cw0 15
set cw1 31
set cw2 63
set cw3 127
set co0 0
set co1 10
set co2 40
set co3 80
set cw $cw0
set co $co0
set psize 1500
puts "num_nodes $num_nodes\n"
set title "set title \"PHY(36) CW($cw0, $cw1, $cw2, $cw3) CO($co0,$co1,$co2,$co3) MTU($psize)\""
# Setup phones on first set of nodes, sending to the node 0
# Flow ids 2 onwards - cbr over UDP
for {set i 0} {$i < $num_phones} {incr i} {
set phone $node_([expr $i + 1])
set udp [new Agent/UDP]
$udp set class_ [expr 2 + $i]
$ns_ attach-agent $phone $udp
set udp_base [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp_base
$ns_ connect $udp $udp_base
set audio [new Application/Traffic/CBR]
$audio attach-agent $udp
$audio set packetSize_ 120
$audio set interval_ 10ms
if {$num_phones == 2} { ;# special default case
$audio set random_ 0
$ns_ at [expr 3.0 + 3.005 * $i] "$audio start"
} else {
$audio set random_ 1
$ns_ at [expr 3.0 + $i] "$audio start"
}
}
# Setup ftp over TCP between remaining pairs of nodes
# modified for AP (node 0) to be the sink
#
# set num_ftp [expr ($num_nodes - $num_phones - 1) / 2]
for {set i 1} {$i < $num_nodes} {incr i} {
# set n [expr $num_phones + (2 * $i) + 1]
# set client $node_($n)
# set server $node_([expr $n + 1])
set client $node_($i)
set server $node_(0)
set src [new Agent/TCP]
# $src set class_ [expr 2 + $num_phones + $i]
$src set class_ [expr 2 + $i] ; # start flow labels at 3
$src set packetSize_ $psize; # MTU
$src set syn_ 1
# $src set wnd_ 1600000
$ns_ attach-agent $client $src; # tcp stack to client
set sink [new Agent/TCPSink/DelAck]
$ns_ attach-agent $server $sink
$ns_ connect $src $sink
# set cw [expr (2 ^ ($i+3)) -1]
# $client setMac CWMin [expr (2 ^ ($i+3)) - 1]
# $client setQosPri 13
if {$i == 1} {
set cw $cw0
set co $co0
}
if {$i == 2} {
set cw $cw1
set co $co1
}
if {$i == 3} {
set cw $cw2
set co $co2
}
if {$i >= 4} {
set cw $cw3
set co $co3
}
$client setMac CWMin $cw
$client setMac CWOffset $co
puts "tcp node $i at CW($cw) CO($co)\n"
set ftp [new Application/FTP] ; # traffic generator
$ftp attach-agent $src
# if {$num_ftp == 1} { ;# special default case
# $ns_ at 9.0025 "$ftp start"
# } else {
# $ns_ at [expr 3.0 + $num_phones + $i] "$ftp start"
# }
$ns_ at [expr 3.0 + $i-1] "$ftp start"
}
puts "$title"
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -