3
# 6.3. Data Recovery by Negative Acknowledgment
6
use Time::HiRes qw( gettimeofday tv_interval );
9
BEGIN { require "test.conf.pl"; }
13
my $mon = PGM::Test->new(tag => 'mon', host => $config{mon}{host}, cmd => $config{mon}{cmd});
14
my $sim = PGM::Test->new(tag => 'sim', host => $config{sim}{host}, cmd => $config{sim}{cmd});
15
my $app = PGM::Test->new(tag => 'app', host => $config{app}{host}, cmd => $config{app}{cmd});
22
$mon = $sim = $app = undef;
26
$SIG{'INT'} = sub { print "interrupt caught.\n"; close_ssh(); };
28
$mon->say ("filter $config{app}{ip}");
29
print "mon: ready.\n";
31
$app->say ("create ao");
32
$app->say ("bind ao");
33
$app->say ("connect ao");
34
$app->say ("listen ao");
36
## capture GSI of test spp
37
$app->say ("send ao nashi");
38
print "mon: wait for odata ...\n";
39
my $odata = $mon->wait_for_odata;
40
print "mon: odata received.\n";
42
$sim->say ("create fake ao");
43
$sim->say ("bind ao");
44
$sim->say ("connect ao");
46
print "sim: publish SPM txw_trail 90,001 txw_lead 90,000 at spm_sqn 3200.\n";
47
$sim->say ("net send spm ao 3200 90001 90000");
49
# no NAKs should be generated.
50
print "sim: waiting 2 seconds for erroneous NAKs ...\n";
51
$sim->die_on_nak ({ 'timeout' => 2 });
52
print "sim: no NAKs received.\n";
54
print "sim: publish ODATA sqn 90,001.\n";
55
$sim->say ("net send odata ao 90001 90001 ringo");
57
print "app: wait for data ...\n";
58
my $data = $app->wait_for_data;
59
print "app: data received [$data].\n";
61
# no NAKs should be generated.
62
print "sim: waiting 2 seconds for erroneous NAKs ...\n";
63
$sim->die_on_nak ({ 'timeout' => 2 });
64
print "sim: no NAKs received.\n";
66
## first run through with regular NAK generation to get regular backoff interval
67
print "sim: publish ODATA sqn 90,003.\n";
68
$sim->say ("net send odata ao 90003 90001 ichigo");
69
my $t0 = [gettimeofday];
70
print "sim: waiting for valid NAK.\n";
72
my $normal_backoff = tv_interval ( $t0, [gettimeofday] );
73
print "sim: NAK received in $normal_backoff seconds.\n";
75
## cleanup by publishing repair data
76
print "sim: publish RDATA sqn 90,002.\n";
77
$sim->say ("net send odata ao 90002 90001 momo");
78
print "app: wait for data ...\n";
79
my $data = $app->wait_for_data;
80
print "app: data received [$data].\n";
82
## second run with NAK suppression
84
print "sim: publish ODATA sqn 90,005.\n";
85
$sim->say ("net send odata ao 90005 90001 anzu");
86
print "sim: publish NCF sqn 90,004.\n";
87
$sim->say ("net send ncf ao $odata->{PGM}->{gsi}.$odata->{PGM}->{sourcePort} 90004");
89
print "sim: waiting for valid NAK.\n";
91
my $suppressed_backoff = tv_interval ( $t0, [gettimeofday] );
92
print "sim: NAK received in $suppressed_backoff seconds.\n";
94
die "NAK suppression failed.\n" unless ($suppressed_backoff > $normal_backoff);
96
print "test completed successfully.\n";