#!/usr/bin/perl # # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 # Yokogawa Electric 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. # # $TAHI: ct/nd.p2/V6LC_2_1_6_A_p1.seq,v 1.1 2006/11/28 06:45:25 akisada Exp $ # ######################################################################## use nd; BEGIN {} END {} startNdiscWorld($Link0); vLogHTML('set RetransTimer=1
'); #-- AdvRetransTimer: 1 ------------------------------------------------# if(setupCommon11_local($Link0) < 0) { exitInitFail(); } vLogHTML(''. 'TEST PROCEDURE
'); my $ereq = 'ndisc_ereq_LL'; vSend($Link0, $ereq); my @frames = mcastNS($ereq); my $recvCount = 0; my $solicit = 0; $TimeOut = 1 + 1; my @recvTimes = (); for( ; ; ) { my %ret = vRecvWrapper($Link0, $TimeOut, 0, 0, @frames); if($ret{'recvCount'}) { $recvCount += $ret{'recvCount'}; foreach my $frame (@frames) { if($ret{'recvFrame'} eq $frame) { $solicit ++; $recvCount --; push(@recvTimes, $ret{'recvTime'.$ret{'recvCount'}}); last; } } if($solicit > $MAX_MULTICAST_SOLICIT) { vLogHTML(''. 'Observed too many NSs
'); exitFail(); } next; } last; } unless($solicit) { vLogHTML(''. 'Could\'t observe NS
'); exitFail(); } if($solicit < $MAX_MULTICAST_SOLICIT) { vLogHTML(''. 'Observed too less NSs
'); exitFail(); } my $retransTimer = 1; if(checkInterval($retransTimer, @recvTimes) < 0) { exitFail(); } exitPass(); #NOTREACHED #------------------------------# # checkInterval # #------------------------------# sub checkInterval($@) { my ($retransTimer, @recvtimes) = @_; my $returnvalue = 0; vLogHTML(''); for(my $d = 0; $d <= $#recvtimes; $d ++) { vLogHTML(''); vLogHTML(""); vLogHTML(''); vLogHTML(""); if($d == 0) { vLogHTML(''); } vLogHTML(''); vLogHTML(''); if($d == $#recvtimes) { vLogHTML(''); } else { my $delta = $recvtimes[$d + 1] - $recvtimes[$d]; vLogHTML(""); vLogHTML(''); vLogHTML(sprintf("", $delta)); my $margin = 0.5; if(($delta < $retransTimer - $margin) || ($delta > $retransTimer + $margin)) { vLogHTML(''); $returnvalue = -1; } else { vLogHTML(''); } } vLogHTML(''); } vLogHTML('
Recv[$d]:$recvtimes[$d] sec. 
 Interval[$d]:%.1f sec.'); vLogHTML('*'); vLogHTML(' 
'); if($returnvalue < 0) { vLogHTML(''. 'Retransmissions MUST be rate-limited to '. 'at most one solicitation per
'); vLogHTML(''. 'neighbor every RetransTimer milliseconds.
'); } return($returnvalue); } #------------------------------# # setupCommon11_local() # #------------------------------# sub setupCommon11_local($) { my ($Link) = @_; $NEED_COMMON_CLEANUP = 1; vLogHTML('START COMMON SETUP 1.1'. '
'); if ($V6evalTool::NutDef{'Type'} eq 'router') { if(vRemote( 'route.rmt', 'cmd=add', 'prefix=default', "gateway=fe80::200:ff:fe00:a0a0", "if=$V6evalTool::NutDef{'Link0_device'}" )) { vLogHTML(''. 'route.rmt: Could\'t set route'. '
'); return($false); } # return(0); } my $ra = 'mcast_ra_commonsetup'; # transit REACHABLE # send RA if ($V6evalTool::NutDef{'Type'} eq 'host') { vClear($Link); vSend($Link, $ra); vRecv($Link, 3, 0, 0); } if($V6evalTool::NutDef{'Type'} eq 'router') { if(vRemote('racontrol.rmt', 'mode=start', 'retrans=1000', "link0=$V6evalTool::NutDef{'Link0_device'}")) { vLogHTML('racontrol.rmt: '. 'Could\'t start to send RA
'); exitFatal(); #NOTREACHED } $rut_rtadvd = 1; vRecv($Link, $MAX_INITIAL_RTR_ADVERT_INTERVAL * $MAX_INITIAL_RTR_ADVERTISEMENTS + $MIN_DELAY_BETWEEN_RAS + 1, 0, 0); } my $ereq = 'ereq_commonsetup'; my @frames = 'ns_setupcommon'; my $mcast_ns = ''; vSend($Link, $ereq); my %ret1 = vRecvWrapper($Link, $TimeOut, 0, 0, @frames); if($ret1{'recvCount'}) { foreach my $frame (@frames) { if($ret1{'recvFrame'} eq $frame) { $mcast_ns = $frame; last; } } } if($mcast_ns eq '') { vLogHTML(''. 'Could\'t observe NS
'); return(-1); } ## send NA my $erep = 'erep_commonsetup'; my $na = 'na_setupcommon'; vSend($Link, $na); my %ret2 = vRecvWrapper($Link, $TimeOut, 0, 0, $erep); if($ret2{'recvCount'}) { if($ret2{'recvFrame'} ne $erep) { return(-1); } } vLogHTML('FINISH COMMON SETUP 1.1'. '
'); } # # perldoc # ######################################################################## __END__ =head1 NAME =begin html
V6LC_2_1_6_A - Verify that the NUT transmits NSs in INCOMPLETE (link-local => link-local) =end html =begin html
=end html =head1 TARGET =begin html
Host/Router
=end html =head1 TOPOLOGY =begin html
                    |
   TN1     NUT      R0
    |       |       |
