📄 video-scenario.tcl
字号:
## A wireless lan scenario with video/cbr traffic over udp### defaultsset num_nodes 6 ;# number of mobilenodes in the scenarioset blocking_factor 1 ;# default blocking factorset transport TCP ;# default transport protocolproc create_scenario { } { global ns_ node_ AP_ title_ mode global blocking_factor transport global pcf_period pcf_duration set pcf_period [expr 2 * $blocking_factor]ms set pcf_duration ${blocking_factor}ms ########################################################## # Setup Video flows V1 and V2 # source for V1 and V2 is the AP # period/pktsize of Video Streams based on the blocking factor set period [expr 2 * $blocking_factor]ms set pktsize [expr 2048 * $blocking_factor] # Flow V1 set V1 [new Application/Traffic/CBR] set V1_src [new Agent/UDP] set V1_sink [new Agent/UDP] $V1 set random_ 0 $V1 set packetSize_ $pktsize $V1 set interval_ $period $V1_src set packetSize_ 2048 $V1_src set class_ 2 $V1_src set prio_ 0 $ns_ attach-agent $AP_ $V1_src $ns_ attach-agent $node_(1) $V1_sink $ns_ connect $V1_src $V1_sink $V1 attach-agent $V1_src puts "V1 flows from AP to Node1" # Flow V2 set V2 [new Application/Traffic/CBR] set V2_sink [new Agent/UDP] set V2_src [new Agent/UDP] $V2 set random_ 0 $V2 set packetSize_ $pktsize $V2 set interval_ $period $V2_src set packetSize_ 2048 $V2_src set class_ 3 $V2_src set prio_ 0 $ns_ attach-agent $AP_ $V2_src $ns_ attach-agent $node_(2) $V2_sink $ns_ connect $V2_src $V2_sink $V2 attach-agent $V2_src puts "V2 flows from AP to Node2" ########################################################## # Setup Background flow B1 # B1 flows from Node3 to Node4 via the AP # B1 is a FTP stream with 1500 byte MTUs set B1 [new Application/FTP] if {$transport == "TCP"} { set B1_src [new Agent/TCP] set B1_sink [new Agent/TCPSink/DelAck] $B1_src set syn_ 1 } elseif {$transport == "UDP"} { set B1_src [new Agent/UDP] set B1_sink [new Agent/UDP] } else { puts "Bad transport protocol" exit } $B1_src set packetSize_ 1500 $B1_src set class_ 4 $B1_src set prio_ 1 $ns_ attach-agent $node_(3) $B1_src $ns_ attach-agent $node_(4) $B1_sink $ns_ connect $B1_src $B1_sink $B1 attach-agent $B1_src puts "B1 flows from Node3 to Node4 over $transport" ########################################################## # Setup Background flow B2 # B2 flows from Node4 to Node5 via the AP # B2 is a FTP stream with 256 byte MTUs set B2 [new Application/FTP] if {$transport == "TCP"} { set B2_src [new Agent/TCP] set B2_sink [new Agent/TCPSink/DelAck] $B2_src set syn_ 1 } elseif {$transport == "UDP"} { set B2_src [new Agent/UDP] set B2_sink [new Agent/UDP] } else { puts "Bad transport protocol" exit } $B2_src set packetSize_ 256 $B2_src set class_ 5 $B2_src set prio_ 1 $ns_ attach-agent $node_(4) $B2_src $ns_ attach-agent $node_(5) $B2_sink $ns_ connect $B2_src $B2_sink $B2 attach-agent $B2_src puts "B2 flows from Node4 to Node5 over $transport" ########################################################## # Start time, nature of simulation if {$mode == "PCF"} { set access PCF_NAV } else { set access $mode if {[PLevels set plevels_] > 1} { set access VDCF } $ns_ at 3.0 "$V1 start" $ns_ at 6.0 "$V2 start" } $ns_ at 9.0 "$B1 start" $ns_ at 12.01 "$B2 start" set phy_bw [Mac/802_11 set bandwidth_] set retries [MAC_MIB set ShortRetryLimit_] set pqlim [Queue/DropTail set pqlim_] set title_ "set title \"VIDEO PHY($phy_bw) $access RETRIES($retries) IFQ($pqlim) MTU(2K) PERIOD($period)\""}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -