Set class _ x set fid _ x

Source: Internet
Author: User

There are some explanations on the network of set class _ x and set fid _ x. When set class _ x is related to the color settings in nam, and set fid _ x is the ID of the network stream, which is irrelevant to the color. Tested in windows XP + cygwin + ns2.29, the priority of set fid _ x coloring in nam is higher than that of set class _ x. For more information, see the following example.# 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 nodes <br/> $ ns duplex-link $ n0 $ n2 2 Mb 10 ms DropTail <br/> $ ns duplex-link $ n1 $ n2 2 Mb 10 ms DropTail <br/> $ ns duplex-link $ n2 $ n3 1.7 Mb 20 ms 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 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 _ 1 mb <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>In this example, the color of the corresponding network stream in nam is changed as long as the 'X' value in set fid _ x is changed. The color of 'X' in set class _ x does not change. After the set fid _ x statement is commented out, change the 'X' value in set class _ x to the corresponding color value, and the color changes accordingly. Comment out set class _ x, and the color is black.

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.