[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] problem with awk script
Hi all,
I have tried to execute, for the first time, an awk script.
This script has been provided by:
<[email protected]>PGP<http://www.ee.surrey.ac.uk/Personal/L.Wood/>
in this mailing list.
You can read the whole message at the following link:
http://www.isi.edu/nsnam/archive/ns-users/webarch/1999/msg02093.html
Or you can read only the script below:
BEGIN {
# simple awk script to generate end-to-end packet lifetime statistics
# in a form suitable for plotting with xgraph.
# Lloyd Wood, July 1999.
# http://www.ee.surrey.ac.uk/Personal/L.Wood/ns/
highest_packet_id = 0;
}
{
action = $1;
time = $2;
node_1 = $3;
node_2 = $4;
src = $5;
flow_id = $8;
node_1_address = $9;
node_2_address = $10;
seq_no = $11;
packet_id = $12;
if ( packet_id > highest_packet_id ) highest_packet_id = packet_id;
# getting start time is not a problem, provided you're not starting
# traffic at 0.0.
# could test for sending node_1_address or flow_id here.
if ( start_time[packet_id] == 0 ) start_time[packet_id] = time;
# only useful for small unicast where packet_id doesn't wrap.
# checking receive means avoiding recording drops
if ( action != "d" ) {
if ( action == "r" ) {
# could test for receiving node_2_address or flow_id here.
end_time[packet_id] = time;
}
} else {
end_time[packet_id] = -1;
}
}
END {
for ( packet_id = 0; packet_id <= highest_packet_id; packet_id++ ) {
start = start_time[packet_id];
end = end_time[packet_id];
packet_duration = end - start;
if ( start < end ) printf("%d %f\n", start, packet_duration);
}
}
I've saved it as end-to-end.awk. At the prompt I have typed:
awk -f end-to-end.awk out.tr > end.tr
I get this error message:
awk: end-to-end.awk:1: BEGIN {
' in expression.awk:1: ^ Invalid char '
Where is my mistake?
Linux distribution: Red Hat 6.2
Any help is appreciated, thank you.