Awk Script for Throughput in Ns2 Wireless

Do you people want to know about the processes based on the throughput calculation in Ns2 wireless using awk scripts? Then stay tuned with this article!!!

Awk Script in Ns2 Wireless Simulation

Through the utilization of awk script file, we have to count the received application packets in the network based on the events in Ns2 wireless simulation trace files.

Calculate Throughput Using Awk Script in Ns2 Wireless

Notable, throughput is defined as the number of successfully received packets in a unit time and it is represented in bps and the awk script is which is used to calculate the throughput is highlighted in the following.

    if (send_id == “0”) {

        if (event == “+”) {

               transSize += pkt_size



    if (event == “r” && rec_id == “2”) {

        if (flow_id == “1”) {

            recvdSize += pkt_size



 printf(“%i\t%i\t%.2f\t%.2f\n”, transSize, recvdSize, startTime, stopTime)

Tcl Code to Call Awk Script

Hereby, we have highlighted the code which is used to call the awk script files in Ns2 wireless simulation main tcl code.

exec awk -f Throughput.awk >

If you have any issues while calculating the throughput in Ns2 wireless using awk script, then reach us to clarify that issue.