----+-------+-------+--- Link0

Link0 global 3ffe:501:ffff:100::/64
link-local fe80::/64
R0 global 3ffe:501:ffff:100:200:ff:fe00:a0a0
link-local fe80::200:ff:fe00:a0a0
ether 00:00:00:00:a0:a0
TN1 global 3ffe:501:ffff:100::<TnDef.Link0_addr>
link-local fe80::<TnDef.Link0_addr>
ether <TnDef.Link0_addr>
NUT global 3ffe:501:ffff:100::<NutDef.Link0_addr>
link-local fe80::<NutDef.Link0_addr>
ether <NutDef.Link0_addr>

=end html =head1 SETUP =begin html
This minimal setup procedure provides the NUT with a default router TR1, a global prefix, and ensures that the NUT can communicate with TR1.
   TR1     HUT
    |       |
    | -->   | RA
    |       |
    *       | Wait (MAX_RTR_SOLICITATION_DELAY + RetransTimer * DupAddrDetectTransmits)
    |       |
    | ----> | Echo Request
    |   <-- | NS
    | ----> | NA
    | <---- | Echo Reply
    |       |
    V       V

1. Send RA
        IPv6 header
            hop limit          = 255
            source             = TR1 (link-local)
            destination        = all-nodes multicast address
        RA
            cur hop limit      = 64
            M                  = 0
            O                  = 0
            router lifetime    = 1800
            reachable time     = 30000
            retrans timer      = 1000
        Prefix Information option
            prefix length      = 64
            L                  = 1
            A                  = 1
            valid Lifetime     = 2592000
            preferred lifetime = 604800
            prefix             = 3ffe:501:ffff:100::
2.  Wait (MAX_RTR_SOLICITATION_DELAY + RetransTimer * DupAddrDetectTransmits)
        Host constants:
            MAX_RTR_SOLICITATION_DELAY: 1 second
        Node constants:
            RETRANS_TIMER             : 1,000 milliseconds
        Host Variables:
            RetransTimer
                Default               : RETRANS_TIMER milliseconds
        Node Variables:
            DupAddrDetectTransmits
                Default               : 1
3. Send Echo Request
        IPv6 header
            source      = TR1 (link-local)
            destination = HUT (link-local)
        Echo Request
4. Observe NS
        IPv6 header
            hop limit   = 255
            source      = HUT (link-local)
            destination = TR1 (solicited-node multicast address)
        NS
            target      = TR1 (link-local)
        SLL option
5. Send NA
        IPv6 header
            hop limit   = 255
            source      = TR1 (link-local)
            destination = HUT (link-local)
        NA
            R           = 1
            S           = 1
            O           = 1
            target      = TR1 (link-local)
        TLL option
6. Observe Echo Reply
        IPv6 header
            source      = HUT (link-local)
            destination = TR1 (link-local)
        Echo Reply
