SCTP (Stream Control Transmission Protocol) represents the transport layer preferred to use for SIGTRAN protocols because it provides:
- Connection oriented and packet based transmissions mechanisms.
- Message loss detection and sequence control algorithms.
- Multi stream message delivery
- Support for multi homed sockets.
- Message fragmentation
- Corrupt packet detection.
Connection oriented and packet based transmissions mechanisms.
For a better understanding let's take a closer look at world's most known socket types.
UDP (User Datagram Protocol)
UDP sockets provides a mechanism to transmit a packet from point A to point B without the need to establish a connection between A and B and with no concern about packet loss and sequence control. The lack of connection allows to an UDP socket user to send/receive messages to/from any destination without the need to create a new socket.
TCP (Transmission Control Protocol)
The TCP sockets also provides a mechanism to transmit messages form a point A to a point B but it provides sequence delivery and packet loss detection, and for this it requires to establish a connection first.
After the connection has been established the messages can start flowing in both directions. For each message the protocol assigns a sequence number to control in order delivery and to detect packet loss.
For a better understanding let's say that A has a message to send to B.
A detects that it needs to send a message to B and it puts the message in a queue, assigns a sequence number, starts a re-transmit timer, sends the message to B and waits for B to acknowledge the message.
If A is not informed by B that it received the message before re-transmit timer expires, it resend's the message. In this way packet loss detection is provided.
Let's say that A need to send another message and the previews message was not acknowledged by B.
A starts the send message procedure and sends the message to B.
B receives the second message and it checks the sequence number of the message. B Detects that the message is not the next one in sequence and it puts the message in a queue and acknowledges the message to A. After A's re-transmit timer expires A re-sends the first message. B receives the first message send by A, it acknowledges it and it delivers to user the firs message and after that the second. In this way sequence control is provided.
As we can see UDP sockets are packet based and TCP sockets are connection based. SCTP sockets can be packet or connection based depending on what they are used for.
Message loss detection and sequence control algorithms
As I was explaining on TCP sockets the SCTP sockets implements mostly the same algorithm for sequence control and packet loss. But this mechanisms are for both packet based and connection based.
Multi stream message delivery
When we have to transport a lot of data in real time over a socket, packet loss can be an issue because when a packet is lost the remote pear will not receive any messages until the lost packet is received ... this can cause delayed message processing witch in case of a M2PA link can trigger abort link alignment.
To avoid packet loss damage, in SCTP was introduced the notion of "stream". Mainly you can specify for each SCTP socket the number of streams to use and the socket will allocate, for each stream, a sequence number a re-trans timer and a message queue. In this way if a message send o stream 0 was lost the remote endpoint will continue delivering the messages received on other streams, without waiting for the message send on stream 0 to be recovered.
As an abstraction i think that we can look at SCTP multi stream delivery as at multiple TCP socket connections on the same coonection.
Support for multi homed sockets
I my opinion the main goal of SCTP sockets is to provide a reliable connection between two endpoints and keep it alive as long as the user needs it regardless of the network issues.
As we can see above the multi stream message delivery minimize the packet loss damage, but another issue is network unavailability.
In this way the SCTP sockets have support for multi homed. Basically this means that if we have two or more IP addresses we can tell to a SCTP socket to use all of them. In this way if the used interface goes down other interface will be selected to be used.
SCTP in YATE
SCTP implementation in YATE is based on LKSCTP library and is located in lksctp module located in modules/server/lksctp.cpp.
The rpm packets for the lksctp library can be found here.
A SCTP socket can be obtained with the help of "socket.sctp" message. For an example please check sigtransport module source file.