From 12acbd29b037da889965e92d784d7dd09bb944ce Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 28 Oct 2026 10:50:36 -0400 Subject: [PATCH] MT#55283 tests for I494018b56 Change-Id: I74e8aa9823a9db3fbb46b415d90e9198fd2b8b8b (cherry picked from commit 04f903178037cb97b76b16340f36bcad94255d24) --- t/auto-daemon-tests-rtcp.pl | 710 +++++++++++++++++++++++++++++++++++- 1 file changed, 709 insertions(+), 1 deletion(-) diff --git a/t/auto-daemon-tests-rtcp.pl b/t/auto-daemon-tests-rtcp.pl index 0d638e406..c5f4b2350 100644 --- a/t/auto-daemon-tests-rtcp.pl +++ b/t/auto-daemon-tests-rtcp.pl @@ -19,7 +19,9 @@ autotest_start(qw(--config-file=none -t -1 -i 203.0.113.1 -i 2001:db8:4321::1 my ($sock_a, $sock_b, $sock_ax, $sock_bx, $port_a, $port_ax, $port_b, $port_bx, - $resp); + $resp, + $srtp_ctx_a, $srtp_ctx_b, $srtp_ctx_c, $srtp_ctx_d, + $key_a, $key_b); ($sock_a, $sock_ax, $sock_b, $sock_bx) = new_call( @@ -107,5 +109,711 @@ is($resp->{SSRC}{26505}{'average MOS'}{MOS}, 43, 'MOS'); is($resp->{SSRC}{26505}{'average MOS'}{'packet loss'}, 0, 'packet loss'); + +($sock_a, $sock_ax, $sock_b, $sock_bx) = new_call( + [qw(198.51.100.1 7136)], + [qw(198.51.100.1 7137)], + [qw(198.51.100.3 7138)], + [qw(198.51.100.3 7139)], +); + +($port_a, $port_ax) = offer('SRTCP generation', { flags => ['generate RTCP'], DTLS => 'off' }, < ['generate RTCP'] }, < $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'aaaa7kxQjhFBp2fP6AYjs3vKw7CeBdWZCj0isbJv', +}; +$srtp_ctx_b = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'cJOJ7kxQjhFBp2fP6AYjs3vKw7CeBdWZCj0isbJv', +}; + +srtp_snd($sock_a, $port_b, rtp(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_snd($sock_a, $port_b, rtp(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_snd($sock_a, $port_b, rtp(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_b); + +srtp_snd($sock_b, $port_a, rtp(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_rcv($sock_a, $port_b, rtpm(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_b, $port_a, rtp(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_rcv($sock_a, $port_b, rtpm(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_b, $port_a, rtp(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_rcv($sock_a, $port_b, rtpm(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_a); + +# wait for RTCP. Jitter is measured from the back-to-back packets above, which +# carry 20 ms of timestamp spacing each. +sleep(6); + +srtcp_rcv($sock_ax, $port_bx, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_a); +srtcp_rcv($sock_bx, $port_ax, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_b); + +# wait for RTCP again +sleep(6); + +srtcp_rcv($sock_ax, $port_bx, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_a); +srtcp_rcv($sock_bx, $port_ax, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_b); + +$resp = rtpe_req('delete', 'delete'); +is($resp->{SSRC}{4660}{packets}, 3, 'packet count'); +is($resp->{SSRC}{4660}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{4660}{'average MOS'}{'packet loss'}, 0, 'packet loss'); +is($resp->{SSRC}{26505}{packets}, 3, 'packet count'); +is($resp->{SSRC}{26505}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{26505}{'average MOS'}{'packet loss'}, 0, 'packet loss'); + + + +($sock_a, $sock_b) = new_call( + [qw(198.51.100.1 7148)], + [qw(198.51.100.3 7150)], +); + +($port_a, $port_ax) = offer('SRTCP generation with mux', { flags => ['generate RTCP'], DTLS => 'off', 'rtcp-mux' => 'require' }, < ['generate RTCP'] }, < $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'aaaa7kxQjhFBp2fP6AYjs3vKw7CeBdWZCj0isbJv', +}; +$srtp_ctx_b = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'cJOJ7kxQjhFBp2fP6AYjs3vKw7CeBdWZCj0isbJv', +}; + +srtp_snd($sock_a, $port_b, rtp(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_snd($sock_a, $port_b, rtp(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_snd($sock_a, $port_b, rtp(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_b); + +srtp_snd($sock_b, $port_a, rtp(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_rcv($sock_a, $port_b, rtpm(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_b, $port_a, rtp(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_rcv($sock_a, $port_b, rtpm(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_b, $port_a, rtp(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_rcv($sock_a, $port_b, rtpm(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_a); + +# wait for RTCP. Jitter is measured from the back-to-back packets above, which +# carry 20 ms of timestamp spacing each. +sleep(6); + +srtcp_rcv($sock_a, $port_b, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_a); +srtcp_rcv($sock_b, $port_a, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_b); + +# wait for RTCP again +sleep(6); + +srtcp_rcv($sock_a, $port_b, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_a); +srtcp_rcv($sock_b, $port_a, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_b); + +$resp = rtpe_req('delete', 'delete'); +is($resp->{SSRC}{4660}{packets}, 3, 'packet count'); +is($resp->{SSRC}{4660}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{4660}{'average MOS'}{'packet loss'}, 0, 'packet loss'); +is($resp->{SSRC}{26505}{packets}, 3, 'packet count'); +is($resp->{SSRC}{26505}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{26505}{'average MOS'}{'packet loss'}, 0, 'packet loss'); + + + +($sock_a, $sock_b, $sock_bx) = new_call( + [qw(198.51.100.1 7160)], + [qw(198.51.100.3 7162)], + [qw(198.51.100.3 7163)], +); + +($port_a, $port_ax) = offer('SRTCP generation with mux/demux', { flags => ['generate RTCP'], DTLS => 'off', 'rtcp-mux' => 'demux' }, < ['generate RTCP'] }, < $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'aaaa7kxQjhFBp2fP6AYjs3vKw7CeBdWZCj0isbJv', +}; +$srtp_ctx_b = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'cJOJ7kxQjhFBp2fP6AYjs3vKw7CeBdWZCj0isbJv', +}; + +srtp_snd($sock_a, $port_b, rtp(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_snd($sock_a, $port_b, rtp(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_snd($sock_a, $port_b, rtp(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_b); + +srtp_snd($sock_b, $port_a, rtp(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_rcv($sock_a, $port_b, rtpm(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_b, $port_a, rtp(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_rcv($sock_a, $port_b, rtpm(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_b, $port_a, rtp(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_a); +srtp_rcv($sock_a, $port_b, rtpm(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_a); + +# wait for RTCP. Jitter is measured from the back-to-back packets above, which +# carry 20 ms of timestamp spacing each. +sleep(6); + +srtcp_rcv($sock_a, $port_b, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_a); +srtcp_rcv($sock_bx, $port_ax, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_b); + +# wait for RTCP again +sleep(6); + +srtcp_rcv($sock_a, $port_b, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_a); +srtcp_rcv($sock_bx, $port_ax, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_b); + +$resp = rtpe_req('delete', 'delete'); +is($resp->{SSRC}{4660}{packets}, 3, 'packet count'); +is($resp->{SSRC}{4660}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{4660}{'average MOS'}{'packet loss'}, 0, 'packet loss'); +is($resp->{SSRC}{26505}{packets}, 3, 'packet count'); +is($resp->{SSRC}{26505}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{26505}{'average MOS'}{'packet loss'}, 0, 'packet loss'); + + + + +($sock_a, $sock_ax, $sock_b, $sock_bx) = new_call( + [qw(198.51.100.1 7228)], + [qw(198.51.100.1 7229)], + [qw(198.51.100.3 7230)], + [qw(198.51.100.3 7231)], +); + +($port_a, $port_ax, undef, undef, $key_a) = offer('SRTCP<>SRTCP generation', { flags => ['generate RTCP'], DTLS => 'off' }, <SRTCP generation', { flags => ['generate RTCP'] }, < $NGCP::Rtpclient::SRTP::crypto_suites{AES_256_CM_HMAC_SHA1_80}, + key => $key_a, +}; +$srtp_ctx_b = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'cJOJ7kxQjhFBp2fP6AYjs3vKw7CeBdWZCj0isbJv', +}; +$srtp_ctx_c = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_256_CM_HMAC_SHA1_80}, + key => 'lj20Z7pgjRJNvZZVLAZDE5HQUA04CQKzRmLgCiRPG35fouAMtDfTPzUZq7w6Tg', +}; +$srtp_ctx_d = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => $key_b, +}; + +srtp_snd($sock_a, $port_b, rtp(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_a, $port_b, rtp(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_a, $port_b, rtp(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_a); + +srtp_snd($sock_b, $port_a, rtp(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_c); +srtp_rcv($sock_a, $port_b, rtpm(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_d); +srtp_snd($sock_b, $port_a, rtp(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_c); +srtp_rcv($sock_a, $port_b, rtpm(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_d); +srtp_snd($sock_b, $port_a, rtp(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_c); +srtp_rcv($sock_a, $port_b, rtpm(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_d); + +# wait for RTCP. Jitter is measured from the back-to-back packets above, which +# carry 20 ms of timestamp spacing each. +sleep(6); + +srtcp_rcv($sock_ax, $port_bx, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_d); +srtcp_rcv($sock_bx, $port_ax, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_a); + +# wait for RTCP again +sleep(6); + +srtcp_rcv($sock_ax, $port_bx, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_d); +srtcp_rcv($sock_bx, $port_ax, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_a); + +$resp = rtpe_req('delete', 'delete'); +is($resp->{SSRC}{4660}{packets}, 3, 'packet count'); +is($resp->{SSRC}{4660}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{4660}{'average MOS'}{'packet loss'}, 0, 'packet loss'); +is($resp->{SSRC}{26505}{packets}, 3, 'packet count'); +is($resp->{SSRC}{26505}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{26505}{'average MOS'}{'packet loss'}, 0, 'packet loss'); + + + +($sock_a, $sock_b) = new_call( + [qw(198.51.100.1 7240)], + [qw(198.51.100.3 7242)], +); + +($port_a, $port_ax, undef, undef, $key_a) = offer('SRTCP<>SRTCP generation with mux', { flags => ['generate RTCP'], DTLS => 'off', 'rtcp-mux' => 'require' }, <SRTCP generation with mux', { flags => ['generate RTCP'] }, < $NGCP::Rtpclient::SRTP::crypto_suites{AES_256_CM_HMAC_SHA1_80}, + key => $key_a, +}; +$srtp_ctx_b = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'cJOJ7kxQjhFBp2fP6AYjs3vKw7CeBdWZCj0isbJv', +}; +$srtp_ctx_c = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_256_CM_HMAC_SHA1_80}, + key => 'lj20Z7pgjRJNvZZVLAZDE5HQUA04CQKzRmLgCiRPG35fouAMtDfTPzUZq7w6Tg', +}; +$srtp_ctx_d = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => $key_b, +}; + +srtp_snd($sock_a, $port_b, rtp(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_a, $port_b, rtp(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_a, $port_b, rtp(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_a); + +srtp_snd($sock_b, $port_a, rtp(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_c); +srtp_rcv($sock_a, $port_b, rtpm(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_d); +srtp_snd($sock_b, $port_a, rtp(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_c); +srtp_rcv($sock_a, $port_b, rtpm(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_d); +srtp_snd($sock_b, $port_a, rtp(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_c); +srtp_rcv($sock_a, $port_b, rtpm(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_d); + +# wait for RTCP. Jitter is measured from the back-to-back packets above, which +# carry 20 ms of timestamp spacing each. +sleep(6); + +srtcp_rcv($sock_a, $port_b, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_d); +srtcp_rcv($sock_b, $port_a, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_a); + +# wait for RTCP again +sleep(6); + +srtcp_rcv($sock_a, $port_b, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_d); +srtcp_rcv($sock_b, $port_a, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_a); + +$resp = rtpe_req('delete', 'delete'); +is($resp->{SSRC}{4660}{packets}, 3, 'packet count'); +is($resp->{SSRC}{4660}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{4660}{'average MOS'}{'packet loss'}, 0, 'packet loss'); +is($resp->{SSRC}{26505}{packets}, 3, 'packet count'); +is($resp->{SSRC}{26505}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{26505}{'average MOS'}{'packet loss'}, 0, 'packet loss'); + + + +($sock_a, $sock_b, $sock_bx) = new_call( + [qw(198.51.100.1 7252)], + [qw(198.51.100.3 7254)], + [qw(198.51.100.3 7255)], +); + +($port_a, $port_ax, undef, undef, $key_a) = offer('SRTCP<>SRTCP generation with mux/demux', { flags => ['generate RTCP'], DTLS => 'off', 'rtcp-mux' => 'demux' }, <SRTCP generation with mux/demux', { flags => ['generate RTCP'] }, < $NGCP::Rtpclient::SRTP::crypto_suites{AES_256_CM_HMAC_SHA1_80}, + key => $key_a, +}; +$srtp_ctx_b = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => 'cJOJ7kxQjhFBp2fP6AYjs3vKw7CeBdWZCj0isbJv', +}; +$srtp_ctx_c = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_256_CM_HMAC_SHA1_80}, + key => 'lj20Z7pgjRJNvZZVLAZDE5HQUA04CQKzRmLgCiRPG35fouAMtDfTPzUZq7w6Tg', +}; +$srtp_ctx_d = { + cs => $NGCP::Rtpclient::SRTP::crypto_suites{AES_CM_128_HMAC_SHA1_80}, + key => $key_b, +}; + +srtp_snd($sock_a, $port_b, rtp(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1000, 3000+160*0, 0x1234, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_a, $port_b, rtp(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1001, 3000+160*1, 0x1234, "\x00" x 160), $srtp_ctx_a); +srtp_snd($sock_a, $port_b, rtp(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_b); +srtp_rcv($sock_b, $port_a, rtpm(0, 1002, 3000+160*2, 0x1234, "\x00" x 160), $srtp_ctx_a); + +srtp_snd($sock_b, $port_a, rtp(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_c); +srtp_rcv($sock_a, $port_b, rtpm(0, 4000, 8000+160*0, 0x6789, "\x00" x 160), $srtp_ctx_d); +srtp_snd($sock_b, $port_a, rtp(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_c); +srtp_rcv($sock_a, $port_b, rtpm(0, 4001, 8000+160*1, 0x6789, "\x00" x 160), $srtp_ctx_d); +srtp_snd($sock_b, $port_a, rtp(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_c); +srtp_rcv($sock_a, $port_b, rtpm(0, 4002, 8000+160*2, 0x6789, "\x00" x 160), $srtp_ctx_d); + +# wait for RTCP. Jitter is measured from the back-to-back packets above, which +# carry 20 ms of timestamp spacing each. +sleep(6); + +srtcp_rcv($sock_a, $port_b, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_d); +srtcp_rcv($sock_bx, $port_ax, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_a); + +# wait for RTCP again +sleep(6); + +srtcp_rcv($sock_a, $port_b, qr/^\x81\xc8\x00\x0c\x00\x00\x67\x89.{8}\x00\x00\x20\x80\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x12\x34\x00\x00\x00\x00\x00\x00\x03\xea\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x67\x89\x01/s, $srtp_ctx_d); +srtcp_rcv($sock_bx, $port_ax, qr/^\x81\xc8\x00\x0c\x00\x00\x12\x34.{8}\x00\x00\x0c\xf8\x00\x00\x00\x03\x00\x00\x02\x22\x00\x00\x67\x89\x00\x00\x00\x00\x00\x00\x0f\xa2\x00\x00\x00[\x01-\x7f].{4}.{4}\x81\xca\x00\x05\x00\x00\x12\x34\x01/s, $srtp_ctx_a); + +$resp = rtpe_req('delete', 'delete'); +is($resp->{SSRC}{4660}{packets}, 3, 'packet count'); +is($resp->{SSRC}{4660}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{4660}{'average MOS'}{'packet loss'}, 0, 'packet loss'); +is($resp->{SSRC}{26505}{packets}, 3, 'packet count'); +is($resp->{SSRC}{26505}{'average MOS'}{MOS}, 43, 'MOS'); +is($resp->{SSRC}{26505}{'average MOS'}{'packet loss'}, 0, 'packet loss'); + #done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit; done_testing();