#!/usr/bin/perl # # Copyright (C) 1999,2000 Yokogawa Electric Corporation and # YDC Corporation. # All rights reserved. # # Redistribution and use of this software in source and binary # forms, with or without modification, are permitted provided that # the following conditions and disclaimer are agreed and accepted # by the user: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with # the distribution. # # 3. Neither the names of the copyrighters, the name of the project # which is related to this software (hereinafter referred to as # "project") nor the names of the contributors may be used to # endorse or promote products derived from this software without # specific prior written permission. # # 4. No merchantable use may be permitted without prior written # notification to the copyrighters. # # 5. The copyrighters, the project and the contributors may prohibit # the use of this software at any time. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHTERS, THE PROJECT AND # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING # BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHTERS, THE PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # $Id: hostRecvRaReachableTime.seq,v 1.1.1.1 2000/10/31 22:39:33 sekiya Exp $ ######################################################################## BEGIN { $V6evalTool::TestVersion = '$Name: $ '; } use V6evalTool; use nd; sub checkReachableTime($$\@\@\%\%\$); ndOptions(@ARGV); # The following generate debugging messages. $nd::debug=$ndOpt_v|$ndOpt_vv; # You can specifies debug optons 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; @null=(); $exit_rtn=$V6evalTool::exitPass; # # # $type=$V6evalTool::NutDef{Type}; if($type eq router) { vLogHTML("This test is for the host only
"); exit $V6evalTool::exitHostOnly; } $type=$V6evalTool::NutDef{Type}; if($type ne host) { vLogHTML(ndErrmsg("ERROR: $V6evalTool::NutDef{Type}: ". "Unknown target type
")); exit $V6evalTool::exitFail; } # # # $ra_name_30='ra_x2allnode_sll_reachable30'; $ra_msg_30='RA w/ SLL, ReachableTime=30sec'; @before_30=((30*0.5-2)); @after_30=((30*1.5+1)); $pktdesc{ra_x2allnode_sll_reachable30}= "Send $ra_msg_30"; $ra_name_60='ra_x2allnode_sll_reachable60'; $ra_msg_60='RA w/ SLL, ReachableTime=60sec'; @before_60=((60*0.5-2)); @after_60=((60*1.5+1)); $pktdesc{ra_x2allnode_sll_reachable60}= "Send $ra_msg_60"; $ra_name_90='ra_x2allnode_sll_reachable90'; $ra_msg_90='RA w/ SLL, ReachableTime=90sec'; @before_90=((90*0.5-2)); @after_90=((90*1.5+1)); $pktdesc{ra_x2allnode_sll_reachable90}= "Send $ra_msg_90"; @ra_name=( \$ra_name_60, \$ra_name_30, \$ra_name_90, ); @ra_msg=( \$ra_msg_60, \$ra_msg_30, \$ra_msg_90, ); @before=( \@before_60, \@before_30, \@before_90, ); @after=( \@after_60, \@after_30, \@after_90, ); # # # vCapture($IF); # # # $idx=0; $i=0; foreach(@ra_name) { my($name)=$_; my($msg)=@ra_msg[$i]; my($b)=@before[$i]; my($a)=@after[$i]; my($r); $r=checkReachableTime($$name, $$msg, @$b, @$a, %title, %result, $idx); $exit_rtn = $r if $r != $V6evalTool::exitPass; $i++; } $idx--; # # # clear(); # # # @col=('PTN', 'EXP', 'RESULT'); ndPrintSummaryHTML("*** Test Summary: RA vs. ReachableTimer ***", @col, %title, %result, $idx); # # # vLogHTML("*** EOT ***
"); exit $exit_rtn; sub checkReachableTime($$\@\@\%\%\$) { my( $my_ra_ptn, $my_ra_title, $before_reachable, $after_reachable, $my_title, $my_result, $my_idx, )=@_; my($my_exit_rtn)=$V6evalTool::exitPass; my($s, %rtn); my($reachable_time)=@$after_reachable[0]; vLogHTML("
*** $my_ra_title ***
"); vLogHTML("
". "*** Before RetransTimer * 0.5 sec ***
"); my($first)=1; foreach(@$before_reachable) { my($wait)=$_; vLogHTML("
". "*** $my_ra_title, $wait sec, exp:REACHABLE ***
"); vLogHTML("
Initialization
"); if($first) { %ret=vSend($IF, $my_ra_ptn); goto error if $ret{status} != 0; } if(nd2NoNceByPacket($IF, $reachable_time) != 0 || ndNoNce2Incomplete($IF) != 0 || ndIncomplete2Reachable($IF) != 0) { $s="ERROR"; } else { vClear($IF); vLogHTML("
Test
"); vSleep($wait); $s=ndIsReachable($IF); } if($s eq REACHABLE) { $$my_result{$$my_idx}=$V6evalTool::exitPass; vLogHTML("OK
"); } else { $my_exit_rtn=$V6evalTool::exitFail; $$my_result{$$my_idx}=$V6evalTool::exitWarn; vLogHTML("The state should be REACHABLE
"); vLogHTML("".ndErrmsg(NG)."
"); } $$my_title{$$my_idx}= "$my_ra_title, $wait secexp:REACHABLE". "result:$s"; } continue { $$my_idx++; $first=0; } vLogHTML("
". "*** After RetransTimer * 1.5 sec ***
"); foreach(@$after_reachable) { my($wait)=$_; vLogHTML("
". "*** $my_ra_title, $wait sec, exp:STALE ***
"); vLogHTML("
Initialization
"); if(nd2NoNceByPacket($IF, $reachable_time) != 0 || ndNoNce2Incomplete($IF) != 0 || ndIncomplete2Reachable($IF) != 0) { $s="ERROR"; } else { vClear($IF); vLogHTML("
Test
"); vLogHTML("wait ($wait sec)
"); vSleep($wait); $s=ndIsReachable($IF); } if($s eq STALE) { $$my_result{$$my_idx}=$V6evalTool::exitPass; vLogHTML("OK
"); } else { $my_exit_rtn=$V6evalTool::exitFail; $$my_result{$$my_idx}=$V6evalTool::exitWarn; vLogHTML("The state should be STALE
"); vLogHTML("".ndErrmsg(NG)."
"); } $$my_title{$$my_idx}= "$my_ra_title, $wait secexp:STALE". "result:$s"; } continue { $$my_idx++; } # # # vLogHTML("
Termination
"); goto error if nd2NoNceByPacket($IF, $reachable_time) != 0; # # # return($my_exit_rtn); error: clear(); vLogHTML(vErrmsg(%ret)."
"); exit $V6evalTool::exitFail; } sub clear() { $pktdesc{ra_x2allnode_sll_reachable30}= 'Set ReachableTime to the default (30 sec)'; $pktdesc{ra_x2allnode_clrrtr}= 'Clear the Default Router List'; vSend($IF, ra_x2allnode_sll_reachable30); vSend($IF, ra_x2allnode_clrrtr); } ######################################################################## __END__ =head1 NAME hostRecvRaReachableTime - Verifying that NUT recognize ReachableTime =head1 TARGET Host only =head1 SYNOPSIS hostRecvRaReachableTime.seq [-tooloption ...] -p hostRecvRaReachableTime.def =head1 INITIALIZATION =begin html
  1. Set ReachableTtime by router X.
  2. Create the state of neighbor cache entry for TN.
  3. Set its state to REACHABLE whose IsRouter flag is FALSE.
  TN                 NUT
  ----------------------
  State: NONCE (for all)

