aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-09-15 18:30:26 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-09-15 18:30:26 +0200
commit2d7298182db8ce8ed84749c89e82f412cacda60f (patch)
tree23f3064a5772fcf3bef65125e91c238bf38ec80a /openbsc/src/libmgcp
parent4b4a187b4ffd9bd3eb1eac69160600f27f019fc1 (diff)
mgcp: Make the packet loss calculation per session
Somehow we end up with calculations of 65536 for the packet loss that is RTP_SEQ_MOD. So there might have been a sequence overflow but no packets to count against it. I have no idea how this can happen and could not reproduce it. But when we change the SSRC we should re-initialize the state. Separate the total packets and octets from the packets we count per SSRC. Related: OW#1489
Diffstat (limited to 'openbsc/src/libmgcp')
-rw-r--r--openbsc/src/libmgcp/mgcp_network.c10
-rw-r--r--openbsc/src/libmgcp/mgcp_protocol.c3
2 files changed, 7 insertions, 6 deletions
diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c
index c39b627c8..9d627aef0 100644
--- a/openbsc/src/libmgcp/mgcp_network.c
+++ b/openbsc/src/libmgcp/mgcp_network.c
@@ -350,6 +350,7 @@ void mgcp_rtp_annex_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *sta
state->stats_jitter = 0;
state->stats_transit = transit;
state->stats_cycles = 0;
+ state->stats_packets = 0;
} else {
uint16_t udelta;
@@ -705,6 +706,7 @@ static int rtp_data_net(struct osmo_fd *fd, unsigned int what)
}
proto = fd == &endp->net_end.rtp ? MGCP_PROTO_RTP : MGCP_PROTO_RTCP;
+ endp->net_state.stats_packets += 1;
endp->net_end.packets += 1;
endp->net_end.octets += rc;
@@ -797,6 +799,7 @@ static int rtp_data_bts(struct osmo_fd *fd, unsigned int what)
}
/* do this before the loop handling */
+ endp->bts_state.stats_packets += 1;
endp->bts_end.packets += 1;
endp->bts_end.octets += rc;
@@ -1026,8 +1029,7 @@ int mgcp_free_rtp_port(struct mgcp_rtp_end *end)
void mgcp_state_calc_loss(struct mgcp_rtp_state *state,
- struct mgcp_rtp_end *end, uint32_t *expected,
- int *loss)
+ uint32_t *expected, int *loss)
{
*expected = state->stats_cycles + state->stats_max_seq;
*expected = *expected - state->stats_base_seq + 1;
@@ -1042,8 +1044,8 @@ void mgcp_state_calc_loss(struct mgcp_rtp_state *state,
* Make sure the sign is correct and use the biggest
* positive/negative number that fits.
*/
- *loss = *expected - end->packets;
- if (*expected < end->packets) {
+ *loss = *expected - state->stats_packets;
+ if (*expected < state->stats_packets) {
if (*loss > 0)
*loss = INT_MIN;
} else {
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index ab98be1d8..4a3ff83c1 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -1522,8 +1522,7 @@ void mgcp_format_stats(struct mgcp_endpoint *endp, char *msg, size_t size)
uint32_t expected, jitter;
int ploss;
int nchars;
- mgcp_state_calc_loss(&endp->net_state, &endp->net_end,
- &expected, &ploss);
+ mgcp_state_calc_loss(&endp->net_state, &expected, &ploss);
jitter = mgcp_state_calc_jitter(&endp->net_state);
nchars = snprintf(msg, size,