📄 sources.tcl
字号:
proc build-tcp { type src dest pktSize window class startTime finishTime fid pri} { global ns_ # build tcp source if { $type == "TCP" } { set tcp [new Agent/TCP] set snk [new Agent/TCPSink] } elseif { $type == "Reno" } { set tcp [new Agent/TCP/Reno] set snk [new Agent/TCPSink] } elseif { $type == "Sack" } { set tcp [new Agent/TCP/Sack1] set snk [new Agent/TCPSink/Sack1] } elseif { $type == "Newreno" } { set tcp [new Agent/TCP/Newreno] set snk [new Agent/TCPSink] } else { puts "ERROR: Invalid tcp type" } $ns_ attach-agent $src $tcp #$tcp set tcpTick_ 0.01 #build tcp sink $ns_ attach-agent $dest $snk # connect source to sink $ns_ connect $tcp $snk # init. tcp parameters if { $pktSize > 0 } { $tcp set packetSize_ $pktSize } if { $window > 0 } { $tcp set window_ $window } else { # default in ns-2 version 2.0 $tcp set window_ 20 } #the flow prio $tcp set prio_ $pri #the flow id $tcp set fid_ $fid set ftp [new Source/FTP] $ftp set agent_ $tcp $ns_ at $startTime "$ftp start" $ns_ at $finishTime "$ftp stop" return $tcp}proc build-cbr { src dest pktSize interval random id startTime finishTime pri} { global ns_ set udp [new Agent/UDP] $ns_ attach-agent $src $udp if { $pktSize > 0 } { $udp set packetSize_ $pktSize } set cbr [new Application/Traffic/CBR] $cbr set packetSize_ $pktSize $cbr set random_ $random $cbr set interval_ $interval #the flow prio $udp set prio_ $pri #the flow id $udp set fid_ $id $cbr set fid_ $id $cbr attach-agent $udp set sink [new Agent/UDP] $ns_ attach-agent $dest $sink $ns_ connect $udp $sink $ns_ at $startTime "$cbr start" $ns_ at $finishTime "$cbr stop" return $udp }proc build-ftp { type src dest pktSize window class numPackets startTime } { global ns # build tcp source if { $type == "TCP" } { set tcp [new Agent/TCP] set snk [new Agent/TCPSink/DelAck] } elseif { $type == "Reno" } { set tcp [new Agent/TCP/Reno] set snk [new Agent/TCPSink] } elseif { $type == "Sack" } { set tcp [new Agent/TCP/Sack1] set snk [new Agent/TCPSink/Sack1] } elseif { $type == "Newreno" } { set tcp [new Agent/TCP/Newreno] set snk [new Agent/TCPSink] } else { puts "ERROR: Inavlid tcp type" } $ns attach-agent $src $tcp #build tcp sink $ns attach-agent $dest $snk # connect source to sink $ns connect $tcp $snk # init. tcp parameters if { $pktSize > 0 } { $tcp set packetSize_ $pktSize } $tcp set class_ $class if { $window > 0 } { $tcp set window_ $window } else { # default in ns-2 version 2.0 $tcp set window_ 20 } $tcp set max_pkt_ $numPackets set ftp [new Source/FTP] $ftp set agent_ $tcp $ns at $startTime "$ftp start"}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -