[Freeswitch-users] TCP vs UDP (was Re: Freeswitch doesnt transcode)

Ken Rice krice at freeswitch.org
Mon Feb 15 21:53:12 MSK 2016


Lawrence,

Well Said! 

There is one upside., atleast Microsoft pushed the TCP stuff hard with Lync
so maybe we'll start seeing more traction there...

In reguards to the WebRTC stuff, imho SIP over WebRTC is a bit heavy
handed... something simple like Verto provides a lower overhead (in the
browser) and allows for push/pull eventing... wish we would see wider
adoption of such things in the near to mid terms

-----Original Message-----
From: freeswitch-users-bounces at lists.freeswitch.org
[mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Lawrence
Conroy
Sent: Monday, February 15, 2016 12:45 PM
To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
Subject: Re: [Freeswitch-users] TCP vs UDP (was Re: Freeswitch doesnt
transcode)

Hi Ken, Conor, folks,
  Along time ago in a land far away ... the [very] early history of SIP was
tied up with a bunch of other multimedia SxP things.
The big driver at that time was being able to do conferencing and media
distribution -- after all, voice calls could be done with H.323 et al. The
SDP (and SIP main part headers) were quite simple and small [**]. This was a
message based scheme, and UDP is a messaging transport, as opposed to TCP
which is a stream transport.

IIRC, mapping from PSTN schemes (again, message-based systems) to UDP seemed
simpler.
TCP required maintaining transport session state in gateways, and the stacks
in those gateways were primitive, to say the least.

Despite that, folk pushing for TCP to be mandatory were told that it was
considered 2nd class and should not be mandatory to implement); that was in
'97 as I recall.

