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


Manual Reference Pages  -  NET::PACKET::FRAME (3)

.ds Aq ’

NAME

Net::Packet::Frame - object encapsulator for Net::Packet layers

CONTENTS

SYNOPSIS



   require Net::Packet::Frame;

   # Because we passed a layer 3 object, a Net::Packet::DescL3 object
   # will be created automatically, by default. See Net::Packet::Env
   # regarding changing this behaviour. Same for Net::Packet::Dump.
   my $frame = Net::Packet::Frame->new(
      l3 => $ipv4,  # Net::Packet::IPv4 object
      l4 => $tcp,   # Net::Packet::TCP object
                    # (here, a SYN request, for example)
   );

   # Without retries
   $frame->send;
   sleep(3);
   if (my $reply = $frame->recv) {
      print $reply->l3->print."\n";
      print $reply->l4->print."\n";
   }

   # Or with retries
   for (1..3) {
      $frame->reSend;

      until ($Env->dump->timeout) {
         if (my $reply = $frame->recv) {
            print $reply->l3->print."\n";
            print $reply->l4->print."\n";
            last;
         }
      }
   }



DESCRIPTION

In <B>Net::PacketB>, each sent and/or received frame is parsed and converted into a <B>Net::Packet::FrameB> object. Basically, it encapsulates various layers (2, 3, 4 and 7) into an object, making it easy to get or set information about it.

When you create a frame object, a <B>Net::Packet::DescB> object is created if none is found in the default <B>B>$Env<B>B> object (from <B>Net::PacketB> module), and a <B>Net::Packet::DumpB> object is also created if none is found in this same <B>B>$Env<B>B> object. You can change this beheaviour, see <B>Net::Packet::EnvB>.

Two <B>newB> invocation method exist, one with attributes passing, another with <B>rawB> attribute. This second method is usually used internally, in order to unpack received frame into all corresponding layers.

ATTRIBUTES

<B>envB> Stores the <B>Net::Packet::EnvB> object. The default is to use <B>B>$Env<B>B> from <B>Net::PacketB>. So, you can send/recv frames to/from different environements.
<B>rawB> Pass this attribute when you want to decode a raw string captured from network. Usually used internally.
<B>paddingB> In Ethernet world, a frame should be at least 60 bytes in length. So when you send frames at layer 2, a padding is added in order to achieve this length, avoiding a local memory leak to network. Also, when you receive a frame from network, this attribute is filled with what have been used to pad it. This padding feature currently works for IPv4 and ARP frames.
<B>l2B> Stores a layer 2 object. See <B>Net::PacketB> for layer 2 classes hierarchy.
<B>l3B> Stores a layer 3 object. See <B>Net::PacketB> for layer 3 classes hierarchy.
<B>l4B> Stores a layer 4 object. See <B>Net::PacketB> for layer 4 classes hierarchy.
<B>l7B> Stores a layer 7 object. See <B>Net::Packet::Layer7B>.
<B>replyB> When <B>recvB> method has been called on a frame object, and a corresponding reply has been catched, a pointer is stored in this attribute.
<B>timestampB> When a frame is packed/unpacked, the happening time is stored here.
<B>encapsulateB> Give the type of the first encapsulated layer. It is a requirement to parse a user provided raw string.

METHODS

<B>newB> Object constructor. If a <B>B>$Env<B>-B>desc> object does not exists, one is created by analyzing attributes (so, either one of <B>Net::Packet::DescL2B>, <B>Net::Packet::DescL3B>. <B>Net::Packet::DescL4B> cannot be created automatically for now). The same behaviour is true for <B>B>$Env<B>-B>dump> object. You can change this default creation behaviour, see <B>Net::Packet::EnvB>. Default values:

timestamp: gettimeofday(),

env: $Env

<B>getLengthFromL7B>
<B>getLengthFromL4B>
<B>getLengthFromL3B>
<B>getLengthFromL2B> Returns the raw length in bytes from specified layer.
<B>getLengthB> Alias for <B>getLengthFromL3B>.
<B>unpackB> Unpacks the raw string from network into various layers. Returns 1 on success, undef on failure.
<B>packB> Packs various layers into the raw string to send to network. Returns 1 on success, undef on failure.
<B>sendB> On the first send invocation in your program, the previously created <B>Net::Packet::DumpB> object is started (if available). That is, packet capturing is run. The <B>timestampB> attribute is set to the sending time. The <B>envB> attribute is used to know where to send this frame.
<B>reSendB> Will call <B>sendB> method if no frame has been <B>recvB>’d, that is the <B>replyB> attribute is undef.
<B>getFilterB> Will return a string which is a pcap filter, and corresponding to what you should receive compared with the frame request.
<B>recvB> Searches <B>framesSortedB> or <B>framesB> from <B>Net::Packet::DumpB> for a matching response. If a reply has already been received (that is <B>replyB> attribute is already set), undef is returned. It no reply is received, return undef, else the <B>Net::Packet::FrameB> response.
<B>printB> Just returns a string in a human readable format describing attributes found in the layer.
<B>dumpB> Just returns a string in hexadecimal format which is how the layer appears on the network.
<B>isEthB>
<B>isRawB>
<B>isNullB>
<B>isSllB>
<B>isPppB>
<B>isArpB>
<B>isIpv4B>
<B>isIpv6B>
<B>isIpB> - either IPv4 or IPv6
<B>isPpplcpB>
<B>isVlanB>
<B>isPppoeB>
<B>isLlcB>
<B>isTcpB>
<B>isUdpB>
<B>isIcmpv4B>
<B>isIcmpB> - currently only ICMPv4
<B>isCdpB>
<B>isStpB>
<B>isOspfB>
<B>isIgmpv4B>
<B>is7B> Returns 1 if the <B>Net::Packet::FrameB> is of specified layer, 0 otherwise.

AUTHOR

Patrice <GomoR> Auffret

COPYRIGHT AND LICENSE

Copyright (c) 2004-2009, Patrice <GomoR> Auffret

You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.

RELATED MODULES

NetPacket, Net::RawIP, Net::RawSock

POD ERRORS

Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 618: Non-ASCII character seen before =encoding in ’# Net::Packet::IPv4’. Assuming ISO8859-1
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 NET::PACKET::FRAME (3) 2009-11-09

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