octoi: differentiate UNDERRUN from SUBSTITUTED in counters

A real _underrun_ happens if the RIFO is empty (depth == 0)
and should be counted different from a mere frame substition
due to packet loss.

Change-Id: I5448430b09ec10a16decdfd0a4a40850fe2ed1a6
changes/45/27845/5
Harald Welte 7 months ago
parent d413cbcb4b
commit 3f342ee28c
  1. 3
      src/octoi/e1oip.c
  2. 1
      src/octoi/e1oip.h
  3. 9
      src/octoi/frame_rifo.c
  4. 8
      src/octoi/octoi.c
  5. 44
      tests/rifo/rifo_test.ok

@ -44,7 +44,8 @@
#include "e1oip.h"
static const struct rate_ctr_desc iline_ctr_description[] = {
[LINE_CTR_E1oIP_UNDERRUN] = { "e1oip:underrun", "Frames missing/substituted in IP->E1 direction"},
[LINE_CTR_E1oIP_UNDERRUN] = { "e1oip:underrun", "Frames underrun / slipped in IP->E1 direction"},
[LINE_CTR_E1oIP_SUBSTITUTED] = { "e1oip:substituted", "Frames substituted in IP->E1 direction"},
[LINE_CTR_E1oIP_OVERFLOW] = { "e1oip:overflow", "Frames overflowed in IP->E1 direction"},
[LINE_CTR_E1oIP_RX_OUT_OF_ORDER] = { "e1oip:rx:pkt_out_of_order", "Packets out-of-order in IP->E1 direction"},
[LINE_CTR_E1oIP_RX_OUT_OF_WIN] = { "e1oip:rx:pkt_out_of_win", "Packets out-of-rx-window in IP->E1 direction"},

@ -15,6 +15,7 @@
enum e1oip_line_ctr {
LINE_CTR_E1oIP_UNDERRUN,
LINE_CTR_E1oIP_SUBSTITUTED,
LINE_CTR_E1oIP_OVERFLOW,
LINE_CTR_E1oIP_RX_OUT_OF_ORDER,
LINE_CTR_E1oIP_RX_OUT_OF_WIN,

@ -132,14 +132,19 @@ int frame_rifo_in(struct frame_rifo *rifo, const uint8_t *frame, uint32_t fn)
/*! pull one frames out of the RIFO.
* \param rifo The RIFO from which we want to pull frames
* \param out Caller-allocated output buffer
* \returns 0 on success; -1 on error (no frame available) */
* \returns 0 on success; -1 if no frame available; -2 if RIFO depth == 0 */
int frame_rifo_out(struct frame_rifo *rifo, uint8_t *out)
{
uint32_t next_out_bucket = (rifo->next_out - rifo->buf) / BYTES_PER_FRAME;
bool bucket_bit = bucket_bit_get(rifo, next_out_bucket);
int rc = 0;
if (!bucket_bit) {
if (frame_rifo_depth(rifo) == 0) {
/* if we don't have any RIFO depth at all, our jitter buffer has
* run empty and most likely there is some fundamental clock sync problem
* somewhere. */
rc = -2;
} else if (!bucket_bit) {
/* caller is supposed to copy/duplicate previous frame */
rc = -1;
} else {

@ -127,10 +127,14 @@ void octoi_peer_e1t_out(struct octoi_peer *peer, uint8_t *buf, int fts)
for (int i = 0; i < fts; i++) {
uint8_t *cur = buf + BYTES_PER_FRAME*i;
rc = frame_rifo_out(&iline->e1t.rifo, cur);
if (rc < 0) {
iline_ctr_add(iline, LINE_CTR_E1oIP_UNDERRUN, 1);
if (rc == -1) {
iline_ctr_add(iline, LINE_CTR_E1oIP_SUBSTITUTED, 1);
/* substitute with last received frame */
memcpy(cur, iline->e1t.last_frame, BYTES_PER_FRAME);
} else if (rc == -2) {
iline_ctr_add(iline, LINE_CTR_E1oIP_UNDERRUN, 1);
/* substitute with all-FF frame */
memset(cur, 0xff, BYTES_PER_FRAME);
}
}
iline_stat_set(iline, LINE_STAT_E1oIP_E1T_FIFO, frame_rifo_depth(&iline->e1t.rifo));

@ -14,7 +14,7 @@ RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [d
RIFO_OUT(0606060606060606060606060606060606060606060606060606060606060606)=0 [depth=2, frames=1]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=1, frames=1]
RIFO_OUT(0808080808080808080808080808080808080808080808080808080808080808)=0 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
TEST: missing_frames, starting at FN: 0
RIFO_IN(0101010101010101010101010101010101010101010101010101010101010101, 1)=0 [depth=2, frames=1]
@ -88,16 +88,16 @@ RIFO_IN(0606060606060606060606060606060606060606060606060606060606060606, 856)=-
RIFO_IN(0707070707070707070707070707070707070707070707070707070707070707, 857)=-34 [depth=0, frames=0]
RIFO_IN(0808080808080808080808080808080808080808080808080808080808080808, 858)=-34 [depth=0, frames=0]
RIFO_IN(0909090909090909090909090909090909090909090909090909090909090909, 859)=-34 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
TEST: bound_check, starting at FN: 0
RIFO_IN(0000000000000000000000000000000000000000000000000000000000000000, 791)=0 [depth=791, frames=1]
@ -138,7 +138,7 @@ RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [d
RIFO_OUT(0606060606060606060606060606060606060606060606060606060606060606)=0 [depth=2, frames=1]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=1, frames=1]
RIFO_OUT(0808080808080808080808080808080808080808080808080808080808080808)=0 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
TEST: missing_frames, starting at FN: 4294967290
RIFO_IN(0101010101010101010101010101010101010101010101010101010101010101, 4294967291)=0 [depth=2, frames=1]
@ -212,16 +212,16 @@ RIFO_IN(0606060606060606060606060606060606060606060606060606060606060606, 850)=-
RIFO_IN(0707070707070707070707070707070707070707070707070707070707070707, 851)=-34 [depth=0, frames=0]
RIFO_IN(0808080808080808080808080808080808080808080808080808080808080808, 852)=-34 [depth=0, frames=0]
RIFO_IN(0909090909090909090909090909090909090909090909090909090909090909, 853)=-34 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-1 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
RIFO_OUT(ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)=-2 [depth=0, frames=0]
TEST: bound_check, starting at FN: 4294967290
RIFO_IN(0000000000000000000000000000000000000000000000000000000000000000, 785)=0 [depth=791, frames=1]

Loading…
Cancel
Save