calricon.
VoIP & Telecom

Fixing SIP UDP Fragmentation and Call Setup Drops in Kamailio

Nov 14, 2026/5 min read/Verified Production Playbook

calricon / field note

Large SIP INVITE packets carrying WebRTC SDPs, multiple codecs,

Nov 14, 2026/VoIP & Telecom
354
Advertisement

Fixing SIP UDP Fragmentation and Call Setup Drops in Kamailio

In production VoIP environments, outbound and inbound SIP INVITE requests occasionally vanish mid-flight with zero response—no 100 Trying, no 4xx rejection, and a hard 408 Request Timeout after 32 seconds. Packet captures taken on the originating Kamailio proxy or Asterisk PBX confirm the INVITE left the network interface, yet the downstream carrier SBC never logs an incoming packet.

The verified root cause is IPv4 UDP fragmentation triggered by oversized SIP signaling payloads. Modern INVITE messages carrying STIR/SHAKEN Identity headers, multi-hop Record-Route chains, WebRTC ICE candidates, and broad codec offers routinely exceed 1,500 bytes, causing intervening firewalls, cloud NAT gateways, and carrier routers to silently discard fragmented UDP datagrams.



Problem Diagnosis & Root Cause Architecture


  • RFC 3261 1,300-Byte Threshold Violation: RFC 3261 Section 18.1.1 specifies that any SIP request larger than 1,300 bytes (or within 200 bytes of the path MTU) must be transmitted over a congestion-controlled transport such as TCP rather than UDP.

  • IPv4 Fragmentation & Stateless Firewall Drops: Standard Ethernet frames enforce a 1,500-byte MTU (1,472 bytes of UDP payload after 20-byte IP and 8-byte UDP headers). Trailing IP fragments lack Layer-4 UDP port headers, causing stateless firewalls, cloud NAT gateways, and carrier SBCs to drop them silently.

  • SDP & SIP Header Bloat Multipliers: WebRTC ICE candidates, SRTP crypto attributes, 8+ offered codecs (Opus, G.722, G.729, PCMU, PCMA), and 600-byte STIR/SHAKEN Identity headers routinely push total INVITE sizes from 900 bytes to 1,800–2,600 bytes.

  • PJSIP Reassembly & Parse Failures: Even when fragmented UDP packets reach a destination PBX, virtualized NICs or SIP stacks may only parse the first fragment, resulting in truncated header exceptions or silent transaction timeouts.



Fragmented SIP over UDP is functionally undeliverable across public carrier interconnects. Reliable call setup requires automatic TCP transport promotion above 1,300 bytes combined with deterministic SDP and header size reduction.


Why Standard Implementations Fail

Default Disabled MTU Switching in Kamailio

Kamailio ships with udp_mtu = 0 by default, which disables automatic protocol switching. Even if a downstream carrier supports SIP over TCP, Kamailio continues transmitting 1,900-byte INVITE packets over UDP unless global MTU fallback is explicitly enabled.



Missing TCP Listeners in Asterisk PJSIP

Asterisk res_pjsip enables automatic UDP-to-TCP switching by default (disable_tcp_switch=no), but PJSIP can only switch to a transport that is actively bound. If pjsip.conf defines a UDP transport without a matching TCP transport block, PJSIP silently falls back to sending the oversized packet over fragmented UDP.



Unfiltered WebRTC and Multi-Codec SDP Offers

Forwarding raw SDP bodies from WebRTC clients or multi-codec IP phones straight to PSTN trunks leaves dozens of a=candidate lines and unused a=rtpmap definitions intact, needlessly inflating every signaling packet by 600–1,000 bytes.



Validated Step-by-Step Resolution Playbook

Step 1: Enable RFC 3261 UDP-to-TCP Fallback in Kamailio

Configure Kamailio's core parameters in /etc/kamailio/kamailio.cfg to automatically promote any outbound SIP request exceeding 1,300 bytes to TCP, and ensure asynchronous TCP handling is active for high-concurrency signaling.



####### Global Parameters #########
udp_mtu=1300
udp_mtu_try_proto=TCP

