This file is indexed.

/usr/bin/mm-throughput-graph is in mahimahi 0.96-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/env perl

use warnings;
use strict;
use POSIX;

sub usage
{
  die qq{Usage: $0 MS_PER_BIN [filename]\n};
}

if ( scalar @ARGV < 1 or scalar @ARGV > 2 ) {
  usage;
}

my $MS_PER_BIN = shift;

if ( $MS_PER_BIN !~ m{^\d+$} ) {
  usage;
}

sub ms_to_bin {
  return int( $_[0] / $MS_PER_BIN );
}

sub bin_to_seconds {
  return sprintf q{%.3f}, $_[0] * $MS_PER_BIN / 1000.0;
}

my ( %capacity, %arrivals, %departures );

my $first_timestamp = undef;
my $last_timestamp = undef;
my $base_timestamp = undef;
my $capacity_sum;
my $arrival_sum;
my $departure_sum;
my @delays;
my %signal_delay;

LINE: while ( <> ) {
  chomp;

  if ( m{^# base timestamp: (\d+)} ) {
    if ( defined $base_timestamp ) {
      die "base timestamp multiply defined";
    } else {
      $base_timestamp = $1;
    }
    next LINE;
  } elsif ( m{^#} ) {
    next LINE;
  }

  # parse and validate line
  my ( $timestamp, $event_type, $num_bytes, $delay ) = split /\s+/, $_;

  if ( not defined $num_bytes ) {
    die q{Format: timestamp event_type num_bytes [delay]};
  }

  if ( $timestamp !~ m{^\d+$} ) {
    die qq{Invalid timestamp: $timestamp};
  }

  if ( $num_bytes !~ m{^\d+$} ) {
    die qq{Invalid byte count: $num_bytes};
  }

  if ( not defined $base_timestamp ) {
    die "logfile is missing base timestamp";
  }

  $timestamp -= $base_timestamp; # correct for startup time variation

  if ( not defined $last_timestamp ) {
    $last_timestamp = $first_timestamp = $timestamp;
  }

  $last_timestamp = max( $timestamp, $last_timestamp );

  my $num_bits = $num_bytes * 8;
  my $bin = ms_to_bin( $timestamp );

  # process the event
  if ( $event_type eq q{+} ) {
    $arrivals{ $bin } += $num_bits;
    $arrival_sum += $num_bits;
  } elsif ( $event_type eq q{#} ) {
    $capacity{ $bin } += $num_bits;
    $capacity_sum += $num_bits;
  } elsif ( $event_type eq q{-} ) {
    if ( not defined $delay ) {
      die q{Departure format: timestamp - num_bytes delay};
    }
    $departures{ $bin } += $num_bits;

    if ( $delay < 0 ) {
	die qq{Invalid delay: $delay};
    }

    if ( $timestamp - $delay < 0 ) {
	die qq{Invalid timestamp and delay: ts=$timestamp, delay=$delay};
    }

    push @delays, $delay;
    $departure_sum += $num_bits;

    $signal_delay{ $timestamp - $delay } = min( $delay,
						(defined $signal_delay{ $timestamp - $delay })
						? $signal_delay{ $timestamp - $delay }
						: POSIX::DBL_MAX );
  } else {
    die qq{Unknown event type: $event_type};
  }
}

sub min {
  my $minval = POSIX::DBL_MAX;

  for ( @_ ) {
    if ( $_ < $minval ) {
      $minval = $_;
    }
  }

  return $minval;
}

sub max {
  my $maxval = - POSIX::DBL_MAX;

  for ( @_ ) {
    if ( $_ > $maxval ) {
      $maxval = $_;
    }
  }

  return $maxval;
}

if ( not defined $first_timestamp ) {
    die q{Must have at least one event};
}

# calculate statistics
my $duration = ($last_timestamp - $first_timestamp) / 1000.0;
my $average_capacity = ($capacity_sum / $duration) / 1000000.0;
my $average_ingress = ($arrival_sum / $duration) / 1000000.0;
my $average_throughput = ($departure_sum / $duration) / 1000000.0;

if ( scalar @delays == 0 ) {
  die q{Must have at least one departure event};
}

@delays = sort { $a <=> $b } @delays;

my $pp95 = $delays[ 0.95 * scalar @delays ];

# measure signal delay every millisecond
# = minimum time for a message created at time t to get to receiver
my @signal_delay_samples = sort { $a <=> $b } keys %signal_delay;

for ( my $ts = $signal_delay_samples[ -1 ]; $ts >= $signal_delay_samples[ 0 ]; $ts-- ) {
  if ( not defined $signal_delay{ $ts } ) {
    $signal_delay{ $ts } = $signal_delay{ $ts + 1 } + 1;
  }
}

my @signal_delays = sort { $a <=> $b } values %signal_delay;
my $pp95s = $signal_delays[ 0.95 * scalar @signal_delays ];

printf STDERR qq{Average capacity: %.2f Mbits/s\n}, $average_capacity;
printf STDERR qq{Average throughput: %.2f Mbits/s (%.1f%% utilization)\n}, $average_throughput, 100.0 * $average_throughput / $average_capacity;
printf STDERR qq{95th percentile per-packet queueing delay: %.0f ms\n}, $pp95;
printf STDERR qq{95th percentile signal delay: %.0f ms\n}, $pp95s;

# make graph
my $earliest_bin = min( keys %arrivals, keys %capacity, keys %departures );
my $latest_bin = max( keys %arrivals, keys %capacity, keys %departures );

if ( $earliest_bin == $latest_bin ) {
  die q{MS_PER_BIN is too large for length of trace};
}

my $current_buffer_occupancy = 0;

sub default {
  return defined $_[ 0 ] ? $_[ 0 ] : 0;
}

open GNUPLOT, q{| gnuplot} or die;

print GNUPLOT <<END;
set xlabel "time (s)"
set ylabel "throughput (Mbits/s)"
set key center outside top horizontal
set style fill solid 0.2 noborder
set terminal svg size 1024,560 fixed  fname 'Arial'  fsize 12 rounded solid mouse standalone name "Throughput"
set output "/dev/stdout"
END

printf GNUPLOT qq{plot [%f:%f] "-" using 1:2 title "Capacity (mean %.2f Mbits/s)" with filledcurves above x1 lw 0.5, "-" using 1:3 with lines lc rgb "#0020a0" lw 4 title "Traffic ingress (mean %.2f Mbits/s)", "-" using 1:4 with lines lc rgb "#ff6040" lw 2 title "Traffic egress (mean %.2f Mbits/s)"\n},
  $first_timestamp / 1000.0, $last_timestamp / 1000.0, $average_capacity, $average_ingress, $average_throughput;

my $output;

for ( my $bin = $earliest_bin; $bin <= $latest_bin; $bin++ ) {
    my $t = bin_to_seconds( $bin );
    my ( $cap, $arr, $dep ) = map { (default $_) / ($MS_PER_BIN / 1000.0) / 1000000.0 } ( $capacity{ $bin }, $arrivals{ $bin }, $departures{ $bin } );

    $current_buffer_occupancy += default $arrivals{ $bin };
    $current_buffer_occupancy -= default $departures{ $bin };

    $output .= qq{$t $cap $arr $dep $current_buffer_occupancy\n};
}

print GNUPLOT $output;
print GNUPLOT qq{\ne\n};
print GNUPLOT $output;
print GNUPLOT qq{\ne\n};
print GNUPLOT $output;

close GNUPLOT or die qq{$!};