rb-wartslib 0.9.10 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -0
- data/bin/count-traces +42 -0
- data/bin/create-aspath +169 -0
- data/bin/extract-trace-addrs +98 -0
- data/bin/modify-traces +137 -0
- data/bin/scdump +18 -1
- data/bin/select-traces +275 -0
- data/bin/show-cycles +55 -0
- data/bin/split-traces-by-type +97 -0
- data/bin/stat-traces +118 -0
- data/bin/trace-gap-size-hist +159 -0
- data/bin/trace-timestamps-hist +51 -0
- data/bin/w2tr +39 -0
- data/bin/wcat +73 -0
- data/bin/wdump +18 -1
- data/ext/scext.c +2 -2
- metadata +15 -4
- data/bin/analyze-order +0 -37
data/CHANGES
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
version 0.9.11, 2007-11-29:
|
2
|
+
* added more sample code to the 'bin' subdirectory
|
3
|
+
* added GPLv2+ license header to sample code
|
4
|
+
|
1
5
|
version 0.9.10, 2007-11-28:
|
2
6
|
* added GPLv2+ license header to source files
|
3
7
|
* changed to use __HAVE_STDINT_H__ instead of __APPLE__ when including
|
data/bin/count-traces
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#############################################################################
|
4
|
+
## Prints out the count of traces in each input warts file, as well as
|
5
|
+
## the total across all files.
|
6
|
+
##
|
7
|
+
## --------------------------------------------------------------------------
|
8
|
+
## Copyright (C) 2007 The Regents of the University of California.
|
9
|
+
##
|
10
|
+
## This program is free software; you can redistribute it and/or modify
|
11
|
+
## it under the terms of the GNU General Public License as published by
|
12
|
+
## the Free Software Foundation; either version 2 of the License, or
|
13
|
+
## (at your option) any later version.
|
14
|
+
##
|
15
|
+
## This program is distributed in the hope that it will be useful,
|
16
|
+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
+
## GNU General Public License for more details.
|
19
|
+
##
|
20
|
+
## You should have received a copy of the GNU General Public License
|
21
|
+
## along with this program; if not, write to the Free Software
|
22
|
+
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
+
##
|
24
|
+
## $Id: count-traces,v 1.1 2007/11/30 01:14:47 youngh Exp $
|
25
|
+
#############################################################################
|
26
|
+
|
27
|
+
require 'rubygems'
|
28
|
+
require 'wartslib'
|
29
|
+
|
30
|
+
total = 0
|
31
|
+
ARGV.each do |path|
|
32
|
+
file = Warts::File::open path
|
33
|
+
file.add_filters Warts::File::TRACE
|
34
|
+
|
35
|
+
count = 0
|
36
|
+
file.read { count += 1 }
|
37
|
+
|
38
|
+
puts "%8d %s" % [count, path]
|
39
|
+
total += count
|
40
|
+
end
|
41
|
+
|
42
|
+
puts "%8d total" % [total]
|
data/bin/create-aspath
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#############################################################################
|
4
|
+
## Converts warts traces to AS paths.
|
5
|
+
##
|
6
|
+
## --------------------------------------------------------------------------
|
7
|
+
## Copyright (C) 2007 The Regents of the University of California.
|
8
|
+
##
|
9
|
+
## This program is free software; you can redistribute it and/or modify
|
10
|
+
## it under the terms of the GNU General Public License as published by
|
11
|
+
## the Free Software Foundation; either version 2 of the License, or
|
12
|
+
## (at your option) any later version.
|
13
|
+
##
|
14
|
+
## This program is distributed in the hope that it will be useful,
|
15
|
+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
## GNU General Public License for more details.
|
18
|
+
##
|
19
|
+
## You should have received a copy of the GNU General Public License
|
20
|
+
## along with this program; if not, write to the Free Software
|
21
|
+
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22
|
+
##
|
23
|
+
## $Id: create-aspath,v 1.1 2007/11/30 01:14:47 youngh Exp $
|
24
|
+
#############################################################################
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'ostruct'
|
28
|
+
require 'optparse'
|
29
|
+
require 'enumerator'
|
30
|
+
require 'tempfile'
|
31
|
+
|
32
|
+
require 'wartslib'
|
33
|
+
require 'asfinder'
|
34
|
+
|
35
|
+
$options = OpenStruct.new
|
36
|
+
|
37
|
+
opts = OptionParser.new
|
38
|
+
opts.banner = "Usage: create-aspath [options] <warts-file-1> <warts-file-2> ..."
|
39
|
+
|
40
|
+
opts.on("-A", "--asfinder", "=FILE",
|
41
|
+
"IP to prefix/AS mapping file in ASFinder format") do |v|
|
42
|
+
$options.asfinder = v
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("-l", "--links", TrueClass,
|
46
|
+
"prints AS links rather than AS paths") do |v|
|
47
|
+
$options.links = v
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on("-v", "--[no-]verbose", TrueClass, "show detailed progress") do |v|
|
51
|
+
$options.verbose = v
|
52
|
+
end
|
53
|
+
|
54
|
+
begin
|
55
|
+
ARGV.replace opts.parse(*ARGV)
|
56
|
+
rescue OptionParser::ParseError
|
57
|
+
$stderr.puts "ERROR: " + $!
|
58
|
+
$stderr.puts opts
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
|
62
|
+
unless $options.asfinder
|
63
|
+
$stderr.puts "ERROR: missing --asfinder argument"
|
64
|
+
$stderr.puts opts
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
#===========================================================================
|
70
|
+
|
71
|
+
# XXX only uses the first response at each hop
|
72
|
+
def extract_ippath(trace)
|
73
|
+
retval = []
|
74
|
+
retval << trace.src
|
75
|
+
|
76
|
+
dest_response = trace.find_dest_response
|
77
|
+
|
78
|
+
trace.each_hop do |hop, exists|
|
79
|
+
if exists
|
80
|
+
break if dest_response && hop == dest_response[0]
|
81
|
+
retval << trace.hop_addr(hop, 0)
|
82
|
+
else
|
83
|
+
retval << "q"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
retval << trace.dst if dest_response
|
88
|
+
retval
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
def create_aspath(asfinder, ippath)
|
93
|
+
retval = []
|
94
|
+
ippath.each do |addr|
|
95
|
+
if addr == "q"
|
96
|
+
retval << "q" unless retval[-1] == "q"
|
97
|
+
else
|
98
|
+
as, prefix, len = asfinder.get_as addr
|
99
|
+
if as
|
100
|
+
if $options.verbose
|
101
|
+
retval << ("%s:%s/%d" % [as, prefix, len])
|
102
|
+
else
|
103
|
+
retval << as
|
104
|
+
end
|
105
|
+
else
|
106
|
+
retval << "?" unless retval[-1] == "?"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
retval
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
#############################################################################
|
115
|
+
# Main
|
116
|
+
#############################################################################
|
117
|
+
|
118
|
+
asfinder = CAIDA::ASFinder.new $options.asfinder
|
119
|
+
|
120
|
+
if $options.links
|
121
|
+
as_links = Hash.new { |h2,k2| h2[k2] = 0 } # "AS1 AS2" => count
|
122
|
+
end
|
123
|
+
|
124
|
+
temp_file = nil
|
125
|
+
ARGV.each do |path|
|
126
|
+
file = Warts::File.open path
|
127
|
+
unless file
|
128
|
+
$stderr.puts "ERROR: couldn't open '#{path}'; skipping"
|
129
|
+
next
|
130
|
+
end
|
131
|
+
|
132
|
+
file.add_filters Warts::File::TRACE
|
133
|
+
file.read do |trace|
|
134
|
+
if $options.verbose
|
135
|
+
puts "-" * 78
|
136
|
+
puts trace.dump
|
137
|
+
end
|
138
|
+
|
139
|
+
ippath = extract_ippath trace
|
140
|
+
puts "\n" + ippath.join(" ") + "\n" if $options.verbose
|
141
|
+
|
142
|
+
aspath = create_aspath asfinder, ippath
|
143
|
+
if $options.verbose
|
144
|
+
puts aspath.join(" ")
|
145
|
+
aspath.map! { |x| x.split(":")[0] }
|
146
|
+
puts "\n" + aspath.join(" ")
|
147
|
+
end
|
148
|
+
|
149
|
+
uniq = [ aspath[0] ]
|
150
|
+
aspath.each do |as|
|
151
|
+
uniq << as unless uniq[-1] == as
|
152
|
+
end
|
153
|
+
puts if $options.verbose
|
154
|
+
puts "P " + uniq.join(" ") if $options.verbose || !$options.links
|
155
|
+
|
156
|
+
if $options.links
|
157
|
+
uniq.each_cons(2) do |x, y|
|
158
|
+
next if x == "q" || x == "?" || y == "q" || y == "?"
|
159
|
+
as_links["#{x} #{y}"] += 1
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
if $options.links
|
166
|
+
as_links.each do |link, count|
|
167
|
+
puts "L #{link} #{count}"
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#############################################################################
|
4
|
+
## Extracts and prints out the unique IP addresses seen in the input warts
|
5
|
+
## traces.
|
6
|
+
##
|
7
|
+
## This doesn't print out the monitor IP address (source address) or
|
8
|
+
## nonresponding destinations.
|
9
|
+
##
|
10
|
+
## --------------------------------------------------------------------------
|
11
|
+
## Copyright (C) 2007 The Regents of the University of California.
|
12
|
+
##
|
13
|
+
## This program is free software; you can redistribute it and/or modify
|
14
|
+
## it under the terms of the GNU General Public License as published by
|
15
|
+
## the Free Software Foundation; either version 2 of the License, or
|
16
|
+
## (at your option) any later version.
|
17
|
+
##
|
18
|
+
## This program is distributed in the hope that it will be useful,
|
19
|
+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
## GNU General Public License for more details.
|
22
|
+
##
|
23
|
+
## You should have received a copy of the GNU General Public License
|
24
|
+
## along with this program; if not, write to the Free Software
|
25
|
+
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
26
|
+
##
|
27
|
+
## $Id: extract-trace-addrs,v 1.1 2007/11/30 01:14:48 youngh Exp $
|
28
|
+
#############################################################################
|
29
|
+
|
30
|
+
require 'rubygems'
|
31
|
+
require 'ostruct'
|
32
|
+
require 'optparse'
|
33
|
+
require 'enumerator'
|
34
|
+
require 'tempfile'
|
35
|
+
|
36
|
+
require 'wartslib'
|
37
|
+
|
38
|
+
$options = OpenStruct.new
|
39
|
+
$options.print_count = true
|
40
|
+
|
41
|
+
opts = OptionParser.new
|
42
|
+
opts.banner = "Usage: extract-trace-addrs [options] <warts-file-1> <warts-file-2> ..."
|
43
|
+
|
44
|
+
opts.on("-c", "--[no-]count", TrueClass, "print address frequency count") do |v|
|
45
|
+
$options.print_count = v
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on("-v", "--[no-]verbose", TrueClass, "show detailed progress") do |v|
|
49
|
+
$options.verbose = v
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
ARGV.replace opts.parse(*ARGV)
|
54
|
+
rescue OptionParser::ParseError
|
55
|
+
$stderr.puts "ERROR: " + $!
|
56
|
+
$stderr.puts opts
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
#===========================================================================
|
62
|
+
|
63
|
+
def extract_addresses(trace, addresses)
|
64
|
+
dest_response = trace.find_dest_response
|
65
|
+
|
66
|
+
trace.each_hop_and_attempt do |hop, attempt, exists|
|
67
|
+
next unless exists
|
68
|
+
break if dest_response && hop == dest_response[0]
|
69
|
+
addresses[trace.hop_addr(hop, attempt)] += 1
|
70
|
+
end
|
71
|
+
|
72
|
+
addresses[trace.dst] += 1 if dest_response
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
#############################################################################
|
77
|
+
# Main
|
78
|
+
#############################################################################
|
79
|
+
|
80
|
+
addresses = Hash.new { |h,k| h[k] = 0 }
|
81
|
+
|
82
|
+
ARGV.each do |path|
|
83
|
+
$stderr.puts "examining #{path} ..."
|
84
|
+
Warts::File.open(path) do |file|
|
85
|
+
file.add_filters Warts::File::TRACE
|
86
|
+
file.read do |trace|
|
87
|
+
extract_addresses trace, addresses
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
addresses.each do |addr, count|
|
93
|
+
if $options.print_count
|
94
|
+
puts addr + "\t" + count.to_s
|
95
|
+
else
|
96
|
+
puts addr
|
97
|
+
end
|
98
|
+
end
|
data/bin/modify-traces
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#############################################################################
|
4
|
+
## A script for modifying the cycle and list information in a trace file.
|
5
|
+
##
|
6
|
+
## --------------------------------------------------------------------------
|
7
|
+
## Copyright (C) 2007 The Regents of the University of California.
|
8
|
+
##
|
9
|
+
## This program is free software; you can redistribute it and/or modify
|
10
|
+
## it under the terms of the GNU General Public License as published by
|
11
|
+
## the Free Software Foundation; either version 2 of the License, or
|
12
|
+
## (at your option) any later version.
|
13
|
+
##
|
14
|
+
## This program is distributed in the hope that it will be useful,
|
15
|
+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
## GNU General Public License for more details.
|
18
|
+
##
|
19
|
+
## You should have received a copy of the GNU General Public License
|
20
|
+
## along with this program; if not, write to the Free Software
|
21
|
+
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22
|
+
##
|
23
|
+
## $Id: modify-traces,v 1.1 2007/11/30 01:14:48 youngh Exp $
|
24
|
+
#############################################################################
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'ostruct'
|
28
|
+
require 'optparse'
|
29
|
+
|
30
|
+
require 'wartslib'
|
31
|
+
|
32
|
+
list_options = {}
|
33
|
+
cycle_options = {}
|
34
|
+
|
35
|
+
options = OpenStruct.new
|
36
|
+
opts = OptionParser.new
|
37
|
+
opts.banner = "Usage: modify-traces [options] <warts-file-1> ..."
|
38
|
+
|
39
|
+
opts.on("--list", "=NUM", "list ID") do |v|
|
40
|
+
list_options[:id] = v.to_i
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on("--name", "=STR", "list name") do |v|
|
44
|
+
list_options[:name] = v
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on("--descr", "=STR", "list descr") do |v|
|
48
|
+
list_options[:descr] = v
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on("--monitor", "=STR", "canonical monitor name") do |v|
|
52
|
+
list_options[:monitor] = v
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on("--cycle", "=NUM", "cycle ID") do |v|
|
56
|
+
cycle_options[:id] = v.to_i
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on("--start-time", "=NUM", "cycle start time") do |v|
|
60
|
+
cycle_options[:start_time] = v.to_i
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on("--stop-time", "=NUM", "cycle stop time") do |v|
|
64
|
+
cycle_options[:stop_time] = v.to_i
|
65
|
+
end
|
66
|
+
|
67
|
+
opts.on("--hostname", "=STR", "hostname name") do |v|
|
68
|
+
cycle_options[:hostname] = v
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.on("--[no-]delete-cycle-start", TrueClass,
|
72
|
+
"delete cycle start records") do |v|
|
73
|
+
options.delete_cycle_start = v
|
74
|
+
end
|
75
|
+
|
76
|
+
opts.on("--[no-]delete-cycle-stop", TrueClass,
|
77
|
+
"delete cycle stop records") do |v|
|
78
|
+
options.delete_cycle_stop = v
|
79
|
+
end
|
80
|
+
|
81
|
+
opts.on("-v", "--[no-]verbose", TrueClass, "show detailed progress") do |v|
|
82
|
+
options.verbose = v
|
83
|
+
end
|
84
|
+
|
85
|
+
begin
|
86
|
+
ARGV.replace opts.parse(*ARGV)
|
87
|
+
rescue OptionParser::ParseError
|
88
|
+
$stderr.puts "ERROR: " + $!
|
89
|
+
$stderr.puts opts
|
90
|
+
exit 1
|
91
|
+
end
|
92
|
+
|
93
|
+
Thread.abort_on_exception = true
|
94
|
+
|
95
|
+
#========================================================================
|
96
|
+
|
97
|
+
ARGV.each do |path|
|
98
|
+
puts "processing #{path} ..."
|
99
|
+
|
100
|
+
file = Warts::File::open path
|
101
|
+
filters = [ Warts::File::TRACE ]
|
102
|
+
filters << Warts::File::CYCLE_START unless options.delete_cycle_start
|
103
|
+
filters << Warts::File::CYCLE_STOP unless options.delete_cycle_stop
|
104
|
+
file.add_filters *filters
|
105
|
+
|
106
|
+
list = nil
|
107
|
+
cycle = nil
|
108
|
+
|
109
|
+
Warts::File::open(path + ".modified", "w") do |out|
|
110
|
+
file.read do |element|
|
111
|
+
list = element.list.derive list_options unless list
|
112
|
+
|
113
|
+
case element.element_type
|
114
|
+
when Warts::File::CYCLE_START, Warts::File::CYCLE_STOP
|
115
|
+
unless cycle
|
116
|
+
options = {:list => list}.merge(cycle_options)
|
117
|
+
options.delete(:stop_time) # leave stop_time to 0 for START records
|
118
|
+
cycle = element.derive options
|
119
|
+
|
120
|
+
if element.element_type == Warts::File::CYCLE_STOP &&
|
121
|
+
cycle_options.has_key?(:stop_time)
|
122
|
+
element = cycle.derive :stop_time => cycle_options[:stop_time]
|
123
|
+
else
|
124
|
+
element = cycle
|
125
|
+
end
|
126
|
+
|
127
|
+
out.write element # write out a START record only once per file
|
128
|
+
end
|
129
|
+
|
130
|
+
when Warts::File::TRACE
|
131
|
+
cycle = element.cycle.derive list, cycle_options unless cycle
|
132
|
+
element.cycle = cycle
|
133
|
+
out.write element
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|