TCP Transport for Endpoints

hraynor

Guru
Joined
Feb 11, 2009
Messages
137
Reaction score
1
Since one of my endpoints is an iPhone using Bria, I wished to used the TCP transport with Asterisk 1.8 (Purple build of PIAF 1.7.5.5.3 with Incredible PBX 1.8) in order to save on battery life...

For those who are interested, to do this, simply use the "Asterisk SIP Settings" under the "Other SIP Settings" item to add the following two items:

tcpenable=yes
tcpbindaddr=0.0.0.0

Then in sip_custom_post.conf , for each extension add:

[ext](+)
transport=tcp

where "ext" is the extension number. ie: for extension 710, add:

[710](+)
transport=tcp

You'll need to restart Asterisk in order to have this enabled (reloading the dial plan probably isn't enough, since Asterisk may not listen on the TCP port until you restart).

Works great for me.

BTW - if you have problems, to see if Asterisk REALLY is listening on TCP port 5060, type:

sudo netstat -tlpn | grep 5060


BTW - t'would be VERY nice if FreePBX not only had an option to specify transport on the Extension setup (or any generic option would do as well).
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,168
Reaction score
5,199
We've already enabled TCP 5060 in IPtables for Incredible PBX 1.8. :biggrin5:

I also passed along your suggestion to Philippe.
 

blanchae

Guru
Joined
Mar 12, 2008
Messages
1,910
Reaction score
9
I wonder if reloading the SIP config (sip reload) in the Asterisk CLI would be enough as opposed to restarting Asterisk?
 

hraynor

Guru
Joined
Feb 11, 2009
Messages
137
Reaction score
1
We've already enabled TCP 5060 in IPtables for Incredible PBX 1.8. :biggrin5:

I also passed along your suggestion to Philippe.

True, but you still need to tell Asterisk to listen on TCP port 5060. By default Asterisk does not (and this apparently holds true for Incredible PBX 1.8).

Thanks for passing along to Philippe. Think these (random options for extension settings and direct transport setting) would be great, and make things much easier without manually modifying the dial plan.
 

hraynor

Guru
Joined
Feb 11, 2009
Messages
137
Reaction score
1
I wonder if reloading the SIP config (sip reload) in the Asterisk CLI would be enough as opposed to restarting Asterisk?

Most likely you're right, just doing sip reload is fine.

I actually did a global "reload" from the Asterisk prompt just in case. I technically didn't kill Asterisk and restart, so that isn't necessary.

BTW - works VERY well, and iPhone battery doesn't seem to drain NEARLY as fast. Wonder if I can now turn off some of the background settings in Bria (can't remember the name, and iPhone is downstairs, I'm too lazy to grab it) to save more battery power (reportedly (from memory), if you use TCP, these are optional).
 

jroper

Guru
Joined
Oct 20, 2007
Messages
3,832
Reaction score
71
Hi

Just a couple of points to note:-

1. SIP over TCP is only supported in Asterisk 1.6 and greater
2. You can add all sorts of global options to SIP and IAX via the SIP and IAX modules under tools, that I believe appeared in FreePBX 2.7

Joe
 

kazibole

New Member
Joined
Oct 24, 2010
Messages
18
Reaction score
0
I've successfully enabled SIP over TCP. My Bria iphone softphone is working fine over TCP.

I have also successfully changed my SIP UDP port to something other than 5060, this works fine.

I am trying to change my SIP TCP port but no matter what I try, Asterisk only listens on 5060 for SIP over TCP (confirmed by sudo netstat -tlpn)

I've tried setting "tcpbindport=xxxx" but that doesn't work. I've also tried changing the "port" entry on the extension without any luck either. I've also made the appropriate port change in iptables, and also disabled iptables, no luck. I am running Asterisk 1.6.

Any ideas? status-output attached.
 

Attachments

  • status-output.txt
    4.8 KB · Views: 9

blanchae

Guru
Joined
Mar 12, 2008
Messages
1,910
Reaction score
9
Here's some background info on TCP vs. UDP. Keep in mind that SIP is the control protocol and RTP is the protocol used for transporting the actual voice call. RTP is used over UDP.

TCP is a connection oriented protocol. It will throttle bandwidth using a sliding window methodology. It guarantees end to end delivery of data by using acknowledgements. It will provide error checking and retransmission of bad or lost data. It puts out of sequence segments back in order. This adds to the overhead, uses more bandwidth and adds latency to the data stream. It is a great protocol for data but bad for real-time multimedia traffic like voice.

UDP is a connectionless protocol. It is send and pray: it sends the data out and hope that it gets there. There is no error checking as it assumes that the application will handle it. Any datagrams that are lost or have errors are simply dropped. This is a horrible protocol for data but great for real-time multimedia like voice.

