Package org.onlab.packet
Class TCP
- java.lang.Object
-
- org.onlab.packet.BasePacket
-
- org.onlab.packet.TCP
-
- All Implemented Interfaces:
IPacket
public class TCP extends BasePacket
Implements TCP packet format.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
acknowledge
protected short
checksum
protected byte
dataOffset
protected int
destinationPort
protected short
flags
protected byte[]
options
protected int
sequence
protected int
sourcePort
protected short
urgentPointer
protected short
windowSize
-
Fields inherited from class org.onlab.packet.BasePacket
parent, payload
-
-
Constructor Summary
Constructors Constructor Description TCP()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Deserializer<TCP>
deserializer()
Deserializer function for TCP packets.boolean
equals(java.lang.Object obj)
int
getAcknowledge()
Gets acknowledge number.short
getChecksum()
Gets checksum.byte
getDataOffset()
Gets offset.int
getDestinationPort()
Gets TCP destination port.short
getFlags()
Gets TCP flags.byte[]
getOptions()
Gets TCP options.int
getSequence()
Gets sequence number.int
getSourcePort()
Gets TCP source port.short
getUrgentPointer()
Gets urgent pointer.short
getWindowSize()
Gets TCP window size.int
hashCode()
void
resetChecksum()
Reset any checksum as needed, and call resetChecksum on all parents.byte[]
serialize()
Serializes the packet.TCP
setAcknowledge(int ack)
Sets acknowledge number.TCP
setChecksum(short checksum)
Sets checksum.TCP
setDataOffset(byte offset)
Sets offset.TCP
setDestinationPort(int destinationPort)
Sets TCP destination port.TCP
setFlags(short flags)
Sets TCP flags.TCP
setOptions(byte[] options)
Sets TCP options.TCP
setSequence(int seq)
Sets sequence number.TCP
setSourcePort(int sourcePort)
Sets TCP source port.TCP
setUrgentPointer(short urgentPointer)
Sets urgent pointer.TCP
setWindowSize(short windowSize)
Sets TCP window size.java.lang.String
toString()
-
Methods inherited from class org.onlab.packet.BasePacket
clone, getParent, getPayload, setParent, setPayload
-
-
-
-
Field Detail
-
sourcePort
protected int sourcePort
-
destinationPort
protected int destinationPort
-
sequence
protected int sequence
-
acknowledge
protected int acknowledge
-
dataOffset
protected byte dataOffset
-
flags
protected short flags
-
windowSize
protected short windowSize
-
checksum
protected short checksum
-
urgentPointer
protected short urgentPointer
-
options
protected byte[] options
-
-
Method Detail
-
getSourcePort
public int getSourcePort()
Gets TCP source port.- Returns:
- TCP source port
-
setSourcePort
public TCP setSourcePort(int sourcePort)
Sets TCP source port.- Parameters:
sourcePort
- the sourcePort to set (unsigned 16 bits integer)- Returns:
- this
-
getDestinationPort
public int getDestinationPort()
Gets TCP destination port.- Returns:
- the destinationPort
-
setDestinationPort
public TCP setDestinationPort(int destinationPort)
Sets TCP destination port.- Parameters:
destinationPort
- the destinationPort to set (unsigned 16 bits integer)- Returns:
- this
-
getChecksum
public short getChecksum()
Gets checksum.- Returns:
- the checksum
-
setChecksum
public TCP setChecksum(short checksum)
Sets checksum.- Parameters:
checksum
- the checksum to set- Returns:
- this
-
getSequence
public int getSequence()
Gets sequence number.- Returns:
- the sequence number
-
setSequence
public TCP setSequence(int seq)
Sets sequence number.- Parameters:
seq
- the sequence number to set- Returns:
- this
-
getAcknowledge
public int getAcknowledge()
Gets acknowledge number.- Returns:
- the acknowledge number
-
setAcknowledge
public TCP setAcknowledge(int ack)
Sets acknowledge number.- Parameters:
ack
- the acknowledge number to set- Returns:
- this
-
getDataOffset
public byte getDataOffset()
Gets offset.- Returns:
- the offset
-
setDataOffset
public TCP setDataOffset(byte offset)
Sets offset.- Parameters:
offset
- the offset to set- Returns:
- this
-
getFlags
public short getFlags()
Gets TCP flags.- Returns:
- the TCP flags
-
setFlags
public TCP setFlags(short flags)
Sets TCP flags.- Parameters:
flags
- the TCP flags to set- Returns:
- this
-
getWindowSize
public short getWindowSize()
Gets TCP window size.- Returns:
- the TCP window size
-
setWindowSize
public TCP setWindowSize(short windowSize)
Sets TCP window size.- Parameters:
windowSize
- the TCP window size to set- Returns:
- this
-
resetChecksum
public void resetChecksum()
Description copied from interface:IPacket
Reset any checksum as needed, and call resetChecksum on all parents.- Specified by:
resetChecksum
in interfaceIPacket
- Overrides:
resetChecksum
in classBasePacket
-
getUrgentPointer
public short getUrgentPointer()
Gets urgent pointer.- Returns:
- the urgent pointer
-
setUrgentPointer
public TCP setUrgentPointer(short urgentPointer)
Sets urgent pointer.- Parameters:
urgentPointer
- the urgent pointer to set- Returns:
- this
-
getOptions
public byte[] getOptions()
Gets TCP options.- Returns:
- the TCP options
-
setOptions
public TCP setOptions(byte[] options)
Sets TCP options.- Parameters:
options
- the options to set- Returns:
- this
-
serialize
public byte[] serialize()
Serializes the packet. Will compute and set the following fields if they are set to specific values at the time serialize is called: -checksum : 0 -length : 0- Returns:
- a byte[] containing this packet and payloads
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classBasePacket
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classBasePacket
-
deserializer
public static Deserializer<TCP> deserializer()
Deserializer function for TCP packets.- Returns:
- deserializer function
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-