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

📄 rdt3.tcl

📁 用ns写的一个网络模拟 实现rdt 里面有所有源代码和文档说明
💻 TCL
字号:
##        s1                 s3#         \                 /# 5Mb,3ms \    2Mb,10ms   / 5Mb,3ms#           r1 --------- r2# 5Mb,3ms /               \ 5Mb,3ms#         /                 \#        s2                 s4 #set ns [new Simulator]#Define different colors for data flows$ns color 1 Red$ns color 2 Blue#Open the nam trace fileset nf [open out.nam w]set tf [open out.tr w]$ns namtrace-all $nf$ns trace-all $tf#Define a 'finish' procedureproc finish {} {        global ns nf tf        $ns flush-trace        #Close the trace file        close $nf        close $tf        #Execute nam on the trace file        exec nam out.nam &        exit 0}set n0 [$ns node]set n1 [$ns node]set n2 [$ns node]set n3 [$ns node]set n4 [$ns node]set n5 [$ns node]$ns duplex-link $n0 $n2 7Mb 3ms DropTail $ns duplex-link $n1 $n2 7Mb 3ms DropTail $ns duplex-link $n2 $n3 2Mb 10ms RED $ns duplex-link $n4 $n3 7Mb 3ms DropTail $ns duplex-link $n5 $n3 7Mb 3ms DropTail #Setup RED queue parameter$ns queue-limit $n2 $n3 20Queue/RED set thresh_ 5Queue/RED set maxthresh_ 10Queue/RED set q_weight_ 0.002Queue/RED set ave_ 0$ns duplex-link-op $n2 $n3 queuePos 0.5$ns duplex-link-op $n0 $n2 orient right-down$ns duplex-link-op $n1 $n2 orient right-up$ns duplex-link-op $n2 $n3 orient right$ns duplex-link-op $n4 $n3 orient left-down$ns duplex-link-op $n5 $n3 orient left-up#Setup a rdt UDP connectionset udp_s [new Agent/UDP/rdt]set udp_r [new Agent/UDP/rdt]$ns attach-agent $n0 $udp_s$ns attach-agent $n4 $udp_r$ns connect $udp_s $udp_r$udp_s set packetSize_ 1000$udp_r set packetSize_ 1000$udp_s set fid_ 1$udp_r set fid_ 1#Setup a rdt Applicationset rdt_s [new Application/rdtApp]set rdt_r [new Application/rdtApp]$rdt_s attach-agent $udp_s$rdt_r attach-agent $udp_r$rdt_s set pktsize_ 1000$rdt_s set random_ false#Setup a TCP connectionset tcp [$ns create-connection TCP/Reno $n1 TCPSink $n5 0]$tcp set window_ 15$tcp set fid_ 2#Setup a FTP Applicationset ftp [$tcp attach-source FTP]#Simulation Scenario$ns at 0.0 "$ftp start"$ns at 0.0 "$rdt_s start"$ns at 7.0 "finish"$ns run

⌨️ 快捷键说明

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