test/comparison/maketable.sh
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 #!/bin/bash
       
     2 
       
     3 #
       
     4 #    Copyright 2005-2006 Intel Corporation
       
     5 # 
       
     6 #    Licensed under the Apache License, Version 2.0 (the "License");
       
     7 #    you may not use this file except in compliance with the License.
       
     8 #    You may obtain a copy of the License at
       
     9 # 
       
    10 #        http://www.apache.org/licenses/LICENSE-2.0
       
    11 # 
       
    12 #    Unless required by applicable law or agreed to in writing, software
       
    13 #    distributed under the License is distributed on an "AS IS" BASIS,
       
    14 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    15 #    See the License for the specific language governing permissions and
       
    16 #    limitations under the License.
       
    17 #
       
    18 
       
    19 
       
    20 
       
    21 usage="$0 <maxnodes> <expname>"
       
    22 example="$0 3 tryfoo/ [basepath]"
       
    23 
       
    24 
       
    25 if [ "$#" = 2 ]; then
       
    26     basepath=/proj/DTN/nsdi/logs
       
    27 elif [ "$#" = 3 ]; then
       
    28     basepath=$3
       
    29 else
       
    30     echo "Usage: $usage"
       
    31 	echo "Example: $example"
       
    32     exit
       
    33 fi
       
    34 
       
    35 exp=$2
       
    36 maxnodes=$1
       
    37    
       
    38 
       
    39 if [ ! -d $basepath/$exp ]; then
       
    40     echo "$basepath/$exp: does not exit"
       
    41     exit 5
       
    42 fi
       
    43 
       
    44 #echo "Make table: exp: $basepath/$exp  nodes:$maxnodes base=$basepath"
       
    45 
       
    46 for proto in tcp0 tcp1 dtn0 dtn1 mail0 mail1 ; 
       
    47 do
       
    48     exppath=$basepath/$exp/$proto
       
    49     
       
    50     if [ ! -d $exppath ]; then
       
    51         continue
       
    52     fi
       
    53 
       
    54     ftplog=$exppath/ftplog
       
    55     n=$maxnodes
       
    56     
       
    57     restmpfile=/tmp/$exp.$proto.res
       
    58     resfile=$exppath/times.txt
       
    59     rm -f $resfile
       
    60     rm -f $restmpfile
       
    61     
       
    62     start=0
       
    63     end=-1
       
    64     
       
    65     txlen=0
       
    66     if [ -e $ftplog.$n ]; then 
       
    67         txlen=`cat $ftplog.1 | wc -l`
       
    68     fi
       
    69     sentlen=$txlen 
       
    70     
       
    71     rcvlen=0
       
    72     if [ -e $ftplog.1 ]; then 
       
    73         rcvlen=`cat $ftplog.$maxnodes | wc -l`
       
    74     fi
       
    75 
       
    76     if [ "$rcvlen" -gt "$txlen" ]; then
       
    77         rcvlen=$txlen
       
    78     fi
       
    79 
       
    80     if [ $rcvlen -eq 0 ]; then
       
    81         echo "Nothing to paste for $exp/$proto ftplog:$ftplog"
       
    82         continue
       
    83     fi
       
    84     echo -n "$exppath : txlen:$txlen rcvlen:$rcvlen ::"
       
    85     
       
    86     
       
    87     rm -f /tmp/$exp.$proto.res
       
    88     rm -f /tmp/$exp.$proto.index
       
    89     rm -f /tmp/$exp.$proto.$n
       
    90     rm -f /tmp/$exp.$proto.1
       
    91         
       
    92     lineno=1
       
    93     while [ "$lineno" -le "$rcvlen" ] 
       
    94     do
       
    95         echo "$lineno " >> /tmp/$exp.$proto.index
       
    96         let lineno=$lineno+1
       
    97     done
       
    98     head -n $rcvlen $ftplog.1 | awk '{print $1}'  > /tmp/$exp.$proto.1
       
    99     head -n $rcvlen $ftplog.$n | awk '{print $1}'  > /tmp/$exp.$proto.$n
       
   100     
       
   101     paste /tmp/$exp.$proto.index /tmp/$exp.$proto.1 /tmp/$exp.$proto.$n > $restmpfile
       
   102     
       
   103     
       
   104 
       
   105 
       
   106     #echo "ftp duration is: start of sending first file to receiving last file"
       
   107     #echo
       
   108     
       
   109     
       
   110     send_start=`cat $restmpfile | head -n 1| awk '{print $2}'`
       
   111     send_end=`cat $restmpfile | tail -n 1| awk '{print $2}'`
       
   112     rcv_start=`cat $restmpfile | head -n 1| awk '{print $3}'`
       
   113     rcv_end=`cat $restmpfile | tail -n 1| awk '{print $3}'`
       
   114     
       
   115     let diff=$rcv_end-$send_start
       
   116     if [ "$rcvlen" -le "0" ]; then
       
   117 	    diff=-1  
       
   118     fi
       
   119     echo  "Time:$diff "
       
   120     
       
   121     
       
   122     echo "# $send_start $send_end $rcv_start $rcv_end  $rcvlen $sentlen" > $resfile
       
   123     cat $restmpfile >> $resfile
       
   124 done