| 1 |
eval 'exec perl $0 -S ${1+"$@"}' # -*- perl -*- |
| 2 |
if 0; |
| 3 |
|
| 4 |
require 5.001; |
| 5 |
|
| 6 |
# |
| 7 |
# set_flow_id.pl |
| 8 |
# Copyright (C) 1997 by USC/ISI |
| 9 |
# |
| 10 |
# Derived from |
| 11 |
# Id: rbp_hack_attr.pl,v 1.1 1997/10/08 20:31:46 johnh Exp |
| 12 |
# from LSAM Project's rate-based pacing work. |
| 13 |
# |
| 14 |
# Copyright (c) 1997 University of Southern California. |
| 15 |
# All rights reserved. |
| 16 |
# |
| 17 |
# Redistribution and use in source and binary forms are permitted |
| 18 |
# provided that the above copyright notice and this paragraph are |
| 19 |
# duplicated in all such forms and that any documentation, advertising |
| 20 |
# materials, and other materials related to such distribution and use |
| 21 |
# acknowledge that the software was developed by the University of |
| 22 |
# Southern California, Information Sciences Institute. The name of the |
| 23 |
# University may not be used to endorse or promote products derived from |
| 24 |
# this software without specific prior written permission. |
| 25 |
# |
| 26 |
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
| 27 |
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 28 |
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 29 |
# |
| 30 |
|
| 31 |
|
| 32 |
sub usage { |
| 33 |
print STDERR <<END; |
| 34 |
usage: $0 |
| 35 |
|
| 36 |
Hack the attribute field in ns trace output to make it |
| 37 |
be the source/dest we want. |
| 38 |
|
| 39 |
By default, sets the attribute to the minimum of the source or destination. |
| 40 |
Options: |
| 41 |
-m take minimum (default) |
| 42 |
-s take source |
| 43 |
-d take destination |
| 44 |
END |
| 45 |
exit 1; |
| 46 |
} |
| 47 |
|
| 48 |
#use strict; |
| 49 |
|
| 50 |
use Getopt::Long; |
| 51 |
&usage if ($#ARGV >= 0 && $ARGV[0] eq '-?'); |
| 52 |
my(%opts); |
| 53 |
&GetOptions(\%opts, qw(m s d)); |
| 54 |
# &usage if ($#ARGV < 0); |
| 55 |
|
| 56 |
my($MODE_MIN, $MODE_SRC, $MODE_DEST) = (0..10); |
| 57 |
my($mode) = $MODE_MIN; |
| 58 |
$mode = $MODE_MIN if (defined($opts{'m'})); |
| 59 |
$mode = $MODE_SRC if (defined($opts{'s'})); |
| 60 |
$mode = $MODE_DEST if (defined($opts{'d'})); |
| 61 |
|
| 62 |
while (<>) { |
| 63 |
if (/^[^-+hdrE]/) { |
| 64 |
print; |
| 65 |
} else { |
| 66 |
chomp; |
| 67 |
my(@f) = split(/ /); |
| 68 |
if ($f[0] ne "E") { |
| 69 |
($hacky_src, $hacky_dest) = @f[8,9]; |
| 70 |
($src) = split(/\./, $hacky_src); |
| 71 |
($dest) = split(/\./, $hacky_dest); |
| 72 |
($min) = ($src < $dest) ? $src : $dest; |
| 73 |
$f[7] = $min if ($mode == $MODE_MIN); |
| 74 |
$f[7] = $src if ($mode == $MODE_SRC); |
| 75 |
$f[7] = $dest if ($mode == $MODE_DEST); |
| 76 |
} else { |
| 77 |
($src, $dest) = @f[2,3]; |
| 78 |
$min = ($src < $dest) ? $src : $dest; |
| 79 |
$f[6] = $min if ($mode == $MODE_MIN); |
| 80 |
$f[6] = $src if ($mode == $MODE_SRC); |
| 81 |
$f[6] = $dest if ($mode == $MODE_DEST); |
| 82 |
} |
| 83 |
print join(" ", @f), "\n"; |
| 84 |
}; |
| 85 |
} |
| 86 |
|
| 87 |
exit 0; |
| 88 |
|