[PATCH 01/10] mgcp/rtp: Add more test cases for RTP header patching

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Thu Dec 5 16:44:16 UTC 2013


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
---
 openbsc/tests/mgcp/mgcp_test.c  |   40 ++++++++++++++++++--
 openbsc/tests/mgcp/mgcp_test.ok |   78 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+), 4 deletions(-)

diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c
index c58f52d..8e130bb 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 3bfd78b..57d3bfb 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
-- 
1.7.9.5





More information about the OpenBSC mailing list