[Asterisk-code-review] res pjsip: Set TCP NODELAY on TCP transports (asterisk[13])

George Joseph asteriskteam at digium.com
Sun May 15 19:08:19 CDT 2016


George Joseph has uploaded a new change for review.

  https://gerrit.asterisk.org/2839

Change subject: res_pjsip:  Set TCP_NODELAY on TCP transports
......................................................................

res_pjsip:  Set TCP_NODELAY on TCP transports

Although it's perfectly legal to place multiple SIP messages in the same packet,
it can cause problems because the Linux default is to enable Path MTU Discovery
which sets the Don't Fragment bit on the packets. If adding a second message to
the packet causes the MTU to be exceeded, and the destination isn't equipped to
send a FRAGMENTATION NEEDED response to a large packet, the packet will just be
dropped.

We can't specifically tell the stack to send only 1 message per packet, but we
can turn on TCP_NODELAY when we create the transport. This will at least tell
the stack to send packets as soon as possible.

ASTERISK-26005 #close
Reported-by: Ross Beer

Change-Id: I820f23227183f2416ca5e393bec510e8fe1c8fbd
---
M res/res_pjsip/config_transport.c
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/39/2839/1

diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c
index 3a5afb6..b920897 100644
--- a/res/res_pjsip/config_transport.c
+++ b/res/res_pjsip/config_transport.c
@@ -562,11 +562,17 @@
 		}
 	} else if (transport->type == AST_TRANSPORT_TCP) {
 		pjsip_tcp_transport_cfg cfg;
+		int option = 1;
 
 		pjsip_tcp_transport_cfg_default(&cfg, temp_state->state->host.addr.sa_family);
 		cfg.bind_addr = temp_state->state->host;
 		cfg.async_cnt = transport->async_operations;
 		set_qos(transport, &cfg.qos_params);
+		cfg.sockopt_params.options[0].level = pj_SOL_TCP();
+		cfg.sockopt_params.options[0].optname = pj_TCP_NODELAY();
+		cfg.sockopt_params.options[0].optval = &option;
+		cfg.sockopt_params.options[0].optlen = sizeof(option);
+		cfg.sockopt_params.cnt = 1;
 
 		for (i = 0; i < BIND_TRIES && res != PJ_SUCCESS; i++) {
 			if (perm_state && perm_state->state && perm_state->state->factory

-- 
To view, visit https://gerrit.asterisk.org/2839
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I820f23227183f2416ca5e393bec510e8fe1c8fbd
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: George Joseph <gjoseph at digium.com>



More information about the asterisk-code-review mailing list