#!/usr/bin/perl # # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Yokogawa Electric Corporation, # IPA (Information-technology Promotion Agency, Japan). # 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. However, using this software for the # purpose of testing or evaluating any products including merchantable # products may be permitted without any notification to the copyrighters. # # # # 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. # # $TAHI: ct/nd/routerSendRedirectOnlink.seq,v 1.10 2002/02/27 01:08:29 masaxmasa Exp $ ######################################################################## BEGIN { $V6evalTool::TestVersion = '$Name: REL_2_1_2 $ '; } use V6evalTool; use nd; use routerRedirect; 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; # # # $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=Link0; $wait_ns=$nd::RETRANS_TIMER * $nd::MAX_MULTICAST_SOLICIT; $exit_rtn=$V6evalTool::exitPass; # # # vCapture($IF); # # # $pktdesc{RRDecho_request_tn2hosttwo}= "Sent echo-request to Host2(on-link) via NUT"; %ret=vSend($IF, RRDecho_request_tn2hosttwo); # $pktdesc{RRDmulticast_ns_nut2tnsolnode_sll}= "Got multicast NS for TN"; $pktdesc{RRDmulticast_ns_nutg2tnsolnode_sll}= "Got multicast NS for TN"; $pktdesc{RRDmulticast_ns_nut2hosttwosolnode_sll}= "Got multicast NS for Host2"; $pktdesc{RRDmulticast_ns_nutg2hosttwosolnode_sll}= "Got multicast NS for Host2"; # $pktdesc{RRDredirect_hosttwo}= "Got redirect(to on-link) message w/o any option"; $pktdesc{RRDredirect_hosttwo_t}= "Got redirect(to on-link) message w/ TLL}"; $pktdesc{RRDredirect_hosttwo_r}= "Got redirect(to on-link) message w/ Redirected Header"; $pktdesc{RRDredirect_hosttwo_r2}= "Got redirect(to on-link) message ". "w/ Redirected Header (HopLimit--)"; $pktdesc{RRDredirect_hosttwo_t_and_r}= "Got redirect message w/ {TLL and Redirected Header}"; $pktdesc{RRDredirect_hosttwo_t_and_r2}= "Got redirect message ". "w/ {TLL and Redirected Header (HopLimit--)}"; # $pktdesc{RRDredirect_any}= ndErrmsg("ERROR: Got unexpected redirect message"); # $pktdesc{RRDecho_request_tn2hosttwo_via_nut}= "NUT forwarded the echo-request to Host2"; # $pktdesc{RRDunicast_na_tn2nut_rSO_tll}= "TN sent NA(r/S/O)"; $pktdesc{RRDunicast_na_tn2nutg_rSO_tll}= "TN sent NA(r/S/O)"; $pktdesc{RRDunicast_na_hosttwo2nut_rSO_tll}= "Host2 sent NA(r/S/O)"; $pktdesc{RRDunicast_na_hosttwo2nutg_rSO_tll}= "Host2 sent NA(r/S/O)"; $is_redirected=0; $is_forwarded=0; while(1) { %ret2=vRecv($IF, $wait_ns, $ret{sentTime1}, 1, RRDmulticast_ns_nut2tnsolnode_sll, RRDmulticast_ns_nutg2tnsolnode_sll, RRDmulticast_ns_nut2hosttwosolnode_sll, RRDmulticast_ns_nutg2hosttwosolnode_sll, RRDredirect_hosttwo, RRDredirect_hosttwo_t, RRDredirect_hosttwo_r, RRDredirect_hosttwo_r2, RRDredirect_hosttwo_t_and_r, RRDredirect_hosttwo_t_and_r2, RRDredirect_any, RRDecho_request_tn2hosttwo_via_nut, ); # last if $ret2{status} == 1; # timeout if($ret2{status} != 0) { vLogHTML(ndErrmsg(vErrmsg(%ret2))."
"); $exit_rtn=$V6evalTool::exitFail; last; } $frame=$ret2{recvFrame}; # if($frame=~/RRDredirect/) { $is_redirected=1; } if($frame=~/RRDecho_request/) { $is_forwarded=1; } # if($frame=~/r2/) { # $exit_rtn=$V6evalTool::exitWarn; # } if($frame eq RRDredirect_any) { $exit_rtn=$V6evalTool::exitFail; } # $s=""; if($frame eq RRDmulticast_ns_nut2tnsolnode_sll) { $s="RRDunicast_na_tn2nut_rSO_tll"; } elsif($frame eq RRDmulticast_ns_nutg2tnsolnode_sll) { $s="RRDunicast_na_tn2nutg_rSO_tll"; } elsif($frame eq RRDmulticast_ns_nut2hosttwosolnode_sll) { $s="RRDunicast_na_hosttwo2nut_rSO_tll"; } elsif($frame eq RRDmulticast_ns_nutg2hosttwosolnode_sll) { $s="RRDunicast_na_hosttwo2nutg_rSO_tll"; } $ret=vSend($IF, $s) if $s ne ""; } # # # if($is_redirected==0) { vLogHTML(ndErrmsg("ERROR: Never got redirect message
")); $exit_rtn=$V6evalTool::exitFail; } if($is_forwarded==0) { vLogHTML(ndErrmsg("ERROR: NUT did not forward the echo-request
")); $exit_rtn=$V6evalTool::exitFail; } # # # if($exit_rtn==$V6evalTool::exitPass) { vLogHTML("OK
"); } elsif($exit_rtn==$V6evalTool::exitWarn) { vLogHTML(ndWarnmsg("WARN
")); } else { vLogHTML(ndErrmsg("NG
")); } exit $exit_rtn; ######################################################################## __END__ =head1 NAME routerSendRedirectOnlink - TBD =head1 TARGET Router Only =head1 SYNOPSIS routerSendRedirectOnlink.seq [-tooloption ...] -p routerSendRedirectOnlink.def =head1 INITIALIZATION =begin html Initialization was done by a previous test. =end html =head1 TEST PROCEDURE B verifies that NUT send a redirect message if NUT know a target is on-link. =begin html
  TN               NUT
  --------------------

