]> git.sesse.net Git - bursty/blob - summarize.pl
Add a small script to deal with the fact that we might not have the entire receiver...
[bursty] / summarize.pl
1 #! /usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 my %buckets = ();
7
8 while (<>) {
9         chomp;
10         my (@x) = split /\s+/, $_;
11
12         my $num_packets = scalar @x;
13         my $num_drops = grep { /\*/ } @x;
14
15         $buckets{$num_packets}->{'num_bursts'}++;
16         $buckets{$num_packets}->{'num_drops'} += $num_drops;
17         if ($num_drops > 0) {
18                 $buckets{$num_packets}->{'bursts_with_drops'}++;
19         }
20 }
21
22 for my $n (sort { $a <=> $b } keys %buckets) {
23         my $drop_rate = $buckets{$n}->{'num_drops'} / ($n * $buckets{$n}->{'num_bursts'});
24         my $drop_event_rate = ($buckets{$n}->{'bursts_with_drops'} // 0) / $buckets{$n}->{'num_bursts'};
25         printf "%3d: drop_rate %.5f  drop_event_rate %.5f\n",
26                 $n, $drop_rate, $drop_event_rate; 
27 }