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.