==== echo-request to H2 ===> TN throws an echo-request to NUT mac src=TN mac dst=NUT ip src=TN's global ip dst=H2's global
<=== NS for H2 (if any) ==== src=NUT's link-local dst=solicited-node[H2's global] target=H2's global w/ SLLA
==== NA for R1 (if any) ===> src=H2's global dst=NUT's link-local target=H2's global R=0, S=1, O=1 w/ TLLA
<=== echo-request to H2 ==== NUT forwards an echo-request to H2 mac src=NUT mac dst=H2 ip src=TN's global ip dst=H2's global
<=== NS for TN (if any) ==== src=NUT's link-local dst=solicited-node[TN's global] target=TN's global w/ SLLA
==== NA for TN (if any) ===> src=TN's global dst=NUT's link-local target=TN's global R=0, S=1, O=1 w/ TLLA
<=== Redirect ==== src=NUT's link-local dst=TN's global target=H2's global icmp dst=H2's global w/ OR w/o TLLA w/ OR w/o Redirected header
=end html =head1 JUDGMENT =begin html
  1. NUT must forwards an echo-request to the host, H2:

2. NUT must send a redirect message to TN: ip src=NUT's link-local ip dst=TN's global icmp target=H2's global icmp dst=H2's global
=end html =head1 TERMINATION N/A =head1 NOTE NUT may send a redirect message that contains a redirected header option, but whose hop limit value is decreased from the original one. It does make sense. In such case, this test will judges "WARN" instead of "PASS" to notify the difference. =head1 REFERENCE =begin html
RFC2461

8.2. Router Specification
A router SHOULD send a redirect message, subject to rate limiting, whenever it forwards a packet that is not explicitly addressed to itself (i.e. a packet that is not source routed through the router) in which:
- the Source Address field of the packet identifies a neighbor, and
- the router determines that a better first-hop node resides on the same link as the sending node for the Destination Address of the packet being forwarded, and
- the Destination Address of the packet is not a multicast address, and
The transmitted redirect packet contains, consistent with the message format given in Section 4.5:
- In the Target Address field: the address to which subsequent packets for the destination SHOULD be sent. If the target is a router, that router's link-local address MUST be used. If the target is a host the target address field MUST be set to the same value as the Destination Address field.
- In the Destination Address field: the destination address of the invoking IP packet.
- In the options:
o Target Link-Layer Address option: link-layer address of the target, if known.
o Redirected Header: as much of the forwarded packet as can fit without the redirect packet exceeding 1280 octets in size.
A router MUST limit the rate at which Redirect messages are sent, in order to limit the bandwidth and processing costs incurred by the Redirect messages when the source does not correctly respond to the Redirects, or the source chooses to ignore unauthenticated Redirect messages. More details on the rate-limiting of ICMP error messages can be found in [ICMPv6].
=head1 SEE ALSO perldoc V6evalTool perldoc V6evalRemote =cut