#!/usr/bin/perl
#
# $Copyright$
#
# $TAHI: ct/robust/FromManyNodes.seq,v 1.6 2001/10/05 06:39:14 masaxmasa Exp $
#
######################################################################
BEGIN {
$V6evalTool::TestVersion = '$Name: $';
}
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