Awk Script For Ns2 Trace File
Posted By admin On 20.09.19I want to calculate throughput of my trace file generated by simulating following parameters 25 nodes(random way point mobility) random traffic.
- NS2 is discrete event simulator used to simulate real time network traffic and topology for analysis. For researcher it is proven to be great tool.
- Throughput is the number of successfully received packets in a unit time and it is represented in bps. Throughput is calculated using awk script which processes the trace file and produces the result. Sample Code; Screenshots.
AWK Scripts are very good in processing the data from the log (trace files) which we get from NS2. If you want to process the trace file manually, here is the detail Here is a sample of trace file from NS2 (However ns2 supports a new type of trace file also), but this post will make you understand the old trace format only. R 0.030085562 0 MAC - 0 message 32 0 ffffffff 1 800 - 1:255 -1:255 32 0 r 0.030110562 0 RTR - 0 message 32 0 ffffffff 1 800 - 1:255 -1:255 32 0 s 1.119926192 0 RTR - 1 message 32 0 0 0 0 - 0:255 -1:255 32 0 AWK Scripts are very good in processing the data column wise. For example the first column in the above trace file represents r, s which indicates receive, sent respectively.
If we want to trace the entire r and s alone from this trace file we can represent it as $1 So $1 represents ACTION $2 Time $3 Node ID $4 Layer $5 Flags $6 seqno $7 type $8 Size $14 Energy (if the network nodes includes EnergyModel) To run the awk script in Linux, gawk –f filename.awk filename.tr So, it is necessary for the researchers to know the basics of awk scripts before they are used. Here this post will let you know some of the scripts that were used to process the data (NB: all these codes were taken from various websites and you can refer those websites for further information). To find the throughput of the Network.
Hi Folks, In this post I, shall give u an awk file I wrote that prints several network statistics of interest (these are of course the basic ones cuz i ain’t that good at statistics). Being fed up with lots of awk files floating on the net and most of them don’t work or work on old trace formats of ns-2.34. So I planned to write my own awk script for my simulations. This awk script i wrote is for 50 nodes and by minor modifications it can be changed to any no. I have used it for 150 nodes.
The statistics u can calculate with this file are:. Total Packets Sent.
Total Packets Received. Total Packets Dropped. Total Packets Forwarded.
Awk Scripts For Ns2 To Process Data From Trace Files
Packet Delivery Ratio%. The total hop counts are.
Average Hop Count. Routing Overhead. Normalized Routing Load. Througphut of the network (KBps). Average End to End Delay. Total Energy Consumed. Protocol Energy Consumption Some of these metrics I have calculated using the above shown image.
However energy consumption metrics have been calculated by me. When u run this awk script using the command: awk -f statistics.awk xyz.tr (xyz.tr is your trace file name) statistics.awk creates 5 files (which contain info related with each node) in your directory they are:. energyleft.txt.
pktdrop.txt. pktfwd.txt. pktrecvd.txt. pktsent.txt Note:- This statistics.awk file was made for 50 nodes. However in the awk file i have put comments so as to where u need to make changes in order to run it for any number of nodes. My view:- I wrote it according to my own logic and understanding however some logic may be wrong or may not be optimal or may be very time consuming.
If any suggestions are there for improving this code. Please suggest. Thanks Let’s support the research community by sharing our code and not hiding it.