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()
          fetches the packet acknowledgment number
 long getAcknowledgmentNumber()
          fetches the packet acknowledgment number
 int getChecksum()
          fetches 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()
          fetches the packet sequence number
 int getSourcePort()
          fetches the port number on the source host
 int getTCPChecksum()
          fetches the header checksum
 byte[] getTCPData()
          fetch the TCP data as a byte array
 byte[] getTCPHeader()
          fetch the TCP header a byte array
 int getTcpHeaderLength()
          fetches the TCP header length in bytes
 int getTCPHeaderLength()
          fetches the TCP header length in bytes
 int getUrgentPointer()
          fetches the urgent pointer
 int getWindowSize()
          fetches the window size
 boolean isAck()
          checks the ACK flag, flag indicates if the ack number is valid
 boolean isFin()
          checks the FIN flag, flag indicates the sender is finished sending
 boolean isPsh()
          checks the PSH flag, flag indicates the receiver should pass the data to the application as soon as possible
 boolean isRst()
          checks the RST flag, flag indicates the session should be reset between the sender and the receiver
 boolean isSyn()
          checks the SYN flag, flag indicates the sequence numbers should be synchronized between the sender and receiver to initiate a connection
 boolean isUrg()
          checks 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()
fetches the port number on the source host


getDestinationPort

public int getDestinationPort()
fetches the port number on the destination host


getSequenceNumber

public long getSequenceNumber()
fetches the packet sequence number


getAcknowledgmentNumber

public long getAcknowledgmentNumber()
fetches the packet acknowledgment number


getAcknowledgementNumber

public long getAcknowledgementNumber()
fetches the packet acknowledgment number


getTCPHeaderLength

public int getTCPHeaderLength()
fetches the TCP header length in bytes


getTcpHeaderLength

public int getTcpHeaderLength()
fetches 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()
fetches the window size


getTCPChecksum

public int getTCPChecksum()
fetches the header checksum


getChecksum

public int getChecksum()
fetches the header checksum

Overrides:
getChecksum in class IPPacket

getUrgentPointer

public int getUrgentPointer()
fetches the urgent pointer


isUrg

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


isAck

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


isPsh

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


isRst

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


isSyn

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


isFin

public boolean isFin()
checks 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