Net::Analysis::Listener::Example2 - accessing TCP info


Net-Analysis documentation  | view source Contained in the Net-Analysis distribution.

Index


NAME

Top

Net::Analysis::Listener::Example2 - accessing TCP info

SYNOPSIS

Top

 package Net::Analysis::Listener::Example2;

 use strict;
 use warnings;
 use base qw(Net::Analysis::Listener::Base);

 sub tcp_monologue {
     my ($self, $args) = @_;
     my ($mono) = $args->{monologue};    # isa Net::Analysis::TCPMonologue
     my ($pkt)  = $mono->first_packet(); # isa Net::Analysis::Packet
     my ($from) = $pkt->{from};
     my ($time) = $pkt->{time}->as_string('full');

     printf "(%s)  %-22.22s % 6d bytes", $time, $from, $mono->length();

     if ($self->{regex}) {
         if ($mono->data() =~ /(.{0,10}$self->{regex}.{0,10})/i) {
             print " ** regex matched: '$1'";
         }
     }

     print "\n";
 }

 1;

You can invoke this example on a TCP capture file from the command line, as follows:

 $ perl -MNet::Analysis -e main Example2,regex=img t/t1_google.tcp

Note the regex parameter being passed to the Example2 listener.

DESCRIPTION

Top

This Listener prints a brief summary of the monologue traffic, and optionally greps the monologue data for a regex, if one is passed via config into $self.

SEE ALSO

Top

Net::Analysis.

AUTHOR

Top

Adam B. Worrall, <worrall@cpan.org>

COPYRIGHT AND LICENSE

Top


Net-Analysis documentation  | view source Contained in the Net-Analysis distribution.