Skip to content

Commit

Permalink
Pass pseudo from netlink to netbench and udpbench to calculate length.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluhm committed Aug 2, 2024
1 parent bba2070 commit 65b3ac7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
28 changes: 21 additions & 7 deletions netbench.pl
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,21 @@
);

my %opts;
getopts('A:a:B:b:c:d:f:i:l:m:N:P:s:t:v', \%opts) or do {
getopts('A:a:B:b:C:c:d:f:i:l:m:N:P:s:t:v', \%opts) or do {
print STDERR <<"EOF";
usage: netbench.pl [-v] [-A address] -a address [-B bitrate] [-b bufsize]
[-c client] [-d delay] [-f frames] [-i idle] [-l length] [-m mmsglen]
[-P packetrate] [-s server] [-t timeout] [test ...]
[-C pseudo] [-c client] [-d delay] [-f frames] [-i idle] [-l length]
[-m mmsglen] [-P packetrate] [-p pseudo] [-s server] [-t timeout]
[test ...]
-A address IP address of relay
-a address IP address for packet destination
-B bitrate bits per seconds send rate
-b bufsize set size of send and receive buffer
-C pseudo pseudo network device changes packet length
-c client connect via ssh to start packet generator
-d delay wait for setup before sending
-f frames calculate udp payload to fragment packet into frames
-i idle idle timeout before receiving stops
-c client connect via ssh to start packet generator
-m mmsglen number of mmsghdr for sendmmsg or recvmmsg
-N repeat run instances in parallel with incremented address
-P packet packets per seconds send rate
Expand All @@ -62,6 +64,7 @@
or die "Relay address must be IPv4 or IPv6";
my $client_ssh = $opts{c};
my $server_ssh = $opts{s};
my $pseudo = $opts{C};

@ARGV or die "No test mode specified";
my %testmode;
Expand Down Expand Up @@ -95,17 +98,27 @@
or die "Use either -f frames or -l lenght";
$opts{f} =~ /\d+$/
or die "Frames must be number";
my $mtu = 1500;
if ($pseudo) {
if ($pseudo eq "gif") {
$mtu = 1480;
} elsif ($pseudo eq "gif6") {
$mtu = 1460;
} elsif ($pseudo eq "gre") {
$mtu = 1472;
}
}
if ($addr =~ /:/) {
if ($opts{f} <= 1) {
# ether frame minus ip6 header
$paylen = (1500 - 40) * $opts{f};
$paylen = ($mtu - 40) * $opts{f};
} else {
# ether frame minus ip6 header minus fragment header minus round
$paylen = (1500 - 40 - 8 - 4) * $opts{f};
$paylen = ($mtu - 40 - 8 - 4) * $opts{f};
}
} else {
# ether frame minus ip header
$paylen = (1500 - 20) * $opts{f};
$paylen = ($mtu - 20) * $opts{f};
}
# minus udp header
$paylen = $paylen < 8 ? 0 : $paylen - 8;
Expand Down Expand Up @@ -215,6 +228,7 @@ sub start_server_udp {
my @cmd = ('udpbench');
push @cmd, "-B$opts{B}" if defined($opts{B});
push @cmd, "-b$opts{b}" if defined($opts{b});
push @cmd, "-C$opts{C}" if defined($opts{C});
push @cmd, "-d$opts{d}" if defined($opts{d});
push @cmd, "-i$opts{i}" if defined($opts{i});
push @cmd, "-l$paylen" if defined($paylen);
Expand Down
7 changes: 5 additions & 2 deletions netlink.pl
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ sub good {
printcmd('ifconfig', $obsd_r_if, 'inet', "$obsd_r_tunnel_addr/24");
printcmd('ifconfig', 'gif0', 'create');
printcmd('ifconfig', 'gif1', 'create');
printcmd('ifconfig', 'gif0',
printcmd('ifconfig', 'gif0', 'mtu', '1480',
'tunnel', $obsd_l_tunnel_addr, $lnx_l_tunnel_addr);
printcmd('ifconfig', 'gif1',
printcmd('ifconfig', 'gif1', 'mtu', '1480',
'tunnel', $obsd_r_tunnel_addr, $lnx_r_tunnel_addr);
printcmd('ifconfig', $obsd_l_if, 'up');
printcmd('ifconfig', $obsd_r_if, 'up');
Expand Down Expand Up @@ -1142,6 +1142,9 @@ sub pingflood_finalize {

my @runcmd = @{$t->{testcmd}};
(my $test = join("_", @runcmd)) =~ s,/.*/,,;
if ($pseudo && $runcmd[0] eq $netbench) {
splice(@runcmd, 1, 0, '-C', $pseudo);
}

my $begin = Time::HiRes::time();
my $date = strftime("%FT%TZ", gmtime($begin));
Expand Down

0 comments on commit 65b3ac7

Please sign in to comment.