#!/usr/bin/perl use strict; use warnings; use NGCP::Rtpengine::Test; use NGCP::Rtpclient::SRTP; use NGCP::Rtpengine::AutoTest; use Test::More; use NGCP::Rtpclient::ICE; use POSIX; autotest_start(qw(--config-file=none -t -1 -i 203.0.113.1 -i 2001:db8:4321::1 --mos=G.107.2 -n 2223 -c 12345 -f -L 7 -E -u 2222 --silence-detect=1 --log-level-internals=7)) or die; my $extended_tests = $ENV{RTPENGINE_MOS_TESTS}; my ($sock_a, $sock_b, $sock_c, $sock_d, $port_a, $port_b, $ssrc, $ssrc_b, $resp, $sock_ax, $sock_bx, $port_ax, $port_bx, $srtp_ctx_a, $srtp_ctx_b, $srtp_ctx_a_rev, $srtp_ctx_b_rev, $ufrag_a, $ufrag_b, @ret1, @ret2, @ret3, @ret4, $srtp_key_a, $srtp_key_b, $ts, $seq, $has_recv); if ($extended_tests) { ($sock_a, $sock_ax, $sock_b, $sock_bx) = new_call([qw(198.51.100.23 3000)], [qw(198.51.100.23 3001)], [qw(198.51.100.23 3002)], [qw(198.51.100.23 3003)]); ($port_a, $port_ax) = offer('MOS basic', { }, <{SSRC}{0x1234567}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{MOS}, 43, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{jitter}, 0, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{'packet loss'}, 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '>=', 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '<', $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '>=', 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '<', $processing_us, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{MOS}, 43, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{jitter}, 0, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{'packet loss'}, 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '>=', 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '<', $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '>=', 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '<', $processing_us, 'metric matches'; ($sock_a, $sock_ax, $sock_b, $sock_bx) = new_call([qw(198.51.100.23 3004)], [qw(198.51.100.23 3005)], [qw(198.51.100.23 3006)], [qw(198.51.100.23 3007)]); ($port_a, $port_ax) = offer('MOS degraded', { }, <{SSRC}{0x1234567}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{MOS}, 36, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{jitter}, 15, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{'packet loss'}, 3, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '>=', 250000, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '<', 250000 + $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '>=', 130000, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '<', 130000 + $processing_us, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{MOS}, 36, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{jitter}, 15, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{'packet loss'}, 3, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '>=', 250000, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '<', 250000 + $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '>=', 120000, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '<', 120000 + $processing_us, 'metric matches'; ($sock_a, $sock_ax, $sock_b, $sock_bx) = new_call([qw(198.51.100.23 3008)], [qw(198.51.100.23 3009)], [qw(198.51.100.23 3010)], [qw(198.51.100.23 3011)]); ($port_a, $port_ax) = offer('MOS very degraded', { }, <{SSRC}{0x1234567}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{MOS}, 29, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{jitter}, 20, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{'packet loss'}, 5, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '>=', 400000, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '<', 400000 + $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '>=', 200000, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '<', 200000 + $processing_us, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{MOS}, 29, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{jitter}, 20, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{'packet loss'}, 5, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '>=', 400000, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '<', 400000 + $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '>=', 200000, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '<', 200000 + $processing_us, 'metric matches'; ($sock_a, $sock_ax, $sock_b, $sock_bx) = new_call([qw(198.51.100.23 3016)], [qw(198.51.100.23 3017)], [qw(198.51.100.23 3018)], [qw(198.51.100.23 3019)]); ($port_a, $port_ax) = offer('Opus MOS basic', { }, <{SSRC}{0x1234567}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{MOS}, 43, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{jitter}, 0, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{'packet loss'}, 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '>=', 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '<', $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '>=', 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '<', $processing_us, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{MOS}, 43, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{jitter}, 0, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{'packet loss'}, 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '>=', 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '<', $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '>=', 0, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '<', $processing_us, 'metric matches'; ($sock_a, $sock_ax, $sock_b, $sock_bx) = new_call([qw(198.51.100.23 3020)], [qw(198.51.100.23 3021)], [qw(198.51.100.23 3022)], [qw(198.51.100.23 3023)]); ($port_a, $port_ax) = offer('Opus MOS degraded', { }, <{SSRC}{0x1234567}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{MOS}, 30, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{jitter}, 15, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{'packet loss'}, 3, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '>=', 250000, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '<', 250000 + $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '>=', 130000, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '<', 130000 + $processing_us, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{MOS}, 30, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{jitter}, 15, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{'packet loss'}, 3, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '>=', 250000, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '<', 250000 + $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '>=', 120000, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '<', 120000 + $processing_us, 'metric matches'; ($sock_a, $sock_ax, $sock_b, $sock_bx) = new_call([qw(198.51.100.23 3024)], [qw(198.51.100.23 3025)], [qw(198.51.100.23 3026)], [qw(198.51.100.23 3027)]); ($port_a, $port_ax) = offer('Opus MOS very degraded', { }, <{SSRC}{0x1234567}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{MOS}, 22, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{jitter}, 20, 'metric matches'; is $resp->{SSRC}{0x1234567}{'average MOS'}{'packet loss'}, 5, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '>=', 400000, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time'}, '<', 400000 + $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '>=', 200000, 'metric matches'; cmp_ok $resp->{SSRC}{0x1234567}{'average MOS'}{'round-trip time leg'}, '<', 200000 + $processing_us, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{samples}, 1, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{MOS}, 22, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{jitter}, 20, 'metric matches'; is $resp->{SSRC}{0x7654321}{'average MOS'}{'packet loss'}, 5, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '>=', 400000, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time'}, '<', 400000 + $processing_us * 2, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '>=', 200000, 'metric matches'; cmp_ok $resp->{SSRC}{0x7654321}{'average MOS'}{'round-trip time leg'}, '<', 200000 + $processing_us, 'metric matches'; } #done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit; done_testing();