[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Trouble with awk
Hi,
i have written an awk script that should calculate the
end to end delay for multicast packets modifying Lloyd
Wood's awk script
(http://www.isi.edu/nsnam/archive/ns-users/webarch/1999/msg02093.html)
i can't get my awk script working:
here is how it is inserted in my tcl script:
proc finish {} {
global ns
exec awk {
BEGIN { max_num_client = 0;
max_num_pack = 0;
}
{
if ($1 == "v") {
if ( $8 == "join-group" ) {
isclient[$7] = 1;
split($9,temp,"}");
whichgroup[$7] =temp[1];
if ( $7 > max_num_client) max_num_client = $7;
}
} else {
action = $1;
time = $2;
node_1 = $3;
node_2 = $4;
src = $5;
node_1_address = $9;
node_2_address = $10;
packet_id = $12;
if (start[packet_id] == 0) start[packet_id] =time;
if ( action != "d" ) {
if ( action == "r" ) {
if (whichgroup[node_2] == $10)
end_time[node_2,packet_id] = time;
}
} else {
end_time[packet_id] = -1;
}
}
}
END {
for ( x=1; x <= max_num_client; x++) {
if (isclient[x] == 1) {
for (p=1; p <= max_num_pack; p++) {
if ((p,x) in end_time) {
delay = end_time[x,p] -
start[packet_id];
print(p, x, delay);
}
}
}
}
}
} aj/ssmawk2.tr > aj/ssmawk2.txt
$ns flush-trace
exit 0
}
Here is the output i get, it seems that some confusion
rises because of some parenthesis (i've counted them,
they should be ok!):
wrong # args: should be "proc name args body"
while executing
"proc finish {} {
global ns
exec awk {
BEGIN { max_num_client = 0;
max_num_pack = 0;
}
{
if ($1 == "v") {
if ( $8 == "join-group" ) ..."
(file "aj/ssmawk2.tcl" line 38)
Moreover, if i run the script from the command line:
awk -f 'prog.awk' ssmawk.tr > ris.txt
I get no error output but the file "ris.txt" is EMPTY
!
Thanks for your help.
______________________________________________________________________
Do You Yahoo!?
Il tuo indirizzo gratis e per sempre @yahoo.it su http://mail.yahoo.it