Featured Post

Trie implementation in C

SCTP Packet Format

    The SCTP packet format is shown below:
  •  An SCTP packet is composed of a common header and chunks. A chunk contains either control information or user data.
  •  Multiple chunks can be bundled into one SCTP packet up to the MTU size, except for the INIT, INIT ACK, and SHUTDOWN COMPLETE chunks.
  • These chunks MUST NOT be bundled with any other chunk in a packet.
  • If a user data message doesn't fit into one SCTP packet it can befragmented into multiple chunks.
  • All integer fields in an SCTP packet MUST be transmitted in network byte order, unless otherwise stated.


SCTP Common Header Format




/* SCTP common header */
typedef struct sctp_hdr {
 uint16_t sh_sport;
 uint16_t sh_dport;
 uint32_t sh_verf;
 uint32_t sh_chksum;
} sctp_hdr_t;

Source Port Number: 16 bits (unsigned integer)


This is the SCTP sender's port number. It can be used by the receiver in combination with the source IP address, the SCTP destination port and possibly the destination IP address to identify the association to which this packet belongs.

Destination Port Number: 16 bits (unsigned integer)

This is the SCTP port number to which this packet is destined. The receiving host will use this port number to de-multiplex the SCTP packet to the correct receiving endpoint/application.

Verification Tag: 32 bits (unsigned integer)

The receiver of this packet uses the Verification Tag to validate the sender of this SCTP packet. On transmit, the value of this Verification Tag MUST be set to the value of the Initiate Tag received from the peer endpoint during the association initialization, with the following exceptions:

  • A packet containing an INIT chunk MUST have a zero Verification Tag.
  • A packet containing a SHUTDOWN-COMPLETE chunk with the T-bit set MUST have the Verification Tag copied from the packet with the SHUTDOWN-ACK chunk.
  • A packet containing an ABORT chunk may have the verification tag copied from the packet which caused the ABORT to be sent.
  • An INIT chunk MUST be the only chunk in the SCTP packet carrying it.

Checksum: 32 bits (unsigned integer)

This field contains the checksum of this SCTP packet. Its calculation uses the Adler- 32 for calculating the checksum


Chunk Field Descriptions

The figure below illustrates the field format for the chunks to be transmitted in the SCTP packet. Each chunk is formatted with a Chunk Type field, a chunk-specific Flag field, a Chunk Length field, and a
Value field.




/* Common chunk header */
typedef struct sctp_chunk_hdr {
 uint8_t  sch_id;
 uint8_t  sch_flags;
 uint16_t sch_len;
} sctp_chunk_hdr_t;
Chunk Type: 8 bits (unsigned integer)


This field identifies the type of information contained in the Chunk Value field. It takes a value from 0 to 254. The value of 255 is reserved for future use as an extension field.
 
The values of Chunk Types are defined as follows:
/* Chunk IDs */
typedef enum {
 CHUNK_DATA,
 CHUNK_INIT,
 CHUNK_INIT_ACK,
 CHUNK_SACK,
 CHUNK_HEARTBEAT,
 CHUNK_HEARTBEAT_ACK,
 CHUNK_ABORT,
 CHUNK_SHUTDOWN,
 CHUNK_SHUTDOWN_ACK,
 CHUNK_ERROR,
 CHUNK_COOKIE,
 CHUNK_COOKIE_ACK,
 CHUNK_ECNE,
 CHUNK_CWR,
 CHUNK_SHUTDOWN_COMPLETE,
 CHUNK_ASCONF_ACK = 128,
 CHUNK_FORWARD_TSN = 192,
 CHUNK_ASCONF = 193
} sctp_chunk_id_t;

ID
Value Chunk Type
0
Payload Data (DATA)
1
Initiation (INIT)
2
Initiation Acknowledgement (INIT ACK)
3
Selective Acknowledgement (SACK)
4
Heartbeat Request (HEARTBEAT)
5
Heartbeat Acknowledgement (HEARTBEAT ACK)
6
Abort (ABORT)
7
Shutdown (SHUTDOWN)
8
Shutdown Acknowledgement (SHUTDOWN ACK)
9
Operation Error (ERROR)
10
State Cookie (COOKIE ECHO)
11
Cookie Acknowledgement (COOKIE ACK)
12
Reserved for Explicit Congestion Notification Echo (ECNE)
13
Reserved for Congestion Window Reduced (CWR)
14
Shutdown Complete (SHUTDOWN COMPLETE)
15 to 62
reserved by IETF
63
IETF-defined Chunk Extensions
64 to 126
reserved by IETF
127
IETF-defined Chunk Extensions
128 to 190
reserved by IETF
191
IETF-defined Chunk Extensions
192 to 254
reserved by IETF
255
IETF-defined Chunk Extensions

Chunk Types are encoded such that the highest-order two bits specify the action that must be taken if the processing endpoint does not recognize the Chunk Type.

00 - Stop processing this SCTP packet and discard it, do not process any further chunks within it.

01 - Stop processing this SCTP packet and discard it, do not process any further chunks within it, and report the unrecognized parameter in an 'Unrecognized Parameter Type' (in either an ERROR or in the INIT ACK).

10 - Skip this chunk and continue processing.

11 - Skip this chunk and continue processing, but report in an ERROR Chunk using the 'Unrecognized Chunk Type' cause of error.

Note: The ECNE and CWR chunk types are reserved for future use of Explicit Congestion Notification (ECN).
 
Chunk Flags: 8 bits

The usage of these bits depends on the chunk type as given by the Chunk Type. Unless otherwise specified, they are set to zero on transmit and are ignored on receipt.

Chunk Length: 16 bits (unsigned integer)

This value represents the size of the chunk in bytes including the Chunk Type, Chunk Flags, Chunk Length, and Chunk Value fields.
Therefore, if the Chunk Value field is zero-length, the Length field will be set to 4. The Chunk Length field does not count any padding.


Chunk Value: variable length

The Chunk Value field contains the actual information to be transferred in the chunk. The usage and format of this field is dependent on the Chunk Type.

The total length of a chunk (including Type, Length and Value fields) MUST be a multiple of 4 bytes. If the length of the chunk is not a multiple of 4 bytes, the sender MUST pad the chunk with all zero bytes and this padding is not included in the chunk length field. The sender should never pad with more than 3 bytes. The receiver MUST ignore the padding bytes.

References : RFC 4960

Comments