Then (late 98 -> 2001) cable labs & 3GPP decided SIP was easier to bend to
their will than H.323/224/..., and the number of headers grew like topsy,
the complexity of the maintained state just kept on building, and we ran
into fragment problems.
Quick fix was header compression, but that ran into company-political issues
in 3GPP and anyway couldn't keep up with the 5,000 new headers there seemed
to be per week. THEN there was a drift away from UDP and towards TCP for
purely practical reasons, and TCP became mandatory to implement (but NOT, of
course mandatory to use, as there were any number of bits of kit out there
that didn't have support for it :).

Long story, but in short -- with the continued introduction of bloat (e.g.,
IMHO all the web RTC driven stuff) UDP is getting VERY tight on MTU limits.
That shouldn't be a problem but is because frags are not dealt with well by
end systems (as customer router/end system IP stacks tend to be nasty
brutish and short on development).

SO ... TCP has advantages (as long as your system can handle many parallel
TCP sessions), is marginally slower on initial set up, but doesn't have to
maintain the t30 et al timer stuff. From memory, getting the TCP stack
tweaked for ultra-high load systems was a pain and led to obscure behaviour,
but available TCP stacks seem generally better now.
UDP was simpler to map to message based systems at gateways, didn't have to
use good IP stacks as you were rolling your own logic, but given the lard
that is SIP/SDP now, that's the least of your coding worries.

For carriers, I understand why they have a reflex against maintaining state,
and they're using kit that is "mature". It's hard to justify replacing kit
that's familiar, has a management UI your staff know, and had its costs
amortised away years ago; VoIP is not a high profit service so the bean
counters WILL ask.

=> TCP may be 'better', but UDP is in kit that isn't going away soon.

all the best,
  Lawrence


**: Remember, at the time ('97-'98) Henning Schulzrinne was teaching at
Columbia University a post-grad course on IP comms during which he gave
"implement a SIP-based voice call system" as a [two week] homework exercise,
followed by interops between the clients. It had to be simple (and he was a
"hard task master" [or words to that effect]; he knew that UDP forced all
the timer logic to be coded as well).

On 15 Feb 2016, at 16:35, Ken Rice <krice at freeswitch.org> wrote:
> The problem still exists for expanding SDPs. using TCP to the 
> user/device then trying to send the same thing out to the carrier over 
> UDP is what was causing the problem in the first place. so the 
> decision was made to prevent those problems we'll only offer what the 
> device offers and not expand the number of codecs even further 
> increasing the already bloated SDPs to the point where they fragment 
> over UDP and get dropped.
>  
> So is TCP better for some things, yes it is, however, the lack of 
> market wide support for it with carriers makes it a pain in the ass 
> even tho the RFCs specifically say you MUST support both UDP and TCP 
> for SIP, but certain VoIP softwares out there only implemented UDP 
> many years ago and now we're stuck with that legacy
>  
> From: freeswitch-users-bounces at lists.freeswitch.org 
> [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of 
> Colton Conor
> Sent: Monday, February 15, 2016 10:30 AM
> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
> Subject: Re: [Freeswitch-users] Freeswitch doesnt transcode
>  
> True,
>  
> But freeswitch talking to the carriers is almost always UPD.
>  
> However, freeswitch talking to the clients I would say TCP would be 
> idea. So its almost like freeswitch is trancoding from TCP to UDP too 
> :)
>  
> On Mon, Feb 15, 2016 at 10:25 AM, Ken Rice <krice at freeswitch.org> wrote:
> The problem isn't necessarily the devices, but there is also the 
> carriers.
>  
> From: freeswitch-users-bounces at lists.freeswitch.org 
> [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of 
> Colton Conor
> Sent: Monday, February 15, 2016 10:04 AM
> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org>
> Subject: Re: [Freeswitch-users] Freeswitch doesnt transcode
>  
> So if the device supports TCP, is there any reason not to use TCP. AKA is
there any reason to keep on using UDP. TCP seems superior. 
>  
> On Mon, Feb 15, 2016 at 9:33 AM, Michael Jerris <mike at jerris.com> wrote:
> any device that even remotely follows sip specs supports TCP.  Most 
> phones I have seen do.
> 
> 
> On Sunday, February 14, 2016, Colton Conor <colton.conor at gmail.com> wrote:
> So is TCP the preferred method of doing SIP these days? I like TCP with
endpoints as they always break through firewalls and we never seem to have
in issue with TCP. However UDP is a headache. So if you have the choice why
not do TCP? I realize some devices only support UDP, but the majority of SIP
phones out there today do support TCP.
>  
> Plus if you use TLS for encryption and security then you are already using
TCP right? 
>  
> On Sun, Feb 14, 2016 at 4:07 PM, Ken Rice <krice at freeswitch.org> wrote:
> This behavior changed a while ago. This was dictates by ever growing 
> SDPs and exceeding MTUs causing udp fragmentation. Udp does not deal 
> with fragmentation and everyone refuses to fully implement sip over 
> tcp for some reason even tho a ton of things support it and the RFCs 
> require it
> 
> Sent from my iPhone
> 
> > On Feb 14, 2016, at 3:37 PM, Rajil Saraswat <rajil.s at gmail.com> wrote:
> >
> > Thanks, after setting media_mix_inbound_outbound_codecs=true,
> > transcoding happens automatically.  I remember not setting this 
> > variable in other installations and transcoding used to work out of 
> > the box. Is media_mix_inbound_outbound_codecs=true default in 
> > Freeswitch?
> >
> >> On 14 February 2016 at 13:56, Russell Treleaven
<rtreleaven at bunnykick.ca> wrote:
> >> fyi 
> >> https://freeswitch.org/confluence/display/FREESWITCH/Codec+Negotiat
> >> ion
> >>
> >>> On Sun, Feb 14, 2016 at 2:04 PM, Rajil Saraswat <rajil.s at gmail.com>
wrote:
> >>>
> >>> The siptrace is at http://pastebin.com/xiGqtj1Y
> >>>
> >>> The call is being made from 303 (Android/CSipsimple with OPUS 
> >>> codec) to 208 (pjsua test client with PCMU codec). The error is on
line 545.
> >>>
> >>> On 14 February 2016 at 11:28, Giovanni Maruzzelli 
> >>> <gmaruzz at gmail.com>
> >>> wrote:
> >>>> How you originate the call? Is a bridge? >From which phone?
> >>>>
> >>>> Also, please pastebin the complete sip trace (from start of leg A 
> >>>> to end of both legs) and put here a link to pastebin
> >>>>
> >>>> Il 14/Feb/2016 03:54, "Rajil Saraswat" <rajil.s at gmail.com> ha
scritto:
> >>>>>
> >>>>> Hello,
> >>>>>
> >>>>> I have a remote sip phone (Linksys SPA3102) which only supports
PCMU.
> >>>>> When I call to this remote sip phone i get a 406 error that opus 
> >>>>> is not supported as shown by the sip trace below. However, if I 
> >>>>> force the codec to absolute like this
> >>>>> {absolute_codec_string='PCMU,PCMA'}sofia/internal/303 at 192.168.1.
> >>>>> 5
> >>>>> the call works fine.
> >>>>>
> >>>>> Is there anyway I can make FreeSWITCH to automatically transcode 
> >>>>> without forcing the codec string in the dial plan?
> >>>>>
> >>>>> The codec preferences is set as  
> >>>>> global_codec_prefs=OPUS,PCMU,PCMA and 
> >>>>> outbound_codec_prefs=PCMU,PCMA,GSM
> >>>>>
> >>>>> ---------------------------siptrace-----------------------------
> >>>>> ---
> >>>>>
> >>>>> recv 333 bytes from udp/[192.168.1.5]:5060 at 08:02:16.368499:
> >>>>>
> >>>>>
> >>>>>
------------------------------------------------------------------------
> >>>>>   SIP/2.0 406 Not Acceptable
> >>>>>   Via: SIP/2.0/UDP
> >>>>>
> >>>>>
> >>>>>
192.168.1.111;rport=5060;received=192.168.1.111;branch=z9hG4bKeS356tttajjej
> >>>>>   Call-ID: 00ff246a-4d66-1234-f4b2-74d02b7a3124
> >>>>>   From: "202" <sip:202 at 192.168.1.111>;tag=DFX0FUvr2vNcm
> >>>>>   To: <sip:303 at 192.168.1.5>;tag=htMF9ckdglw3EJRZaILd6XWt4uVKAO8q
> >>>>>   CSeq: 87372504 INVITE
> >>>>>   Content-Length:  0
> >>>>>
> >>>>>
> >>>>>
> >>>>> ----------------------------------------------------------------
> >>>>> -------- send 324 bytes to udp/[192.168.1.5]:5060 at 
> >>>>> 08:02:16.368591:
> >>>>>
> >>>>>
> >>>>>
------------------------------------------------------------------------
> >>>>>   ACK sip:303 at 192.168.1.5 SIP/2.0
> >>>>>   Via: SIP/2.0/UDP 192.168.1.111;rport;branch=z9hG4bKeS356tttajjej
> >>>>>   Max-Forwards: 68
> >>>>>   From: "202" <sip:202 at 192.168.1.111>;tag=DFX0FUvr2vNcm
> >>>>>   To: <sip:303 at 192.168.1.5>;tag=htMF9ckdglw3EJRZaILd6XWt4uVKAO8q
> >>>>>   Call-ID: 00ff246a-4d66-1234-f4b2-74d02b7a3124
> >>>>>   CSeq: 87372504 ACK
> >>>>>   Content-Length: 0
> >>>>>
> >>>>>
> >>>>>
> >>>>> ----------------------------------------------------------------
> >>>>> --------
> >>>>> 2016-02-14 08:02:16.356283 [DEBUG] sofia.c:6760 Channel
> >>>>> sofia/internal/303 at 192.168.1.5 entering state [terminated][406]
> >>>>> 2016-02-14 08:02:16.356283 [NOTICE] sofia.c:7779 Hangup
> >>>>> sofia/internal/303 at 192.168.1.5 [CS_CONSUME_MEDIA] 
> >>>>> [SERVICE_NOT_IMPLEMENTED]
> >>>>>
> >>>>> Thanks
> >>>>> Rajil
> >>>>>
> >>>>>
> >>>>> ________________________________________________________________
> >>>>> _________ Professional FreeSWITCH Consulting Services:
> >>>>> consulting at freeswitch.org
> >>>>> http://www.freeswitchsolutions.com
> >>>>>
> >>>>> Official FreeSWITCH Sites
> >>>>> http://www.freeswitch.org
> >>>>> http://confluence.freeswitch.org http://www.cluecon.com
> >>>>>
> >>>>> FreeSWITCH-users mailing list
> >>>>> FreeSWITCH-users at lists.freeswitch.org
> >>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> >>>>>
> >>>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswit
> >>>>> ch-users
> >>>>> http://www.freeswitch.org
> >>>>
> >>>>
> >>>>
> >>>> _________________________________________________________________
> >>>> ________ Professional FreeSWITCH Consulting Services:
> >>>> consulting at freeswitch.org
> >>>> http://www.freeswitchsolutions.com
> >>>>
> >>>> Official FreeSWITCH Sites
> >>>> http://www.freeswitch.org
> >>>> http://confluence.freeswitch.org
> >>>> http://www.cluecon.com
> >>>>
> >>>> FreeSWITCH-users mailing list
> >>>> FreeSWITCH-users at lists.freeswitch.org
> >>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> >>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitc
> >>>> h-users
> >>>> http://www.freeswitch.org
> >>>
> >>> __________________________________________________________________
> >>> _______ Professional FreeSWITCH Consulting Services:
> >>> consulting at freeswitch.org
> >>> http://www.freeswitchsolutions.com
> >>>
> >>> Official FreeSWITCH Sites
> >>> http://www.freeswitch.org
> >>> http://confluence.freeswitch.org
> >>> http://www.cluecon.com
> >>>
> >>> FreeSWITCH-users mailing list
> >>> FreeSWITCH-users at lists.freeswitch.org
> >>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> >>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch
> >>> -users
> >>> http://www.freeswitch.org
> >>
> >>
> >>
> >> ___________________________________________________________________
> >> ______ Professional FreeSWITCH Consulting Services:
> >> consulting at freeswitch.org
> >> http://www.freeswitchsolutions.com
> >>
> >> Official FreeSWITCH Sites
> >> http://www.freeswitch.org
> >> http://confluence.freeswitch.org
> >> http://www.cluecon.com
> >>
> >> FreeSWITCH-users mailing list
> >> FreeSWITCH-users at lists.freeswitch.org
> >> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> >> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-
> >> users
> >> http://www.freeswitch.org
> >
> > ____________________________________________________________________
> > _____ Professional FreeSWITCH Consulting Services:
> > consulting at freeswitch.org
> > http://www.freeswitchsolutions.com
> >
> > Official FreeSWITCH Sites
> > http://www.freeswitch.org
> > http://confluence.freeswitch.org
> > http://www.cluecon.com
> >
> > FreeSWITCH-users mailing list
> > FreeSWITCH-users at lists.freeswitch.org
> > http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> > UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-u
> > sers
> > http://www.freeswitch.org
> 
> ______________________________________________________________________
> ___ Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
> 
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-use
> rs
> http://www.freeswitch.org
>  
> 
> ______________________________________________________________________
> ___ Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
> 
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-use
> rs
> http://www.freeswitch.org
>  
> 
> ______________________________________________________________________
> ___ Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
> 
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-use
> rs
> http://www.freeswitch.org
>  
> ______________________________________________________________________
> ___ Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
> 
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-use
> rs
> http://www.freeswitch.org


_________________________________________________________________________
Professional FreeSWITCH Consulting Services: 
consulting at freeswitch.org
http://www.freeswitchsolutions.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org




Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list