How to Calculate Throughput in Ns2

          This article is about the depiction of calculating the throughput based on the Ns2 simulator. Let’s take a look over the overall process of calculation.

Step: 1 Script Code to Calculate Throughput in Ns2

         Firstly, we have highlighted the awk script code to calculate the throughput in Ns2 based events in Ns2 trace files.

if (level == “RTR” && event == “r” && time >0 && $7 ==”AODV”) {

if (time > stopTime) { stopTime = time }



if(thru !=”inf” ){

printf(” %.2f %.2f \n” ,time,thru)

} }

Step: 2 Run Ns2 Main File

        Then, we have to run the Ns2 main file and for that we have to change the Ns 2 main file location using the below mentioned commands.

cd /home/research/Desktop/ns2_simulation

sudo ./ns Main.tcl

Result of Ns2 Simulation


As an additional note, we have highlighted result which is acquired through Ns2 simulation as per the main file execution.

Then, the result of graph generation based on auto generated file is stored with the file extension .tr through the utilization of Xgraph tool for the average throughput calculation based on number of nodes.

Average Throughput Calculation

        Hopefully, we have come up with the most wanted process to calculate the throughput in Ns2. What else? Just begin to implement by your own and hit us through various platforms if assistance required.