#!/bin/tcsh
# Usage: process-hstcp-250s
if ($1 =="") then
echo "Usage: process-hstcp-250s "
exit
endif
set BINDIR = "/home/research/hs-tcp/bin"
set dir = $1
set outfile = "STATS"
# Assume there are files in the directory named cwnd_hstcp0.out,
# cwnd_hstcp1.out, tput_hstcp0.out tput_hstcp1.out
set cwnd0 = "$dir/cwnd_hstcp0.out"
set cwnd1 = "$dir/cwnd_hstcp1.out"
set tput0 = "$dir/tput_hstcp0.out"
set tput1 = "$dir/tput_hstcp1.out"
set report = "$dir/report.txt"
if !(-e $outfile) then
echo "# exp flow cwnd loss tput asym" >! STATS
endif
# Flow 0 Stats
set f0_tput = 0
if (-e "$tput0") then
set f0_tput = `awk -f $BINDIR/avgt250-500.awk $tput0`
# echo "f0 tput: $f0_tput"
endif
set f0_cwnd = 0
if (-e "$cwnd0") then
set f0_cwnd = `awk -f $BINDIR/avgc250-500.awk $cwnd0`
# echo "f0 cwnd: $f0_cwnd"
endif
set f0_loss = 0
if (-e "$report") then
set f0_loss = `awk '{if ($2=="0:" && $3=="overall" && $4=="lossrate") printf "%.6f", $6}' $report`
# echo "f0 loss: $f0_loss"
endif
# Flow 1 Stats
set f1_tput = 0
if (-e "$tput1") then
set f1_tput = `awk -f $BINDIR/avgt250-500.awk $tput1`
# echo "f1 tput: $f1_tput"
endif
set f1_cwnd = 0
if (-e "$cwnd1") then
set f1_cwnd = `awk -f $BINDIR/avgc250-500.awk $cwnd1`
# echo "f1 cwnd: $f1_cwnd"
endif
set f1_loss = 0
if (-e "$report") then
set f1_loss = `awk '{if ($2=="1:" && $3=="overall" && $4=="lossrate") printf "%.6f", $6}' $report`
# echo "f1 loss: $f1_loss"
endif
# Asymmetry
set t1 = `perl -e 'print '$f0_tput' - '$f1_tput''`
set t2 = `perl -e 'print '$f0_tput' + '$f1_tput''`
set asym = `perl -e 'printf "%.3f", '$t1'/'$t2' '`
#echo "asym: $asym"
# RTTs
#set rtt0 = `awk '{if ($1=="hstcp0," && $2=="RTT") print $4}' $report`
#set rtt1 = `awk '{if ($1=="hstcp1," && $2=="RTT") print $4}' $report`
#printf "%-22s 1 %-6.2f %-5d %-.6f %-6.2f %-.3f\n" $dir $rtt0 $f0_cwnd $f0_loss $f0_tput $asym >> $outfile
#printf "%-22s 2 %-6.2f %-5d %-.6f %-6.2f %-.3f\n" $dir $rtt1 $f1_cwnd $f1_loss $f1_tput $asym >> $outfile
printf "%-22s 1 %-5d %-.6f %-6.2f %-.3f\n" $dir $f0_cwnd $f0_loss $f0_tput $asym >> $outfile
printf "%-22s 2 %-5d %-.6f %-6.2f %-.3f\n" $dir $f1_cwnd $f1_loss $f1_tput $asym >> $outfile