|
SourceForge Jpcap | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.jpcap.net.Packet
net.sourceforge.jpcap.net.EthernetPacket
net.sourceforge.jpcap.net.IP.Packet
net.sourceforge.jpcap.net.IPv4.Packet
net.sourceforge.jpcap.net.IPPacket
net.sourceforge.jpcap.net.TCPPacket
public class TCPPacket
A TCP packet.
Extends an IP packet, adding a TCP header and TCP data payload. Please use IPv4.TCP.Packet for new code.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class net.sourceforge.jpcap.net.IPPacket |
|---|
IPPacket.TestProbe |
| Field Summary |
|---|
| Fields inherited from class net.sourceforge.jpcap.net.IP.Packet |
|---|
_ipHeaderLength, _ipOffset |
| Fields inherited from class net.sourceforge.jpcap.net.EthernetPacket |
|---|
_byteBuffer, _bytes, _ethOffset, _timeval |
| 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. |
|
TCPPacket(int lLen,
byte[] bytes,
Timeval tv)
Create a new TCP packet. |
|
TCPPacket(int lLen,
ByteBuffer bb,
Timeval tv)
|
|
| Method Summary | |
|---|---|
long |
getAcknowledgementNumber()
Deprecated. Please use getAcknowledgmentNumber() |
long |
getAcknowledgmentNumber()
Fetch the byte acknowledgment number, i.e. |
int |
getChecksum()
Return the actual packet checksum as received. Derived classes override this to return the most specific checksum, e.g.:
Packet.getChecksum() returns zero. |
String |
getColor()
Fetch ASCII escape sequence of the color associated with this packet type. |
byte[] |
getData()
Fetch the data portion of the packet. This is overridden in derived classes to return successively smaller and smaller amounts of data. For example:
|
int |
getDestinationPort()
Fetches the destination port number. |
byte[] |
getHeader()
Fetch header portion of the packet. This is overridden in derived classes to return the header appropriate to the packet class. For example:
|
int |
getHeaderLength()
Return the length of the header. |
int |
getPayloadDataLength()
Fetches the length of the payload data. |
long |
getSequenceNumber()
Fetch the byte sequence number. |
int |
getSourcePort()
Fetch the source port number. |
int |
getTCPChecksum()
Fetch the TCP checksum. |
byte[] |
getTCPData()
Fetch the TCP data as a byte array. |
byte[] |
getTCPHeader()
Fetch the TCP header as a byte array. |
int |
getTcpHeaderLength()
Deprecated. Please use getTCPHeaderLength() |
int |
getTCPHeaderLength()
Fetch the TCP header length in bytes. |
int |
getUrgentPointer()
Fetch the urgent pointer. |
int |
getWindowSize()
Fetch the window size. |
boolean |
isAck()
Return the ACK flag, indicating that the ack number is valid. |
boolean |
isFin()
Return the FIN flag, indicating that the sender has finished sending. |
boolean |
isPsh()
Return the PSH flag, indicating that the receiver should pass the data to the application as soon as possible. |
boolean |
isRst()
Return the RST flag, indicating that the connection has been reset by the sender. |
boolean |
isSyn()
Return the SYN flag, set to synchronize the sequence numbers between the sender and receiver as part of the connect handshake. |
boolean |
isUrg()
Return the URG flag, indicating that the urgent pointer is valid. |
boolean |
isValidChecksum()
Return true iff all the checksums in the packet are valid, otherwise false. Derived classes with checksums should override, and should call super.isValidChecksum()
to check the validity of base class checksums.
The Packet.isValidChecksum() implementation just returns true. |
boolean |
isValidTCPChecksum()
Return true if the TCP checksum is valid |
void |
setChecksums()
Set all the checksums in this packet prior to sending. Calling this method sets all the IP, ICMP, IGMP, TCP, UDP etc checksums as appropriate. It is called automatically by PacketOutputStream.writePacket(Packet).
Derived classes must override this abstract method, and must call super.setChecksums(),
after setting their own checksums
(unless super.setChecksums() is abstract, i.e. this method).
Otherwise the lower-level checksums will not be correct.
After calling this method the |
String |
toColoredString(boolean colored)
Generate string with contents describing this packet. |
String |
toColoredVerboseString(boolean colored)
Convert this IP packet to a more verbose string. |
| Methods inherited from class net.sourceforge.jpcap.net.IPPacket |
|---|
getDestinationAddress, getDestinationAddressAsLong, getDestinationAddressBytes, getIpHeaderLength, getSourceAddress, getSourceAddressAsLong, getSourceAddressBytes, onesCompSum |
| Methods inherited from class net.sourceforge.jpcap.net.IPv4.Packet |
|---|
computeReceiverChecksum, computeReceiverIPChecksum, computeSenderChecksum, computeSenderIPChecksum, getDestinationInetAddress, getFragmentFlags, getFragmentOffset, getId, getIPChecksum, getIPData, getIPHeader, getIPHeaderLength, getIPProtocol, getLength, getProtocol, getSourceInetAddress, getTimeToLive, getTypeOfService, getVersion, isValidIPChecksum, setDestinationInetAddress, setSourceInetAddress |
| Methods inherited from class net.sourceforge.jpcap.net.EthernetPacket |
|---|
equals, getDestinationHwAddress, getDestinationMACAddress, getEthernetCRC32, getEthernetData, getEthernetHeader, getEthernetHeaderLength, getEthernetProtocol, getPacketData, getPacketLength, getSourceHwAddress, getSourceMACAddress, getTimeval, hashCode, setDestinationMACAddress, setEthernetProtocol, setSourceMACAddress, toByteArray, toString |
| Methods inherited from class net.sourceforge.jpcap.net.Packet |
|---|
ipChecksum |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TCPPacket(int lLen,
byte[] bytes)
lLen - link-layer header lengthbytes - Packet data
public TCPPacket(int lLen,
byte[] bytes,
Timeval tv)
lLen - link-layer header lengthbytes - Packet datatv - Timestamp
public TCPPacket(int lLen,
ByteBuffer bb,
Timeval tv)
| Method Detail |
|---|
@Deprecated public long getAcknowledgementNumber()
getAcknowledgmentNumber()
@Deprecated public int getTcpHeaderLength()
getTCPHeaderLength()
public int getSourcePort()
IP.TCP
getSourcePort in interface IP.TCPpublic int getDestinationPort()
IP.TCP
getDestinationPort in interface IP.TCPpublic long getSequenceNumber()
IP.TCP
getSequenceNumber in interface IP.TCPpublic long getAcknowledgmentNumber()
IP.TCP
getAcknowledgmentNumber in interface IP.TCPpublic int getTCPHeaderLength()
IP.TCP
getTCPHeaderLength in interface IP.TCPpublic int getHeaderLength()
getHeaderLength in class IP.PacketPacket.getHeader().Packet.getHeader()public int getPayloadDataLength()
IP.TCP
getPayloadDataLength in interface IP.TCPpublic int getWindowSize()
IP.TCP
getWindowSize in interface IP.TCPpublic int getTCPChecksum()
IP.TCP
getTCPChecksum in interface IP.TCPpublic int getChecksum()
IPv4.Packet.getChecksum() returns the IP checksum
getChecksum() returns the TCP checksum
Packet.getChecksum() returns zero.
getChecksum in class IPv4.Packetpublic int getUrgentPointer()
IP.TCP
getUrgentPointer in interface IP.TCPpublic boolean isUrg()
IP.TCP
isUrg in interface IP.TCPpublic boolean isAck()
IP.TCP
isAck in interface IP.TCPpublic boolean isPsh()
IP.TCP
isPsh in interface IP.TCPpublic boolean isRst()
IP.TCP
isRst in interface IP.TCPpublic boolean isSyn()
IP.TCP
isSyn in interface IP.TCPpublic boolean isFin()
IP.TCP
isFin in interface IP.TCPpublic byte[] getTCPHeader()
IP.TCP
getTCPHeader in interface IP.TCPpublic byte[] getHeader()
EthernetPacket.getHeader() returns the Ethernet header
IP.Packet.getHeader() returns the IP header, which is in the Ethernet payload
getHeader() returns the TCP header, which is in the IP payload
getHeader in class IP.Packetpublic byte[] getTCPData()
IP.TCP
getTCPData in interface IP.TCPpublic byte[] getData()
EthernetPacket.getData() returns the entire Ethernet payload excluding the Ethernet header
IP.Packet.getData() only returns the IP payload, i.e. excluding the IP header which is in the Ethernet payload
getData() only returns the TCP payload, i.e. excluding the TCP header which is in the IP payload
getData in class IP.Packetpublic boolean isValidChecksum()
super.isValidChecksum()
to check the validity of base class checksums.
The Packet.isValidChecksum() implementation just returns true.
isValidChecksum in class IPv4.Packetpublic boolean isValidTCPChecksum()
IP.TCP
isValidTCPChecksum in interface IP.TCPpublic void setChecksums()
PacketOutputStream.writePacket(Packet).
Derived classes must override this abstract method, and must call super.setChecksums(),
after setting their own checksums
(unless super.setChecksums() is abstract, i.e. this method).
Otherwise the lower-level checksums will not be correct.
After calling this method the EthernetPacket.hashCode() of this object will probably change.
setChecksums in class IPv4.Packetpublic String toColoredString(boolean colored)
toColoredString in class IP.Packetcolored - whether or not the string should contain ansi
color escape sequences.public String toColoredVerboseString(boolean colored)
toColoredVerboseString in class IPv4.Packetpublic String getColor()
getColor in class IP.Packet
|
Copyright © Patrick Charles & Jonas Lehmann, 2001; Esmond Pitt, 2008. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||