with SIP, when to use TCP not UDP?

Marcos picture Marcos · Mar 26, 2013 · Viewed 61.2k times · Source

I know pretty the differences between UDP and TCP in general (eg. http://www.onsip.com/about-voip/sip/udp-versus-tcp-for-voip)

Question is, in what circumstances would using TCP as the transport have advantages specifically under SIP VOiP communications?

Answer

MickJ picture MickJ · Mar 26, 2013

A lot of people would generally associate UDP with voip and probably leave it at that, but in simple terms there are two parts to voip - connection and voice data transfer.

SIP is a very light weight protocol, once the connections is established it's effectively left idle until the infrequent event of someone making a phone call. TCP (unlike UDP) will actually reduce traffic to the server by eliminating need to;

  1. Re-register every few minutes
  2. Refresh/ping server

You can run SIP over TCP and then use (as is recommended) UDP for RTP.

I couldn't help but also point out the obvious things that I have looked over. Eg. number of devices connecting to the server. As the number grows, the equation tilts in UDPs favor. But then you also have to consider SIP User Agents expanding to cover multiple codecs, multimedia, video and screen-sharing. The INVITE packets can start to grow large and potentially run over the UDP single datagram size thereby tilting the equation again in favor of TCP.

All that being said I hope you have enough information to answer the question you were looking to answer.

Hope this helps.

Credit: The wonderful discussion at onSip: https://www.onsip.com/blog/sip-via-udp-vs-tcp