Hi,

Below I have write my awk script to calculate throughput.

The columns that you need are:

column 7: TCP bytes sent
column 8: interval

then the throughput is

column7/column8

And, this script also calculates: bytes drops, packets drops, bytes 
arrivals als packets arrivals.

I'm sorry, but the names of variables are in Spanish.

/salva




#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo "[$1:$2:$3] ...Obteniendo bytes/packets/flows sent/dropped TCP "
cat $TMP/out.tr | perl column 3 0 2 1 | sort -g | 
awk '
   BEGIN { max = 0 }
   {
     # i          = fid
     # flujo[i,1] = packets_arrivals (+)
     # flujo[i,2] = packets_drops    (d)
     # flujo[i,3] = packets_sent     (-)
     # flujo[i,4] = bytes_arrivals
     # flujo[i,5] = bytes_drops
     # flujo[i,6] = bytes_sent
     # flujo[i,7] = instante inicio
     # flujo[i,8] = instante final

     i      = $1;
     tiempo = $4;
     evento = $2;

     max = ((i > max) ? i : max);

     contabilizar = 0;

     if (evento == "+") {
        flujo[i,1]++;
        flujo[i,4] += $3;
        contabilizar = 1;
     } else if (evento == "d") {
        flujo[i,2]++;
        flujo[i,5] += $3;
        contabilizar = 1;
     } else if (evento == "-") {
        flujo[i,3]++;
        flujo[i,6] += $3;
        contabilizar = 1;
     }

     if (contabilizar == 1) {
        tiempo = $4;

        if (flujo[i,7] == 0) { flujo[i,7]= tiempo };
        if (flujo[i,8] == 0) { flujo[i,8]= tiempo };

        if ( tiempo < flujo[i,7]) { flujo[i,7] = tiempo};
        if ( tiempo > flujo[i,8]) { flujo[i,8] = tiempo};
     }
   }
   END {
      for (i=0; i<=max ; i++) {
        lapsus = flujo[i,8] - flujo[i,7];

        if ( lapsus > 0 ) { 
printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%f\n",i,flujo[i,1],flujo[i,2],flujo[i,3],flujo[i,4],flujo[i,5],flujo[i,6],lapsus)
 }
      }
   }' > $TMP/tcp_flows.dat


#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#::: FIN
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::











On Mon, 26 Mar 2007, paul yoong wrote:

>
> Hi all,
>
> I want to calculate the throughput of a link using awk. Can anyone tell me 
> how to do this for a simple 2 node link. If anyone could direct me to any 
> example on the web that would be great.
>
> Thanks
>
>
>
>
>
> ___________________________________________________________
> Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. 
> http://uk.docs.yahoo.com/nowyoucan.html
>

Reply via email to