How do I Run Ns2 Code

This article “how do I run Ns2 code” is considered as the depiction of step by step processes that are required to run the code based network simulator 2.

Ns2 Source Code

For your reference, we have highlighted the sample Ns2 source code in the following along with its specifications.

  • AODV based routing process, stored in the file extension .cc in Ns-2.35

static class AODVclass : public TclClass {


        AODVclass() : TclClass(“Agent/AODV”) {}

        TclObject* create(int argc, const char*const* argv) {

          assert(argc == 5);

              return (new AODV((nsaddr_t) Address::instance().str2addr(argv[4])));


} class_rtProtoAODV;

  • scrpt code for call the AODV routing protocol, stored in the file extension .tcl in the workspace location

set val(mac)                Mac/802_11

set val(rp)       AODV

set val(nn)       50

set val(x)         1000

set val(y)         1000

set val(simtim)           9.0

Run Ns2 Code

To run the Ns2 code, we have to implement the commands that have been highlighted in the following in the terminal window.

cd  /home/research/Desktop/NS2_Code

sudo ./ns NS2Code.tcl

Running Ns2 Code

Following that, we have highlighted the results acquired through running the Ns2 code.

Result of Running Ns2 Code

In addition to that, we are ready to offer the research guidance at any time for the research scholars. So, reach us without any hesitation.