In real-time traffic, there is no time to request retransmission, error checking, resequence datagrams or waste time with acknowledgements. Lost voice information is just dropped. As long as the datagrams are small in size, the lost information is not noticable. Typical voice datagram data size is only 10 - 30 bytes which is about 10 mS of voice.

The following is information from Digium's bug tracker on SIP over TCP and some problems that may occur:

----------------------------------------------------------------------
rjain - 11-03-07 09:33
----------------------------------------------------------------------
I haven't studied this patch in great detail. However, one thing about
supporting SIP-over-TCP is that it is much more than delineating SIP
messages in a TCP byte stream. There are quite a few issues that one needs
to grapple with.

A some of use wrote an internet-draft in the IETF to provide guidelines to
implementers who wish to develop SIP over connection-oriented transport
protocols such as TCP and SCTP:

http://www.croczilla.com/zap/rfcs/draft-gurbani-sipping-connection-guidelines-01.txt

In general, SIP-over-TCP implementations face some major issues:

1. NAT Traversal: The problem of SIP NAT traversal is much worst w/ TCP
than UDP. Basically, you'll have to always initiate the TCP connection from
the client sitting behind the NAT and keep it always open else the NAT will
block the call from * to user/peer. The I-D below discusses this topic in
plenty detail:

http://www.ietf.org/internet-drafts/draft-ietf-sip-outbound-10.txt

1. The need for persistent-connections becomes really important when you
run SIP/TLS/TCP. The issue is latency introduced in TLS connection
establishments which will add to post-dial latency. So, this becomes a
pretty critical requirement for SIP trunking scenarios. The I-D below
discusses this topic (it proposes using LRU for managing TCP sockets and
also offers a nice optimization that allows you to use one TCP socket for
transactions in opposite directions):

http://www.ietf.org/internet-drafts/draft-ietf-sip-connect-reuse-08.txt
-

Now on the other side of the coin is this pro SIP over TCP argument which provides a detailed argument why no network service should use SIP over UDP and an extemely strong argument as to why SIP over TCP is a good thing.

A lot of the pro SIP over TCP is to interface with Microsoft's Office Communication Server (OCS) which uses SIP over TCP. A big issue with SIP is that it is clear text and can be easily read and hacked. TCP helps secure it.
 

blanchae

Guru
Joined
Mar 12, 2008
Messages
1,910
Reaction score
9
I would like to see some hard data on whether or not using TCP versus UDP actually saves battery life. So far, we have "it appears to last longer".
 

lifespeed

Member
Joined
Sep 25, 2010
Messages
287
Reaction score
0
no luck so far

In Other SIP Settings in FreePBX I entered:
Code:
tcpenable=yes
tcpbindaddr=0.0.0.0

in sip_custom_post.conf I inserted the following for extension 1:
Code:
[1](+)
transport=tcp

Then I rebooted the atom PC.

SSH'ing into the PIAF box I entered:

Code:
root@pbx:~ $ sudo netstat -tlpn | grep 5060
tcp        0      0 0.0.0.0:5060                0.0.0.0:*                   LISTEN      3278/asterisk

Unfortunately, the iPhone with Bria still fails to register over TCP. The edits to sip_custom_post.conf also broke UDP registration, so had to remove them for the moment.

Any idea what I am doing wrong?
 

tbrummell

Guru
Joined
Jan 8, 2011
Messages
1,275
Reaction score
339
Thanks for the instructions. My Android phone is now using native SIP over TCP. Will see how long battery life is like this. It's horrible using UDP, hoping for an improvement.
 

nunya

Member
Joined
Oct 1, 2010
Messages
44
Reaction score
3
Thanks for posting the tutorial. I'm using Groundwire (Acrobits) via TCP for incoming. I hope this saves some battery life.
 
Joined
Feb 13, 2011
Messages
330
Reaction score
12
In Other SIP Settings in FreePBX I entered:
Code:
tcpenable=yes
tcpbindaddr=0.0.0.0

in sip_custom_post.conf I inserted the following for extension 1:
Code:
[1](+)
transport=tcp

Then I rebooted the atom PC.

SSH'ing into the PIAF box I entered:

Code:
root@pbx:~ $ sudo netstat -tlpn | grep 5060
tcp        0      0 0.0.0.0:5060                0.0.0.0:*                   LISTEN      3278/asterisk

Unfortunately, the iPhone with Bria still fails to register over TCP. The edits to sip_custom_post.conf also broke UDP registration, so had to remove them for the moment.

Any idea what I am doing wrong?


Same problem here ..................... no one ??????????

I manage to register the extension but incoming calls dont work...
 

nunya

Member
Joined
Oct 1, 2010
Messages
44
Reaction score
3
I wanted to update. I have been using the iPhone 4 with Groundwire (Acrobits) for a while now. With the SIP over TCP, the increase in battery life was minimal - at best.
 

Members online

No members online now.

Forum statistics

Threads
25,779
Messages
167,505
Members
19,199
Latest member
leocipriano
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top