Hello Kamailio Community,
I recently encountered an interesting behavior when using Kamailio to relay SIP messages from a WebSocket client to FreeSWITCH over UDP. *Observed Behavior:*
- The WebSocket client sends an *INVITE* with a large SDP. - Kamailio forwards this request over UDP to FreeSWITCH. - Upon inspection, the *SDP in the relayed message appears truncated*. (Probably MTU limit) - *Surprisingly, the call still establishes successfully*, and there are no noticeable issues with audio or call setup.
*My Questions:*
1. *Is this expected behavior?* Should Kamailio automatically truncate SDP when relaying from WebSocket to UDP? 2. *Could this be working accidentally?* For example, is FreeSWITCH handling the partial SDP gracefully by default? 3. *Should I be concerned about potential failures in different scenarios?* (e.g., ICE candidate loss, missing codec negotiation)
I would appreciate any insights from the community on whether this is a known or expected behavior in Kamailio, or if it might be a configuration issue.
Thanks in advance for your help!
Best regards, Pavan Kumar
On Mar 11, 2025, at 10:24 PM, Pavan Kumar via sr-users sr-users@lists.kamailio.org wrote:
Hello Kamailio Community, • Is this expected behavior? Should Kamailio automatically truncate SDP when relaying from WebSocket to UDP?
Yes. Often referred to as UDP fragmentation.
• Could this be working accidentally? For example, is FreeSWITCH handling the partial SDP gracefully by default?
It could be working non-accidentally. ;) As long as the packets are received well, there may not be a problem.
• Should I be concerned about potential failures in different scenarios? (e.g., ICE candidate loss, missing codec negotiation)
Alex Balashov wrote up a nice piece many years ago… https://blog.evaristesys.com/2016/02/04/sip-udp-fragmentation-and-kamailio-t...
There’s generally 2 ways of approaching it…
A) Switch to TCP for that connection B) Keep as is
Depending on the amount of traffic you are pushing through, TCP is generally a safe method of handling. If you’re running a considerable load (especially considering the system is also running websockets), you may need to tune your system appropriately.
If these two systems were (let’s say) on the same LAN and even lucky enough to be on dedicated VLAN, then if there wasn’t any problem in the fragmentation, you may just be fine to let it go as is.
Regards,
Fred Posner
Hi
Technically, the SDP does not get truncated. At the SIP/SDP level, there's no truncation. Fragmentation happens at the IP layer. If kamailio sends a large SIP/SDP message and the other side receives only one fragment, then it the receiving SIP application will never see it. There's no danger of the SIP application getting only a partial SIP/SDP message due to fragmentation.
is FreeSWITCH handling the partial SDP
No. It cannot receive only a partial SDP. It's all or nothing.
Should I be concerned about ... missing codec negotiation
No. It can't happen.
Maybe you captured traffic and didn't see all of the fragments. Check it again and see that the whole SDP was definitely sent and received. If the traffic is working, then (as Fred says) you may just be fine to let it go as is. You're possibly simply thinking you have a problem when it may not even exist. On the other hand, if you start getting packet loss, then you may have a problem.
James
On Wed, 12 Mar 2025 at 03:27, Fred Posner via sr-users sr-users@lists.kamailio.org wrote:
On Mar 11, 2025, at 10:24 PM, Pavan Kumar via sr-users sr-users@lists.kamailio.org wrote:
Hello Kamailio Community, • Is this expected behavior? Should Kamailio automatically truncate SDP when relaying from WebSocket to UDP?
Yes. Often referred to as UDP fragmentation.
• Could this be working accidentally? For example, is FreeSWITCH handling the partial SDP gracefully by default?
It could be working non-accidentally. ;) As long as the packets are received well, there may not be a problem.
• Should I be concerned about potential failures in different scenarios? (e.g., ICE candidate loss, missing codec negotiation)
Alex Balashov wrote up a nice piece many years ago… https://blog.evaristesys.com/2016/02/04/sip-udp-fragmentation-and-kamailio-t...
There’s generally 2 ways of approaching it…
A) Switch to TCP for that connection B) Keep as is
Depending on the amount of traffic you are pushing through, TCP is generally a safe method of handling. If you’re running a considerable load (especially considering the system is also running websockets), you may need to tune your system appropriately.
If these two systems were (let’s say) on the same LAN and even lucky enough to be on dedicated VLAN, then if there wasn’t any problem in the fragmentation, you may just be fine to let it go as is.
Regards,
Fred Posner
Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Thanks, Fred and James, for pointing me to the UDP fragmentation mechanism.
As James mentioned, using tcpdump with the -A option didn’t display the fragmented part, that's where all confusion arised.
Best regards, Pavan Kumar
On Wed, Mar 12, 2025 at 3:42 PM James Browne james@frideo.com wrote:
Hi
Technically, the SDP does not get truncated. At the SIP/SDP level, there's no truncation. Fragmentation happens at the IP layer. If kamailio sends a large SIP/SDP message and the other side receives only one fragment, then it the receiving SIP application will never see it. There's no danger of the SIP application getting only a partial SIP/SDP message due to fragmentation.
is FreeSWITCH handling the partial SDP
No. It cannot receive only a partial SDP. It's all or nothing.
Should I be concerned about ... missing codec negotiation
No. It can't happen.
Maybe you captured traffic and didn't see all of the fragments. Check it again and see that the whole SDP was definitely sent and received. If the traffic is working, then (as Fred says) you may just be fine to let it go as is. You're possibly simply thinking you have a problem when it may not even exist. On the other hand, if you start getting packet loss, then you may have a problem.
James
On Wed, 12 Mar 2025 at 03:27, Fred Posner via sr-users sr-users@lists.kamailio.org wrote:
On Mar 11, 2025, at 10:24 PM, Pavan Kumar via sr-users <
sr-users@lists.kamailio.org> wrote:
Hello Kamailio Community, • Is this expected behavior? Should Kamailio automatically
truncate SDP when relaying from WebSocket to UDP?
Yes. Often referred to as UDP fragmentation.
• Could this be working accidentally? For example, is FreeSWITCH
handling the partial SDP gracefully by default?
It could be working non-accidentally. ;) As long as the packets are
received well, there may not be a problem.
• Should I be concerned about potential failures in different
scenarios? (e.g., ICE candidate loss, missing codec negotiation)
Alex Balashov wrote up a nice piece many years ago…
https://blog.evaristesys.com/2016/02/04/sip-udp-fragmentation-and-kamailio-t...
There’s generally 2 ways of approaching it…
A) Switch to TCP for that connection B) Keep as is
Depending on the amount of traffic you are pushing through, TCP is
generally a safe method of handling. If you’re running a considerable load (especially considering the system is also running websockets), you may need to tune your system appropriately.
If these two systems were (let’s say) on the same LAN and even lucky
enough to be on dedicated VLAN, then if there wasn’t any problem in the fragmentation, you may just be fine to let it go as is.
Regards,
Fred Posner
Kamailio - Users Mailing List - Non Commercial Discussions --
sr-users@lists.kamailio.org
To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to
the sender!
Note that it's not just the -A option you have going. I will guess that you've got a capture filter like port 5060. The fragmented UDP packets don't have port numbers, so they will get dropped by the capture.
Regards, Kaufman
________________________________ From: Pavan Kumar via sr-users sr-users@lists.kamailio.org Sent: Thursday, March 13, 2025 11:16 AM To: James Browne james@frideo.com Cc: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org; Fred Posner fred@pgpx.io; Pavan Kumar pavanputhra@gmail.com Subject: [SR-Users] Re: SDP Truncation When Relaying from WebSocket to UDP – Expected Behavior?
CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Thanks, Fred and James, for pointing me to the UDP fragmentation mechanism.
As James mentioned, using tcpdump with the -A option didn’t display the fragmented part, that's where all confusion arised.
Best regards, Pavan Kumar
On Wed, Mar 12, 2025 at 3:42 PM James Browne <james@frideo.commailto:james@frideo.com> wrote: Hi
Technically, the SDP does not get truncated. At the SIP/SDP level, there's no truncation. Fragmentation happens at the IP layer. If kamailio sends a large SIP/SDP message and the other side receives only one fragment, then it the receiving SIP application will never see it. There's no danger of the SIP application getting only a partial SIP/SDP message due to fragmentation.
is FreeSWITCH handling the partial SDP
No. It cannot receive only a partial SDP. It's all or nothing.
Should I be concerned about ... missing codec negotiation
No. It can't happen.
Maybe you captured traffic and didn't see all of the fragments. Check it again and see that the whole SDP was definitely sent and received. If the traffic is working, then (as Fred says) you may just be fine to let it go as is. You're possibly simply thinking you have a problem when it may not even exist. On the other hand, if you start getting packet loss, then you may have a problem.
James
On Wed, 12 Mar 2025 at 03:27, Fred Posner via sr-users <sr-users@lists.kamailio.orgmailto:sr-users@lists.kamailio.org> wrote:
On Mar 11, 2025, at 10:24 PM, Pavan Kumar via sr-users <sr-users@lists.kamailio.orgmailto:sr-users@lists.kamailio.org> wrote:
Hello Kamailio Community, • Is this expected behavior? Should Kamailio automatically truncate SDP when relaying from WebSocket to UDP?
Yes. Often referred to as UDP fragmentation.
• Could this be working accidentally? For example, is FreeSWITCH handling the partial SDP gracefully by default?
It could be working non-accidentally. ;) As long as the packets are received well, there may not be a problem.
• Should I be concerned about potential failures in different scenarios? (e.g., ICE candidate loss, missing codec negotiation)
Alex Balashov wrote up a nice piece many years ago… https://blog.evaristesys.com/2016/02/04/sip-udp-fragmentation-and-kamailio-t...
There’s generally 2 ways of approaching it…
A) Switch to TCP for that connection B) Keep as is
Depending on the amount of traffic you are pushing through, TCP is generally a safe method of handling. If you’re running a considerable load (especially considering the system is also running websockets), you may need to tune your system appropriately.
If these two systems were (let’s say) on the same LAN and even lucky enough to be on dedicated VLAN, then if there wasn’t any problem in the fragmentation, you may just be fine to let it go as is.
Regards,
Fred Posner
Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.orgmailto:sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.orgmailto:sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Interesting, I definitely hand port filter. Now it makes sense.
Thanks Kaufman.
On Thu, 13 Mar 2025 at 10:19 PM, Ben Kaufman bkaufman@bcmone.com wrote:
Note that it's not just the -A option you have going. I will guess that you've got a capture filter like port 5060. The fragmented UDP packets don't have port numbers, so they will get dropped by the capture.
Regards, Kaufman
*From:* Pavan Kumar via sr-users sr-users@lists.kamailio.org *Sent:* Thursday, March 13, 2025 11:16 AM *To:* James Browne james@frideo.com *Cc:* Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org; Fred Posner fred@pgpx.io; Pavan Kumar pavanputhra@gmail.com *Subject:* [SR-Users] Re: SDP Truncation When Relaying from WebSocket to UDP – Expected Behavior?
*CAUTION:* This email originated from outside the organization. *Do not click links or open attachments* unless you recognize the sender and know the content is safe.
Thanks, Fred and James, for pointing me to the UDP fragmentation mechanism.
As James mentioned, using tcpdump with the -A option didn’t display the fragmented part, that's where all confusion arised.
Best regards, Pavan Kumar
On Wed, Mar 12, 2025 at 3:42 PM James Browne james@frideo.com wrote:
Hi
Technically, the SDP does not get truncated. At the SIP/SDP level, there's no truncation. Fragmentation happens at the IP layer. If kamailio sends a large SIP/SDP message and the other side receives only one fragment, then it the receiving SIP application will never see it. There's no danger of the SIP application getting only a partial SIP/SDP message due to fragmentation.
is FreeSWITCH handling the partial SDP
No. It cannot receive only a partial SDP. It's all or nothing.
Should I be concerned about ... missing codec negotiation
No. It can't happen.
Maybe you captured traffic and didn't see all of the fragments. Check it again and see that the whole SDP was definitely sent and received. If the traffic is working, then (as Fred says) you may just be fine to let it go as is. You're possibly simply thinking you have a problem when it may not even exist. On the other hand, if you start getting packet loss, then you may have a problem.
James
On Wed, 12 Mar 2025 at 03:27, Fred Posner via sr-users sr-users@lists.kamailio.org wrote:
On Mar 11, 2025, at 10:24 PM, Pavan Kumar via sr-users <
sr-users@lists.kamailio.org> wrote:
Hello Kamailio Community, • Is this expected behavior? Should Kamailio automatically
truncate SDP when relaying from WebSocket to UDP?
Yes. Often referred to as UDP fragmentation.
• Could this be working accidentally? For example, is FreeSWITCH
handling the partial SDP gracefully by default?
It could be working non-accidentally. ;) As long as the packets are
received well, there may not be a problem.
• Should I be concerned about potential failures in different
scenarios? (e.g., ICE candidate loss, missing codec negotiation)
Alex Balashov wrote up a nice piece many years ago…
https://blog.evaristesys.com/2016/02/04/sip-udp-fragmentation-and-kamailio-t...
There’s generally 2 ways of approaching it…
A) Switch to TCP for that connection B) Keep as is
Depending on the amount of traffic you are pushing through, TCP is
generally a safe method of handling. If you’re running a considerable load (especially considering the system is also running websockets), you may need to tune your system appropriately.
If these two systems were (let’s say) on the same LAN and even lucky
enough to be on dedicated VLAN, then if there wasn’t any problem in the fragmentation, you may just be fine to let it go as is.
Regards,
Fred Posner
Kamailio - Users Mailing List - Non Commercial Discussions --
sr-users@lists.kamailio.org
To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to
the sender!