GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Net::Analysis::Listener::Example3(3) User Contributed Perl Documentation Net::Analysis::Listener::Example3(3)

Net::Analysis::Listener::Example3 - looking at HTTP transactions

 package Net::Analysis::Listener::Example3;

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

 sub http_transaction {
     my ($self, $args) = @_;
     my ($req)       = $args->{req};         # isa HTTP::Request
     my ($req_mono)  = $args->{req_mono};    # isa Net::Analysis::TCPMonologue
     my ($resp_mono) = $args->{resp_mono};   # isa Net::Analysis::TCPMonologue

     # Print out time between sending last part of request, and receiving
     #  first part of response.
     # (Note; these are Net::Analsysis::Time objects)
     my ($network_wait_time) = $resp_mono->t_start() - $req_mono->t_end();
     printf "%-50.50s: %8.2f\n", $req->uri(), $network_wait_time;
 }

 1;

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

 $ perl -MNet::Analysis -e main HTTP Example3 t/t1_google.tcp

Note the regex parameter being passed to the Example2 listener.

How to sit on top of Net::Analysis::Listener::HTTP. Note that you need to load the HTTP listener as well as Example3 in the Perl command line ! If you don't do this, then only the TCP listener will be loaded, no "http_transaction" events will be emitted, and so Example3 will listen in vain.

Other gotcahs; the "t_start" and "t_end" methods for TCPMonologue return Net::Analysis::Time objects, which while useful for certain things, might not be what you want. You can turn them into floating point seconds easily enough though.

Net::Analysis, Net::Analysis::Time, Net::Analysis::Listener::HTTP.

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

Copyright (C) 2004 by Adam B. Worrall

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.

2010-03-24 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.