1#!/bin/bash 2 3# Copyright 2018 Google LLC 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# https://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# 18# Render a trace using gnuplot into a png file. 19# 20 21if [ -z "$1" ]; then 22 echo "Usage: time_sequence_gnuplot.sh path/to/trace output.png" 23 exit 1 24fi 25 26if [ ! -f "$1" ]; then 27 echo "File $1 does not exist or is not a file" 28 exit 1 29fi 30 31if [ -z "$2" ]; then 32 echo "Output file not specified" 33 exit 1 34fi 35 36if [ ! -x "$QUIC_TRACE_CONV_BIN" ]; then 37 QUIC_TRACE_CONV_BIN="$0.runfiles/com_google_quic_trace/tools/quic_trace_to_time_sequence_gnuplot" 38fi 39 40if [ ! -x "$QUIC_TRACE_CONV_BIN" ]; then 41 echo "Cannot find conversion tool binary" 42 exit 1 43fi 44 45TMPDIR="$(mktemp -d)" 46for event_type in send ack loss; do 47 "$QUIC_TRACE_CONV_BIN" --sequence=$event_type < "$1" > "$TMPDIR/$event_type.txt" 48done 49 50if [ -z "$GNUPLOT_SIZE" ]; then 51 GNUPLOT_SIZE="7680,4320" 52fi 53if [ -z "$GNUPLOT_TERMINAL" ]; then 54 GNUPLOT_TERMINAL="png size $GNUPLOT_SIZE" 55fi 56 57 58gnuplot <<EOF 59set terminal $GNUPLOT_TERMINAL 60set output "$2" 61plot \ 62 "$TMPDIR/send.txt" with lines lt rgb "blue" title "Sent", \ 63 "$TMPDIR/ack.txt" with lines lt rgb "green" title "Ack", \ 64 "$TMPDIR/loss.txt" with lines lt rgb "red" title "Loss" 65EOF 66 67rm -rf "$TMPDIR" 68