# Ensure TCP listeners and async workers are enabled
listen=udp:https://www.google.com/url?q=https://www.google.com/url?q%3Dhttp://203.0.113.10:5060%26source%3Dgmail%26ust%3D1794763349802000%26sa%3DE&source=gmail&ust=1794763415295000&sa=E
listen=tcp:https://www.google.com/url?q=https://www.google.com/url?q%3Dhttp://203.0.113.10:5060%26source%3Dgmail%26ust%3D1794763349802000%26sa%3DE&source=gmail&ust=1794763415295000&sa=E
tcp_async=yes
tcp_connection_lifetime=3605
tcp_max_connections=4096

For per-route control when interfacing with specific trunks that support TLS or TCP, invoke udp_mtu_try_proto(TCP); inside your relay route before calling t_relay().



Step 2: Prune Unused Codecs and ICE Candidates in rtpengine

When bridging WebRTC or internal endpoints to PSTN carriers via rtpengine, strip ICE attributes and restrict the outbound SDP codec list to only the codecs supported by your carrier trunk. This typically cuts SDP body size by 50–70%.



route[NATMANAGE] {
if (is_request() && has_body("application/sdp")) {
# Strip ICE candidates and whitelist only G.711 + DTMF for PSTN trunks
rtpengine_offer("replace-origin replace-session-connection ICE=remove codec-strip-all codec-offer-PCMU codec-offer-PCMA codec-offer-telephone-event");
}
}


Step 3: Configure PJSIP TCP Transport and Compact Headers in Asterisk

On Asterisk servers, bind a dedicated TCP transport alongside UDP and enable RFC 3261 compact header notation (f:, t:, v:, i:, m:, c:, l:) in /etc/asterisk/pjsip.conf. Compact headers alone save 80–150 bytes per INVITE without altering signaling semantics.



[global]
type=global
compact_headers=yes
disable_tcp_switch=no

[transport-udp]
type=transport
protocol=udp
bind=https://www.google.com/url?q=https://www.google.com/url?q%3Dhttp://0.0.0.0:5060%26source%3Dgmail%26ust%3D1794763349802000%26sa%3DE&source=gmail&ust=1794763415295000&sa=E

[transport-tcp]
type=transport
protocol=tcp
bind=https://www.google.com/url?q=https://www.google.com/url?q%3Dhttp://0.0.0.0:5060%26source%3Dgmail%26ust%3D1794763349802000%26sa%3DE&source=gmail&ust=1794763415295000&sa=E

Reload the configuration or restart Asterisk so the global PJSIP stack parameters take effect:



systemctl restart asterisk
asterisk -rx "pjsip show transports"


Step 4: Trim Non-Essential Headers on Legacy UDP-Only Trunks

When a legacy carrier strictly refuses SIP over TCP and requires UDP delivery, trim strictly informational SIP headers in Kamailio as a controlled fallback—never remove routing, Supported, or session-timer headers.



route[TRIM_UDP_HEADERS] {
if ($proto == "udp" && $ml > 1300) {
remove_hf("User-Agent");
remove_hf("Server");
remove_hf("Allow");
remove_hf("Date");
msg_apply_changes();
}
}


Step 5: Verify Packet Sizes and Fragmentation in Production

Confirm that zero fragmented SIP packets are leaving your network interfaces and validate that oversized INVITE transactions are cleanly switching to TCP.



# Capture any fragmented IPv4 packets on SIP port 5060 (should return 0 packets)
tcpdump -ni any 'ip[6:2] & 0x1fff != 0 and port 5060' -c 20

# Verify TCP SIP signaling traffic on port 5060
tcpdump -ni any 'tcp port 5060' -c 20

# Check Kamailio TCP connection statistics
kamcmd core.tcp_info
Advertisement
Engineering Advisory 48-Hour Audit Turnaround

Experiencing this issue in your production systems?

Calricon conducts senior-level VoIP, SIP trunking, Asterisk, and cloud infrastructure audits. We review your live configs, identify packet drops or contention bottlenecks, and provide exact remediation runbooks.