📄 uwb.tcl.tcl
字号:
# ======================================================================
# Defaults
# ======================================================================
#source ../defaults.tcl
source ../defaults-802.15.4a.tcl
Mac/IFControl set RTSThreshold 0
#Mac/IFControl set RTSThreshold 5000
#Propagation/Tarokh set average_pathlossExp_ 1.7
#Propagation/Tarokh set average_pathlossExp_ 2.0
# no random component
#Propagation/Tarokh set sigma_g_ 0.0
#Propagation/Tarokh set mi_s_ 0.0
#Propagation/Tarokh set sigma_s_ 0.0
#Phy/WirelessPhy/InterferencePhy set use_timehopping_ $privateTHS
#Phy/WirelessPhy/InterferencePhy set preamble_time_ [expr $preamble * 1e-9]
# if {$privateTHS == 0} {
# Phy/WirelessPhy/InterferencePhy set preamble_local_ 0
# } elseif {$privateTHS == 1} {
# Phy/WirelessPhy/InterferencePhy set preamble_local_ 1
# }
# if {$privateTHS == 0} {
# Mac/IFControl set fixed_code 7
# }
#set tracename "$propagation-$mac-ths$privateTHS-$nodes-$dist-pr$preamble-$num"
# ======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(modulation) Modulation/CodedPPM ;# modulation model
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_15_4 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(seed) 0.0 ;# to add some randomness
set val(ifqlen) 50 ;# max packet in ifq
set val(rp) AODV ;# routing protocol
set val(nn) 2 ;# number of mobilenodes
set val(x) 150 ;# X dimension of topography
set val(y) 150 ;# Y dimension of topography
set val(stop) 1500 ;# time of simulation end
set ns [new Simulator]
set tracefd [open uwb.tr w]
set windowVsTime2 [open win.tr w]
set namtrace [open uwb.nam w]
set val(traffic) ftp ;# cbr/poisson/ftp
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
Phy/WirelessPhy/InterferencePhy set Pt_ 0.28e-3
# taken from Community Wireless Project FAQ (between -80 and -96 dbm)
Phy/WirelessPhy/InterferencePhy set CSThresh_ 2.5e-13;
# center frequency
Phy/WirelessPhy/InterferencePhy set freq_ 4e+9
Phy/WirelessPhy/InterferencePhy set frequency_range_ 1e+9
Phy/WirelessPhy/InterferencePhy set use_timehopping_ 1
Phy/WirelessPhy/InterferencePhy set bitrate_ 1Mb
Phy/WirelessPhy/InterferencePhy set erasure_coefficient_ 5
Mac/IFControl set RTSThreshold 0
Mac/802_15_4 set RTSThreshold 0
# set all MAC capacity to 18MBit as well
Mac set bandwidth_ 1Mb
# PropTarokh propagation model
#Propagation/Tarokh set average_pathlossExp_ 1.7
#Propagation/Tarokh set std_db_ 4.0
#Propagation/Tarokh set dist0_ 1.0
#Propagation/Tarokh set seed_ 0
#Propagation/Tarokh set sigma_g_ 0.3
#Propagation/Tarokh set mi_s_ 1.6
#Propagation/Tarokh set sigma_s_ 0.5
#Propagation/Tarokh set n1_low_ -0.75
#Propagation/Tarokh set n1_high_ 0.75
#Propagation/Tarokh set n2_low_ -2
#Propagation/Tarokh set n2_high_ 2
#Propagation/Tarokh set n3_low_ -2
#Propagation/Tarokh set n3_high_ 2
# For model 'TwoRayGround'
set dist(5m) 7.69113e-06
set dist(9m) 2.37381e-06
set dist(10m) 1.92278e-06
set dist(11m) 1.58908e-06
set dist(12m) 1.33527e-06
set dist(13m) 1.13774e-06
set dist(14m) 9.81011e-07
set dist(15m) 8.54570e-07
set dist(16m) 7.51087e-07
set dist(20m) 4.80696e-07
set dist(25m) 3.07645e-07
set dist(30m) 2.13643e-07
set dist(35m) 1.56962e-07
set dist(140m) 1.20174e-07
Phy/WirelessPhy set CSThresh_ $dist(140m)
Phy/WirelessPhy set RXThresh_ $dist(140m)
# --------------------------------------------------
# Transport
#Agent/TCP set overhead_ 0.002
#Agent/TCP set window_ 10000
#Application/Traffic/CBR set random_ 0
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
# configure the nodes
$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
for {set i 0} {$i < $val(nn) } { incr i } {
set node_($i) [$ns node]
}
# Provide initial location of mobilenodes
$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 5.0
$node_(1) set Y_ 5.0
$node_(1) set Z_ 0.0
set chan_ [new $val(chan)]
# Randomness
ns-random $val(seed)
# Set a TCP connection between node_(0) and node_(1)
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $sink
$ns attach-agent $node_(1) $tcp
$ns connect $tcp $sink
$tcp set fid_ 1
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 1.0 "$ftp start"
# Printing the window size
proc plotWindow {tcpSource file} {
global ns
set time 0.01
set now [$ns now]
set cwnd [$tcpSource set cwnd_]
puts $file "$now $cwnd"
$ns at [expr $now+$time] "plotWindow $tcpSource $file" }
$ns at 1.1 "plotWindow $tcp $windowVsTime2"
# Generation of movements
$ns at 1.0 "$node_(0) setdest 25.0 25.0 3.0"
$ns at 1.0 "$node_(1) setdest 100.0 25.0 3.0"
# 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) 30
}
# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "$node_($i) reset";
}
# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 150.00 "puts \"end simulation\" ; $ns halt"
proc stop {} {
global ns tracefd namtrace
$ns flush-trace
close $windowVsTime2
close $tracefd
close $namtrace
}
$ns run
exec nam uwb.nam & nam.exe
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -