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

📄 ping.tcl

📁 在linux下开发的用于仿真ping协议的仿真文件
💻 TCL
字号:
#Create a simulator objectset ns [new Simulator]#Open a trace fileset nf [open out.nam w]$ns namtrace-all $nf#Define a 'finish' procedureproc finish {} {        global ns nf        $ns flush-trace        close $nf        exec nam out.nam &        exit 0}#Create three nodesset n0 [$ns node]set n1 [$ns node]set n2 [$ns node]#Connect the nodes with two links$ns duplex-link $n0 $n1 1Mb 10ms DropTail$ns duplex-link $n1 $n2 1Mb 10ms DropTail#Define a 'recv' function for the class 'Agent/Ping'Agent/Ping instproc recv {from rtt} {	$self instvar node_	puts "node [$node_ id] received ping answer from \              $from with round-trip-time $rtt ms."}#Create two ping agents and attach them to the nodes n0 and n2set p0 [new Agent/Ping]$ns attach-agent $n0 $p0set p1 [new Agent/Ping]$ns attach-agent $n2 $p1#Connect the two agents$ns connect $p0 $p1#Schedule events$ns at 0.2 "$p0 send"$ns at 0.4 "$p1 send"$ns at 0.6 "$p0 send"$ns at 0.6 "$p1 send"$ns at 1.0 "finish"#Run the simulation$ns run

⌨️ 快捷键说明

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