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 intacknowledgeprotected shortchecksumprotected bytedataOffsetprotected intdestinationPortprotected shortflagsprotected byte[]optionsprotected intsequenceprotected intsourcePortprotected shorturgentPointerprotected shortwindowSize-
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.booleanequals(Object obj)intgetAcknowledge()Gets acknowledge number.shortgetChecksum()Gets checksum.bytegetDataOffset()Gets offset.intgetDestinationPort()Gets TCP destination port.shortgetFlags()Gets TCP flags.byte[]getOptions()Gets TCP options.intgetSequence()Gets sequence number.intgetSourcePort()Gets TCP source port.shortgetUrgentPointer()Gets urgent pointer.shortgetWindowSize()Gets TCP window size.inthashCode()voidresetChecksum()Reset any checksum as needed, and call resetChecksum on all parents.byte[]serialize()Serializes the packet.TCPsetAcknowledge(int ack)Sets acknowledge number.TCPsetChecksum(short checksum)Sets checksum.TCPsetDataOffset(byte offset)Sets offset.TCPsetDestinationPort(int destinationPort)Sets TCP destination port.TCPsetFlags(short flags)Sets TCP flags.TCPsetOptions(byte[] options)Sets TCP options.TCPsetSequence(int seq)Sets sequence number.TCPsetSourcePort(int sourcePort)Sets TCP source port.TCPsetUrgentPointer(short urgentPointer)Sets urgent pointer.TCPsetWindowSize(short windowSize)Sets TCP window size.StringtoString()-
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:IPacketReset any checksum as needed, and call resetChecksum on all parents.- Specified by:
resetChecksumin interfaceIPacket- Overrides:
resetChecksumin 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:
hashCodein classBasePacket
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classBasePacket
-
deserializer
public static Deserializer<TCP> deserializer()
Deserializer function for TCP packets.- Returns:
- deserializer function
-
-