Default socket option for TCP and TLS sockets to avoid sending more than one SIP message per TCP packet - suggestion for improvement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was working with the older Asterisk PBX and used PJSIP to get calls going a with secure RTP and over TLS. 

My registrations and subscriptions were all working fine. Yet, when I was making calls there was a problem 

with TLS. Wireshark was showing as if the PBX was terminating TCP/TLS connections. It boiled down to a 

fact that the PBX was not able to process 2 consecutive SIP messages coming from the PJSIP client.


Client                            PBX

-----------INVITE------------------>

<--------------401------------------

---------------ACK----------------->

-------------INVITE---------------->  // the PBX had problems getting this message


It turns out that PJSIP was stuffing 2 SIP messages in a single TCP packet. The PBX was smart enough to get the ACK 

but failed to figure out there was an INVITE too.


TCP connection by default uses Nagle's algorithm in which it collects several smaller packets and then sends it as

one. Since telephony is a more real-time thing rather than not, it is better to configure TCP not to use Nangle's algorithm

and send each SIP messages in a separate TCP packet. A way to do so is to set TCP_NODELAY socket option.


I saw few posts on the internet where people complained a TLS connection was terminated by the PBX during a call

setup. They could not figure out reasons for such behavior.  It took me a while to find out why it was happening to

me. Especially, since some other branded phones worked with the PBX just fine.


Please consider this improvement it may save someone else's time and efforts.


Regards,

Zarko

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux