net.sourceforge.jpcap.net
Class TCPPacket

java.lang.Object
  |
  +--net.sourceforge.jpcap.net.Packet
        |
        +--net.sourceforge.jpcap.net.EthernetPacket
              |
              +--net.sourceforge.jpcap.net.IPPacket
                    |
                    +--net.sourceforge.jpcap.net.TCPPacket
All Implemented Interfaces:
EthernetFields, IPFields, TCPFields

public class TCPPacket
extends IPPacket
implements TCPFields

A TCP packet.

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


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 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 data portion of the tcp header.
 int getDestinationPort()
          Fetch the port number on the target host.
 byte[] getHeader()
          Fetch the tcp header, excluding tcp data payload.
 int getHeaderLength()
          Fetch the packet header length.
 long getSequenceNumber()
          Fetch the packet sequence number.
 int getSourcePort()
          Fetch the port number on the source host.
 byte[] getTCPData()
          Fetch data portion of the tcp header.
 byte[] getTCPHeader()
          Fetch the tcp header, excluding tcp data payload.
 int getTcpHeaderLength()
          Fetch the packet header length.
 int getUrgentPointer()
          Fetch the urgent pointer.
 int getWindowSize()
          Fetch the window size.
 boolean isAck()
          Check the ACK flag.
 boolean isFin()
          Check the FIN flag.
 boolean isPsh()
          Check the PSH flag.
 boolean isRst()
          Check the RST flag.
 boolean isSyn()
          Check the SYN flag.
 boolean isUrg()
          Check the URG flag.
 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
getDestinationAddress, getFragmentFlags, getFragmentOffset, getHeaderLength, getHeaderLength, getId, getIPData, getIPHeader, getIpHeaderLength, getLength, getProtocol, getSourceAddress, getTimeToLive, getTypeOfService, getVersion
 
Methods inherited from class net.sourceforge.jpcap.net.EthernetPacket
getDestinationHwAddress, getEthernetData, getEthernetHeader, 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()
Fetch the port number on the target host.

getSequenceNumber

public long getSequenceNumber()
Fetch the packet sequence number.

getAcknowledgmentNumber

public long getAcknowledgmentNumber()
Fetch the packet acknowledgment number.

getHeaderLength

public int getHeaderLength()
Fetch the packet header length.
Overrides:
getHeaderLength in class IPPacket

getTcpHeaderLength

public int getTcpHeaderLength()
Fetch the packet header length.

getWindowSize

public int getWindowSize()
Fetch the window size.

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. The flag indicates if the urgent pointer is valid.

isAck

public boolean isAck()
Check the ACK flag. The flag indicates whether the acknowledgment number is valid.

isPsh

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

isRst

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

isSyn

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

isFin

public boolean isFin()
Check the FIN flag. The flag indicates that the sender is finished sending data.

getTCPHeader

public byte[] getTCPHeader()
Fetch the tcp header, excluding tcp data payload.

getTCPData

public byte[] getTCPData()
Fetch data portion of the tcp header.

getHeader

public byte[] getHeader()
Fetch the tcp header, excluding tcp data payload.
Overrides:
getHeader in class IPPacket

getData

public byte[] getData()
Fetch data portion of the tcp header.
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