ns2 code for network

At present, do you guys have any idea about the code based on network simulator 2? If not, no worries!!! Our research experts acquired all the required steps and functions over this article. Let’s get to know the significances.

Ns2 Code Using C++

To write the Ns2 source code in Ns2.35 and that is stored along with the file extension of .cc and .h Ns2 code for the hash generation using the sha algorithm.

void SHA( char *hash_out, const char *str, int len) {

SHA_CTX ctx;

int ii;


for (ii=0; ii<len; ii+=1)

       SHAUpdate(&ctx, (const unsigned char*)str + ii, 1);

SHAFinal((unsigned char *)hash_out, &ctx);

hash_out[20] = ‘\0’; }

Then, we have to modify the Makefile.in file code to build the sha process as mentioned in the following image.

Building Sha Process

Ns2 Code Using Tcl

Here, we have to write the Ns2 code in main simulation script file which is stored along with the file extension of .tcl.

  • Ns2 code to specify trace annotate

$ns at 0.0000001 “$ns trace-annotate \”      \””

$ns at 0.0000001 “$ns trace-annotate \” A MANET , it consists of 100 – Mobile Nodes.  \””

  • Ns2 code for node configuration

$ns at 0.5 “$node_(1) label \” Destination \””

$ns at 0.5 “$node_(1) color blue”

$ns at 0.5 “$node_(1) add-mark m1 red square”

Research us to get to know a lot about network simulator 2!!!