#!/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/robust/FromManyNodes.seq,v 1.6 2001/10/05 06:39:14 masaxmasa Exp $ # ###################################################################### BEGIN { $V6evalTool::TestVersion = '$Name: REL_2_1_2 $'; } use V6evalTool; sub ping_one(); sub updateTnDef(); sub incLinkAddr($); sub incMac($); %pktdesc = ( echo_request => 'Send Echo Request (Link-Local Address)', echo_reply => 'Recv Echo Reply (Link-Local Address)', ns => 'Recv Neighbor Solicitation', na => 'Send Neighbor Advertisement', ); $IF=Link0; $nodes=1; #----- get arguments foreach (@ARGV) { /^nodes=([0-9]+)/ && do {$nodes=$1; next; }; print STDERR "Unknown option $_\n"; } #----- start Capturing vCapture($IF); for($i=0; $i < $nodes; $i++){ incLinkAddr($IF); updateTnDef(); my $mac = $V6evalTool::TnDef{"$IF"."_addr"}; vLogHTML("--- ping from node #$i ($mac) ---"); ping_one(); } vLogHTML('OK'); exit $V6evalTool::exitPass; end; sub ping_one(){ vSend($IF, echo_request); %ret = vRecv($IF, 5, 0, 0, ns, echo_reply); if ($ret{status} != 0) { vLogHTML('No response from NUT
'); vLogHTML('NG'); exit $V6evalTool::exitFail; } if ($ret{recvFrame} eq 'ns') { vSend($IF, na); %ret = vRecv($IF, 5, 0, 0, echo_reply); if ($ret{status} != 0) { vLogHTML('Cannot receive Echo Reply
'); vLogHTML('NG'); exit $V6evalTool::exitFail; } } if ($ret{recvFrame} ne 'echo_reply') { vLogHTML('Cannot receive Echo Reply
'); vLogHTML('NG'); exit $V6evalTool::exitFail; } } sub updateTnDef() { if(open(FILE, "> tn.def") == 0) { vLogHTML("update fail : can't open ./tn.def: $!
"); exit $V6evalTool::exitFatal; } foreach(keys(%V6evalTool::TnDef)) { next if(/^Link[0-9]+_device$/ || /^Link[0-9]+_addr$/); print FILE "$_ $V6evalTool::TnDef{$_}\n"; } close(FILE); } sub incLinkAddr($) { my($if)=@_; my($mac)=$V6evalTool::TnDef{$if."_addr"}; my($newmac)=incMac($mac); $V6evalTool::TnDef{$if."_addr"}=$newmac; $V6evalTool::TnDef{$if}=$V6evalTool::TnDef{$if."_device"}. " ".$V6evalTool::TnDef{$if."_addr"}; } sub incMac($) { my($hex)=@_; my($max)=hex(ffffff); my($mask)=$max+1; my($offset)=128; my(@hex)=split(/:/, $hex); my($uhex)="$hex[0]$hex[1]$hex[2]"; my($lhex)="$hex[3]$hex[4]$hex[5]"; my($udec)=hex($uhex); my($ldec)=hex($lhex); $ldec++; if($ldec > $max) { $ldec%=$mask; $udec++; if($udec > $max) { $udec%=$mask; } } if(($udec==0 && $ldec==0)||($udec==$max && $ldec==$max)) { $udec=0; $ldec=$offset; } my($uhex2)=sprintf("%06x", $udec); my($lhex2)=sprintf("%06x", $ldec); my(@uhex2)=split(//, $uhex2); my(@lhex2)=split(//, $lhex2); my($hex3)="$uhex2[0]$uhex2[1]:$uhex2[2]$uhex2[3]:$uhex2[4]$uhex2[5]:". "$lhex2[0]$lhex2[1]:$lhex2[2]$lhex2[3]:$lhex2[4]$lhex2[5]"; return($hex3); } ###################################################################### __END__ =head1 NAME FromManyNodes.seq - Ping from Many Many node =head1 TARGET Host and Router =head1 SYNOPSIS B [I] =head1 INITIALIZATION NONE =head1 TEST PROCEDURE This is one of robustness tests for neighbor cache entry (NCE) and destination cache entry (DCE) memory management. The test emulate that there are many nodes (the number as specified [nodes=num] option) on a link (Figure .1) and each nodes send ICMP Echo Request to NUT. =over 4 ---+--------+----------+-------------+--- Link0 | | | | +-+-+ +--+---+ +--+---+ +---+--+ |NUT| |Node 1| |Node 2| ... |Node N| +---+ +------+ +------+ +------+ Figure. 1 =back Each node send packets as following sequence. =over 4 =item 1 Node #N send a ICMP Echo Request Packet to NUT. [Node #N] ------> [NUT] request =item 2 If NUT send a NS packet to Node #N, reply NA. [Node #N] <------ [NUT] NS [Node #N] ------> [NUT] NA =item 3 Wait a ICMP Echo Reply Packet from NUT. [Node #N] <------ [NUT] Reply =back In these sequence, NUT makes NCE and DCE for each node. And NUT maybe delete the entry as : expire time. can't allocate more memory for the cache. When make the entry, NUT allocate the memory and when delete the entry, free the memory. In the test, NUT is tested whether NUT have a problem of these memory handling. =head1 JUDGMENT If TN receive echo reply packets for all request, the NUT pass the test, but if NUT can't receive one of echo replies, the script presume NUT have some problem and judged FAIL. =head1 TERMINATION NONE =head1 SEE ALSO perldoc V6evalTool =cut