Awk File in Ns2
Mainly, it is one among significant article in Ns2 simulator and it’s about the integration of awk file in network simulator 2. This article is about the depiction of the keynotes about the awk files in Ns2.
Awk Script in Ns2
The awk scripts (.awk) are deployed for the extraction of necessary information from the trace files (.tr) and they are also used to plot the graphs using the Xgraph (.xgr) utility of network simulator 2.
Calculate Throughput Using awk Script in Ns2
Here, we have highlighted the formula which is used for the calculation of throughput in the following.
Throughput = received_data*8/DataTransmissionPeriod
In addition to that, we have highlighted the awk script which is deployed to calculate the throughput.
recvdSize = 0
startTime = 400
stopTime = 0
event = $1
time = $2
node_id = $3
pkt_size = $8
level = $4
hdr_size = pkt_size % 512
pkt_size -= hdr_size
recvdSize += pkt_size
printf(“Average Throughput[kbps] = %.2f\t\t StartTime=%.2f\tStopTime=%.2f\n”,(recvdSize/(stopTime-startTime))*(8/1000),startTime,stopTime)
The Tcl code to execute the awk script based on network simulator 2 is highlighted in the following.
exec awk -f Throughput.awk sample27.tr > Throughput.xgr &
The below mentioned command is executed to generate the graph along with the background color as while.
sudo ./xgraph Throughput.xgr -bg white
Reach us to aid more about Ns2 simulator!!!