Browse Source

extend the re-invite simulator to include port changes.

add some more debug messages to make sure the right things are happening.
git.mgm/mediaproxy-ng/2.0
Richard Fuchs 15 years ago
parent
commit
9d37914496
2 changed files with 160 additions and 111 deletions
  1. +4
    -0
      daemon/call.c
  2. +156
    -111
      tests/reinvite-simulator

+ 4
- 0
daemon/call.c View File

@ -832,19 +832,23 @@ found:
if (r && p == r->up) {
/* best case, nothing to do */
DBG("case 1");
;
}
else if (r && cs_o != cs) {
/* found something, but it's linked to a different stream */
DBG("case 2");
steal_peer(p, r->up);
}
else if (!r && !p->filled) {
/* nothing found to steal, but this end is open */
DBG("case 3");
setup_peer(p, t, tag);
}
else {
/* nothing found to steal and this end is used */
/* need a new call stream after all */
DBG("case 4");
cs_o = cs;
cs = g_slice_alloc(sizeof(*cs));
callstream_init(cs, c, 0, 0);


+ 156
- 111
tests/reinvite-simulator View File

@ -57,11 +57,17 @@ sub send_rcv {
print("local port $lport sending to $sendtoip:$sendtoport... ");
my $pkt = join('',map(rand,1..10));
send($sendfd, $pkt, 0, sockaddr_in($sendtoport, inet_aton($sendtoip))) or die;
my $inc;
alarm(5);
my $addr = recv($recvfd, $inc, length($pkt), 0);
alarm(0);
$inc eq $pkt or die;
my ($inc, $addr);
{
local $SIG{ALRM} = sub {
print("timeout!\n");
return;
};
alarm(1);
$addr = recv($recvfd, $inc, length($pkt), 0);
alarm(0);
}
$inc eq $pkt or print("did NOT receive packet\n"), return;
my ($port, $ip) = sockaddr_in($addr);
$laddr = getsockname($recvfd);
($lport, $lip) = sockaddr_in($laddr);
@ -144,182 +150,221 @@ brk();
my @forward = ('A', 'B', $lp1, $lp2, $client1, $client2, $fromtag, $totag);
my @backward = ('B', 'A', $lp2, $lp1, $client2, $client1, $totag, $fromtag);
my ($src, $dst, $p1, $p2, $c1, $c2, $ft, $tt);
for my $case (0 .. 3) {
my $sub;
if ($case == 0) {
$sub = sub { ; };
}
elsif ($case == 1) {
$sub = sub {
print("\tchanging ports on client 1\n");
($client1, $lp1) = udp_sock();
};
}
elsif ($case == 2) {
$sub = sub {
print("\tchanging ports on client 2\n");
($client2, $lp2) = udp_sock();
};
}
elsif ($case == 3) {
$sub = sub {
print("\tchanging ports on client 1 and 2\n");
($client1, $lp1) = udp_sock();
($client2, $lp2) = udp_sock();
};
}
for my $tuple (\@forward, \@backward) {
($src, $dst, $p1, $p2, $c1, $c2, $ft, $tt) = @$tuple;
print("\n\n\n");
print("re-invite coming from $src with no intermediate traffic\n");
print("$src tells $dst: send RTP to $p1\n");
brk();
my ($mpip1, $mpport1) = sim_rq($callid, $local_ip, $p1, $ft);
print("mediaproxy: tell $dst to send to $mpport1 instead of $p1\n");
brk();
my @forward = ('A', 'B', \$lp1, \$lp2, \$client1, \$client2, $fromtag, $totag);
my @backward = ('B', 'A', \$lp2, \$lp1, \$client2, \$client1, $totag, $fromtag);
my ($src, $dst, $p1, $p2, $c1, $c2, $ft, $tt);
print("$dst tells $src: send RTP to $p2\n");
brk();
my ($mpip2, $mpport2) = sim_lk($callid, $local_ip, $p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport2 instead of $p2\n");
brk();
send_rcv4($c2, $mpip1, $mpport1, $c1, $mpip2, $mpport2);
brk();
}
for my $tuple (\@forward, \@backward) {
($src, $dst, $p1, $p2, $c1, $c2, $ft, $tt) = @$tuple;
$sub->();
print("\n\n\n");
print("re-invite coming from $src with no intermediate traffic\n");
print("$src tells $dst: send RTP to $$p1\n");
brk();
my ($mpip1, $mpport1) = sim_rq($callid, $local_ip, $$p1, $ft);
print("mediaproxy: tell $dst to send to $mpport1 instead of $$p1\n");
brk();
print("$dst tells $src: send RTP to $$p2\n");
brk();
my ($mpip2, $mpport2) = sim_lk($callid, $local_ip, $$p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport2 instead of $$p2\n");
brk();
send_rcv4($$c2, $mpip1, $mpport1, $$c1, $mpip2, $mpport2);
brk();
}
for my $tuple (\@forward, \@backward) {
($src, $dst, $p1, $p2, $c1, $c2, $ft, $tt) = @$tuple;
print("\n\n\n");
print("re-invite coming from $src with intermediate traffic from $dst to the new port only\n");
print("$src tells $dst: send RTP to $p1\n");
brk();
my ($mpip1, $mpport1) = sim_rq($callid, $local_ip, $p1, $ft);
print("mediaproxy: tell $dst to send to $mpport1 instead of $p1\n");
brk();
for (1 .. 4) {
send_rcv_brk($c2, $mpip1, $mpport1, $c1);
}
print("$dst tells $src: send RTP to $p2\n");
brk();
my ($mpip2, $mpport2) = sim_lk($callid, $local_ip, $p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport2 instead of $p2\n");
brk();
send_rcv4($c2, $mpip1, $mpport1, $c1, $mpip2, $mpport2);
brk();
for my $tuple (\@forward, \@backward) {
($src, $dst, $p1, $p2, $c1, $c2, $ft, $tt) = @$tuple;
$sub->();
print("\n\n\n");
print("re-invite coming from $src with intermediate traffic from $dst to the new port only\n");
print("$src tells $dst: send RTP to $$p1\n");
brk();
my ($mpip1, $mpport1) = sim_rq($callid, $local_ip, $$p1, $ft);
print("mediaproxy: tell $dst to send to $mpport1 instead of $$p1\n");
brk();
for (1 .. 4) {
send_rcv_brk($$c2, $mpip1, $mpport1, $$c1);
}
print("\n\n\n");
print("re-invite coming from $src with intermediate traffic from both sides to both old and new ports\n");
print("$dst tells $src: send RTP to $$p2\n");
brk();
print("$src tells $dst: send RTP to $p1\n");
brk();
my ($mpip2, $mpport2) = sim_lk($callid, $local_ip, $$p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport2 instead of $$p2\n");
brk();
my ($mpip3, $mpport3) = sim_rq($callid, $local_ip, $p1, $ft);
print("mediaproxy: tell $dst to send to $mpport3 instead of $p1\n");
brk();
send_rcv4($$c2, $mpip1, $mpport1, $$c1, $mpip2, $mpport2);
send_rcv4($c2, $mpip1, $mpport1, $c1, $mpip2, $mpport2);
print("switching to new port...\n");
send_rcv4($c2, $mpip3, $mpport3, $c1, $mpip2, $mpport2);
brk();
print("$dst tells $src: send RTP to $p2\n");
brk();
my ($mpip4, $mpport4) = sim_lk($callid, $local_ip, $p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport4 instead of $p2\n");
brk();
send_rcv4($c2, $mpip3, $mpport3, $c1, $mpip2, $mpport2);
print("switching to new port...\n");
send_rcv4($c2, $mpip3, $mpport3, $c1, $mpip4, $mpport4);
brk();
$sub->();
print("\n\n\n");
print("re-invite coming from $src with intermediate traffic from both sides to both old and new ports\n");
print("$src tells $dst: send RTP to $$p1\n");
brk();
my ($mpip3, $mpport3) = sim_rq($callid, $local_ip, $$p1, $ft);
print("mediaproxy: tell $dst to send to $mpport3 instead of $$p1\n");
brk();
send_rcv4($$c2, $mpip1, $mpport1, $$c1, $mpip2, $mpport2);
print("switching to new port...\n");
send_rcv4($$c2, $mpip3, $mpport3, $$c1, $mpip2, $mpport2);
print("\n\n\n");
print("re-invite coming from $src with intermediate traffic from $dst only to both old and new ports\n");
print("$dst tells $src: send RTP to $$p2\n");
brk();
print("$src tells $dst: send RTP to $p1\n");
brk();
my ($mpip4, $mpport4) = sim_lk($callid, $local_ip, $$p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport4 instead of $$p2\n");
brk();
my ($mpip5, $mpport5) = sim_rq($callid, $local_ip, $p1, $ft);
print("mediaproxy: tell $dst to send to $mpport5 instead of $p1\n");
brk();
send_rcv4($$c2, $mpip3, $mpport3, $$c1, $mpip2, $mpport2);
print("switching to new port...\n");
send_rcv4($$c2, $mpip3, $mpport3, $$c1, $mpip4, $mpport4);
for (1 .. 4) {
send_rcv_brk($c2, $mpip3, $mpport3, $c1);
}
print("switching to new port...\n");
for (1 .. 4) {
send_rcv_brk($c2, $mpip5, $mpport5, $c1);
}
brk();
print("$dst tells $src: send RTP to $p2\n");
brk();
my ($mpip6, $mpport6) = sim_lk($callid, $local_ip, $p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport6 instead of $p2\n");
brk();
for (1 .. 4) {
send_rcv_brk($c2, $mpip5, $mpport5, $c1);
}
send_rcv4($c2, $mpip5, $mpport5, $c1, $mpip6, $mpport6);
brk();
$sub->();
print("\n\n\n");
print("re-invite coming from $src with intermediate traffic from $dst only to both old and new ports\n");
print("$src tells $dst: send RTP to $$p1\n");
brk();
my ($mpip5, $mpport5) = sim_rq($callid, $local_ip, $$p1, $ft);
print("mediaproxy: tell $dst to send to $mpport5 instead of $$p1\n");
brk();
for (1 .. 4) {
send_rcv_brk($$c2, $mpip3, $mpport3, $$c1);
}
print("switching to new port...\n");
for (1 .. 4) {
send_rcv_brk($$c2, $mpip5, $mpport5, $$c1);
}
print("$dst tells $src: send RTP to $$p2\n");
brk();
print("\n\n\n");
print("re-invite coming from $src with intermediate traffic from $src only to both old and new ports\n");
my ($mpip6, $mpport6) = sim_lk($callid, $local_ip, $$p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport6 instead of $$p2\n");
brk();
print("$src tells $dst: send RTP to $p1\n");
brk();
for (1 .. 4) {
send_rcv_brk($$c2, $mpip5, $mpport5, $$c1);
}
my ($mpip7, $mpport7) = sim_rq($callid, $local_ip, $p1, $ft);
print("mediaproxy: tell $dst to send to $mpport7 instead of $p1\n");
brk();
send_rcv4($$c2, $mpip5, $mpport5, $$c1, $mpip6, $mpport6);
for (1 .. 4) {
send_rcv_brk($c1, $mpip6, $mpport6, $c2);
}
brk();
print("$dst tells $src: send RTP to $p2\n");
brk();
my ($mpip8, $mpport8) = sim_lk($callid, $local_ip, $p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport8 instead of $p2\n");
brk();
for (1 .. 4) {
send_rcv_brk($c1, $mpip6, $mpport6, $c2);
}
print("switching to new port...\n");
for (1 .. 4) {
send_rcv_brk($c1, $mpip8, $mpport8, $c2);
}
send_rcv4($c2, $mpip7, $mpport7, $c1, $mpip8, $mpport8);
brk();
$sub->();
print("\n\n\n");
print("re-invite coming from $src with intermediate traffic from $src only to both old and new ports\n");
print("$src tells $dst: send RTP to $$p1\n");
brk();
my ($mpip7, $mpport7) = sim_rq($callid, $local_ip, $$p1, $ft);
print("mediaproxy: tell $dst to send to $mpport7 instead of $$p1\n");
brk();
for (1 .. 4) {
send_rcv_brk($$c1, $mpip6, $mpport6, $$c2);
}
print("$dst tells $src: send RTP to $$p2\n");
brk();
my ($mpip8, $mpport8) = sim_lk($callid, $local_ip, $$p2, $ft, $tt);
print("mediaproxy: tell $src to send to $mpport8 instead of $$p2\n");
brk();
for (1 .. 4) {
send_rcv_brk($$c1, $mpip6, $mpport6, $$c2);
}
print("switching to new port...\n");
for (1 .. 4) {
send_rcv_brk($$c1, $mpip8, $mpport8, $$c2);
}
send_rcv4($$c2, $mpip7, $mpport7, $$c1, $mpip8, $mpport8);
brk();
}
}

Loading…
Cancel
Save