=end html =head1 INITIALIZATION =begin html
none
=end html =head1 TEST PROCEDURE =begin html
- Verify that NUT transmits valid NSs in INCOMPLETE state
- Verify that NUT transmits multicast NSs 3 times
- Verify that NUT selects source address of NS correctly
   TN1     NUT
    |       |
    | ----> | Echo Request
    |   <-- | NS (multicast) [Judgment #1]
    |   <-- | NS (multicast)
    |   <-- | NS (multicast)
    |       |
    | -->   | RA
    | ----> | Echo Request
    |   <-- | NS (multicast) [Judgment #2]
    |   <-- | NS (multicast)
    |   <-- | NS (multicast)
    |       |
    V       V

1. Send Echo Request
        IPv6 header
            source      = TN1 (link-local)
            destination = NUT (link-local)
        Echo Request
    State: INCOMPLETE (TN1) (global)
2. Observe MAX_MULTICAST_SOLICIT NSs [Judgment #1]
        IPv6 header
            hop limit   = 255
            source      = NUT (link-local)
            destination = TN1 (solicited-node multicast address)
        NS
            target      = TN1 (link-local)
        SLL option
        Node constants:
            MAX_MULTICAST_SOLICIT: 3 transmissions
3. Send RA
        IPv6 header
            hop limit          = 255
            source             = TR1 (link-local)
            destination        = all-nodes multicast address
        RA
            cur hop limit      = 64
            M                  = 0
            O                  = 0
            router lifetime    = 1800
            reachable time     = 30000
            retrans timer      = 5000
        Prefix Information option
            prefix length      = 64
            L                  = 1
            A                  = 1
            valid Lifetime     = 2592000
            preferred lifetime = 604800
            prefix             = 3ffe:501:ffff:100::
4. Send Echo Request
        IPv6 header
            source      = TN1 (link-local)
            destination = NUT (link-local)
        Echo Request
5. Observe MAX_MULTICAST_SOLICIT NSs [Judgment #2]
        IPv6 header
            hop limit   = 255
            source      = NUT (link-local)
            destination = TN1 (solicited-node multicast address)
        NS
            target      = TN1 (link-local)
        SLL option
        Node constants:
            MAX_MULTICAST_SOLICIT: 3 transmissions
=end html =head1 JUDGEMENT =begin html
[Judgment #1] NUT must transmit 3 NSs to TN1 (solicited-node multicast address) at intervals of 1 second
[Judgment #2] NUT must transmit 3 NSs to TN1 (solicited-node multicast address) at intervals of 5 seconds
=end html =head1 CLEANUP =begin html
- Remove global address
   TN1     NUT      R0
    |       |       |
    |       |   <-- | RA (rltime=0, vltime=0, pltime=0) (If NUT isn't Router)
    |       |       |
    V       V       V

    State: NONE (TN1) (link-local)
1. Send RA (If NUT isn't Router)
        IPv6 header
            hop limit   = 255
            source      = R0 (link-local)
            destination = all-nodes multicast address
        RA
            cur hop limit   = 64
            M               = 0
            O               = 0
            router lifetime = 0
            reachable time  = 0
            retrans timer   = 0
        Prefix Information option
            prefix length      = 64
            L                  = 1
            A                  = 1
            valid Lifetime     = 0
            preferred lifetime = 0
            prefix             = 3ffe:501:ffff:100::
    State: NONE (TN1) (link-local)
=end html =cut # =head1 REFERENCE # # =begin html #
# RFC2461 Neighbor Discovery for IPv6 #
#
# 7.2.2.  Sending Neighbor Solicitations
# 
#
#    When a node has a unicast packet to send to a neighbor, but does not
#    know the neighbor's link-layer address, it performs address
#    resolution.  For multicast-capable interfaces this entails creating a
#    Neighbor Cache entry in the INCOMPLETE state and transmitting a
#    Neighbor Solicitation message targeted at the neighbor.  The
#    solicitation is sent to the solicited-node multicast address
#    corresponding to the target address.
# 
#
#    If the source address of the packet prompting the solicitation is the
#    same as one of the addresses assigned to the outgoing interface, that
#    address SHOULD be placed in the IP Source Address of the outgoing
#    solicitation.  Otherwise, any one of the addresses assigned to the
#    interface should be used.  Using the prompting packet's source
#    address when possible insures that the recipient of the Neighbor
#    Solicitation installs in its Neighbor Cache the IP address that is
#    highly likely to be used in subsequent return traffic belonging to
#    the prompting packet's "connection".
# 
#
#    If the solicitation is being sent to a solicited-node multicast
#    address, the sender MUST include its link-layer address (if it has
#    one) as a Source Link-Layer Address option.  Otherwise, the sender
#    SHOULD include its link-layer address (if it has one) as a Source
#    Link-Layer Address option.  Including the source link-layer address
#    in a multicast solicitation is required to give the target an address
#    to which it can send the Neighbor Advertisement.  On unicast
#    solicitations, an implementation MAY omit the Source Link-Layer
#    Address option. The assumption here is that if the sender has a
#    peer's link-layer address in its cache, there is a high probability
#    that the peer will also have an entry in its cache for the sender.
#    Consequently, it need not be sent.
# 
#

# RFC2461 Neighbor Discovery for IPv6 #


#
# 7.2.2.  Sending Neighbor Solicitations
# 
#
#    If no Neighbor Advertisement is received after MAX_MULTICAST_SOLICIT
#    solicitations, address resolution has failed.  The sender MUST return
#    ICMP destination unreachable indications with code 3 (Address
#    Unreachable) for each packet queued awaiting address resolution.
# 
#
# # =end html # =pod =head1 REFERENCE =begin html
RFC 2461 - Neighbor Discovery for IPv6
=end html =cut