NS2_awk-throughput_upstream10/downstream10

|

BEGIN {
 n=0;
 total0 = 0;
 total1 = 0;
 total2 = 0;
 total3 = 0;
 total4 = 0;
 throughput0=0;
 throughput1=0;
 throughput2=0;
 throughput3=0;
 throughput4=0;
 nm0=(nn+2);
 nm1=(nn+3);
 nm2=(nn+4);
 nm3=(nn+5);
 nm4=(nn+6);
 nm5=(nn+7);
 nm6=(nn+8);
 nm7=(nn+9);
 nm8=(nn+10);
 nm9=(nn+11);
 SIMUL_TIME=500;
 AWK_INTERVAL=400;
}

{
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 ==nm0)) {
   if (n == 0) start0 = $2;
   total0 += $8 * 8;
   end0 = $2;
  }
  if (1<nn)
  {
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 == (nm1))) {
   if (n == 0) start1 = $2;
   total1 += $8 * 8;
   end1 = $2;
  }
  if (2<nn)
  {
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 == (nm2))) {
   if (n == 0) start2 = $2;
   total2 += $8 * 8;
   end2 = $2;
  }if (3<nn)
  {
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 == (nm3))) {
   if (n == 0) start3 = $2;
   total3 += $8 * 8;
   end3 = $2;
  }if (4<nn)
  {
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 == (nm4))) {
   if (n == 0) start4 = $2;
   total4 += $8 * 8;
   end4 = $2;
  }if (5<nn)
  {
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 == (nm5))) {
   if (n == 0) start5 = $2;
   total5 += $8 * 8;
   end5 = $2;
  }if (6<nn)
  {
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 == (nm6))) {
   if (n == 0) start6 = $2;
   total6 += $8 * 8;
   end6 = $2;
  }if (7<nn)
  {
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 == (nm7))) {
   if (n == 0) start7 = $2;
   total7 += $8 * 8;
   end7 = $2;
  }if (8<nn)
  {
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 == (nm8))) {
   if (n == 0) start8 = $2;
   total8 += $8 * 8;
   end8 = $2;
  }if (9<nn)
  {
  if ( ($1 =="r") && ($4 =="AGT") && ($7 =="tcp") && ($3 == (nm9))) {
   if (n == 0) start9 = $2;
   total9 += $8 * 8;
   end9 = $2;
  }
  }
  }
  }
  }
  }
  }
  }
  }
  }
}

END {
  throughput0 = (total0)/ ( (1000) * 500 );
  throughput1 = (total1)/ ( (1000) * 500 );
         throughput2 = (total2)/ ( (1000) * 500 );
         throughput3 = (total3)/ ( (1000) * 500 );
         throughput4 = (total4)/ ( (1000) * 500 );
         throughput5 = (total5)/ ( (1000) * 500 );
  throughput6 = (total6)/ ( (1000) * 500 );
  throughput7 = (total7)/ ( (1000) * 500 );
  throughput8 = (total8)/ ( (1000) * 500 );
  throughput9 = (total9)/ ( (1000) * 500 );        
 #Bandwidth 1Mbps = 1000Kbps
        
 print throughput0,"\t",total0;
 print throughput1,"\t",total1;
 print throughput2,"\t",total2;
 print throughput3,"\t",total3;
 print throughput4,"\t",total4;
 print throughput5,"\t",total5;
 print throughput6,"\t",total6;
 print throughput7,"\t",total7;
 print throughput8,"\t",total8;
 print throughput9,"\t",total9;
 print "========================================================="
}


And