[erlang-questions] gen_tcp:send(Sock, SmallPacket) issue

Fredrik Thulin ft@REDACTED
Thu Jun 21 10:47:42 CEST 2007


David Mercer wrote:
...
> My own personal experience has been the opposite: that I have defaulted to
> using TCP because that is the more popular protocol, and it is touted as
> being more reliable than UDP.  However, most ad hoc protocols require some
> sort of acknowledgement from the receiving application.  If the receiving
> application is sending an ack anyway, and you're going to rely on that
> rather than just assuming TCP is reliable, then why not drop TCP altogether
> in favor of its faster cousin, UDP?  With the caveat that your messages must
> be short enough to fit in a single datagram, so that you do not have to
> implement message reassembly at the receiving application or anything like
> that.

I've implemented a SIP stack (in Erlang), and would like to share my 
opinion here. I don't mean to offend anyone, I just have a strong 
opinion ;).

Doing anything except streaming data over UDP is a mistake (*). SIP is 
_much_ more complex today than it would've been if it had not been 
designed to work over unreliable transports, such as UDP. The complexity 
comes from having to implement retransmissions yourself, and even though 
SIP has done just that, it hasn't solved all issues with flow control 
and messages larger than your typical MTU.

I understand that you talk about a simple protocol, but even then I 
would use TCP, with an application level ACK, because in my experience 
you always end up reimplementing TCP over UDP, or end up using UDP and 
missing out of useful features of TCP.

/Fredrik

* Oh sure, there _are_ things that you actually have to do using UDP 
(like DNS, because of the root nameserver situation) but IMO these 
things are so few that we can just as well just leave them out of the 
discussion.



More information about the erlang-questions mailing list