Friday, 24 May 2019

Plot a graph of node energy from NS2 trace file

use the below awk script to find the energy of node
#!/usr/bin/awk -f
BEGIN{
#print "energy of node 1"
data=0
}

{
if ($1=="N" && $5==0)
{
    print $3,$7
}
}
END{
#print "Completed"
}
save this file as energy.awk
in terminal type
$gawk -f energy.awk "yourtracefile.tr" > node0.dat
on executing this command you'll get a file node0.dat
in terminal
$xgraph -P node0.dat
you'll get a graph

No comments:

Post a Comment