net.sourceforge.jpcap.net
Class IPPacket

java.lang.Object
  |
  +--net.sourceforge.jpcap.net.Packet
        |
        +--net.sourceforge.jpcap.net.EthernetPacket
              |
              +--net.sourceforge.jpcap.net.IPPacket
Direct Known Subclasses:
ICMPPacket, TCPPacket, UDPPacket

public class IPPacket
extends EthernetPacket

An IP protocol packet.

Extends an ethernet packet, adding IP header information and an IP data payload.


Constructor Summary
IPPacket(int lLen, byte[] bytes, java.lang.String macSourceAddress, java.lang.String macDestinationAddress, java.lang.String sourceAddress, java.lang.String destinationAddress)
          Create a new IP packet which is of an unrecognized protocol.
IPPacket(int lLen, byte[] bytes, java.lang.String macSourceAddress, java.lang.String macDestinationAddress, java.lang.String sourceAddress, java.lang.String destinationAddress, int protocol)
          Create a new IP packet which is of a recognized protocol.
 
Method Summary
 byte[] getData()
          Fetch data portion of the ip header.
 java.lang.String getDestinationAddress()
           
 byte[] getHeader()
          Fetch the ip header, excluding ip data.
 int getProtocol()
           
 java.lang.String getSourceAddress()
           
 java.lang.String toString()
          Convert this IP packet to a readable string.
 
Methods inherited from class net.sourceforge.jpcap.net.EthernetPacket
getDestinationHwAddress, getSourceHwAddress, getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IPPacket

public IPPacket(int lLen,
                byte[] bytes,
                java.lang.String macSourceAddress,
                java.lang.String macDestinationAddress,
                java.lang.String sourceAddress,
                java.lang.String destinationAddress,
                int protocol)
Create a new IP packet which is of a recognized protocol. If the protocol code in the IP header is recognized, this constructor is used to specify the protocol. For example, a recognized IP protocol is TCP.

IPPacket

public IPPacket(int lLen,
                byte[] bytes,
                java.lang.String macSourceAddress,
                java.lang.String macDestinationAddress,
                java.lang.String sourceAddress,
                java.lang.String destinationAddress)
Create a new IP packet which is of an unrecognized protocol. If the protocol code in the IP header is not recognized, this constructor is used.
Method Detail

getHeader

public byte[] getHeader()
Fetch the ip header, excluding ip data.
Overrides:
getHeader in class EthernetPacket

getData

public byte[] getData()
Fetch data portion of the ip header.
Overrides:
getData in class EthernetPacket

toString

public java.lang.String toString()
Convert this IP packet to a readable string.
Overrides:
toString in class EthernetPacket

getSourceAddress

public java.lang.String getSourceAddress()

getDestinationAddress

public java.lang.String getDestinationAddress()

getProtocol

public int getProtocol()