đ#!/usr/bin/env bash
# ==========================================================================
#         _   _      _   ____            __ __  __      _
#        | \ | | ___| |_|  _ \ ___ _ __ / _|  \/  | ___| |_ ___ _ __
#        |  \| |/ _ \ __| |_) / _ \ '__| |_| |\/| |/ _ \ __/ _ \ '__|
#        | |\  |  __/ |_|  __/  __/ |  |  _| |  | |  __/ ||  __/ |
#        |_| \_|\___|\__|_|   \___|_|  |_| |_|  |_|\___|\__\___|_|
#
#                  NetPerfMeter -- Network Performance Meter
#                 Copyright (C) 2009-2026 by Thomas Dreibholz
# ==========================================================================
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Contact:  dreibh@simula.no
# Homepage: https://www.nntb.no/~dreibh/netperfmeter/

# Bash options:
set -eu

# ====== Handle arguments ===================================================
if [ $# -lt 1 ] ; then
   echo >&2 "Usage: $0 server:port"
   exit 1
fi
SERVER="$(echo "$1" | sed -s 's/:.*$//g')"
PORT="$(echo "$1" | sed -s 's/^.*://g')"
if [[ ! "${PORT}" =~ ^[0-9]+$ ]] ; then
   echo >&2 "ERROR: Invalid port ${PORT}!"
   exit 1
fi

make
rm -f vgcore.* core.* core

# ====== Run NetPerfMeter ===================================================
./netperfmeter "${SERVER}:${PORT}" \
   -control-over-tcp \
   -config=misc1.config -scalar=misc1.sca.bz2 -vector=misc1.vec.bz2 \
   -tcp const30:const68000:const30:const68000:maxmsgsize=1300 \
   -runtime=5

./netperfmeter "${SERVER}:${PORT}" \
   -control-over-tcp \
   -config=misc2.config -scalar=misc2.sca.bz2 -vector=misc2.vec.bz2 \
   -udp const30:const68000:const30:const68000:maxmsgsize=1300 \
   -tcp const30:const68000:const30:const68000:maxmsgsize=1300 \
   -sctp const30:const68000:const30:const68000:maxmsgsize=1300 \
   -dccp const30:const68000:const30:const68000:maxmsgsize=1300 \
   -runtime=5

./netperfmeter "${SERVER}:${PORT}" \
   -control-over-tcp \
   -config=misc3.config -scalar=misc3.sca.bz2 -vector=misc3.vec.bz2 \
   -sctp const30:const6800:const30:const6800:maxmsgsize=1300 const30:const6800:const30:const6800:maxmsgsize=1300 const30:const6800:const30:const6800:maxmsgsize=1300 \
   -runtime=5
