These days i just identified that most of the NS2 Users are facing problem with running AWK scripts and getting final simulation results.
Here are some common mistakes :
1) Running with out generating the Trace file.2) Running with out testing the trace file format(old/new)
3) Division by zero awk script error.
4) Using New trace file with old awk script combination or Old trace file with New awk script-->This is the major mistake.
Solution:
Before you proceed with applying awk scripts, Make sure which stage you are in currently.In my view the stages are
Stage 1: creation of scenario(environmental setup) and creating TCL file.Important step check for new trace file or old trace file.....
- If you want new trace file (contains energy and node position details) : put $ns use-newtrace in your TCL file.
- If you want old trace file format : just comment the above command in your TCL file with #.
Stage 2: Execution of TCL file and getting TRACE file (.tr file) . Generated with run the command $ns example.tcl
Stage 3: Download or modify the AWK scripts according to your scenario
Stage 4: Use xgraph to generate graph associated to your results.
Checking Awk script for Old/New trace file format:
AWK scripts are very useful to apply and execute trace file. important aspect is checking the column values in the awk script.AWK script for New trace file:
It contains more than 35 columns. which gives energy in joules, (x,y,z)axis location of node, send,receive, etc.
So if you found any value like $16 or $34 or $23 means that the script is for new trace file . Use when you need energy calculation apart from that pdf, jitter,throughput,delay else go with Old awk script.
AWK script for Old trace file:
- column values will be less than 10. you can see like $5 ,$9 in the script.
Now please check the trace file whether it is old or new and then apply associated AWK script..Search appropriate AWK script and use.
NOTE:
Please open trace file and now check how many columns are there. old trace file for example
s 2.556838879 _0_ RTR --- 0 AODV 48 [0 0 0 0] ------- [0:255 -1:255 30 0]
Columns in AWK script
-------------------------------
$1-->s
$2--> 2.556838879
$3-->_0_
$4--> RTR
Hope this Post helps you folks