summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Adam <jakub.adam@ktknet.cz>2015-09-02 16:32:05 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2015-09-02 16:33:22 +0100
commitab4ced5a46a7edba7cd49c0495bc41cd8fff7cc2 (patch)
treef68c5996d6a4a7bdc3ee4e2631d56f52788e9f2b
parentabdab053af41068406caf95e80a64c512fd3db90 (diff)
downloadlibnice-ab4ced5a46a7edba7cd49c0495bc41cd8fff7cc2.tar.gz
ms-turn: don't wait for a reply to STUN_SEND request
As per [MS-TURN] Section 2.2.1, TURN message type 0x0104 "Send request response" isn't supported and the TURN server MUST NOT send them. Thus, libnice should not remember Send requests in agent->sent_ids because without replies coming, the number of allowed pending transaction gets quickly exhausted, causing our data packets to be dropped until a request timeout frees some space in the queue. This behavior resulted in choppy reception of our audio on a Lync client when connected via Lync Edge (TURN) Server. Maniphest Tasks: T126 Reviewers: pwithnall Projects: #libnice Reviewed By: pwithnall Subscribers: pwithnall Differential Revision: https://phabricator.freedesktop.org/D223
-rw-r--r--socket/udp-turn.c3
-rw-r--r--stun/stunagent.c16
2 files changed, 16 insertions, 3 deletions
diff --git a/socket/udp-turn.c b/socket/udp-turn.c
index 2b20142..12f90a0 100644
--- a/socket/udp-turn.c
+++ b/socket/udp-turn.c
@@ -816,7 +816,8 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
/* Finish the message. */
msg_len = stun_agent_finish_message (&priv->agent, &msg,
priv->password, priv->password_len);
- if (msg_len > 0 && stun_message_get_class (&msg) == STUN_REQUEST) {
+ if (msg_len > 0 && stun_message_get_class (&msg) == STUN_REQUEST &&
+ priv->compatibility != NICE_TURN_SOCKET_COMPATIBILITY_OC2007) {
SendRequest *req = g_slice_new0 (SendRequest);
req->priv = priv;
diff --git a/stun/stunagent.c b/stun/stunagent.c
index 2abcc29..bd243cb 100644
--- a/stun/stunagent.c
+++ b/stun/stunagent.c
@@ -513,8 +513,20 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
uint32_t fpr;
int saved_id_idx = 0;
uint8_t md5[16];
+ bool remember_transaction;
- if (stun_message_get_class (msg) == STUN_REQUEST) {
+ remember_transaction = (stun_message_get_class (msg) == STUN_REQUEST);
+
+ if (agent->compatibility == STUN_COMPATIBILITY_OC2007 &&
+ stun_message_get_method (msg) == STUN_SEND) {
+ /* As per [MS-TURN] Section 2.2.1, the TURN server doesn't send responses to
+ * STUN_SEND requests, so don't bother waiting for them. More details at
+ * https://msdn.microsoft.com/en-us/library/dd946797%28v=office.12%29.aspx.
+ */
+ remember_transaction = FALSE;
+ }
+
+ if (remember_transaction) {
for (saved_id_idx = 0; saved_id_idx < STUN_AGENT_MAX_SAVED_IDS; saved_id_idx++) {
if (agent->sent_ids[saved_id_idx].valid == FALSE) {
break;
@@ -620,7 +632,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
}
- if (stun_message_get_class (msg) == STUN_REQUEST) {
+ if (remember_transaction) {
stun_message_id (msg, agent->sent_ids[saved_id_idx].id);
agent->sent_ids[saved_id_idx].method = stun_message_get_method (msg);
agent->sent_ids[saved_id_idx].key = (uint8_t *) key;