==== unsolicited RA ===> src=X's link-local dst=all-node M=0, O=0 RouterLifetime=600 ReachableTime=a test condition RetransTimer=0 w/ SLLA
State: NONE (for TN), STALE(for X)
==== echo-request ===> src=TN's link-local dst=NUT's link-local
<=== multicast NS ==== src=NUT's link-local dst=solicited-node[TN's link-local] w/ SLLA timeout=RETRANS_TIMER * MAX_MULTICAST_SOLICIT
==== solicited NA ===> src=TN's link-local dst=NUT's link-local R=0, S=1, O=1 target=TN's link-local w/ TLLA
State: REACHABLE (for TN), STALE (for X)
=head1 TEST PROCEDURE B verifies that NUT recognize ReachableTime. =begin html
  TN               NUT
  ----------------------
  State: REACHABLE (for TN)

Wait for some seconds
Judgment: Examining NUT's neighbor cache state =end html =head1 JUDGMENT =begin html

6.3.4. Processing Received Router Advertisements
If the received Reachable Time value is non-zero the host SHOULD set its BaseReachableTime variable to the received value. If the new value differs from the previous value, the host SHOULD recompute a new random ReachableTime value. ReachableTime is computed as a uniformly-distributed random value between MIN_RANDOM_FACTOR and MAX_RANDOM_FACTOR times the BaseReachableTime. Using a random component eliminates the possibility Neighbor Unreachability Detection messages synchronize with each other.
==============+===================+================== RA received | Wait Time by NUT | --------------+-------------------+------------------ ReachableTime | t < | t > | ReachableTime * | ReachableTime * | MIN_RANDOM_FACTOR | MAX_RANDOM_FACTOR ==============+===================+================== 60 | t < 30, REACHABLE | t > 90, STALE --------------+-------------------+------------------ 30 | t < 15, REACHABLE | t > 45, STALE --------------+-------------------+------------------ 90 | t < 45, REACHABLE | t > 135, STALE ==============+===================+==================
=end html =head1 TERMINATION 1. Send RA with ReachableTime=30sec to set TN's reachable time to the default value. 2. Send RA with RouterLifetime=0 to clear the Default Router List. =head1 NOTE The test does not invoke any remote command. =head1 SEE ALSO perldoc V6evalTool perldoc V6evalRemote =cut