Skip to content
Snippets Groups Projects
Commit e26f9399 authored by Mohamed Chibani's avatar Mohamed Chibani
Browse files

ice/pjnath: use higher Ta interval

Use a higher Ta value (50ms instead of 20ms) as
recommended by newer ICE spec (RFC-8445).
This will reduce bandwith usage (peaks) needed for the connectivity
checks as described in RFC-8445.

Gitlab: #605

Change-Id: I6a228a47d5f6cf574003d1354c4410294aedf95a
parent 504e5460
No related branches found
No related tags found
No related merge requests found
From f448e54047b49938218f120e72d34563a94c3078 Mon Sep 17 00:00:00 2001
From: Mohamed Chibani <mohamed.chibani@savoirfairelinux.com>
Date: Thu, 26 Aug 2021 10:41:39 -0400
Subject: [PATCH 1/2] pjproject/0016-use-larger-Ta-interval
---
pjnath/include/pjnath/config.h | 2 +-
pjnath/src/pjnath/ice_session.c | 31 ++++++++++++++++++++-----------
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/pjnath/include/pjnath/config.h b/pjnath/include/pjnath/config.h
index 89b421c51..fe58be9c9 100644
--- a/pjnath/include/pjnath/config.h
+++ b/pjnath/include/pjnath/config.h
@@ -340,7 +340,7 @@
* Default: 20
*/
#ifndef PJ_ICE_TA_VAL
-# define PJ_ICE_TA_VAL 20
+# define PJ_ICE_TA_VAL 50
#endif
diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c
index 77d014d62..2e35d930e 100644
--- a/pjnath/src/pjnath/ice_session.c
+++ b/pjnath/src/pjnath/ice_session.c
@@ -2704,9 +2704,8 @@ static pj_status_t perform_check(pj_ice_sess *ice,
return status;
}
-
/* Start periodic check for the specified checklist.
- * This callback is called by timer on every Ta (20msec by default)
+ * This callback is called by timer on every Ta
*/
static pj_status_t start_periodic_check(pj_timer_heap_t *th,
pj_timer_entry *te)
@@ -2734,8 +2733,7 @@ static pj_status_t start_periodic_check(pj_timer_heap_t *th,
/* Set checklist state to Running */
clist_set_state(ice, clist, PJ_ICE_SESS_CHECKLIST_ST_RUNNING);
- LOG5((ice->obj_name, "Starting checklist periodic check"));
- pj_log_push_indent();
+ pj_ice_sess_check *check = NULL;
/* Send STUN Binding request for check with highest priority on
* Retry state.
@@ -2743,9 +2741,11 @@ static pj_status_t start_periodic_check(pj_timer_heap_t *th,
if (start_count == 0) {
for (i = 0; i < clist->count; ++i) {
- pj_ice_sess_check *check = &clist->checks[i];
+ check = &clist->checks[i];
// Reconnect closed TURN sockets
if (check->state == PJ_ICE_SESS_CHECK_STATE_NEEDS_RETRY) {
+ LOG5((ice->obj_name, "re-Starting periodic check for check %i (needs retry)", i));
+ pj_log_push_indent();
status = perform_check(ice, clist, i, ice->is_nominating);
if (status != PJ_SUCCESS && status != PJ_EPENDING) {
check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED,
@@ -2762,13 +2762,15 @@ static pj_status_t start_periodic_check(pj_timer_heap_t *th,
// TODO (sblin) remove - https://github.com/coturn/coturn/issues/408
pj_bool_t inc_counter = PJ_TRUE;
for (i = 0; i < clist->count; ++i) {
- pj_ice_sess_check *check = &clist->checks[i];
+ check = &clist->checks[i];
if (check->state == PJ_ICE_SESS_CHECK_STATE_NEEDS_FIRST_PACKET) {
if (inc_counter) {
td->first_packet_counter += 1;
inc_counter = PJ_FALSE;
}
if (td->first_packet_counter % 50 == 0) {
+ LOG5((ice->obj_name, "re-Starting periodic check for check %i (needs 1st packet)", i));
+ pj_log_push_indent();
status = perform_check(ice, clist, i, ice->is_nominating);
if (status != PJ_SUCCESS && status != PJ_EPENDING) {
check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED,
@@ -2788,9 +2790,12 @@ static pj_status_t start_periodic_check(pj_timer_heap_t *th,
if (start_count == 0) {
for (i = 0; i < clist->count; ++i) {
- pj_ice_sess_check *check = &clist->checks[i];
+ check = &clist->checks[i];
if (check->state == PJ_ICE_SESS_CHECK_STATE_WAITING) {
+ LOG5((ice->obj_name, "Starting periodic check for check %i (was waiting)", i));
+ pj_log_push_indent();
+
status = perform_check(ice, clist, i, ice->is_nominating);
if (status != PJ_SUCCESS && status != PJ_EPENDING) {
check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED,
@@ -2808,9 +2813,11 @@ static pj_status_t start_periodic_check(pj_timer_heap_t *th,
*/
if (start_count == 0) {
for (i = 0; i < clist->count; ++i) {
- pj_ice_sess_check *check = &clist->checks[i];
+ check = &clist->checks[i];
if (check->state == PJ_ICE_SESS_CHECK_STATE_FROZEN) {
+ LOG5((ice->obj_name, "Starting periodic check for check %i (was frozen)", i));
+ pj_log_push_indent();
status = perform_check(ice, clist, i, ice->is_nominating);
if (status != PJ_SUCCESS && status != PJ_EPENDING) {
check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED, status);
@@ -2825,7 +2832,7 @@ static pj_status_t start_periodic_check(pj_timer_heap_t *th,
if (start_count == 0) {
// If all sockets are pending, do nothing
for (i = 0; i < clist->count; ++i) {
- pj_ice_sess_check *check = &clist->checks[i];
+ check = &clist->checks[i];
if (check->state == PJ_ICE_SESS_CHECK_STATE_PENDING) {
++start_count;
break;
@@ -2833,8 +2840,11 @@ static pj_status_t start_periodic_check(pj_timer_heap_t *th,
}
}
- // Cannot start check because there's no suitable candidate pair.
+ // The checks are performed at the rate of 1 check per Ta
+ // interval. If a new check was started, we need to re-schedule
+ // for the next one (if any).
if (start_count!=0) {
+ pj_assert(check != NULL);
pj_time_val timeout = {0, PJ_ICE_TA_VAL};
pj_time_val_normalize(&timeout);
@@ -2847,7 +2857,6 @@ static pj_status_t start_periodic_check(pj_timer_heap_t *th,
return PJ_SUCCESS;
}
-
/* Start sending connectivity check with USE-CANDIDATE */
static void start_nominated_check(pj_ice_sess *ice)
{
--
2.25.1
......@@ -19,6 +19,7 @@
"0013-ignore-addresses-for-RFC7335.patch",
"0014-fix-socket-leak.patch",
"0015-fix-socktype-and-duplicate-checking.patch",
"0016-use-larger-Ta-interval.patch",
"0017-auto-register-thread.patch",
"0018-fix-ioqueue-lock-acquire.patch",
"0019-resort-check-list-after-adding-prflx.patch",
......
......@@ -61,6 +61,7 @@ pjproject: pjproject-$(PJPROJECT_VERSION).tar.gz .sum-pjproject
$(APPLY) $(SRC)/pjproject/0013-ignore-addresses-for-RFC7335.patch # TODO remove with 2.12 (https://github.com/pjsip/pjproject/commit/d245ffaf91120fab7bb70e3f46206faeb5b01269)
$(APPLY) $(SRC)/pjproject/0014-fix-socket-leak.patch
$(APPLY) $(SRC)/pjproject/0015-fix-socktype-and-duplicate-checking.patch # TODO remove with 2.12 (https://github.com/pjsip/pjproject/commits/2feee8db77ed47e7b574367295d4f03f9aea67f8)
$(APPLY) $(SRC)/pjproject/0016-use-larger-Ta-interval.patch
$(APPLY) $(SRC)/pjproject/0017-auto-register-thread.patch
$(APPLY) $(SRC)/pjproject/0018-fix-ioqueue-lock-acquire.patch
$(APPLY) $(SRC)/pjproject/0019-resort-check-list-after-adding-prflx.patch
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment