SCTP - TCP meets UDP
After reading an IBM developerworks article on SCTP, the code looks relatively simple and I got inspired to try it out. According to the article:
The Stream Control Transmission Protocol (SCTP) is a reliable transport protocol that provides stable, ordered delivery of data between two endpoints (much like TCP) and also preserves data message boundaries (like UDP). However, unlike TCP and UDP, SCTP offers such advantages as multi-homing and multi-streaming capabilities, both of which increase availability. In this article, get to know the key features of SCTP in the Linux® 2.6 kernel and take a look at the server and client source code that shows the protocol’s ability to deliver multi-streaming.
I have a Fedora Core 4 system and to my dismay I do not have the proper headers and libraries installed to try out the examples. Fortunately, Fedora Core 4’s kernel comes with SCTP support. However, the actual implementation requires user space headers and libraries. A few additional package were necessary.
yum install lksctp-tools lksctp-tools-devel
After this, the code now built properly. I decided to write a multi-process (with 2 streams) version and see how it fares compared to a TCP version. Well, after sending 10,000 messages, it takes the TCP version 4-5 seconds to reply to all of these messages. It takes the SCTP version 6-7 seconds to reply to all of these messages. Considering this SCTP version sends data in two (2) streams (or more or less the same data size - 427 bytes), this is pretty good. However, after compiling the sources to do 100,000 messages, the gap widens. The SCTP versions took around 46 seconds. While, the TCP version took 27 seconds to complete. Probably the two (2) streams do play a role after all.
Then, I removed the two (2) streams and made it one. Surprisingly, the durations did not change significantly. The SCTP version still took around 46 seconds and the TCP version still took around 27 seconds. Anyway, for those of you who would like to validate my code here it is.
SCTP probably has a greater packet overhead than both TCP and UDP (I configured it to do a max of 4 attempts until success, 2 stream and the second stream was empty). I was expecting a best of both worlds system where SCTP’s performance was in the middle of both TCP and UDP. Well, all these benefits come at a price after all.
