📄 exp
字号:
##in this program i want to build a topology, in that condition,cbr1 start before cbr0, and cbr1's #bw add to cbr0's is bigger than the wireless channel's bandw. so ,the cbr0 should recover another #path when it start for a time.#set tcpthroughputxg0 [open tcpthroughput0.xg w]set tcpthroughputxg1 [open tcpthroughput1.xg w]set tcpthroughputxg2 [open tcpthroughput2.xg w]set tcpbdeparturespre0 0set tcpbdeparturespre1 0set tcpbdeparturespre2 0set interval 1.5# ======================================================================# Define options# ======================================================================set val(chan) Channel/WirelessChannelset val(prop) Propagation/TwoRayGroundset val(netif) Phy/WirelessPhyset val(mac) Mac/802_11set val(ifq) Queue/DropTail/PriQueueset val(ll) LLset val(ant) Antenna/OmniAntennaset val(x) 1000 ;#it is 800 beforeset val(y) 1000 ;# Y dimension of the topography it is 670 beforeset val(ifqlen) 50 ;# max packet in ifqset val(seed) 0.0set val(adhocRouting) DSRset val(nn) 11 ;# how many nodes are simulated(it is 8 before)set val(cp) "./cbr-3-test-6"set val(sc) "./scen-3-test-6.tcl"set record "./record-cbr-20.tcl"set val(stop) 50 ;# simulation time(it is 40 before)#puts [Phy/WirelessPhy set bandwidth_ 600000000] ;#( it is 2e6 before)# =====================================================================# Main Program# ======================================================================## Initialize Global Variables## create simulator instanceset ns_ [new Simulator]# setup topography objectset topo [new Topography]# create trace object for ns and nam#$ns_ use-newtraceset tracefd [open exp-out.tr w]set namtrace [open exp-out.nam w]$ns_ trace-all $tracefd$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)tracefd# define topology$topo load_flatgrid $val(x) $val(y)## Create God#set god_ [create-god $val(nn)]## define how node should be created##global node settingset chan_ [new $val(chan)]$ns_ node-config -adhocRouting $val(adhocRouting) \ -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 \ -agentTrance ON \ -routerTrace ON \ -macTrace ON ## Create the specified number of nodes [$val(nn)] and "attach" them# to the channel.for {set i 0} {$i < $val(nn) } {incr i} {set node_($i) [$ns_ node]$node_($i) random-motion 1;# disable random motion it is 0 before}# # Define node movement model#puts "Loading connection pattern..."source $val(cp)# # Define traffic model#puts "Loading scenario file..."source $val(sc)source $record# Define node initial position in namfor {set i 0} {$i < $val(nn)} {incr i} { # 20 defines the node size in nam, must adjust it according to your scenario # The function must be called after mobility model is defined $ns_ initial_node_pos $node_($i) 20# $node_($i) radius 700}## Tell nodes when the simulation ends#for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at $val(stop).0 "$node_($i) reset";}$ns_ at 0.1 "record0"$ns_ at 0.1 "record1"$ns_ at 0.1 "record2"$ns_ at $val(stop) "put_throughput"$ns_ at $val(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"#$ns_ at $val(stop).0001 "exec nam wireless1-out.nam ; exit 1"puts $tracefd "M 0.0 nn $val(nn) x $val(x) y $val(y) rp $val(adhocRouting)"puts $tracefd "M 0.0 sc $val(sc) cp $val(cp) seed $val(seed)"puts $tracefd "M 0.0 prop $val(prop) ant $val(ant)"#exec xgraph out0.tr out1.tr out2.tr -geometry 800*400 &#exit 0#debug 1puts "Starting Simulation..."$ns_ run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -