Export to GitHub

csipsimple - issue #705

TCP vs UDP


Posted on Feb 10, 2011 by Swift Horse

I am still a little unclear about the usage of TCP and UDP. I am using a Nexus One, CM6.1, csipsimple (latest dev version), and pbxes.

My small understanding of VoIP is that there are two sort of data exchange processes. The first takes care of the signalling, set-up, tear-down, etc. between the client and server.

The second is the actually flow of audio (media) packets once the call is underway.

My intuition is that, ideally, the first data stream (signalling) should use TCP, the second (media) should use UDP.

I know that pbxes is somewhat unique in that it supports TCP (I understand sipsorcery also does, but I don't have an account). Is that for signalling, media, or both?

Where are these settings made? I see a per-account "Transport" option. Is this for signalling, media, both?

I apologize if this has been covered elsewhere. Feel free to merge this issue with others as appropriate.

Comment #1

Posted on Feb 10, 2011 by Quick Hippo

Your understood is absolutely right.

Media use RTP (real time packets which is UDP). This is the only way to pass media. There is more evolved level such as ZRTP and SRTP which are secured, but always using UDP. For signaling you can use UDP or TCP (or both). TCP is better for signaling cause : * You can pass bigger packets * NAT traversal is easier * Keep alive could be less important cause routers usually keep longer TCP stream alive.

So if possible and CORRECTLY supported by the SIP server, better to use TCP instead of UDP.

In CSipSimple it's a per account setting and can be configured using specific wizards if the sip provider is known as supporting correctly TCP transport (for example ippi) or in expert wizard mode as you stated.

However, pbxes.org has an weird bug with their server so that their support of TCP transport is not compliant with SIP specifications. SipDroid is not affected by the bug cause it does not follow the SIP specifications at the letter.

As consequence I do not enable to activate TCP transport in pbxes.org wizard util pbxes.org fix their server or somebody (or me) contribute a workaround that not break the rest of the standard behavior of CSipSimple regarding SIP routes. For more details about that, read issue 604 .

Comment #2

Posted on Feb 10, 2011 by Swift Horse

If the transport is selected per account, why is there the option to enable or disable UDP and TCP in Settings->Network?

Comment #3

Posted on Feb 10, 2011 by Quick Hippo

You should not disable this transport unless you know exactly what you are doing (that's expert settings ;) ).

In fact, globally you can decide to not create TCP or UDP transport. Then accounts, stun, turn and everything in the stack that need to access network will try to use one of the globaly available transport.

The account setting tell that for this account sip stack has to find a TCP transport and send it using TCP transport. However, if SIP server ask implicitly or explicitly to use UDP while configured over TCP, sip stack will use UDP transport (cause that's actually asked by the SIP server). It could happen in many case (request xfer / routing changes to another server that only support udp...). Besides other stuff such as STUN only works using UDP transport. As consequence, unless you know exactly what you are doing and have a good knowledge of the pjsip stack, do not disable UDP or TCP in global settings (this one is just for pjsip experts ;) ).

Comment #4

Posted on Feb 10, 2011 by Quick Hippo

In fact the transport is not "set" per account : when you choose transport TCP,

  • If account is set to proxy its request (proxy field is set), it add an information to the proxy uri telling the stack that request done to this proxy should be done using TCP
  • If no proxy is set for the account it only add the information to the registrar uri so that register will be done over TCP. As without proxy, your sip client directly send requests to others client, INVITEs will be sent using tcp unless you manually when dialing (username@domain.loc;transport=tcp)

So, when using TCP, if you'd like all request going through TCP, it's better to use a SIP proxy for your request. That make absolutely sense cause other clients may not support TCP, so it's better to have a TCP proxy in the middle.

Status: Duplicate

Labels:
Type-Defect Priority-Medium