TCP Transport for Endpoints

Discussion in 'PIAF 3 Add-Ons' started by hraynor, Nov 8, 2010.

  1. hraynor

    hraynor Guru

    Joined:
    Feb 11, 2009
    Messages:
    137
    Likes Received:
    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).
     
  2. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,630
    Likes Received:
    2,497
    We've already enabled TCP 5060 in IPtables for Incredible PBX 1.8. :biggrin5:

    I also passed along your suggestion to Philippe.
     
  3. blanchae

    blanchae Guru

    Joined:
    Mar 12, 2008
    Messages:
    1,910
    Likes Received:
    9
    I wonder if reloading the SIP config (sip reload) in the Asterisk CLI would be enough as opposed to restarting Asterisk?
     
  4. hraynor

    hraynor Guru

    Joined:
    Feb 11, 2009
    Messages:
    137
    Likes Received:
    1
    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.
     
  5. hraynor

    hraynor Guru

    Joined:
    Feb 11, 2009
    Messages:
    137
    Likes Received:
    1
    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).
     
  6. jroper

    jroper Guru

    Joined:
    Oct 20, 2007
    Messages:
    3,833
    Likes Received:
    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
     
  7. kazibole

    kazibole New Member

    Joined:
    Oct 24, 2010
    Messages:
    18
    Likes Received:
    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.
     

    Attached Files:

  8. blanchae

    blanchae Guru

    Joined:
    Mar 12, 2008
    Messages:
    1,910
    Likes Received:
    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:

    -

    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.
     
  9. blanchae

    blanchae Guru

    Joined:
    Mar 12, 2008
    Messages:
    1,910
    Likes Received:
    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".
     
  10. lifespeed

    lifespeed Member

    Joined:
    Sep 25, 2010
    Messages:
    287
    Likes Received:
    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:
    [email protected]:~ $ 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?
     
  11. tbrummell

    tbrummell Guru

    Joined:
    Jan 8, 2011
    Messages:
    538
    Likes Received:
    40
    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.
     
  12. nunya

    nunya Member

    Joined:
    Oct 1, 2010
    Messages:
    44
    Likes Received:
    3
    Thanks for posting the tutorial. I'm using Groundwire (Acrobits) via TCP for incoming. I hope this saves some battery life.
     
  13. grillovillegas

    Joined:
    Feb 13, 2011
    Messages:
    302
    Likes Received:
    6

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

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

    nunya Member

    Joined:
    Oct 1, 2010
    Messages:
    44
    Likes Received:
    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.