How do I Run a Program in Ns2

As the matter of fact, running a program in network simulator 2 is the simple task when we used to follow all the required steps in the following.

Program Code in Ns2

All of us can write the Ns2 program code in the simulation code file and that has to be stored with the file extension .cc. For your ease, we have highlighted the program code based on network simulator.

  • Ns2 code to update queue status

double now = Scheduler::instance().clock();

        double newtime = now – total_time_;

        if (newtime > 0.0) {

                double oldave = true_ave_;

                double oldtime = total_time_;

                double newtime = now – total_time_;

                true_ave_ = (oldtime * oldave + newtime * queuesize) /now;

                total_time_ = now;

        }

  • TCL script code in Ns2 to configure the queue

set val(ant)      Antenna/OmniAntenna

set val(ifq)      Queue/DropTail/PriQueue

set val(ifqlen)             50

set val(netif)  Phy/WirelessPhy

Run Program in Ns2

To run the program in network simulator 2, we have to implement the below mentioned commands.

cd /home/research/Desktop/program_in_NS2

./ns programinNS2.tcl

Running Program in Ns2

At this moment, we have highlighted the result which is acquired through running the program in Ns2.

If you want to know more data about the additional process of Ns2, you can contact us to acquire more.