Stream Control Transmission Protocol

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.

I did not know about the existence of this kind of socket:

Similar to TCP and UDP, SCTP provides some features of both. It is message-oriented, and provides a reliable sequenced delivery of messages. SCTP supports multi-homing, i.e., multiple IPs on both sides of the connection. So it is called an association instead of a connection, as a connection involves communication between two IPs, while an association refers to communication between two systems that may have multiple IPs.

SCTP can provide multiple streams between connection endpoints, and each stream will have its own reliable sequenced delivery of messages, so any lost message will not block the delivery of messages in any of the other streams. SCTP is not vulnerable to SYN flooding, as it requires a 4-way handshake.

We will discuss the science later, and now jump to the code, as we usually do. But first you need to know the types of SCTP sockets:

A one-to-one socket that corresponds to exactly one SCTP association (similar to TCP).

A one-to-many socket, where many SCTP associations can be active on a socket simultaneously (similar to UDP receiving datagrams from several endpoints).

One-to-one sockets (also called TCP-style sockets) were developed to ease porting existing TCP applications to SCTP, so the difference between a server implemented using TCP and SCTP is not much. We just need to modify the call to socket() to socket(AF_INET, SOCK_STREAM, and IPPROTO_SCTP) while everything else stays the same — the calls to listen(), accept() for the server, and connect() for the client, with read() and write() calls for both.

Post external references

  1. 1
    http://www.opensourceforu.com/2011/12/socket-api-part-5-sctp/
Source