add test/ping-sweep
This commit is contained in:
parent
9470245fe1
commit
41d3f66458
4 changed files with 129 additions and 5 deletions
3
Changes
3
Changes
|
|
@ -1,3 +1,6 @@
|
||||||
|
* Fri Nov 25 2005 Brendan O'Dea <bod@optus.net> 2.1.13
|
||||||
|
- Add test/ping-sweep.
|
||||||
|
|
||||||
* Thu Nov 17 2005 Brendan O'Dea <bod@optus.net> 2.1.12
|
* Thu Nov 17 2005 Brendan O'Dea <bod@optus.net> 2.1.12
|
||||||
- Set MTU on tunnel interface so the kernel will re-fragment large
|
- Set MTU on tunnel interface so the kernel will re-fragment large
|
||||||
packets to within MRU.
|
packets to within MRU.
|
||||||
|
|
|
||||||
4
l2tpns.h
4
l2tpns.h
|
|
@ -1,5 +1,5 @@
|
||||||
// L2TPNS Global Stuff
|
// L2TPNS Global Stuff
|
||||||
// $Id: l2tpns.h,v 1.99 2005/11/17 07:35:35 bodea Exp $
|
// $Id: l2tpns.h,v 1.100 2005/11/25 02:18:40 bodea Exp $
|
||||||
|
|
||||||
#ifndef __L2TPNS_H__
|
#ifndef __L2TPNS_H__
|
||||||
#define __L2TPNS_H__
|
#define __L2TPNS_H__
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <libcli.h>
|
#include <libcli.h>
|
||||||
|
|
||||||
#define VERSION "2.1.12"
|
#define VERSION "2.1.13"
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
#define MAXTUNNEL 500 // could be up to 65535
|
#define MAXTUNNEL 500 // could be up to 65535
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Summary: A high-speed clustered L2TP LNS
|
Summary: A high-speed clustered L2TP LNS
|
||||||
Name: l2tpns
|
Name: l2tpns
|
||||||
Version: 2.1.12
|
Version: 2.1.13
|
||||||
Release: 1
|
Release: 1
|
||||||
Copyright: GPL
|
Copyright: GPL
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
|
|
@ -43,5 +43,5 @@ rm -rf %{buildroot}
|
||||||
%attr(644,root,root) /usr/share/man/man[58]/*
|
%attr(644,root,root) /usr/share/man/man[58]/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Thu Nov 17 2005 Brendan O'Dea <bod@optus.net> 2.1.12-1
|
* Fri Nov 25 2005 Brendan O'Dea <bod@optus.net> 2.1.13-1
|
||||||
- 2.1.12 release, see /usr/share/doc/l2tpns-2.1.12/Changes
|
- 2.1.13 release, see /usr/share/doc/l2tpns-2.1.13/Changes
|
||||||
|
|
|
||||||
121
test/ping-sweep
Normal file
121
test/ping-sweep
Normal file
|
|
@ -0,0 +1,121 @@
|
||||||
|
#! /usr/bin/perl -w
|
||||||
|
|
||||||
|
# Ping test: run through packet sizes (default: 56-3000)
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use Socket;
|
||||||
|
|
||||||
|
use constant TRIES => 4;
|
||||||
|
use constant TIMEOUT => 3; # 3s
|
||||||
|
use constant MAXPACK => 16*1024;
|
||||||
|
|
||||||
|
use constant ICMP_TYPE_ECHOREPLY => 0; # ICMP packet types
|
||||||
|
use constant ICMP_TYPE_ECHO => 8;
|
||||||
|
use constant ICMP_CODE => 0; # No ICMP code for ECHO and ECHOREPLY
|
||||||
|
|
||||||
|
use constant SOL_IP => 0;
|
||||||
|
use constant IP_MTU_DISCOVER => 10;
|
||||||
|
use constant IP_PMTUDISC_WANT => 0;
|
||||||
|
use constant IP_PMTUDISC_DONT => 1;
|
||||||
|
use constant IP_PMTUDISC_DO => 2;
|
||||||
|
|
||||||
|
my $verbose = shift if @ARGV and $ARGV[0] =~ /^--?v(erbose)?$/;
|
||||||
|
my ($host, $min, $max) = @ARGV;
|
||||||
|
|
||||||
|
die "Usage: $0 [-v] HOST [MIN [MAX]]\n" unless $host;
|
||||||
|
my $addr = inet_aton $host or die "$0: invalid host $host\n";
|
||||||
|
my $sin = sockaddr_in 0, $addr;
|
||||||
|
|
||||||
|
$min = 56 if @ARGV < 2;
|
||||||
|
$max = 3000 if @ARGV < 3;
|
||||||
|
$max = $min if $min > $max;
|
||||||
|
|
||||||
|
my $icmp = getprotobyname 'icmp' or die "$0: can't get ICMP proto ($!)\n";
|
||||||
|
socket my $sock, PF_INET, SOCK_RAW, $icmp
|
||||||
|
or die "$0: can't create ICMP socket ($!)\n";
|
||||||
|
|
||||||
|
setsockopt $sock, SOL_IP, IP_MTU_DISCOVER, IP_PMTUDISC_DONT
|
||||||
|
or die "$0: can't disable PMTU discovery ($!)\n";
|
||||||
|
|
||||||
|
{
|
||||||
|
my $seq = 0;
|
||||||
|
sub icmp_out
|
||||||
|
{
|
||||||
|
my $len = shift;
|
||||||
|
|
||||||
|
# fill data with the *$len*$len*$len*...
|
||||||
|
my $d = sprintf '*%d', $len;
|
||||||
|
my $data = $d x (int ($len / length $d) + 1);
|
||||||
|
|
||||||
|
my $s = 0 + $seq++;
|
||||||
|
$seq %= 65536;
|
||||||
|
|
||||||
|
my $pack = pack "C C n n n a$len" =>
|
||||||
|
ICMP_TYPE_ECHO, # icmp_type
|
||||||
|
ICMP_CODE, # icmp_code
|
||||||
|
0, # icmp_cksum
|
||||||
|
$$, # icmp_id
|
||||||
|
$s, # icmp_seq
|
||||||
|
$data; # payload
|
||||||
|
|
||||||
|
my $cksum = 0;
|
||||||
|
$cksum += $_ for unpack 'n*' => $pack . "\x00";
|
||||||
|
my $wrap;
|
||||||
|
$cksum = ($cksum & 0xffff) + $wrap while ($wrap = ($cksum >> 16));
|
||||||
|
|
||||||
|
substr $pack, 2, 2, pack n => ~$cksum;
|
||||||
|
($s, $pack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub icmp_in
|
||||||
|
{
|
||||||
|
my ($pack, $seq) = @_;
|
||||||
|
return unless length $pack >= 28;
|
||||||
|
my ($type, $code, $cksum, $id, $s) = unpack 'C C n n n' => substr $pack, 20;
|
||||||
|
return $type == ICMP_TYPE_ECHOREPLY
|
||||||
|
and $code == ICMP_CODE
|
||||||
|
and $id == $$
|
||||||
|
and $s == $seq;
|
||||||
|
}
|
||||||
|
|
||||||
|
$|++ if $verbose;
|
||||||
|
|
||||||
|
for (my $size = $min; $size <= $max; $size++)
|
||||||
|
{
|
||||||
|
my ($seq, $pack) = icmp_out $size;
|
||||||
|
|
||||||
|
print "$size: " if $verbose;
|
||||||
|
my $res = 0;
|
||||||
|
|
||||||
|
for (my $t = 0; $t < TRIES; $t++)
|
||||||
|
{
|
||||||
|
send $sock, $pack, 0, $sin
|
||||||
|
or die "$0: sendto failed ($!)\n";
|
||||||
|
|
||||||
|
my $rin = '';
|
||||||
|
(vec $rin, fileno $sock, 1) = 1;
|
||||||
|
select $rin, undef, undef, TIMEOUT or next;
|
||||||
|
|
||||||
|
my $peer = recv $sock, my $buf, MAXPACK, 0
|
||||||
|
or die "$0: recvfrom failed ($!)\n";
|
||||||
|
|
||||||
|
next unless (sockaddr_in $peer)[1] eq $addr
|
||||||
|
and icmp_in $buf, $seq;
|
||||||
|
|
||||||
|
# OK
|
||||||
|
$res++;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($verbose)
|
||||||
|
{
|
||||||
|
print +($res ? 'OK' : 'FAIL'), "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "$size\n" unless $res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue