|
| 1 | +#!/usr/bin/env bash |
| 2 | +# ========================================================================== |
| 3 | +# _ _ _ ____ __ __ __ _ |
| 4 | +# | \ | | ___| |_| _ \ ___ _ __ / _| \/ | ___| |_ ___ _ __ |
| 5 | +# | \| |/ _ \ __| |_) / _ \ '__| |_| |\/| |/ _ \ __/ _ \ '__| |
| 6 | +# | |\ | __/ |_| __/ __/ | | _| | | | __/ || __/ | |
| 7 | +# |_| \_|\___|\__|_| \___|_| |_| |_| |_|\___|\__\___|_| |
| 8 | +# |
| 9 | +# NetPerfMeter -- Network Performance Meter |
| 10 | +# Copyright (C) 2009-2025 by Thomas Dreibholz |
| 11 | +# ========================================================================== |
| 12 | +# |
| 13 | +# This program is free software: you can redistribute it and/or modify |
| 14 | +# it under the terms of the GNU General Public License as published by |
| 15 | +# the Free Software Foundation, either version 3 of the License, or |
| 16 | +# (at your option) any later version. |
| 17 | +# |
| 18 | +# This program is distributed in the hope that it will be useful, |
| 19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | +# GNU General Public License for more details. |
| 22 | +# |
| 23 | +# You should have received a copy of the GNU General Public License |
| 24 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 25 | +# |
| 26 | + |
| 27 | +# Homepage: https://www.nntb.no/~dreibh/netperfmeter/ |
| 28 | + |
| 29 | +# Bash options: |
| 30 | +set -eu |
| 31 | + |
| 32 | + |
| 33 | +TCP_FLOWS=5 |
| 34 | +TCP_PARAMS="const0:const0:const0:const1460:cmt=off" |
| 35 | + |
| 36 | +UDP_FLOWS=5 |
| 37 | +UDP_PARAMS="const0:const0:const25:const2500:onoff=+pareto0.166667,1.5,+pareto0.166667,1.5,repeat" |
| 38 | + |
| 39 | + |
| 40 | +# ====== Handle arguments =================================================== |
| 41 | +if [ $# -lt 1 ] ; then |
| 42 | + echo >&2 "Usage: $0 server:port [runtime]" |
| 43 | + exit 1 |
| 44 | +fi |
| 45 | +SERVER="$(echo "$1" | sed -s 's/:.*$//g')" |
| 46 | +PORT="$(echo "$1" | sed -s 's/^.*://g')" |
| 47 | +if [[ ! "${PORT}" =~ ^[0-9]+$ ]] ; then |
| 48 | + echo >&2 "ERROR: Invalid port ${PORT}!" |
| 49 | + exit 1 |
| 50 | +fi |
| 51 | +RUNTIME=10 |
| 52 | +if [ $# -ge 2 ] ; then |
| 53 | + RUNTIME="$2" |
| 54 | +fi |
| 55 | +if [[ ! "${RUNTIME}" =~ ^[0-9]+$ ]] ; then |
| 56 | + echo >&2 "ERROR: Invalid runtime ${RUNTIME}!" |
| 57 | + exit 1 |
| 58 | +fi |
| 59 | + |
| 60 | +make |
| 61 | +rm -f vgcore.* core.* core |
| 62 | + |
| 63 | + |
| 64 | +# ====== Run NetPerfMeter =================================================== |
| 65 | +options="" |
| 66 | +i=0 ; while [ $i -lt $TCP_FLOWS ] ; do |
| 67 | + options="${options} -tcp ${TCP_PARAMS}" |
| 68 | + i=$((i+1)) |
| 69 | +done |
| 70 | +i=0 ; while [ $i -lt $UDP_FLOWS ] ; do |
| 71 | + options="${options} -udp ${UDP_PARAMS}" |
| 72 | + i=$((i+1)) |
| 73 | +done |
| 74 | + |
| 75 | +echo "OPTIONS=${options}" |
| 76 | +# shellcheck disable=SC2086 |
| 77 | +./netperfmeter "${SERVER}:${PORT}" \ |
| 78 | + ${options} \ |
| 79 | + -runtime="${RUNTIME}" |
0 commit comments