diff options
author | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2013-12-03 12:48:07 +0100 |
---|---|---|
committer | Jacob Erlbeck <jerlbeck@sysmocom.de> | 2013-12-05 16:54:25 +0100 |
commit | 83c052373907c1cdaa134b5a7420eacabd893901 (patch) | |
tree | 1b617bec3eaaa046fe0a4df54756f34c6c4b804c /openbsc/tests/mgcp/mgcp_test.c | |
parent | 598b1c72310d4fad7500206cc47fe00b0fad9ec9 (diff) |
mgcp/rtp: Add more test cases for RTP header patching
This patch extends the existing RTP error check test by adding a
check for timestamp errors after SSRC changes and a check for a
segno delta of 2 (with a timestamp delta of 320).
To test SSRC patching too, a corresponding line will be written on
each SSRC change that has been detected in the output stream.
In addition there is now support for selectively enabling/disabling
SSRC and timestamp patching. The RTP test sequence is repeated for
all combinations thereof.
Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/tests/mgcp/mgcp_test.c')
-rw-r--r-- | openbsc/tests/mgcp/mgcp_test.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c index c58f52d9e..8e130bbd8 100644 --- a/openbsc/tests/mgcp/mgcp_test.c +++ b/openbsc/tests/mgcp/mgcp_test.c @@ -510,13 +510,33 @@ struct rtp_packet_info test_rtp_packets1[] = { /* RTP: SeqNo=14, TS=35008 */ {0.280000, 20, "\x80\x62\x00\x0E\x00\x00\x88\xC0\x10\x20\x30\x40" "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, + /* Non 20ms RTP timestamp (delta = 120): */ + /* RTP: SeqNo=15, TS=35128 */ + {0.300000, 20, "\x80\x62\x00\x0F\x00\x00\x89\x38\x10\x20\x30\x40" + "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, + /* RTP: SeqNo=16, TS=35288 */ + {0.320000, 20, "\x80\x62\x00\x10\x00\x00\x89\xD8\x10\x20\x30\x40" + "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, + /* RTP: SeqNo=17, TS=35448 */ + {0.340000, 20, "\x80\x62\x00\x11\x00\x00\x8A\x78\x10\x20\x30\x40" + "\x01\x23\x45\x67\x8A\xAB\xCD\xEF"}, + /* SeqNo increment by 2, RTP timestamp delta = 320: */ + /* RTP: SeqNo=19, TS=35768 */ + {0.360000, 20, "\x80\x62\x00\x13\x00\x00\x8B\xB8\x10\x20\x30\x40" + "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, + /* RTP: SeqNo=20, TS=35928 */ + {0.380000, 20, "\x80\x62\x00\x14\x00\x00\x8C\x58\x10\x20\x30\x40" + "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, + /* RTP: SeqNo=21, TS=36088 */ + {0.380000, 20, "\x80\x62\x00\x14\x00\x00\x8C\xF8\x10\x20\x30\x40" + "\x01\x23\x45\x67\x89\xAB\xCD\xEF"}, }; void mgcp_patch_and_count(struct mgcp_endpoint *endp, struct mgcp_rtp_state *state, struct mgcp_rtp_end *rtp_end, struct sockaddr_in *addr, char *data, int len); -static void test_packet_error_detection(void) +static void test_packet_error_detection(int patch_ssrc, int patch_ts) { int i; @@ -526,8 +546,11 @@ static void test_packet_error_detection(void) struct mgcp_rtp_end *rtp = &endp.net_end; struct sockaddr_in addr = {0}; char buffer[4096]; + uint32_t last_ssrc = 0; - printf("Testing packet error detection.\n"); + printf("Testing packet error detection%s%s.\n", + patch_ssrc ? ", patch SSRC" : "", + patch_ts ? ", patch timestamps" : ""); memset(&trunk, 0, sizeof(trunk)); memset(&endp, 0, sizeof(endp)); @@ -545,7 +568,7 @@ static void test_packet_error_detection(void) mgcp_free_endp(&endp); rtp->payload_type = 98; - endp.allow_patch = 1; + endp.allow_patch = patch_ssrc; for (i = 0; i < ARRAY_SIZE(test_rtp_packets1); ++i) { struct rtp_packet_info *info = test_rtp_packets1 + i; @@ -557,6 +580,12 @@ static void test_packet_error_detection(void) mgcp_patch_and_count(&endp, &state, rtp, &addr, buffer, info->len); + if (state.out_stream.ssrc != last_ssrc) { + printf("Output SSRC changed to %08x\n", + ntohl(state.out_stream.ssrc)); + last_ssrc = state.out_stream.ssrc; + } + printf("TS: %d, dTS: %d, TS Errs: in %d, out %d\n", state.out_stream.last_timestamp, state.out_stream.last_tsdelta, @@ -575,7 +604,10 @@ int main(int argc, char **argv) test_packet_loss_calc(); test_rqnt_cb(); test_mgcp_stats(); - test_packet_error_detection(); + test_packet_error_detection(1, 0); + test_packet_error_detection(0, 0); + test_packet_error_detection(0, 1); + test_packet_error_detection(1, 1); printf("Done\n"); return EXIT_SUCCESS; |