NS2 How to set the node color

Source: Internet
Author: User

Many people may set the color of the NS2 stream, but rarely set the node color. In fact, if the different nodes have different colors, it is sometimes more obvious to observe. For example, I added in the previous blog black Hole attack node, these nodes set the color, the effect is better estimated. Very article said set node color is very troublesome, but I tried, seemingly no such trouble. Needless to say, the addition of the node color process is generally as follows (two words on the line).

# $ns _ node-config-adhocrouting $val (BRP)
For {set I $val (NNAODV)} {$i < $val (NN)} {incr i} {
Set Node_ ($i) [$ns _ node]
$node _ ($i) random-motion 0;
$ns _ at 0.01 "$node _ ($i) label \" Blackhole node\ ""
$ns _ at 0.01 "[$node _ ($i) set Ragent_] Blackhole"
$node _ ($i) color "BLACK";
$ns _ at 0.01 "$node _ ($i) color \" Red\ "";
}


Here I set the black hole before the attack node color is red, that is the two words

$node _ ($i) color "BLACK";
$ns _ at 0.01 "$node _ ($i) color \" Red\ "";

Note that no matter what color you want to set, the first sentence must be there, otherwise it cannot be executed. It's so simple.



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.