raw2xg-sctp
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:6k
源码类别:

通讯编程

开发平台:

Visual C++

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