CAIDA::Traffic2::Interval - Storage/reading object for intervals
use CAIDA::Traffic2::Interval; use CAIDA::Traffic2::FileReader;
# Set up $reader and $interval with initialization data my @id_infos = $interval->get_id_infos(); my $table = $interval->get_table($id_infos[0], $type); my $pkt_drop = $interval->get_metadata('dropped pkt');
my $accumulator = new CAIDA::Traffic2::Interval; $accumulator->add($interval); $accumulator->nadd($interval);
Interval is a class that assists in the reading of Traffic2-style output files. Traffic2-style is that which is output by crl_traffic2 (or crl_flow -I). Interval objects are generally created by the FileReader class, but one could use a stand-alone Interval object as an accumulator over several different Intervals. When created by FileReader, these objects are initialized with a list of desired table types, which Interval will autogenerate whenever possible.
Interval has the following member functions:
nadd()
is the same as add()
, but
it is free to do destructive operations on INTERVAL. INTERVAL
should not be used again for anything after calling nadd()
.
A typical case involving Traffic2-style file format would involve an input file with only Tuple Tables. The following code will read that file (from STDIN), and automatically convert the Tuple Tables into Proto Tables, which the user might also want:
use CAIDA::Traffic2::FileReader; my $reader = new CAIDA::Traffic2::FileReader(*STDIN); $reader->set_desired_table_types("Tuple Table", "Proto Table"); while (my $interval = $reader->get_next_interval()) { foreach my $id_info ($interval->get_id_infos()) { foreach my $type ($id_info->get_table_types()) { my $table = $interval->get_table($id_info, $type); if (not defined $table) { # Issue some warning or ignore } else { # Do fun stuff with $table. } } } }
The CAIDA::Tables, CAIDA::Traffic2::SubinterfaceInfo, CAIDA::Traffic2::FileWriter and CAIDA::Traffic2::FileReader manpages.
crl_flow can output in several different formats than the 'Traffic2' format, which are readable by Interval objects, but cause possibly unexpected behavior. crl_flow allows multiple different expiration algorithms, which can cause the output of multiple entries with the same key. These separate entries will be added together when read by these classes. In addition, 'active' flows are currently ignored entirely.
For best results, use crl_flow -I.
If you have any ideas about how better to deal with this (creating different tables for active and expired flows, creating tables that accept multiple separate entries with the same key), please write us at coral-bugs@caida.org
Ryan Koga <rkoga@caida.org>