#!/bin/sh
#
# tcpf2xgr -- convert full-tcp trace file to xgraph or gnuplot
# Usage: tcpf2xgr tracefile <xgraph | gnuplot> [name]
#
PATH=$PATH:../../bin:.
PROGNAME=$0
if [ $# -lt 2 ]; then
	echo "Usage: $0 tracefile <xgraph | gnuplot> testname"
	exit 1;
fi
GNAME=$1
if [ $# -eq 3 ]; then
	GNAME=$3;
fi
PROGDIR=`dirname $PROGNAME`
tclsh $PROGDIR/tcpfull-summarize.tcl $1 $1
tclsh $PROGDIR/tcpfull-summarize.tcl $1 $1.r reverse
tclsh $PROGDIR/cplot.tcl $2 $GNAME.forw \
	$1.p "segments sent" \
	$1.acks "acks w/data rcvd" \
	$1.packs "pure acks rcvd" \
	$1.d "drops" \
	$1.es "zero-len segments sent" \
	$1.ctrl "SYN or FIN" \
	$1.ecn "EcnEcho ACKs" \
	$1.cact "Cong Action" \
	$1.sack "Acks w/SACK info" | $2 &

tclsh $PROGDIR/cplot.tcl $2 $GNAME.REV $1.r.p "segments sent" \
	$1.r.acks "acks w/data rcvd" \
	$1.r.packs "pure acks rcvd" \
	$1.r.d "drops" \
	$1.r.es "zero-len segments sent" \
	$1.r.ctrl "SYN or FIN" \
	$1.r.ecn "EcnEcho ACKs" \
	$1.r.cact "Cong Action" \
	$1.r.sack "Acks w/SACK info" | $2 &

sleep 2
rm -f $1.p $1.acks $1.packs $1.d $1.ctrl $1.es $1.ecn $1.cact $1.sack
rm -f $1.r.p $1.r.acks $1.r.packs $1.r.d $1.r.ctrl $1.r.es $1.r.ecn $1.r.cact $1.r.sack
