summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2014-10-05 13:32:24 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2014-10-09 16:26:07 -0400
commitb4081039c52d91acb99c19a278d1119f8f13aabf (patch)
tree95390706da66352649cafa09cd8f6b7ae7df59e1
parentfa21e01e9b24bf8877a44a76b01e0192127e9abb (diff)
conncheck: Computer STUN retransmission timeout (RTO) dynamically
This is how it is specified in RFC 5245 section 16
-rw-r--r--agent/conncheck.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/agent/conncheck.c b/agent/conncheck.c
index fb6b87d..057fc81 100644
--- a/agent/conncheck.c
+++ b/agent/conncheck.c
@@ -1779,6 +1779,34 @@ size_t priv_get_password (NiceAgent *agent, Stream *stream,
return 0;
}
+/* Implement the computation specific in RFC 5245 section 16 */
+
+static unsigned int priv_compute_conncheck_timer (NiceAgent *agent,
+ Stream *stream)
+{
+ GSList *item;
+ guint waiting_and_in_progress = 0;
+ unsigned int rto = 0;
+
+ for (item = stream->conncheck_list; item; item = item->next) {
+ CandidateCheckPair *pair = item->data;
+
+ if (pair->state == NICE_CHECK_IN_PROGRESS ||
+ pair->state == NICE_CHECK_WAITING)
+ waiting_and_in_progress++;
+ }
+
+ /* FIXME: This should also be multiple by "N", which I believe is the
+ * number of Streams currently in the conncheck state. */
+ rto = agent->timer_ta * waiting_and_in_progress;
+
+ /* We assume non-reliable streams are RTP, so we use 100 as the max */
+ if (agent->reliable)
+ return MAX (rto, 500);
+ else
+ return MAX (rto, 100);
+}
+
/*
* Sends a connectivity check over candidate pair 'pair'.
*
@@ -1865,7 +1893,8 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
if (nice_socket_is_reliable(pair->sockptr)) {
stun_timer_start_reliable(&pair->timer, STUN_TIMER_DEFAULT_RELIABLE_TIMEOUT);
} else {
- stun_timer_start (&pair->timer, STUN_TIMER_DEFAULT_TIMEOUT,
+ stun_timer_start (&pair->timer,
+ priv_compute_conncheck_timer (agent, stream),
STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS);
}
@@ -2019,8 +2048,9 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
"restarting the timer again?: %s ..", agent,
p->timer_restarted ? "no" : "yes");
if (!nice_socket_is_reliable (p->sockptr) && !p->timer_restarted) {
- stun_timer_start (&p->timer, STUN_TIMER_DEFAULT_TIMEOUT,
- STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS);
+ stun_timer_start (&p->timer,
+ priv_compute_conncheck_timer (agent, stream),
+ STUN_TIMER_DEFAULT_MAX_RETRANSMISSIONS);
p->timer_restarted = TRUE;
}
}