aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-12-03 12:48:07 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2013-12-05 16:54:25 +0100
commit83c052373907c1cdaa134b5a7420eacabd893901 (patch)
tree1b617bec3eaaa046fe0a4df54756f34c6c4b804c /openbsc
parent598b1c72310d4fad7500206cc47fe00b0fad9ec9 (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')
-rw-r--r--openbsc/tests/mgcp/mgcp_test.c40
-rw-r--r--openbsc/tests/mgcp/mgcp_test.ok78
2 files changed, 114 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;
diff --git a/openbsc/tests/mgcp/mgcp_test.ok b/openbsc/tests/mgcp/mgcp_test.ok
index 3bfd78b3d..57d3bfbcb 100644
--- a/openbsc/tests/mgcp/mgcp_test.ok
+++ b/openbsc/tests/mgcp/mgcp_test.ok
@@ -42,7 +42,79 @@ Testing packet loss calculation.
Testing stat parsing
Parsing result: 0
Parsing result: 0
+Testing packet error detection, patch SSRC.
+Output SSRC changed to 11223344
+TS: 0, dTS: 0, TS Errs: in 0, out 0
+TS: 160, dTS: 160, TS Errs: in 0, out 0
+TS: 320, dTS: 160, TS Errs: in 0, out 0
+TS: 320, dTS: 160, TS Errs: in 1, out 1
+TS: 480, dTS: 160, TS Errs: in 1, out 1
+TS: 640, dTS: 160, TS Errs: in 1, out 1
+TS: 960, dTS: 320, TS Errs: in 2, out 2
+TS: 1120, dTS: 160, TS Errs: in 3, out 3
+TS: 1280, dTS: 160, TS Errs: in 3, out 3
+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
+TS: 1880, dTS: 160, TS Errs: in 5, out 5
+TS: 2040, dTS: 160, TS Errs: in 5, out 5
+TS: 2200, dTS: 160, TS Errs: in 5, out 5
+TS: 2320, dTS: 120, TS Errs: in 6, out 6
+TS: 2480, dTS: 160, TS Errs: in 7, out 7
+TS: 2640, dTS: 160, TS Errs: in 7, out 7
+TS: 2960, dTS: 160, TS Errs: in 7, out 7
+TS: 3120, dTS: 160, TS Errs: in 7, out 7
+TS: 3280, dTS: 160, TS Errs: in 8, out 8
Testing packet error detection.
+Output SSRC changed to 11223344
+TS: 0, dTS: 0, TS Errs: in 0, out 0
+TS: 160, dTS: 160, TS Errs: in 0, out 0
+TS: 320, dTS: 160, TS Errs: in 0, out 0
+TS: 320, dTS: 160, TS Errs: in 1, out 1
+TS: 480, dTS: 160, TS Errs: in 1, out 1
+TS: 640, dTS: 160, TS Errs: in 1, out 1
+TS: 960, dTS: 320, TS Errs: in 2, out 2
+TS: 1120, dTS: 160, TS Errs: in 3, out 3
+TS: 1280, dTS: 160, TS Errs: in 3, out 3
+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
+Testing packet error detection, patch timestamps.
+Output SSRC changed to 11223344
+TS: 0, dTS: 0, TS Errs: in 0, out 0
+TS: 160, dTS: 160, TS Errs: in 0, out 0
+TS: 320, dTS: 160, TS Errs: in 0, out 0
+TS: 320, dTS: 160, TS Errs: in 1, out 1
+TS: 480, dTS: 160, TS Errs: in 1, out 1
+TS: 640, dTS: 160, TS Errs: in 1, out 1
+TS: 960, dTS: 320, TS Errs: in 2, out 2
+TS: 1120, dTS: 160, TS Errs: in 3, out 3
+TS: 1280, dTS: 160, TS Errs: in 3, out 3
+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
+Testing packet error detection, patch SSRC, patch timestamps.
+Output SSRC changed to 11223344
TS: 0, dTS: 0, TS Errs: in 0, out 0
TS: 160, dTS: 160, TS Errs: in 0, out 0
TS: 320, dTS: 160, TS Errs: in 0, out 0
@@ -58,4 +130,10 @@ TS: 1720, dTS: 160, TS Errs: in 5, out 5
TS: 1880, dTS: 160, TS Errs: in 5, out 5
TS: 2040, dTS: 160, TS Errs: in 5, out 5
TS: 2200, dTS: 160, TS Errs: in 5, out 5
+TS: 2320, dTS: 120, TS Errs: in 6, out 6
+TS: 2480, dTS: 160, TS Errs: in 7, out 7
+TS: 2640, dTS: 160, TS Errs: in 7, out 7
+TS: 2960, dTS: 160, TS Errs: in 7, out 7
+TS: 3120, dTS: 160, TS Errs: in 7, out 7
+TS: 3280, dTS: 160, TS Errs: in 8, out 8
Done