Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEL-6127 Do not count in invalid or unsupported XR reports. #313

Open
wants to merge 3 commits into
base: telnyx/telephony/development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions src/switch_rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7578,7 +7578,7 @@ static switch_status_t process_rtcp_xr_report(switch_rtcp_report_data_t *report_
uint16_t blen = 0;
uint16_t count = 0;

switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1,
"RTCP XR packet bytes %" SWITCH_SIZE_T_FMT " ssrc %u type %02x block len %d\n",
bytes, ntohl(packet->ssrc), header->bt & 0xff, plen);

Expand All @@ -7599,15 +7599,14 @@ static switch_status_t process_rtcp_xr_report(switch_rtcp_report_data_t *report_
header = (switch_rtcp_xr_rb_header *)((int32_t *)header + blen + 1);
}

switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Found %d report blocks\n", count);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Found %d report blocks\n", count);

if (!count) {
// No report blocks found
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "No report blocks found\n");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "No report blocks found\n");
return status;
}

report_data->xr_count = count;
switch_malloc(report_data->rtcp_data.xr_blocks, sizeof(switch_rtcp_xr_report) * count);
damirn marked this conversation as resolved.
Show resolved Hide resolved
header = &packet->rb_header;
count = 0;
Expand All @@ -7619,42 +7618,52 @@ static switch_status_t process_rtcp_xr_report(switch_rtcp_report_data_t *report_
// Skip any block with length == 0
if (blen) {
switch (header->bt) {
case XR_RR_TIME: {
case XR_RR_TIME:
{
switch_rtcp_xr_rb_rr_time *rr_time = (switch_rtcp_xr_rb_rr_time *) header;
uint32_t lsr = ntohl(rr_time->ntp_sec);
uint32_t dlsr = ntohl(rr_time->ntp_frac);
uint32_t rtt = 0;

if (lsr) {
rtt = (switch_micro_time_now() - lsr) - dlsr;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1,
"RTCP XR RR Time: LSR: %u DLSR: %u RTT: %u\n",
lsr, dlsr, rtt);
}
report_data->rtcp_data.xr_blocks[count].xr_pt = header->bt;
report_data->rtcp_data.xr_blocks[count].report_data.rr_time = rr_time;
}
break;
case XR_VOIP_METRICS: {
++count;
}
break;
case XR_VOIP_METRICS:
{
switch_rtcp_xr_rb_voip_metrics *voip_metrics = (switch_rtcp_xr_rb_voip_metrics *) header;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG,
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1,
"RTCP XR VoIP metrics: loss rate: %02x rt delay: %d es delay: %d \n", voip_metrics->loss_rate, voip_metrics->round_trip_delay, voip_metrics->end_system_delay);
report_data->rtcp_data.xr_blocks[count].xr_pt = header->bt;
report_data->rtcp_data.xr_blocks[count].report_data.voip_metrics = voip_metrics;
++count;
}
break;
damirn marked this conversation as resolved.
Show resolved Hide resolved
case XR_STATS: {
case XR_STATS:
{
switch_rtcp_xr_rb_stats *stats = (switch_rtcp_xr_rb_stats *) header;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1,
"RTCP XR Statistics summary: begin seq %d, end seq %d, lost packets %d\n", stats->begin_seq, stats->end_seq, stats->lost_packets);
damirn marked this conversation as resolved.
Show resolved Hide resolved
report_data->rtcp_data.xr_blocks[count].xr_pt = header->bt;
report_data->rtcp_data.xr_blocks[count].report_data.stats = stats;
++count;
}
default:
break;
default:
break;
}
++count;
}
header = (switch_rtcp_xr_rb_header *)((int32_t *)header + blen + 1);
}
report_data->xr_count = count;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Parsed %d report blocks\n", count);

return status;
}
#endif
Expand Down Expand Up @@ -7830,9 +7839,7 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t
}
}

if (report_data.xr_count > 0) {
switch_safe_free(report_data.rtcp_data.xr_blocks)
}
switch_safe_free(report_data.rtcp_data.xr_blocks)

if (!report) {
return status; // we received only XR report in this packet, do not calculate internal stats
Expand Down