net.sourceforge.jpcap.net
Class TCPPacket

java.lang.Object
  extended bynet.sourceforge.jpcap.net.Packet
      extended bynet.sourceforge.jpcap.net.EthernetPacket
          extended bynet.sourceforge.jpcap.net.IPPacket
              extended bynet.sourceforge.jpcap.net.TCPPacket
All Implemented Interfaces:
EthernetFields, IPFields, java.io.Serializable, TCPFields

public class TCPPacket
extends IPPacket
implements TCPFields, java.io.Serializable

A TCP packet.

Extends an IP packet, adding a TCP header and TCP data payload.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class net.sourceforge.jpcap.net.IPPacket
IPPacket.TestProbe
 
Field Summary
 
Fields inherited from class net.sourceforge.jpcap.net.IPPacket
_ipOffset
 
Fields inherited from class net.sourceforge.jpcap.net.EthernetPacket
_bytes, _ethOffset
 
Fields inherited from interface net.sourceforge.jpcap.net.TCPFields
TCP_ACK_LEN, TCP_ACK_MASK, TCP_ACK_POS, TCP_CSUM_LEN, TCP_CSUM_POS, TCP_DP_POS, TCP_FIN_MASK, TCP_FLAG_LEN, TCP_FLAG_POS, TCP_HEADER_LEN, TCP_PORT_LEN, TCP_PSH_MASK, TCP_RST_MASK, TCP_SEQ_LEN, TCP_SEQ_POS, TCP_SP_POS, TCP_SYN_MASK, TCP_URG_LEN, TCP_URG_MASK, TCP_URG_POS, TCP_WIN_LEN, TCP_WIN_POS
 
Fields inherited from interface net.sourceforge.jpcap.net.IPFields
IP_CODE_LEN, IP_CODE_POS, IP_CSUM_LEN, IP_CSUM_POS, IP_DST_POS, IP_FRAG_LEN, IP_FRAG_POS, IP_HEADER_LEN, IP_ID_LEN, IP_ID_POS, IP_LEN_LEN, IP_LEN_POS, IP_SRC_POS, IP_TOS_LEN, IP_TOS_POS, IP_TTL_LEN, IP_TTL_POS, IP_VER_LEN, IP_VER_POS
 
Fields inherited from interface net.sourceforge.jpcap.net.EthernetFields
ETH_CODE_LEN, ETH_CODE_POS, ETH_DST_POS, ETH_HEADER_LEN, ETH_SRC_POS
 
Constructor Summary
TCPPacket(int lLen, byte[] bytes)
          Create a new TCP packet.
 
Method Summary
 long getAcknowledgementNumber()
          Fetch the packet acknowledgment number.
 long getAcknowledgmentNumber()
          Fetch the packet acknowledgment number.
 int getChecksum()
          Fetch the header checksum.
 java.lang.String getColor()
          Fetch ascii escape sequence of the color associated with this packet type.
 byte[] getData()
          Fetch the TCP data as a byte array.
 int getDestinationPort()
          Fetches the port number on the destination host.
 byte[] getHeader()
          Fetch the TCP header as a byte array.
 int getHeaderLength()
          Fetches the packet TCP header length.
 int getPayloadDataLength()
          Fetches the length of the payload data.
 long getSequenceNumber()
          Fetch the packet sequence number.
 int getSourcePort()
          Fetch the port number on the source host.
 int getTCPChecksum()
          Fetch the header checksum.
 byte[] getTCPData()
          Fetch the TCP data as a byte array.
 byte[] getTCPHeader()
          Fetch the TCP header a byte array.
 int getTcpHeaderLength()
          Fetch the TCP header length in bytes.
 int getTCPHeaderLength()
          Fetch the TCP header length in bytes.
 int getUrgentPointer()
          Fetch the urgent pointer.
 int getWindowSize()
          Fetch the window size.
 boolean isAck()
          Check the ACK flag, flag indicates if the ack number is valid.
 boolean isFin()
          Check the FIN flag, flag indicates the sender is finished sending.
 boolean isPsh()
          Check the PSH flag, flag indicates the receiver should pass the data to the application as soon as possible.
 boolean isRst()
          Check the RST flag, flag indicates the session should be reset between the sender and the receiver.
 boolean isSyn()
          Check the SYN flag, flag indicates the sequence numbers should be synchronized between the sender and receiver to initiate a connection.
 boolean isUrg()
          Check the URG flag, flag indicates if the urgent pointer is valid.
 java.lang.String toColoredString(boolean colored)
          Generate string with contents describing this TCP packet.
 java.lang.String toColoredVerboseString(boolean colored)
          Convert this TCP packet to a verbose.
 java.lang.String toString()
          Convert this TCP packet to a readable string.
 
Methods inherited from class net.sourceforge.jpcap.net.IPPacket
computeReceiverChecksum, computeReceiverIPChecksum, computeSenderChecksum, computeSenderIPChecksum, getDestinationAddress, getDestinationAddressAsLong, getDestinationAddressBytes, getFragmentFlags, getFragmentOffset, getId, getIPChecksum, getIPData, getIPHeader, getIpHeaderLength, getIPHeaderLength, getIPProtocol, getLength, getProtocol, getSourceAddress, getSourceAddressAsLong, getSourceAddressBytes, getTimeToLive, getTypeOfService, getVersion, isValidChecksum, isValidIPChecksum, onesCompSum
 
Methods inherited from class net.sourceforge.jpcap.net.EthernetPacket
getDestinationHwAddress, getEthernetData, getEthernetHeader, getEthernetHeaderLength, getEthernetProtocol, getSourceHwAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TCPPacket

public TCPPacket(int lLen,
                 byte[] bytes)
Create a new TCP packet.

Method Detail

getSourcePort

public int getSourcePort()
Fetch the port number on the source host.


getDestinationPort

public int getDestinationPort()
Fetches the port number on the destination host.


getSequenceNumber

public long getSequenceNumber()
Fetch the packet sequence number.


getAcknowledgmentNumber

public long getAcknowledgmentNumber()
Fetch the packet acknowledgment number.


getAcknowledgementNumber

public long getAcknowledgementNumber()
Fetch the packet acknowledgment number.


getTCPHeaderLength

public int getTCPHeaderLength()
Fetch the TCP header length in bytes.


getTcpHeaderLength

public int getTcpHeaderLength()
Fetch the TCP header length in bytes.


getHeaderLength

public int getHeaderLength()
Fetches the packet TCP header length.

Overrides:
getHeaderLength in class IPPacket

getPayloadDataLength

public int getPayloadDataLength()
Fetches the length of the payload data.


getWindowSize

public int getWindowSize()
Fetch the window size.


getTCPChecksum

public int getTCPChecksum()
Fetch the header checksum.


getChecksum

public int getChecksum()
Fetch the header checksum.

Overrides:
getChecksum in class IPPacket

getUrgentPointer

public int getUrgentPointer()
Fetch the urgent pointer.


isUrg

public boolean isUrg()
Check the URG flag, flag indicates if the urgent pointer is valid.


isAck

public boolean isAck()
Check the ACK flag, flag indicates if the ack number is valid.


isPsh

public boolean isPsh()
Check the PSH flag, flag indicates the receiver should pass the data to the application as soon as possible.


isRst

public boolean isRst()
Check the RST flag, flag indicates the session should be reset between the sender and the receiver.


isSyn

public boolean isSyn()
Check the SYN flag, flag indicates the sequence numbers should be synchronized between the sender and receiver to initiate a connection.


isFin

public boolean isFin()
Check the FIN flag, flag indicates the sender is finished sending.


getTCPHeader

public byte[] getTCPHeader()
Fetch the TCP header a byte array.


getHeader

public byte[] getHeader()
Fetch the TCP header as a byte array.

Overrides:
getHeader in class IPPacket

getTCPData

public byte[] getTCPData()
Fetch the TCP data as a byte array.


getData

public byte[] getData()
Fetch the TCP data as a byte array.

Overrides:
getData in class IPPacket

toString

public java.lang.String toString()
Convert this TCP packet to a readable string.

Overrides:
toString in class IPPacket

toColoredString

public java.lang.String toColoredString(boolean colored)
Generate string with contents describing this TCP packet.

Overrides:
toColoredString in class IPPacket
Parameters:
colored - whether or not the string should contain ansi color escape sequences.

toColoredVerboseString

public java.lang.String toColoredVerboseString(boolean colored)
Convert this TCP packet to a verbose.

Overrides:
toColoredVerboseString in class IPPacket

getColor

public java.lang.String getColor()
Fetch ascii escape sequence of the color associated with this packet type.

Overrides:
getColor in class IPPacket