Asterisk and TCP

Hi everyone.
I have a question. I configured my Asterisk (1.6.0.22) to use TCP as transportation layer in this way:

sip.conf
[general]

tcpenable=yes
tcpbindaddr=0.0.0.0

Then on extensions I want to use TCP, I added:
transport=tcp
While other and trunks keep using UDP as normal.

I captured the packets, and I noticed the communications between IP Phones and Asterisk (e.g. 100, 180, 200, etc.) are now made by TCP.
But, the RTP ones, are still all on UDP.

I had never tried this, so I am going to ask you if it’s normal RTP keep run through UDP.

Thanks, MasterLog

RTP is always UDP. There are good reasons for using UDP for voice (retransmissions cause a short drop out, rather than a very long pause)…

Hi david55,
I didn’t know about that, so thanks for your reply.

So, using TCP, if a packet drops due to VPN lag, Asterisk should resend it after some seconds.
And the result, for example if “INVITE SIP/XXX” will get lost, due to its re-transmission the IP Phone will ring, but with a small delay, right?
With UDP, if the same “INVITE” packet will get lost, the IP Phone will never start to ring.
Am I correct?

Anyway, are there any valid reasons to avoid using TCP in cases like a VPN, where some packets can drop easily?

Thanks, MasterLog

With SIP over TCP, TCP will deal with retransmissions of SIP. With UDP, the SIP protocol is responsible for retransmissions.

If RTP where sent over TCP, TCP retransmissions rules would apply, which would mean that no packets would get through until all preceding ones were successfully received. That means that if there is a lost packet, you would have to wait for the TCP timeout. By that time several following packets would be stale, and would be ignored when they finally arrived.

Hi david55,
thank you very much for your reply.

Anyway, I still have a question: I was worried for some IP phones at the end of VPN who sometimes don’t start to ring, or sometimes don’t stop to ring. But no probs or less with voice communications.
I hope to fix them by using TCP protocols for SIP.

MasterLog