📄 wire.tcl
字号:
set val(chan) Channel/WirelessChannel ;# channel typeset val(prop) Propagation/TwoRayGround ;# radio-propagation modelset val(netif) Phy/WirelessPhy ;# network interface typeset val(mac) Mac/802_11 ;# MAC typeset val(ifq) Queue/DropTail/PriQueue ;# interface queue typeset val(ll) LL ;# link layer typeset val(ant) Antenna/OmniAntenna ;# antenna modelset val(ifqlen) 50 ;# max packet in ifqset val(nn) 30 ;# number of mobilenodesset val(rp) AODV ;# routing protocolset val(x) 670 ;# X dimension of the topographyset val(y) 670 ;# Y dimension of the topographyset ns_ [new Simulator]set tracefd [open out.tr w]$ns_ trace-all $tracefdset namtracefd [open out.nam w]$ns_ namtrace-all-wireless $namtracefd $val(x) $val(y)set packetSize 650set topo [new Topography]$topo load_flatgrid $val(x) $val(y)set god_ [create-god $val(nn)]$ns_ node-config -addressType def\ -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 OFF for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] $node_($i) random-motion 0 ;# disable random motion}source "scene-500-5s-10t"for {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}set udp1 [new Agent/myUDP]$ns_ attach-agent $node_(0) $udp1$udp1 set packetSize_ $packetSize$udp1 set_filename sd_beset null1 [new Agent/myUdpSink3] $ns_ attach-agent $node_(15) $null1$ns_ connect $udp1 $null1$null1 set_trace_filename rd_beset original_file_name fm_500_11.txtset trace_file_name video1.datset original_file_id [open $original_file_name r]set trace_file_id [open $trace_file_name w]set frame_count 0set last_time 0set pre_time 0while {[eof $original_file_id] == 0} { gets $original_file_id current_line scan $current_line "%d%f%d%d" seq nexttime length type set time [expr ($nexttime-$pre_time)*1000000.0] puts $trace_file_id "$time $length $type" set pre_time $nexttime incr frame_count}close $original_file_idclose $trace_file_idset end_sim_time $nexttimeputs "$end_sim_time"set trace_file [new Tracefile]$trace_file filename $trace_file_nameset video1 [new Application/Traffic/myTrace3]$video1 attach-agent $udp1$video1 attach-tracefile $trace_fileproc finish {} { global ns_ tracefd namtracefd $ns_ flush-trace close $tracefd close $namtracefd #exec nam out.nam & exit 0 }$ns_ at 0.0 "$video1 start"$ns_ at [expr $end_sim_time + 0.5] "$video1 stop"$ns_ at [expr $end_sim_time + 5.0] "$null1 closefile"for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at [expr $end_sim_time + 5.0] "$node_($i) reset";}$ns_ at [expr $end_sim_time + 5.0] "finish"$ns_ run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -