Thursday, 30 January 2014

Awk Script To calculate Energy Level From Ns2 Trace Files

Use the Below Awk script to  calculate Energy Level From Ns2 Trace Files


BEGIN {

seqno = -1;

start_time = 0;

}

{

action = $1;

time = $2;

node_id = $3;

layer = $4;

flags = $5;

seqno = $6;

type = $7;

size = $8;

a = $9;

b = $10;

c = $11;

d = $12;

energy = $14;

if(seqno < $6 && node_id == "_4_" && (action == "r" || action == "s")) {

seqno = $6;

remaining_energy = energy;

start_time = time;

printf("%f\t%f\n",start_time,remaining_energy);


}
}

END {

}

2 comments:

  1. It is not give a correct output sir. I think this is for old trace format.

    ReplyDelete
  2. hello ! please i have a question about trace file .tr and awk ! could you help me ?

    how i could use time and enrgy from .tr file to draw a graph ?

    ReplyDelete