SCTP Protocol tutorial
The Internet is an IP based network. Which exists for a long time. A node in the IP network has a unique IP address. IP protocol provides functionality for routing a message from the source IP address to the destination IP address in a network. Two IP nodes may be directly reachable or via single or multiple routers. For application developers, there was a need for a protocol that can maintain a session. TCP was the first protocol for creating a session or connection with the peer TCP. Web-based communication is based on TCP/IP. With time, the network at the hardware level getting faster and faster. There were requirements to make the internet more suitable for real-time, robust, and high-performance applications, mainly telecom. Then standards for SCTP or Stream Control protocol was standardized in RFC 4960.
SCTP protocol overcomes many issues against TCP, which makes it suitable for robust and real-time communications.
SCTP vs TCP:
Both are transport level protocols, uses services of IP protocol. Before understanding the SCTP protocol and the purpose of its existence. One should understand the top-level differences between these two protocols.
|Age||TCP is a much older protocol, has its presence for decades.||SCTP is a newer protocol.|
|Connection or PATH Monitoring||Do not have protocol messages for connection health monitoring. A user of TCP needs to implement a mechanism for failure detection. E.g HTTP timeout.||The protocol defines messages for link or path health checks. These messages are heartbeat messages. SCTP users immediately get a connection failure indication.|
|Stream-Based (sequence of bytes)||Messages flow over TCP connection in a stream of bytes. This requires functionality in the user of TCP to put start and end patterns for messages.||Message-based. The sender and receiver need to send and receive a full message. It is like a UDP message flow.|
|Number of Streams||All communication is on one stream. It blocks all bytes in a flow until a corrupted byte is not retransmitted. Not suitable for real-time applications, where time is essential.||Have multiple streams. If one streams blocks, other streams keep carrying bytes. Important for telecom. If a call blocks from one telephone exchange to another. The remaining calls will not block.|
|Network Failure||Having a single network path between source and destination. Because TCP/IP has a single IP address in an endpoint.||It can have multiple network paths from source to destination. Because SCTP/IP has multiple IP addresses in an endpoint.|
|User Base||Due to the older protocol. TCP is used in many places. All HTTP based communication is based on TCP.||The user base is less in number. Mainly peer or peer applications for telecom or others.|
|Availability||Available on most of the platforms.|| Available on lesser platforms, mainly on
Linux and Solaris.
The message has a header and multiple chunks.
SCTP Header :
It is 12 bytes long. Have the source port, destination port, Verification tag, and checksum.
Other than the header, the remaining message contains chunks. A chuck is a control message for a layer or a user message. Control messages are used for setup or tear-down the connection with the peer. user message chunk sends user data to the peer node of data to the user received from the peer node.
SCTP Chunk types:
INIT – The client sends this chunk to start the association. INIT can not be bundled with any other chunk. For setting SCTP association client sends SCTP INIT and advertises its own IP addresses. This is the first message for a four-way handshake.
INIT-ACK – Acknowledge of INIT, send by the server in the response to a received INIT. The INIT ACK should be returned to the source port of INIT and source IP of INIT if the server accepts a new connection from the client. In this message, the server includes a list of IP addresses for its local point code.
COOKIE ECHO – It is part of an association setup. On successful receive of INIT-ACK, the client sends a COOKIE ECHO. The chunk has only one parameter, cookie.
COOKIE ACK- Acknowledgement send by the server for COOKIE-ECHO.
SACK- SCTP is a reliable protocol, which means if a packet is lost, then the SCTP layer will do error correction by sending the same packet again. A user of the layer will remain unknown from res-transmission at the SCTP layer. Till packet is not received by the peer, the sender keeps a packet in the sending queue. The remote peer sends the SACK or selective acknowledgment for a received packet. Upon receiving a SACK, the sender removes the packet from the queue.
HEARTBEAT – After an association set up, each end starts monitoring link health. For this, each end sends heartbeat messages to a peer and expects its responses.
HEARTBEAT ACK – Acknowledge message for the heartbeat. Upon missing ack message for a fixed number of a count, association marked as inactive and communication lost indication is sent to the user.
SCTP was standardized with many new features that were missing in legacy network protocols. These features enable SCTP, to use for critical applications, e.g telephony. Following is a list of key features of the protocol.
Multi Streaming :
Before this protocol, connection-oriented protocols e.g TCP was using a single stream for transferring data from source to destination. Single stream creates an issue of all communication blocking, in case of single-byte failure, until the failed byte is re-transmitted. This is not suitable for time-critical applications. Suppose there are ten calls are going on a TCP connection, there is a problem in byte related to a single call. This turns into the blocking of packets for the remaining 9 calls. This eventually may cause loss of call at all, because of timeout on a telephone exchange.
SCTP overcome from a single point of blocking, by providing multiple streams in a connection with the peer. This makes communication faster as well.
Datagram Protocol Style :
Despite that it’s connection-oriented, but it is a datagram-based protocol. In TCP, a sender and receiver have to put an identifier for the start and end of a message. It creates an additional burden over transport protocol users and before communication both sides should agree on common delimiters. This protocol provides message-based communication over a connection.
In TCP, an endpoint has a single IP address and a port. If that IP becomes unreachable or disconnects from the network, the TCP connection break down with the peer node. SCTP has the feature of multihoming, where the SCTP endpoint may have multiple IP addresses and a port. So if one IP is unreachable, any other IP can be used for communication with the peer node. During connection set up each side of SCTP, advertise the IP address list to the peer node. The IP chosen for communication is called the primary IP.
This feature of SCTP provides carrying more than one user data messages inside a single SCTP data messages.
The protocol provides the heartbeat mechanism for SCTP connection monitoring. Once a connection is set up, each end starts sending a heartbeat to the peer and wait for its acknowledgment on each path within the connection.