1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
|
#!/usr/bin/perl
use strict;
use warnings;
use NGCP::Rtpengine::Test;
use NGCP::Rtpclient::SRTP;
use NGCP::Rtpengine::AutoTest;
use Test::More;
use POSIX;
use Data::Dumper;
use Bencode;
use Socket;
autotest_start(qw(--config-file=test4.conf))
or die;
my ($resp, $sock_sig, $sock_a, $sock_b, $sock_tc,
$port_a, $port_b, $port_tc, $cookie, $addr_sig, $port_sig, $seq, $ts, $ssrc);
$sock_sig = IO::Socket::IP->new(Type => &SOCK_DGRAM, Proto => 'udp', LocalHost => '203.0.113.42', LocalPort => 3334);
($sock_a, $sock_b) = new_call([qw(198.51.100.14 3000)], [qw(198.51.100.14 3002)]);
($port_a) = offer('control passthrough', { }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
c=IN IP4 198.51.100.14
t=0 0
m=audio 3000 RTP/AVP 8
a=sendrecv
----------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
SDP
($port_b) = answer('control passthrough', { }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
c=IN IP4 198.51.100.14
t=0 0
m=audio 3002 RTP/AVP 8
a=sendrecv
----------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
SDP
snd($sock_a, $port_b, rtp(0, 1000, 3000, 0x1234567, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(0, 1000, 3000, 0x1234567, "\x00" x 160));
snd($sock_b, $port_a, rtp(0, 2000, 4000, 0x7654321, "\x00" x 160));
rcv($sock_a, $port_b, rtpm(0, 2000, 4000, 0x7654321, "\x00" x 160));
snd($sock_a, $port_b, rtp(8, 5000, 9000, 0x1234567, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(8, 5000, 9000, 0x1234567, "\x00" x 160));
snd($sock_b, $port_a, rtp(8, 6000, 10000, 0x7654321, "\x00" x 160));
rcv($sock_a, $port_b, rtpm(8, 6000, 10000, 0x7654321, "\x00" x 160));
rcv_no($sock_sig);
($sock_a, $sock_b) = new_call([qw(198.51.100.14 3004)], [qw(198.51.100.14 3006)]);
($port_a) = offer('control transcode', { codec => { transcode => [ 'G722' ] } }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
c=IN IP4 198.51.100.14
t=0 0
m=audio 3004 RTP/AVP 8
a=sendrecv
----------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
t=0 0
m=audio PORT RTP/AVP 8 9
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=sendrecv
a=rtcp:PORT
SDP
($port_b) = answer('control transcode', { }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
c=IN IP4 198.51.100.14
t=0 0
m=audio 3006 RTP/AVP 9
a=sendrecv
----------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
SDP
snd($sock_a, $port_b, rtp(8, 1000, 3000, 0x1234567, "\x00" x 160));
Time::HiRes::usleep(20000);
snd($sock_a, $port_b, rtp(8, 1001, 3160, 0x1234567, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(9, 1000, 3000, 0x1234567, "\x34\x8a\x20\x85\x21\x84\x04\x8a\x0e\x91\xd2\xd3\xd5\xd6\xd6\xd7\xd8\xd8\xd7\xd8\xd8\xd8\xd8\xd8\xd8\xd8\xd8\xd8\xd9\xd9\xd9\xd9\xda\xda\xda\xda\xdb\xdb\xdb\xdc\xd9\xda\xda\xda\xda\xda\xdb\xdc\xd9\xd9\xda\xda\xd9\xd9\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xda\xda\xda\xda\xd9\xd9\xd9\xd9\xd9\xd8\xd8\xd8\xd8\xd7\xdd\xd8\xd8\xd8\xd7\xdd\xd6\xdc\xd8\xd8\xd8\xd5\xdb\xda\xda\xdb\xdc\xd7\xda\xd9\xd8\xd7\xde\xdb\xda\xd9\xd8\xd8\xd5\xdb\xdd\xd8\xd8\xd8\xd7\xdc\xd5\xdb\xdf\xda\xda\xd7\xdf\xd8\xd5\xdd\xda\xdb\xd8\xd8\xd9\xd6\xdf\xdb\xdc\xd5\xdb\xde\xd5\xda\xdd\xda\xd9\xd8\xd9\xd8\xd6\xff\xd8\xd7\xfe\xd5\xda\xd8\xda\xdf\xd8\xda\xda\xda\xd9\xd9\xdc\xd8"));
snd($sock_b, $port_a, rtp(9, 2000, 4000, 0x7654321, "\x34\x8a\x20\x85\x21\x84\x04\x8a\x0e\x91\xd2\xd3\xd5\xd6\xd6\xd7\xd8\xd8\xd7\xd8\xd8\xd8\xd8\xd8\xd8\xd8\xd8\xd8\xd9\xd9\xd9\xd9\xda\xda\xda\xda\xdb\xdb\xdb\xdc\xd9\xda\xda\xda\xda\xda\xdb\xdc\xd9\xd9\xda\xda\xd9\xd9\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xda\xda\xda\xda\xd9\xd9\xd9\xd9\xd9\xd8\xd8\xd8\xd8\xd7\xdd\xd8\xd8\xd8\xd7\xdd\xd6\xdc\xd8\xd8\xd8\xd5\xdb\xda\xda\xdb\xdc\xd7\xda\xd9\xd8\xd7\xde\xdb\xda\xd9\xd8\xd8\xd5\xdb\xdd\xd8\xd8\xd8\xd7\xdc\xd5\xdb\xdf\xda\xda\xd7\xdf\xd8\xd5\xdd\xda\xdb\xd8\xd8\xd9\xd6\xdf\xdb\xdc\xd5\xdb\xde\xd5\xda\xdd\xda\xd9\xd8\xd9\xd8\xd6\xff\xd8\xd7\xfe\xd5\xda\xd8\xda\xdf\xd8\xda\xda\xda\xd9\xd9\xdc\xd8"));
Time::HiRes::usleep(20000);
snd($sock_b, $port_a, rtp(9, 2001, 4160, 0x7654321, "\x34\x8a\x20\x85\x21\x84\x04\x8a\x0e\x91\xd2\xd3\xd5\xd6\xd6\xd7\xd8\xd8\xd7\xd8\xd8\xd8\xd8\xd8\xd8\xd8\xd8\xd8\xd9\xd9\xd9\xd9\xda\xda\xda\xda\xdb\xdb\xdb\xdc\xd9\xda\xda\xda\xda\xda\xdb\xdc\xd9\xd9\xda\xda\xd9\xd9\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xdb\xda\xda\xda\xda\xd9\xd9\xd9\xd9\xd9\xd8\xd8\xd8\xd8\xd7\xdd\xd8\xd8\xd8\xd7\xdd\xd6\xdc\xd8\xd8\xd8\xd5\xdb\xda\xda\xdb\xdc\xd7\xda\xd9\xd8\xd7\xde\xdb\xda\xd9\xd8\xd8\xd5\xdb\xdd\xd8\xd8\xd8\xd7\xdc\xd5\xdb\xdf\xda\xda\xd7\xdf\xd8\xd5\xdd\xda\xdb\xd8\xd8\xd9\xd6\xdf\xdb\xdc\xd5\xdb\xde\xd5\xda\xdd\xda\xd9\xd8\xd9\xd8\xd6\xff\xd8\xd7\xfe\xd5\xda\xd8\xda\xdf\xd8\xda\xda\xda\xd9\xd9\xdc\xd8"));
rcv($sock_a, $port_b, rtpm(8, 2000, 4000, 0x7654321, "\x54\xd5\x54\xd4\x57\xd6\x51\xd0\x50\xd7\xc5\x17\x04\x03\x00\x01\x00\x00\x01\x01\x00\x00\x01\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"));
rcv_no($sock_sig);
($sock_a, $sock_b, $sock_tc) = new_call(
[qw(198.51.100.14 3008)], [qw(198.51.100.14 3010)],
[qw(198.51.100.18 3012)]
);
($port_a) = offer('G.711 transform', { codec => { transcode => ['PCMU'] } }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
c=IN IP4 198.51.100.14
t=0 0
m=audio 3008 RTP/AVP 8
a=sendrecv
----------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
t=0 0
m=audio PORT RTP/AVP 8 0
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
rcv_no($sock_sig);
$NGCP::Rtpengine::req_cb = sub {
my ($cid, $tag);
($port_sig, $addr_sig, $cookie, $cid, $tag, $port_tc) = rcv($sock_sig, -1, qr/^(.{16}) d7:command9:transform7:call-id\d+:(\w{8} for .*?)8:from-tag\d+:(\w{8} for .*?)5:mediald4:type5:audio5:codecld5:inputd5:codec4:PCMA12:payload typei8e10:clock ratei8000e8:channelsi1e6:format0:7:options0:e6:outputd5:codec4:PCMU12:payload typei0e10:clock ratei8000e8:channelsi1e6:format0:7:options0:eee11:destinationd6:family3:IP47:address11:203.0.113.14:porti(\d{5})eeee9:interface7:default8:instance12:.{12}e$/);
snd($sock_sig, $port_sig, $cookie . ' ' . Bencode::bencode( {
result => 'ok',
'call-id' => 'foobar',
'from-tag' => 'yolo',
'media' => [
{
id => 'id',
family => 'IP4',
address => '198.51.100.18',
port => 3012,
},
],
} ), $addr_sig );
};
($port_b) = answer('G.711 transform', { }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
c=IN IP4 198.51.100.14
t=0 0
m=audio 3010 RTP/AVP 0
a=sendrecv
----------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
t=0 0
m=audio PORT RTP/AVP 8
c=IN IP4 203.0.113.1
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
SDP
$NGCP::Rtpengine::req_cb = undef;
rcv_no($sock_sig);
snd($sock_a, $port_b, rtp(0, 1000, 3000, 0x1234567, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(0, 1000, 3000, 0x1234567, "\x00" x 160));
rcv_no($sock_a);
rcv_no($sock_tc);
rcv_no($sock_sig);
snd($sock_a, $port_b, rtp(8, 1001, 3160, 0x7894561, "\x00" x 160));
rcv_no($sock_b);
rcv_no($sock_a);
rcv($sock_tc, -1, rtpm(8, 1001, 3160, 0x7894561, "\x00" x 160));
rcv_no($sock_sig);
snd($sock_tc, $port_tc, rtp(0, 1001, 3160, 0x7894561, "\x22" x 160));
rcv($sock_b, $port_a, rtpm(0, 1001, 3160, 0x7894561, "\x22" x 160));
rcv_no($sock_a);
rcv_no($sock_tc);
rcv_no($sock_sig);
snd($sock_b, $port_a, rtp(0, 1300, 3300, 0x1234693, "\x00" x 160));
rcv($sock_a, $port_b, rtpm(8, 1300, 3300, 0x1234693, "\x2a" x 160));
rcv_no($sock_a);
rcv_no($sock_tc);
rcv_no($sock_sig);
$NGCP::Rtpengine::req_cb = sub {
($port_sig, $addr_sig, $cookie) = rcv($sock_sig, -1, qr/^(.{16}) d7:command6:delete7:call-id6:foobar8:from-tag4:yolo12:delete delayi0ee$/);
snd($sock_sig, $port_sig, $cookie . ' ' . Bencode::bencode( { result => 'ok', } ), $addr_sig );
};
rtpe_req('delete', 'delete call', { 'delete-delay' => 0 } );
$NGCP::Rtpengine::req_cb = undef;
($sock_a, $sock_b, $sock_tc) = new_call(
[qw(198.51.100.14 3040)], [qw(198.51.100.14 3042)],
[qw(198.51.100.18 3044)]
);
$NGCP::Rtpengine::req_cb = sub {
my ($cid, $tag);
($port_sig, $addr_sig, $cookie, $cid, $tag, $port_tc) = rcv($sock_sig, -1, qr/^(.{16}) d7:command9:transform7:call-id\d+:(\w{8} for .*?)8:from-tag\d+:(\w{8} for .*?)5:mediald4:type5:audio5:codecld5:inputd5:codec4:PCMA12:payload typei8e10:clock ratei8000e8:channelsi1e6:format0:7:options0:e6:outputd5:codec4:PCMU12:payload typei0e10:clock ratei8000e8:channelsi1e6:format0:7:options0:eee11:destinationd6:family3:IP47:address11:203.0.113.14:porti(\d{5})eeee9:interface7:default8:instance12:.{12}e$/);
snd($sock_sig, $port_sig, $cookie . ' ' . Bencode::bencode( {
result => 'ok',
'call-id' => $cid,
'from-tag' => $tag,
'media' => [
{
id => 'id',
family => 'IP4',
address => '198.51.100.18',
port => 3044,
},
],
} ), $addr_sig );
};
($port_a) = offer('G.711 transform reverse', { codec => { transcode => ['PCMA'] } }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
c=IN IP4 198.51.100.14
t=0 0
m=audio 3040 RTP/AVP 0
a=sendrecv
----------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
t=0 0
m=audio PORT RTP/AVP 0 8
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=sendrecv
a=rtcp:PORT
SDP
$NGCP::Rtpengine::req_cb = undef;
rcv_no($sock_sig);
($port_b) = answer('G.711 transform reverse', { }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
c=IN IP4 198.51.100.14
t=0 0
m=audio 3042 RTP/AVP 8
a=sendrecv
----------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.14
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
rcv_no($sock_sig);
snd($sock_a, $port_b, rtp(8, 1000, 3000, 0x1234567, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(8, 1000, 3000, 0x1234567, "\x00" x 160));
rcv_no($sock_a);
rcv_no($sock_tc);
rcv_no($sock_sig);
snd($sock_a, $port_b, rtp(0, 1201, 3360, 0x7894629, "\x00" x 160));
rcv($sock_b, $port_a, rtpm(8, 1201, 3360, 0x7894629, "\x2a" x 160));
rcv_no($sock_a);
rcv_no($sock_tc);
rcv_no($sock_sig);
snd($sock_b, $port_a, rtp(8, 1500, 3500, 0x123475b, "\x00" x 160));
rcv_no($sock_a);
rcv_no($sock_b);
rcv($sock_tc, -1, rtpm(8, 1500, 3500, 0x123475b, "\x00" x 160));
rcv_no($sock_sig);
snd($sock_tc, $port_tc, rtp(0, 1500, 3500, 0x789475b, "\x22" x 160));
rcv($sock_a, $port_b, rtpm(0, 1500, 3500, 0x789475b, "\x22" x 160));
rcv_no($sock_b);
rcv_no($sock_tc);
rcv_no($sock_sig);
done_testing();
#done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit;
|