SCTP Protocol tutorial:
The Internet is an IP based network. Which is in existence from a long time. A node in the IP network having a unique IP address. IP protocol provides functionality for routing a message from 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 which can maintain a session. TCP was the first protocol for creating a session or connection with the peer TCP. The web-based communication is based on TCP/IP. With the time, network at 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 purpose of its existence. One should understand the top level differences between these two protocols.
|Age||TCP is a much older protocol, have its presence from 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 check. These messages are heartbeat messages. SCTP user immediate get connection failure indication.|
|Stream-Based (sequence of bytes)||Messages flow over TCP connection in a stream of bytes. This required functionality in user of TCP to put start and end patterns for messages.||Message-based. Sender and receiver need to send and receive 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 application, 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 other. Remaining calls should not block.|
|Network Failure||Have single network between source to destination. Because TCP/IP have single IP address in an end point.||Can have multiple network from source to destination. Because SCTP/IP have multiple IP address in an end point.|
|User Base||Due to older protocol. TCP is used at many places. All http based communication is based on TCP.||Have uses at lesser places. 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 have a header and multiple chunks.
SCTP Header :
It is of 12 bytes long. Have source port , destination port , Verification tag and checksum.
Other than header , remaining message, contains chunks. A chuck is a control message for 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 peer node of data to user received from peer node.
SCTP Chunk types:
INIT - 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 advertise its own ip address. This is the first message for four way handshake.
INIT-ACK - Acknowledge of INIT, send by the server in response of 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 client. In this message, server includes list of ip address for its local point code.
COOKIE ECHO - It is part of association setup .On successful receive of INIT-ACK, client sends this message. This chunk have only one parameter , cookie.
COOKIE ACK- Acknowledgement send by the server for COOKIE-ECHO.
SACK- SCTP is a reliable protocol, means if a packet is lost , then the SCTP layer will do error correction by sending same packet again. User of layer will remain unknown from res-transmission. Till packet is not received by peer , sender keeps in sending queue. Remote peer sends the SACK or selective acknowledgement for a received packet. Upon receiving SACK , sender removes packet from queue.
HEARTBEAT - After association setup, each end starts monitoring link health. For this each end sends heartbeat message to peer and expects its response.
HEARTBEAT ACK - Acknowledge message for heartbeat. Upon missing ack message for a fix number of time, association marked as inactive and communication lost indication is sent to the user.
SCTP was standardized with many new features those were missing in legacy network protocols. These features enables sctp, to use for critical applications , e.g telephony. Following is list of key features of protocol.
Multi Streaming :
Before this protocol, connection oriented protocols e.g TCP, were using a single stream for transferring of data from source to destination. Single stream creates a issue of all communication blocking, in case of single byte failure, till the failed byte is re-transmitted. This is not suitable for time critical applications. Suppose there are ten calls are going on a TCP connections, there is problem in byte related to a single call. This turns into blocking of packets for remaining 9 calls. Which eventually may cause lost of call at all, because of timeout on telephone exchange.
SCTP over come from single point of blocking, by providing multiple streams in a connection with peer. This makes communication faster as well.
Datagram Protocol Style :
Despite that its a connection oriented, but it is a datagram based protocol. In TCP, a sender and receiver has to put identifier for start and end of a message. Creates additional burden over transport protocol users and before communication both sides should agreed on common delimiters. This protocol, provides message based communication over a connection.
In TCP, an endpoint have single ip address and a port. If that ip is unreachable or disconnected from network, the TCP connection break down with the peer node. Sctp have feature of multi homing, where the sctp endpoint may have multiple ip addresses and a port. So if one ip unreachable , any other ip can be used for communication with peer node. During connection setup each end advertise its sets of ips to the peee node. The ip chosen for communication is called 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 setup, each end starts sends heartbeat and wait for its acknowledgment on each path with in the connection.