Namespace inet::tcp
TCPSegment
packetRepresents a TCP segment, to be used with the TCP module.
TCP header fields not explicitly modelled: work on going
- Data Offset (number of 32 bit words in the header): represented by cMessage::length().
- Reserved (reserved for future use)
- Checksum (header checksum): modelled by cMessage::hasBitError()
- Header Options: Currently only EOL, NOP, MSS, WS, SACK_PERMITTED, SACK and TS are implemented
- Padding
cMessage::getKind() may be set to an arbitrary value: TCP entities will ignore it and use only the header fields (synBit, ackBit, rstBit).
Fields
Name | Type | Description |
---|---|---|
srcPort | unsigned short |
Source Port |
destPort | unsigned short |
Destination Port |
sequenceNo | unsigned int |
Sequence Number: first sequence number of the first data octet in the respective segment (except if SYN is set; then the the seq. number is the initial seq. number (ISS) and the first data octet is ISS + 1) |
ackNo | unsigned int |
Acknowledgement Number: if ACK flag is set, this field contains the next sequence number the sender of this segment is expecting to receive |
headerLength | unsigned short |
TCP Header Length - default: 20 bytes if header options are used the headerLength is greater than 20 bytes (default) |
urgBit | bool |
URG: urgent pointer field significant if set |
ackBit | bool |
ACK: ackNo significant if set |
pshBit | bool |
PSH: push function |
rstBit | bool |
RST: reset the connection |
synBit | bool |
SYN: synchronize seq. numbers |
finBit | bool |
FIN: finish - no more data from sender |
window | unsigned short |
Window Size: the number of data octets beginning with the one indicated in the acknowledgement field which the sender of this segment is willing to accept |
urgentPointer | unsigned short |
Urgent Pointer: communicates the current value of the urgent pointer as a positive offset from the sequence number in this segment. The urgent pointer points to the sequence number of the octet following the urgent data. This field is only be interpreted in segments with the URG control bit set. |
headerOption | TCPOption[] |
Header options (optional) Currently only EOL, NOP, MSS, WS, SACK_PERMITTED, SACK and TS are implemented |
payloadLength | unsigned long |
Payload length in octets (not an actual TCP header field). This may not always be the same as encapsulatedPacket()->getByteLength(); e.g. when simulating a virtual data stream there's no encapsulated packet at all. |
payloadEndSequenceNo | unsigned int[] |
Message objects (cMessages) that travel in this segment as data. This field is used only when the TCPDataTransferMode is TCP_TRANSFER_OBJECT. Every message object is put into the TCPSegment that would (in real life) carry its first octet. That is, if message object 'msg' with length=100 bytes occupies stream offset number range 10000..10099, it will travel in the TCPSegment which carries the octet 10000. This way it is easily achieved that the receiving TCP passes up the message object to its client when the last byte of the message has arrived. These vectors has same size, paired elements in vectors. |
payloadMsg | cPacket[] |
pointer to payload msg |
byteArray | ByteArray |
Message bytes that travel in this segment as data. This field is used only when the TCPDataTransferMode is TCP_TRANSFER_BYTESTREAM. |
Source code
// // Represents a TCP segment, to be used with the ~TCP module. // // TCP header fields not explicitly modelled: work on going // - Data Offset (number of 32 bit words in the header): represented // by cMessage::length(). // - Reserved (reserved for future use) // - Checksum (header checksum): modelled by cMessage::hasBitError() // - Header Options: Currently only EOL, NOP, MSS, WS, SACK_PERMITTED, SACK and TS are implemented // - Padding // // cMessage::getKind() may be set to an arbitrary value: TCP entities will // ignore it and use only the header fields (synBit, ackBit, rstBit). // packet TCPSegment { @customize(true); // Source Port unsigned short srcPort; // Destination Port unsigned short destPort; // Sequence Number: first sequence number of the first data octet // in the respective segment (except if SYN is set; then the the // seq. number is the initial seq. number (ISS) and the first data // octet is ISS + 1) unsigned int sequenceNo; // Acknowledgement Number: if ACK flag is set, this field contains // the next sequence number the sender of this segment is expecting // to receive unsigned int ackNo; // TCP Header Length - default: 20 bytes // if header options are used the headerLength is greater than 20 bytes (default) unsigned short headerLength = TCP_HEADER_OCTETS; // TCP_HEADER_OCTETS = 20 bool urgBit; // URG: urgent pointer field significant if set bool ackBit; // ACK: ackNo significant if set bool pshBit; // PSH: push function bool rstBit; // RST: reset the connection bool synBit; // SYN: synchronize seq. numbers bool finBit; // FIN: finish - no more data from sender // Window Size: the number of data octets beginning with the one indicated // in the acknowledgement field which the sender of this segment is // willing to accept unsigned short window; // Urgent Pointer: communicates the current value of the urgent pointer // as a positive offset from the sequence number in this segment. The // urgent pointer points to the sequence number of the octet following // the urgent data. This field is only be interpreted in segments with // the URG control bit set. unsigned short urgentPointer; // Header options (optional) // Currently only EOL, NOP, MSS, WS, SACK_PERMITTED, SACK and TS are implemented TCPOption *headerOption[] @owned; // Payload length in octets (not an actual TCP header field). // This may not always be the same as encapsulatedPacket()->getByteLength(); // e.g. when simulating a virtual data stream there's no encapsulated // packet at all. unsigned long payloadLength; // Message objects (cMessages) that travel in this segment as data. // This field is used only when the ~TCPDataTransferMode is TCP_TRANSFER_OBJECT. // Every message object is put into the TCPSegment that would (in real life) // carry its first octet. That is, if message object 'msg' with length=100 bytes // occupies stream offset number range 10000..10099, it will travel in the // TCPSegment which carries the octet 10000. This way it is easily achieved // that the receiving TCP passes up the message object to its client // when the last byte of the message has arrived. // These vectors has same size, paired elements in vectors. unsigned int payloadEndSequenceNo[]; cPacket *payloadMsg[] @owned; // pointer to payload msg // Message bytes that travel in this segment as data. // This field is used only when the ~TCPDataTransferMode is TCP_TRANSFER_BYTESTREAM. ByteArray byteArray; }File: src/inet/transportlayer/tcp_common/TCPSegment.msg