~ubuntu-branches/ubuntu/precise/libpgm/precise

« back to all changes in this revision

Viewing changes to openpgm/pgm/test/.svn/text-base/ncf_suppression.pl.svn-base

  • Committer: Bazaar Package Importer
  • Author(s): Gabriel de Perthuis
  • Date: 2011-04-07 16:48:52 UTC
  • Revision ID: james.westby@ubuntu.com-20110407164852-8uamem42ojeptj6l
Tags: upstream-5.1.116~dfsg
ImportĀ upstreamĀ versionĀ 5.1.116~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
# ncf_suppression.pl
 
3
# 6.3. Data Recovery by Negative Acknowledgment
 
4
 
 
5
use strict;
 
6
use Time::HiRes qw( gettimeofday tv_interval );
 
7
use PGM::Test;
 
8
 
 
9
BEGIN { require "test.conf.pl"; }
 
10
 
 
11
$| = 1;
 
12
 
 
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});
 
16
 
 
17
$mon->connect;
 
18
$sim->connect;
 
19
$app->connect;
 
20
 
 
21
sub close_ssh {
 
22
        $mon = $sim = $app = undef;
 
23
        print "finished.\n";
 
24
}
 
25
 
 
26
$SIG{'INT'} = sub { print "interrupt caught.\n"; close_ssh(); };
 
27
 
 
28
$mon->say ("filter $config{app}{ip}");
 
29
print "mon: ready.\n";
 
30
 
 
31
$app->say ("create ao");
 
32
$app->say ("bind ao");
 
33
$app->say ("connect ao");
 
34
$app->say ("listen ao");
 
35
 
 
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";
 
41
 
 
42
$sim->say ("create fake ao");
 
43
$sim->say ("bind ao");
 
44
$sim->say ("connect ao");
 
45
 
 
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");
 
48
 
 
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";
 
53
 
 
54
print "sim: publish ODATA sqn 90,001.\n";
 
55
$sim->say ("net send odata ao 90001 90001 ringo");
 
56
 
 
57
print "app: wait for data ...\n";
 
58
my $data = $app->wait_for_data;
 
59
print "app: data received [$data].\n";
 
60
 
 
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";
 
65
 
 
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";
 
71
$sim->wait_for_nak;
 
72
my $normal_backoff = tv_interval ( $t0, [gettimeofday] );
 
73
print "sim: NAK received in $normal_backoff seconds.\n";
 
74
 
 
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";
 
81
 
 
82
## second run with NAK suppression
 
83
$t0 = [gettimeofday];
 
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");
 
88
 
 
89
print "sim: waiting for valid NAK.\n";
 
90
$sim->wait_for_nak;
 
91
my $suppressed_backoff = tv_interval ( $t0, [gettimeofday] );
 
92
print "sim: NAK received in $suppressed_backoff seconds.\n";
 
93
 
 
94
die "NAK suppression failed.\n" unless ($suppressed_backoff > $normal_backoff);
 
95
 
 
96
print "test completed successfully.\n";
 
97
 
 
98
$mon->disconnect (1);
 
99
$sim->disconnect;
 
100
$app->disconnect;
 
101
close_ssh;
 
102
 
 
103
# eof