| 1 |
eval 'exec perl -S $0 ${1+"$@"}' # -*-perl-*- |
| 2 |
if 0; |
| 3 |
|
| 4 |
require 5.001; |
| 5 |
|
| 6 |
($progname) = ($0 =~ m!([^/]+)$!); |
| 7 |
sub usage { |
| 8 |
print STDERR <<END; |
| 9 |
usage: $progname [options] [trace files...] |
| 10 |
|
| 11 |
options: |
| 12 |
-a plot SACKs when leaving data recevier |
| 13 |
-A plot SACKs when arriving at data sender |
| 14 |
-f plot FORWARD CUM TSNs when leaving data sender |
| 15 |
-F plot FORWARD CUM TSNs when received at data recevier |
| 16 |
-s SCALE scale TSN numbers by SCALE |
| 17 |
-n FACTOR scale flow number by FACTOR |
| 18 |
-m MODULUS treat TSN numbers as mod MODULUS |
| 19 |
-q show queueing delay |
| 20 |
-t TITLE title of test |
| 21 |
|
| 22 |
Traditional ``wrapping'' ns plots (as called from the test scripts) |
| 23 |
can be generated with -s 0.01 -m 90. |
| 24 |
END |
| 25 |
exit 1; |
| 26 |
}; |
| 27 |
$usage = "usage: $progname [-a] [trace files...]\n"; |
| 28 |
|
| 29 |
require 'getopts.pl'; |
| 30 |
&Getopts('aAfFs:m:n:qt:') || usage; |
| 31 |
|
| 32 |
$c = 0; |
| 33 |
@pplus = @pminus = (); |
| 34 |
@splus = @sminus = @srec = (); |
| 35 |
@rplus = @rminus = @rrec = (); |
| 36 |
@d = @lu = @ld = (); |
| 37 |
%q_time_seg = (); |
| 38 |
|
| 39 |
$plot_sacks_sent = defined($opt_a); |
| 40 |
$plot_sacks_received = defined($opt_A); |
| 41 |
$plot_forward_sent = defined($opt_f); |
| 42 |
$plot_forward_received = defined($opt_F); |
| 43 |
|
| 44 |
$scale = defined($opt_s) ? $opt_s : 1; |
| 45 |
$modulus = defined($opt_m) ? $opt_m : 2 ** 31; |
| 46 |
$flow_factor = defined($opt_n) ? $opt_n : 1; |
| 47 |
|
| 48 |
$plot_queueing_delay = defined($opt_q); |
| 49 |
|
| 50 |
$file = $sacks = ''; |
| 51 |
|
| 52 |
sub translate_point { |
| 53 |
my($time, $seq, $flow) = @_; |
| 54 |
return ($time, $flow * $flow_factor + ($seq % $modulus) * $scale); |
| 55 |
} |
| 56 |
|
| 57 |
while (<>) { |
| 58 |
$dfile = $ARGV; |
| 59 |
@F = split; |
| 60 |
/testName/ && ($file = $F[2], next); |
| 61 |
|
| 62 |
/^\- / && do { |
| 63 |
$c = $F[7] if ($c < $F[7]); |
| 64 |
$is_init = ($F[6] =~ /I/); |
| 65 |
next if ($is_init); |
| 66 |
$is_sack = ($F[6] =~ /S/); |
| 67 |
$is_nrsack = ($F[6] =~ /N/); |
| 68 |
next if (($is_sack || $is_nrsack) && !$plot_sacks_sent); |
| 69 |
$is_forward = ($F[6] =~ /R/); |
| 70 |
next if ($is_forward && !$plot_forward_sent); |
| 71 |
$is_heartbeat = ($F[6] =~ /H/); |
| 72 |
$is_heartbeat_ack = ($F[6] =~ /B/); |
| 73 |
next if ($is_heartbeat || $is_heartbeat_ack); |
| 74 |
|
| 75 |
($x, $y) = translate_point(@F[1, 11, 7]); |
| 76 |
$statement = "$x $y\n"; |
| 77 |
|
| 78 |
if ($is_sack || $is_nrsack) { |
| 79 |
push(@sminus, $statement); |
| 80 |
} else { |
| 81 |
if ($is_forward) { |
| 82 |
push(@rminus, $statement); |
| 83 |
} else { |
| 84 |
push(@pminus, $statement); |
| 85 |
}; |
| 86 |
}; |
| 87 |
next; |
| 88 |
}; |
| 89 |
|
| 90 |
/^\+ / && do { |
| 91 |
if ($plot_queueing_delay) { |
| 92 |
$c = $F[7] if ($c < $F[7]); |
| 93 |
$is_init = ($F[6] =~ /I/); |
| 94 |
next if ($is_init); |
| 95 |
$is_sack = ($F[6] =~ /S/); |
| 96 |
$is_nrsack = ($F[6] =~ /N/); |
| 97 |
next if (($is_sack || $is_nrsack) && !$plot_sacks_sent); |
| 98 |
$is_forward = ($F[6] =~ /R/); |
| 99 |
next if ($is_forward && !$plot_forward_sent); |
| 100 |
$is_heartbeat = ($F[6] =~ /H/); |
| 101 |
$is_heartbeat_ack = ($F[6] =~ /B/); |
| 102 |
next if ($is_heartbeat || $is_heartbeat_ack); |
| 103 |
|
| 104 |
($x, $y) = translate_point(@F[1, 11, 7]); |
| 105 |
$statement = "$x $y\n"; |
| 106 |
|
| 107 |
if ($is_sack || $is_nrsack) { |
| 108 |
push(@splus, $statement); |
| 109 |
} else { |
| 110 |
if ($is_forward) { |
| 111 |
push(@rplus, $statement); |
| 112 |
} else { |
| 113 |
push(@pplus, $statement); |
| 114 |
}; |
| 115 |
}; |
| 116 |
}; |
| 117 |
next; |
| 118 |
}; |
| 119 |
|
| 120 |
/^r / && do { |
| 121 |
$c = $F[7] if ($c < $F[7]); |
| 122 |
$is_init = ($F[6] =~ /I/); |
| 123 |
next if ($is_init); |
| 124 |
$is_sack = ($F[6] =~ /S/); |
| 125 |
$is_nrsack = ($F[6] =~ /N/); |
| 126 |
next if (($is_sack || $is_nrsack) && !$plot_sacks_received); |
| 127 |
$is_forward = ($F[6] =~ /R/); |
| 128 |
next if ($is_forward && !$plot_forward_received); |
| 129 |
$is_heartbeat = ($F[6] =~ /H/); |
| 130 |
$is_heartbeat_ack = ($F[6] =~ /B/); |
| 131 |
next if ($is_heartbeat || $is_heartbeat_ack); |
| 132 |
|
| 133 |
($x, $y) = translate_point(@F[1, 11, 7]); |
| 134 |
$statement = "$x $y\n"; |
| 135 |
|
| 136 |
if ($is_sack || $is_nrsack) { |
| 137 |
push(@srec, $statement); |
| 138 |
} else { |
| 139 |
if($is_forward) { |
| 140 |
push(@rrec, $statement); |
| 141 |
}; |
| 142 |
}; |
| 143 |
next; |
| 144 |
}; |
| 145 |
|
| 146 |
|
| 147 |
/^d / && do { |
| 148 |
$is_init = ($F[6] =~ /I/); |
| 149 |
next if ($is_init); |
| 150 |
$is_heartbeat = ($F[6] =~ /H/); |
| 151 |
$is_heartbeat_ack = ($F[6] =~ /B/); |
| 152 |
next if ($is_heartbeat || $is_heartbeat_ack); |
| 153 |
|
| 154 |
($x, $y) = translate_point(@F[1, 11, 7]); |
| 155 |
push(@d, "$x $y\n"); |
| 156 |
next; |
| 157 |
}; |
| 158 |
/link-down/ && (push(@ld, $F[1]), next); |
| 159 |
/link-up/ && (push(@lu, $F[1]), next); |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
if ($file eq '') { |
| 165 |
($file) = ($dfile =~ m!([^/]+)$!); |
| 166 |
} |
| 167 |
|
| 168 |
$title = defined($opt_t) ? $opt_t : $file; |
| 169 |
print "TitleText: $title\n" . |
| 170 |
"Device: Postscript\n" . |
| 171 |
"BoundBox: true\n" . |
| 172 |
"Ticks: true\n" . |
| 173 |
(defined($opt_q) ? "" : "NoLines: true\n") . |
| 174 |
"Markers: true\n" . |
| 175 |
"XUnitText: time\n" . |
| 176 |
"YUnitText: chunks\n"; |
| 177 |
|
| 178 |
if ($plot_queueing_delay) { |
| 179 |
@sorted_pplus = sort (@pplus); |
| 180 |
print "\n\"data sent (buffered)\n", @sorted_pplus; |
| 181 |
} else { |
| 182 |
printf "\n\"[data sent (buffered)]\n0 1\n"; |
| 183 |
}; |
| 184 |
|
| 185 |
@sorted_pminus = sort (@pminus); |
| 186 |
print "\n\"data sent\n", @sorted_pminus; |
| 187 |
|
| 188 |
if ($plot_sacks_received) { |
| 189 |
@sorted_srec = sort (@srec); |
| 190 |
|
| 191 |
if ($is_sack) { |
| 192 |
print "\n\"sack received\n", @sorted_srec; |
| 193 |
} |
| 194 |
else { |
| 195 |
print "\n\"nr-sack received\n", @sorted_srec; |
| 196 |
} |
| 197 |
} else { |
| 198 |
printf "\n\"[sack received]\n0 1\n"; |
| 199 |
}; |
| 200 |
|
| 201 |
# |
| 202 |
# Repeat the first line twice in the drops file because often we have only |
| 203 |
# one drop and xgraph won't print marks for data sets with only one point. |
| 204 |
# |
| 205 |
if(@d) { |
| 206 |
@sorted_d = sort (@d); |
| 207 |
print "\n\"drops\n", @d[0..3], @sorted_d; |
| 208 |
} else { |
| 209 |
print "\n\"[drops]\n0 1\n"; |
| 210 |
} |
| 211 |
|
| 212 |
if ($plot_sacks_sent) { |
| 213 |
@sorted_splus = sort (@splus); |
| 214 |
if ($is_sack) { |
| 215 |
print "\n\"sack sent\n", @sorted_splus; |
| 216 |
} |
| 217 |
else { |
| 218 |
print "\n\"nr-sack sent\n", @sorted_splus; |
| 219 |
} |
| 220 |
} else { |
| 221 |
printf "\n\"[sack sent]\n0 1\n"; |
| 222 |
}; |
| 223 |
|
| 224 |
# Commented out by ALC because doesn't seem to be too useful and is wasting |
| 225 |
# limited colored shapes provided by xgraph. |
| 226 |
# |
| 227 |
#if ($plot_sacks_sent && $plot_queueing_delay) { |
| 228 |
# @sorted_sminus = sort (@sminus); |
| 229 |
# print "\n\"sack sent (buffered)\n", @sorted_sminus; |
| 230 |
#} else { |
| 231 |
# printf "\n\"[sack sent (buffered)]\n0 1\n"; |
| 232 |
#}; |
| 233 |
|
| 234 |
if ($plot_forward_received) { |
| 235 |
@sorted_rrec = sort (@rrec); |
| 236 |
print "\n\"forward received\n", @sorted_rrec; |
| 237 |
} else { |
| 238 |
printf "\n\"[forward received]\n0 1\n"; |
| 239 |
}; |
| 240 |
|
| 241 |
if ($plot_forward_sent) { |
| 242 |
@sorted_rplus = sort (@rplus); |
| 243 |
print "\n\"forward sent\n", @sorted_rplus; |
| 244 |
} else { |
| 245 |
printf "\n\"[forward sent]\n0 1\n"; |
| 246 |
}; |
| 247 |
|
| 248 |
# Commented out by ALC because doesn't seem to be too useful and is wasting |
| 249 |
# limited colored shapes provided by xgraph. |
| 250 |
# |
| 251 |
#if ($plot_forward_sent && $plot_queueing_delay) { |
| 252 |
# @sorted_rminus = sort (@rminus); |
| 253 |
# print "\n\"forward sent (buffered)\n", @sorted_rminus; |
| 254 |
#} else { |
| 255 |
# printf "\n\"[forward sent (buffered)]\n0 1\n"; |
| 256 |
#}; |
| 257 |
|
| 258 |
$c++; |
| 259 |
print "\n"; |
| 260 |
foreach $i (@ld) { |
| 261 |
print "\"link-down\n$i 0\n$i $c\n"; |
| 262 |
} |
| 263 |
foreach $i (@lu) { |
| 264 |
print "\"link-up\n$i 0\n$i $c\n"; |
| 265 |
} |
| 266 |
|
| 267 |
exit 0; |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|