Hi

i am doing a script with awk, but i faces a few problem maybe you can help
me...

BEGIN {
    i = 0;
    p = 0;
    cont = 0;
}

{
    while(getline>0) {
        if($1 == "r")
            p+=1;
    }

    close(FILENAME);

    for(cont = 0; cont < nnodes; cont++) {
        while((getline<FILENAME)>0) {
            split($0,pkt);
            if(pkt[1] == "r" && pkt[3] == "_$cont_") {
                print nnodes","pkt[3]","pkt[18]","pkt[19]","pkt[20];
                if(pkt[18] in rcvdPackets) {
                        if(rcvdPackets[pkt[19]] >= pkt[20])
                            i+=1;
                        else
                            rcvdPackets[pkt[19]] = pkt[20];
                } else
                        rcvdPackets[pkt[19]] = pkt[20];
                }
        }
        close(FILENAME);
    }
}

END {
    print nnodes" "i/nnodes" "100*i/p" "p" "cont;
}

The script analyze a NS trace file. It opens the same trace as many times as
the number of nodes in the simulation. The problem is with the second
getline. I seems with the getline it copies all in $0 (that is the normal
behavior), but also the variable "cont", which should be a simple counter,
contains the same data of $0. A little bit strange...

Any suggestions??

Thks
Maurizio

Reply via email to