1f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes#!/bin/bash 2f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 3f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 4f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# 5f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# Use of this source code is governed by a BSD-style license 6f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# that can be found in the LICENSE file in the root of the source 7f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# tree. An additional intellectual property rights grant can be found 8f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# in the file PATENTS. All contributing project authors may 9f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# be found in the AUTHORS file in the root of the source tree. 10f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 11f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# To set up in e.g. Eclipse, run a separate shell and pipe the output from the 12f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# test into this script. 13f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# 14f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# In Eclipse, that amounts to creating a Run Configuration which starts 15f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# "/bin/bash" with the arguments "-c [trunk_path]/out/Debug/modules_unittests 16f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# --gtest_filter=*BweTest* | [trunk_path]/webrtc/modules/ 17f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# remote_bitrate_estimator/test/plot_bars.sh 18f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 19f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# This script supports multiple figures (windows), the figure is specified as an 20f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# identifier at the first argument after the PLOT command. Each figure has a 21f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# single y axis and a dual y axis mode. If any line specifies an axis by ending 22f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# with "#<axis number (1 or 2)>" two y axis will be used, the first will be 23f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# assumed to represent bitrate (in kbps) and the second will be assumed to 24f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# represent time deltas (in ms). 25f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 26f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaeslog=$(</dev/stdin) 27f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 28f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes# Plot histograms. 29f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaesfunction gen_gnuplot_bar_input { 30f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_start=1 31f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_end=3.75 32f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes bars=$(echo "$log" | grep "BAR") 33f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 34f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes labels=$(echo "$log" | grep "^LABEL") 35f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes figures=($(echo "$bars" | cut -f 2 | sort | uniq)) 36f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 37d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes echo "reset" # Clears previous settings. 38f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 39f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set title font 'Verdana,22'" 40f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set xtics font 'Verdana,24'" 41f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set ytics font 'Verdana,14'" 42f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set ylabel font 'Verdana,16'" 43f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 44f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set xrange[$x_start:$x_end]" 45f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set style fill solid 0.5" 46f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set style fill solid border -1" 47f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 48d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes declare -a ydist=(11.5 10.5 10.5) # Used to correctly offset the y label. 49d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes i=0 50f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes for figure in "${figures[@]}" ; do 51f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 52f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set terminal wxt $figure size 440,440 dashed" 53d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes echo "set ylabel offset ${ydist[$i]}, -3" 54d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes (( i++ )) 55f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 56f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes title=$(echo "$labels" | grep "^LABEL.$figure" | cut -f 3 | \ 57f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes head -n 1 | sed 's/_/ /g') 58f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes y_label=$(echo "$labels" | grep "^LABEL.$figure" | cut -f 4 | \ 59f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes head -n 1 | sed 's/_/ /g') 60f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 61f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # RMCAT flows. 62f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes num_flows=$(echo "$labels" | grep "^LABEL.$figure" | cut -f 5 | \ 63f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes head -n 1) 64f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 65f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # RMCAT algorithm 1. 66f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_label_1=$(echo "$log" | grep "BAR.$figure" | cut -f 3 | sed 's/_/\t/g' \ 67f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes | cut -f 1 | sort | uniq | head -n 1 ) 68f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 69f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # RMCAT algorithm 2. 70f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_label_2=$(echo "$log" | grep "BAR.$figure" | cut -f 3 | sed 's/_/\t/g' \ 71f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes | cut -f 1 | sort | uniq | sed -n 2p) 72f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 73f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_labels="('$x_label_1' 2, '$x_label_2' 3)" 74f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes tcp_flow=false 75f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 76f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes tcp_space=0.2 # Extra horizontal space between bars. 77f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 78f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # Parse labels if there are other flows in addition to RMCAT ones. 79f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes IFS='x' read -ra split_label_1 <<< "$x_label_1" 80f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 81f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes if (( ${#split_label_1[@]} > "1" )); then 82f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes tcp_flow=true 83f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes box_width=$(echo "(1.0-$tcp_space/2)/$num_flows" | bc -l) 84f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set xtics font 'Verdana,16'" 85f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_labels="(" 86f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes delimiter="" 87f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes abscissa=$(echo $x_start + 0.5 + 0.5*$box_width | bc) 88f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes for label in "${split_label_1[@]}" ; do 89f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_labels+="$delimiter'$label' $abscissa" 90f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes abscissa=$(echo $abscissa + $box_width | bc) 91f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes delimiter=", " 92f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes done 93f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes abscissa=$(echo $abscissa + $tcp_space | bc) 94f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes IFS='x' read -ra split_label_2 <<< "$x_label_2" 95f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes for label in "${split_label_2[@]}" ; do 96f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_labels+="$delimiter'$label' $abscissa" 97f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes abscissa=$(echo $abscissa + $box_width | bc) 98f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes done 99f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_labels="$x_labels)" 100f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes else 101f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes box_width=$(echo 1.0/$num_flows | bc -l) 102f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes fi 103f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 104f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set boxwidth $box_width" 105f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 106f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # Plots can be directly exported to image files. 107f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes file_name=$(echo "$labels" | grep "^LABEL.$figure" | cut -f 5 | head -n 1) 108f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 109f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes y_max=0 # Used to scale the plot properly. 110f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 111d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes # Scale all latency plots with the same vertical scale. 112d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes delay_figure=5 113d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes if (( $figure==$delay_figure )) ; then 114e2cb1f12c3d1c5500de1b733dfc8bbfea504d89fCesar Magalhaes y_max=400 115d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes else # Take y_max = 1.1 * highest plot value. 116d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes 117d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes # Since only the optimal bitrate for the first flow is being ploted, 118d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes # consider only this one for scalling purposes. 119d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes data_sets=$(echo "$bars" | grep "LIMITERRORBAR.$figure" | cut -f 3 | \ 120d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes sed 's/_/\t/g' | cut -f 1 | sort | uniq) 121d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes 122d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes if (( ${#data_sets[@]} > "0" )); then 123d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes for set in $data_sets ; do 124d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes y=$(echo "$bars" | grep "LIMITERRORBAR.$figure.$set" | cut -f 8 | \ 125d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes head -n 1) 126d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes if (( $(bc <<< "$y > $y_max") == 1 )); then 127d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes y_max=$y 128d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes fi 129d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes done 130d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes fi 131f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 132d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes data_sets=$(echo "$bars" | grep "ERRORBAR.$figure" | cut -f 3 | \ 133d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes sort | uniq) 134d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes if (( ${#data_sets[@]} > "0" )); then 135d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes for set in $data_sets ; do 136d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes y=$(echo "$bars" | grep "ERRORBAR.$figure.$set" | cut -f 6 | \ 137d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes head -n 1) 138d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes if (( $(bc <<< "$y > $y_max") == 1 )) ; then 139d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes y_max=$y 140d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes fi 141d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes done 142d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes fi 143d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes 144d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes data_sets=$(echo "$bars" | grep "BAR.$figure" | cut -f 3 | sort | uniq) 145f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 146f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes for set in $data_sets ; do 147d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes y=$(echo "$bars" | grep "BAR.$figure.$set" | cut -f 4 | head -n 1) 148f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes if (( $(bc <<< "$y > $y_max") == 1 )) ; then 149f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes y_max=$y 150f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes fi 151f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes done 152f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 153d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes y_max=$(echo $y_max*1.1 | bc) 154f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes fi 155f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 156d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes 157f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set ylabel \"$y_label\"" 158f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set yrange[0:$y_max]" 159f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 160f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set multiplot" 161f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 162f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # Plot bars. 163f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes data_sets=$(echo "$bars" | grep "BAR.$figure" | cut -f 3 | sort | uniq) 164f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 165f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set xtics $x_labels" 166f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "plot '-' using 1:4:2 with boxes lc variable notitle" 167f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 168f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo 169f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 170f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes color=11 # Green. 171f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_bar=$(echo $x_start + 0.5 + 0.5*$box_width | bc) 172f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes for set in $data_sets ; do 173f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo -n "$x_bar $color " 174f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "$bars" | grep "BAR.$figure.$set" | cut -f 3,4 175f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 176f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # Add extra space if TCP flows are being plotted. 177f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes if $tcp_flow && \ 178f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes (( $(bc <<< "$x_bar < $x_start + 1.5 - 0.5*$tcp_space") == 1 )) && \ 179f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes (( $(bc <<< "$x_bar + $box_width > $x_start + 1.5 + 0.5*$tcp_space") \ 180f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes == 1 )); then 181f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_bar=$(echo $x_bar + $tcp_space | bc) 182f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes fi 183f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 184f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_bar=$(echo $x_bar + $box_width | bc) 185f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 186f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes if (( $(bc <<< "$x_bar > 2.5") == 1 )) ; then 187f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes color=12 # Blue. 188f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes fi 189f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # Different bar color for TCP flows: 190f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes if $tcp_flow && \ 191f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes (( $(bc <<< "(100*$x_bar)%100 < 50") == 1 )) 192f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes then 193f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes color=18 # Gray. 194f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes fi 195f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes done 196f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "e" 197f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 198f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # Plot Baseline bars, e.g. one-way path delay on latency plots. 199f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes data_sets=$(echo "$log" | grep "BASELINE.$figure" | cut -f 3 | sort | uniq) 200f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 201d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes if (( ${#data_sets} > "0" )); then 202d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes echo "set xtics $x_labels" 203d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes echo "plot '-' using 1:4:2 with boxes lc variable notitle" 204f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 205d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes echo 206f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 207d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes color=18 # Gray. 208d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes x_bar=$(echo $x_start + 0.5 + 0.5*$box_width | bc) 209d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes for set in $data_sets ; do 210d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes echo -n "$x_bar $color " 211d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes echo "$log" | grep "BASELINE.$figure.$set" | cut -f 3,4 212f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 213d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes # Add extra space if TCP flows are being plotted. 214d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes if $tcp_flow && \ 215d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes (( $(bc <<< "$x_bar < $x_start + 1.5 - 0.5*$tcp_space") == 1 )) && \ 216d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes (( $(bc <<< "$x_bar + $box_width > $x_start + 1.5 \ 217d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes + 0.5*$tcp_space") == 1 )); then 218d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes x_bar=$(echo $x_bar + $tcp_space | bc) 219d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes fi 220f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 221d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes x_bar=$(echo $x_bar + $box_width | bc) 222f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 223d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes done 224d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes echo "e" 225d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes fi 226f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 227f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # Plot vertical error lines, e.g. y +- sigma. 228f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes data_sets=$(echo "$bars" | grep "ERRORBAR.$figure" | cut -f 3 | sort | uniq) 229f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 230f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes if (( ${#data_sets} > "0" )); then 231f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 232f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set key left" 233f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes error_title=$(echo "$bars" | grep "ERRORBAR.$figure" | cut -f 7 | \ 234f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes head -n 1 | sed 's/_/ /g') 235f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 236f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set xtics $x_labels" 237f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "plot '-' using 1:3:4:5 title '$error_title' with yerr" 238f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 239f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_error_line=$(echo $x_start + 0.5 + 0.5*$box_width | bc) 240f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes for set in $data_sets ; do 241f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo -n "$x_error_line " 242f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "$bars" | grep "ERRORBAR.$figure.$set" | cut -f 3,4,5,6 243f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 244f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # Add extra space if TCP flows are being plotted. 245f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes if $tcp_flow && \ 246f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes (( $(bc <<< "$x_error_line < $x_start + 1.5 - 0.5*$tcp_space") == 1 \ 247f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes )) && (( $(bc <<< "$x_error_line + $box_width > $x_start + 1.5 \ 248f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes + 0.5*$tcp_space") == 1 )); then 249f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_error_line=$(echo $x_error_line + $tcp_space | bc) 250f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes fi 251f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 252f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes x_error_line=$(echo $x_error_line + $box_width | bc) 253f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes done 254f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "e" 255f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes fi 256f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 257f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes # Plot horizontal dashed lines, e.g. y = optimal bitrate. 258f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes data_sets=$(echo "$bars" | grep "LIMITERRORBAR.$figure" | cut -f 3 \ 259f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes | sort | uniq) 260f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes if (( ${#data_sets} > "0" )); then 261f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 262f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set style line 1 lt 1 lw 3 pt 3 ps 0 linecolor rgb 'black'" 263f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 264f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes limit_titles=$(echo "$bars" | grep "LIMITERRORBAR.$figure" | cut -f 9 \ 265f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes | sort | uniq) 266f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 267f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes for title in $limit_titles ; do 268f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes y_max=$(echo "$bars" | grep "LIMITERRORBAR.$figure" | grep "$title" \ 269f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes | cut -f 8 | head -n 1) 270f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 271f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes retouched_title=$(echo "$title" | sed 's/#/\t/g' | cut -f 1 \ 272f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes | sed 's/_/ /g') 273f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 274f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set key right top" 275f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "set xtics $x_labels" 276f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "plot $y_max lt 7 lw 1 linecolor rgb 'black' \ 277f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes title '$retouched_title'" 278f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes done 279f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 280f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes fi 281f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes 282f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes echo "unset multiplot" 283f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes done 284f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaes} 285d55ce2ddb9eb67e237725820b751f404df6dba0dCesar Magalhaes 286f24b2bc48ca0e62194d6a1bdb1cacd37c4d0a635Cesar Magalhaesgen_gnuplot_bar_input | gnuplot -persist 287