What is Awk File in Ns2

             The AWK is denoted as significant programming language which is designed to process the text based data over the files that are functioning with the data streams and that is deployed to analyze the trace file as per the requirement. It is mainly deployed in the pattern scanning and processing and it is the script language deployed to manipulate the data and to generate reports. The AWK command programming language needs logical operators, string functions, numeric functions, permits the users to utilize variables and no compiling.

Program Invocation

           The invocation of AWK is processed over the command prompt in two methods and they are highlighted in the following syntax.

>>awk [ -F< ch> ] {< pgm>} [ < vars> ] [ < data_file> ]
>>awk [ -F< ch> ] { -f < pgm_file> } [ < vars> ] [ < data_file> ]

           This command includes some variables in bracket and depicts the field separator, AWK script, file of AWK script, variables in AWK script and input text file.

AWK Programming Structure

         The below mentioned is the general form of AWK program and it is the prior procession of input text file and it performs that <initialization> to start the process. The <final action> is the performed to denote the end process.

BEGIN {< initialization>}
< pattern1> {< actions>}
< pattern2> {< actions>}
.
.
.
END {< final actions>}

        For your reference, our research professionals have enlisted the significant AWK script related to the throughput based on Ns2.

AWK Script for Throughput Based on Ns2

BEGIN {
recvdSize = 0
startTime = 400
stopTime = 0
}
{
event = $1
time = $2
node_id = $3
pkt_size = $8
level = $4
# Store start time
if (level == "AGT" && event == "s" && pkt_size >= 512) {
if (time < startTime) {
startTime = time
}
}
# Update total received packets' size and store packets arrival time
if (level == "AGT" && event == "r" && pkt_size >= 512) {
if (time > stopTime) {
stopTime = time
}
# Rip off the header
hdr_size = pkt_size % 512
pkt_size -= hdr_size
# Store received packet's size
recvdSize += pkt_size
}
}

END {
printf("Average Throughput[kbps] = %.2f\t\t StartTime=%.2f\tStopTime=%.2f\n",(recvdSize/(stopTime-startTime))*(8/1000),startTime,stopTime)
}

          Our technical developers include the finest research knowledge about the functions of AWK file in Ns2 through that we have depicted this article and if you guys require any additional guidance, you can contact us.