set class_ x set fid_ x

來源:互聯網
上載者:User

關於 set class_ x , set fid_ x  網路上有一些解釋。http://blog.csdn.net/wanghui_one/archive/2009/03/12/3985331.aspxhttp://www.baisi.net/thread-3005681-1-32.htmlhttp://www.baisi.net/thread-31289-1-4.html主要意思是 set class_ x跟nam中顏色設定有關,而set fid_ x是標註網路流ID,跟著色無關。經在windows XP + cygwin + ns2.29下測試,set fid_ x 在nam中著色的優先順序比set class_ x高。具體見後面的例子。#Create a simulator object<br />set ns [new Simulator]</p><p>#Define different colors for data flows (for NAM)<br />$ns color 1 Blue<br />$ns color 2 Red</p><p>#Open the NAM trace file<br />set nf [open out.nam w]<br />$ns namtrace-all $nf</p><p>#Define a 'finish' procedure<br />proc finish {} {<br /> global ns nf<br /> $ns flush-trace<br /> #Close the NAM trace file<br /> close $nf<br /> #Execute NAM on the trace file<br /> exec nam out.nam &<br /> exit 0<br />}</p><p>#Create four nodes<br />set n0 [$ns node]<br />set n1 [$ns node]<br />set n2 [$ns node]<br />set n3 [$ns node]</p><p>#Create links between the nodes<br />$ns duplex-link $n0 $n2 2Mb 10ms DropTail<br />$ns duplex-link $n1 $n2 2Mb 10ms DropTail<br />$ns duplex-link $n2 $n3 1.7Mb 20ms DropTail</p><p>#Set Queue Size of link (n2-n3) to 10<br />$ns queue-limit $n2 $n3 10</p><p>#Give node position (for NAM)<br />$ns duplex-link-op $n0 $n2 orient right-down<br />$ns duplex-link-op $n1 $n2 orient right-up<br />$ns duplex-link-op $n2 $n3 orient right</p><p>#Monitor the queue for link (n2-n3). (for NAM)<br />$ns duplex-link-op $n2 $n3 queuePos 0.5</p><p>#Setup a TCP connection<br />set tcp [new Agent/TCP]<br />$tcp set class_ 2<br />$ns attach-agent $n0 $tcp<br />set sink [new Agent/TCPSink]<br />$ns attach-agent $n3 $sink<br />$ns connect $tcp $sink<br />$tcp set fid_ 1</p><p>#Setup a FTP over TCP connection<br />set ftp [new Application/FTP]<br />$ftp attach-agent $tcp<br />$ftp set type_ FTP</p><p>#Setup a UDP connection<br />set udp [new Agent/UDP]<br />$ns attach-agent $n1 $udp<br />set null [new Agent/Null]<br />$ns attach-agent $n3 $null<br />$ns connect $udp $null<br />$udp set fid_ 2</p><p>#Setup a CBR over UDP connection<br />set cbr [new Application/Traffic/CBR]<br />$cbr attach-agent $udp<br />$cbr set type_ CBR<br />$cbr set packet_size_ 1000<br />$cbr set rate_ 1mb<br />$cbr set random_ false</p><p>#Schedule events for the CBR and FTP agents<br />$ns at 0.1 "$cbr start"<br />$ns at 1.0 "$ftp start"<br />$ns at 4.0 "$ftp stop"<br />$ns at 4.5 "$cbr stop"</p><p>#Detach tcp and sink agents (not really necessary)<br />$ns at 4.5 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"</p><p>#Call the finish procedure after 5 seconds of simulation time<br />$ns at 5.0 "finish"</p><p>#Print CBR packet size and interval<br />puts "CBR packet size = [$cbr set packet_size_]"<br />puts "CBR interval = [$cbr set interval_]"</p><p>#Run the simulation<br />$ns run</p><p>此例中只要改變 set fid_ x 中 'x'的值,在nam中對應網路流的顏色必改變。而改變set class_ x 中 'x'的值,顏色不改變。當把set fid_ x 語句都注釋掉後,再把set class_ x 中的 'x' 值改為對應的顏色值,顏色隨之改變。再把set class_ x 都注釋掉,顏色都為黑色。

 

 

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.