#!/usr/bin/perl
#
# $Copyright_v6PC$
#
# $Copyright$
#
# $TAHI: ct/nd/routerSendSolRaDefault.seq,v 1.11 2004/04/02 02:28:23 akisada Exp $
########################################################################
BEGIN { $V6evalTool::TestVersion = '$Name: $ '; }
use V6evalTool;
use nd;
use ra;
my $wait_readout = $nd::DELAY_FIRST_PROBE_TIME +
$nd::RETRANS_TIMER * $nd::MAX_UNICAST_SOLICIT + 1;
ndOptions(@ARGV);
# The following generate debugging messages.
$nd::debug=$ndOpt_v|$ndOpt_vv;
# You can specifies debug options to a remote control program.
# If you want to know more detail, please see the following:
# - V6evalTool.pm: perldoc V6evalTool
# - V6evalRemote.pm: perldoc V6evalRemote
$nd::remote_debug="-o1" if $ndOpt_vv;
$IF=Link0;
$exit_rtn=$V6evalTool::exitPass;
$wait_ra=$ra::defaultRA2maxInterval*2;
$delay=1;
#
#
#
$type=$V6evalTool::NutDef{Type};
if($type eq host) {
vLogHTML("This test is for the router only
");
exit $V6evalTool::exitRouterOnly;
}
$type=$V6evalTool::NutDef{Type};
if($type ne router) {
vLogHTML(ndErrmsg("ERROR: $V6evalTool::NutDef{Type}: ".
"Unknown target type
"));
exit $V6evalTool::exitFail;
}
if(raIsMarkDefaultRA2() == 0) {
vLogHTML(ndErrmsg("ERROR: Need RA configuration
"));
readout($IF, $wait_readout);
exit $V6evalTool::exitFail;
}
#
#
#
vCapture($IF);
#
#
#
if(beforeLimit() == 0) {
$exit_rtn=$V6evalTool::exitFail;
readout($IF, $wait_readout);
}
if(afterLimit() == 0) {
$exit_rtn=$V6evalTool::exitFail;
readout($IF, $wait_readout);
}
#
#
#
end:
exit $exit_rtn;
sub readout($$) {
my ($if, $timeout) = @_;
return(vRecv($if, $timeout, 0, 0));
}
sub beforeLimit()
{
#
#
#
vClear($IF);
#
#
#
if(raRecvAnyRA($IF, $wait_ra, 0, 0, %ret1) == 0) {
vLogHTML("ERROR: Never got RA
");
goto error;
}
#
#
#
vSleep($nd::MIN_DELAY_BETWEEN_RAS - $delay,
"Wait (MIN_DELAY_BETWEEN_RAS - $delay) sec.");
$pktdesc{rs_tn2allrouter}="Send RS";
%ret2=vSend($IF, rs_tn2allrouter);
#
#
#
if(raRecvAnyRA($IF, $wait_ra, $ret2{sentTime1}, 0, %ret3) == 0) {
vLogHTML("ERROR: Never got RA
");
goto error;
}
#
#
#
$n=$ret1{recvCount};
$time_first=$ret1{"recvTime$n"};
$n=$ret3{recvCount};
$time_last=$ret3{"recvTime$n"};
$interval=$time_last-$time_first;
vLogHTML("Interval between RAs (1st and 2nd): $interval
");
if($interval < $nd::MIN_DELAY_BETWEEN_RAS ||
$interval > $nd::MIN_DELAY_BETWEEN_RAS+1) {
vLogHTML(ndErrmsg("ERROR: $nd::MIN_DELAY_BETWEEN_RAS < ".
"The interval < ".
"$nd::MIN_DELAY_BETWEEN_RAS+1
"));
goto error;
}
#
#
#
return(1);
error:
return(0);
}
sub afterLimit()
{
#
#
#
vClear($IF);
#
#
#
if(raRecvAnyRA($IF, $wait_ra, 0, 0, %ret1) == 0) {
vLogHTML("ERROR: Never got RA
");
goto error;
}
#
#
#
vSleep($nd::MIN_DELAY_BETWEEN_RAS + $delay,
"Wait (MIN_DELAY_BETWEEN_RAS + $delay) sec.");
$pktdesc{rs_tn2allrouter}="Send RS";
%ret2=vSend($IF, rs_tn2allrouter);
#
#
#
if(raRecvAnyRA($IF, $wait_ra, $ret2{sentTime1}, 0, %ret3) == 0) {
vLogHTML("ERROR: Never got RA
");
goto error;
}
#
#
#
$time_first=$ret2{sentTime1};
$n=$ret3{recvCount};
$time_last=$ret3{"recvTime$n"};
$interval=$time_last-$time_first;
vLogHTML("Interval between RS and RA: $interval
");
if($interval > $nd::MAX_RA_DELAY_TIME) {
vLogHTML(ndErrmsg("ERROR: $nd::MAX_RA_DELAY_TIME < ".
"The interval
"));
goto error;
}
#
#
#
return(1);
error:
return(0);
}
########################################################################
__END__
=head1 NAME
routerSendSolRaDefault - Verify that NUT sends Solicited RA by default value specified in RFC
=head1 TARGET
Router Only
=head1 SYNOPSIS
routerSendSolRaDefault.seq [-tooloption ...] -p routerSendSolRaDefault.def
=head1 INITIALIZATION
=begin html
Start NUT advertising RAs whose parameters are as same as
those
except the followings:
CASE I=end html =head1 JUDGMENT =begin html
TN NUT ----------------------
<=== RA ==== src=NUT dst=all-node any option is accepted.
T1 <= received time
Wait(MIN_DELAY_BETWEEN_RAS - 1 sec)
==== RS ===> src=TN dst=all-router
<=== RA ==== src=NUT dst=allnode any option is accepted.
T2 <= received time
Judgment: MIN_DELAY_BETWEEN_RAS < T2 - T1 < MIN_DELAY_BETWEEN_RAS + RA_MAX_DELAY_TIME
CASE II
TN NUT ----------------------
<=== RA ==== src=NUT dst=all-node any option is accepted.
Wait(MIN_DELAY_BETWEEN_RAS + 1 sec)
==== RS ===> src=TN dst=all-router
T1 <= sent time
<=== RA ==== src=NUT dst=all-node any option is accepted.
T2 <= received time
Judgment: 0 < = T2 - T1 < RA_MAX_DELAY_TIME
CASE I
Solicited
Multicast Multicast
RA RS RA
^ | ^
| | |
| V |
----+------------------+-----+----+----> time
|<======================>| |
| MIN_DELAY_BETWEEN_RAS |
| |
|<===========================>|
MIN_DELAY_BETWEEN_RAS + T
MIN_DELAY_BETWEEN_RAS=3 sec.
0 < T < MAX_RA_DELAY_TIME (0.5 sec)
CASE II
Solicited
Multicast Multicast
RA RS RA
^ | ^
| | |
| V |
----+------------------------+----+-----+---> time
|<======================>| |<===>|
MIN_DELAY_BETWEEN_RAS T
MIN_DELAY_BETWEEN_RAS=3 sec.
0 < T < MAX_RA_DELAY_TIME (0.5 sec)
=end html
=head1 TERMINATION
N/A
=head1 NOTE
The test does not invoke any remote command.
=head1 REFERENCE
=begin html
6.2.6. Processing Router Solicitations=end html =head1 SEE ALSO perldoc V6evalTool perldoc V6evalRemote =cut
A host MUST silently discard any received Router Solicitation messages.
In addition to sending periodic, unsolicited advertisements, a router sends advertisements in response to valid solicitations received on an advertising interface. A router MAY choose to unicast the response directly to the soliciting host's address (if the solicitation's source address is not the unspecified address), but the usual case is to multicast the response to the all-nodes group. In the latter case, the interface's interval timer is reset to a new random value, as if an unsolicited advertisement had just been sent (see Section 6.2.4).
In all cases, Router Advertisements sent in response to a Router Solicitation MUST be delayed by a random time between 0 and MAX_RA_DELAY_TIME seconds. (If a single advertisement is sent in response to multiple solicitations, the delay is relative to the first solicitation.) In addition, consecutive Router Advertisements sent to the all-nodes multicast address MUST be rate limited to no more than one advertisement every MIN_DELAY_BETWEEN_RAS seconds.
A router might process Router Solicitations as follows:
- Upon receipt of a Router Solicitation, compute a random delay within the range 0 through MAX_RA_DELAY_TIME. If the computed value corresponds to a time later than the time the next multicast Router Advertisement is scheduled to be sent, ignore the random delay and send the advertisement at the already-scheduled time.
- If the router sent a multicast Router Advertisement (solicited or unsolicited) within the last MIN_DELAY_BETWEEN_RAS seconds, schedule the advertisement to be sent at a time corresponding to MIN_DELAY_BETWEEN_RAS plus the random value after the previous advertisement was sent. This ensures that the multicast Router Advertisements are rate limited.
- Otherwise, schedule the sending of a Router Advertisement at the time given by the random value.
Note that a router is permitted to send multicast Router Advertisements more frequently than indicated by the MinRtrAdvInterval configuration variable so long as the more frequent advertisements are responses to Router Solicitations. In all cases, however, unsolicited multicast advertisements MUST NOT be sent more frequently than indicated by MinRtrAdvInterval.