⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udpinwirelessnetwork.tcl

📁 无线网络中进行UDP模拟
💻 TCL
字号:
set 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(ifqlen)   50set val(rp)      DSDVset ns_ [new Simulator]set topo    [new Topography]$topo load_flatgrid 700 700set f [open 2-2.tr w]$ns_ trace-all $f$ns_ eventtrace-allset nf [open 2-2.nam w]$ns_ namtrace-all-wireless $nf 700 700create-god 2$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 Channel/WirelessChannel \                -topoInstance $topo \                -agentTrace ON \                -routerTrace OFF \                -macTrace ON \                -movementTrace OFFset node_(0) [$ns_ node]set node_(1) [$ns_ node]$node_(0) label "Node 0"$node_(0) set X_ 10.0$node_(0) set Y_ 10.0$node_(0) set Z_ 0.0$node_(1) label "Node 1"$node_(1) set X_ 600.0$node_(1) set Y_ 600.0$node_(1) set Z_ 0.0 set udp1 [new Agent/UDP]set null1 [new Agent/Null]$ns_ attach-agent $node_(0) $udp1$ns_ attach-agent $node_(1) $null1$ns_ connect $udp1 $null1set cbr1 [new Application/Traffic/CBR]$cbr1 set rate_ 0.5Mb$cbr1 set packetSize_ 200$cbr1 attach-agent $udp1$ns_ at 5.0 "$cbr1 start"$ns_ at 0.0 "$node_(0) reset"$ns_ at 0.0 "$node_(1) reset"$ns_ at 0.6 "$node_(0) setdest 300.0 250.0 60.0"$ns_ at 1.1 "$node_(1) setdest 300.0 300.0 60.0"$ns_ at 40 "$node_(0) setdest 600.0 600.0 20.0"$ns_ at 40.1 "$node_(1) setdest 100.0 100.0 20.0"$ns_ at 50.0 "finish"$ns_ at 50.1 "puts \"NS EXITING...\";$ns_ halt"proc finish {} {     global ns_ f nf val     $ns_ flush-trace     close $f     close $nf}puts "Starting Simulation..."$ns_ run     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -