From 55ba140da126c78013fe1a6055d750ee10b60ecf Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Fri, 29 Nov 2013 11:16:07 +0100 Subject: mgcp/rtp: Fix output timing error counter The tsdelta computation and error detection didn't handle the intialisation phase properly. This patches fixes this by skipping the output timing validation when the SSRCs don't match. Sponsored-by: On-Waves ehf --- openbsc/src/libmgcp/mgcp_network.c | 17 ++++++++++++++--- openbsc/tests/mgcp/mgcp_test.ok | 36 ++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index 75d39c195..53f1a20e9 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -237,6 +237,16 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta state->jitter = 0; state->transit = arrival_time - timestamp; state->out_stream = state->in_stream; + state->out_stream.last_timestamp = timestamp; + /* force output SSRC change */ + state->out_stream.ssrc = rtp_hdr->ssrc - 1; + LOGP(DMGCP, LOGL_INFO, + "Initializing stream on 0x%x SSRC: %u timestamp: %u " + "from %s:%d in %d\n", + ENDPOINT_NUMBER(endp), state->in_stream.ssrc, + state->seq_offset, + inet_ntoa(addr->sin_addr), ntohs(addr->sin_port), + endp->conn_mode); } else if (state->in_stream.ssrc != rtp_hdr->ssrc) { int32_t tsdelta = state->out_stream.last_tsdelta; if (tsdelta == 0) { @@ -286,9 +296,10 @@ void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta } /* Check again, whether the timestamps are still valid */ - check_rtp_timestamp(endp, &state->out_stream, rtp_end, addr, - seq, timestamp, "output", - &state->out_stream.last_tsdelta); + if (state->out_stream.ssrc == rtp_hdr->ssrc) + check_rtp_timestamp(endp, &state->out_stream, rtp_end, addr, + seq, timestamp, "output", + &state->out_stream.last_tsdelta); /* * The below takes the shape of the validation from Appendix A. Check diff --git a/openbsc/tests/mgcp/mgcp_test.ok b/openbsc/tests/mgcp/mgcp_test.ok index 57d3bfbcb..4d3caacb5 100644 --- a/openbsc/tests/mgcp/mgcp_test.ok +++ b/openbsc/tests/mgcp/mgcp_test.ok @@ -80,15 +80,15 @@ TS: 1400, dTS: 120, TS Errs: in 4, out 4 TS: 1560, dTS: 160, TS Errs: in 5, out 5 TS: 1720, dTS: 160, TS Errs: in 5, out 5 Output SSRC changed to 10203040 -TS: 34688, dTS: 32968, TS Errs: in 5, out 6 -TS: 34848, dTS: 160, TS Errs: in 5, out 7 -TS: 35008, dTS: 160, TS Errs: in 5, out 7 -TS: 35128, dTS: 120, TS Errs: in 6, out 8 -TS: 35288, dTS: 160, TS Errs: in 7, out 9 -TS: 35448, dTS: 160, TS Errs: in 7, out 9 -TS: 35768, dTS: 160, TS Errs: in 7, out 9 -TS: 35928, dTS: 160, TS Errs: in 7, out 9 -TS: 36088, dTS: 160, TS Errs: in 8, out 10 +TS: 34688, dTS: 160, TS Errs: in 5, out 5 +TS: 34848, dTS: 160, TS Errs: in 5, out 5 +TS: 35008, dTS: 160, TS Errs: in 5, out 5 +TS: 35128, dTS: 120, TS Errs: in 6, out 6 +TS: 35288, dTS: 160, TS Errs: in 7, out 7 +TS: 35448, dTS: 160, TS Errs: in 7, out 7 +TS: 35768, dTS: 160, TS Errs: in 7, out 7 +TS: 35928, dTS: 160, TS Errs: in 7, out 7 +TS: 36088, dTS: 160, TS Errs: in 8, out 8 Testing packet error detection, patch timestamps. Output SSRC changed to 11223344 TS: 0, dTS: 0, TS Errs: in 0, out 0 @@ -104,15 +104,15 @@ TS: 1400, dTS: 120, TS Errs: in 4, out 4 TS: 1560, dTS: 160, TS Errs: in 5, out 5 TS: 1720, dTS: 160, TS Errs: in 5, out 5 Output SSRC changed to 10203040 -TS: 34688, dTS: 32968, TS Errs: in 5, out 6 -TS: 34848, dTS: 160, TS Errs: in 5, out 7 -TS: 35008, dTS: 160, TS Errs: in 5, out 7 -TS: 35128, dTS: 120, TS Errs: in 6, out 8 -TS: 35288, dTS: 160, TS Errs: in 7, out 9 -TS: 35448, dTS: 160, TS Errs: in 7, out 9 -TS: 35768, dTS: 160, TS Errs: in 7, out 9 -TS: 35928, dTS: 160, TS Errs: in 7, out 9 -TS: 36088, dTS: 160, TS Errs: in 8, out 10 +TS: 34688, dTS: 160, TS Errs: in 5, out 5 +TS: 34848, dTS: 160, TS Errs: in 5, out 5 +TS: 35008, dTS: 160, TS Errs: in 5, out 5 +TS: 35128, dTS: 120, TS Errs: in 6, out 6 +TS: 35288, dTS: 160, TS Errs: in 7, out 7 +TS: 35448, dTS: 160, TS Errs: in 7, out 7 +TS: 35768, dTS: 160, TS Errs: in 7, out 7 +TS: 35928, dTS: 160, TS Errs: in 7, out 7 +TS: 36088, dTS: 160, TS Errs: in 8, out 8 Testing packet error detection, patch SSRC, patch timestamps. Output SSRC changed to 11223344 TS: 0, dTS: 0, TS Errs: in 0, out 0 -- cgit v1.2.3