tpf-netperf 3.64 KB
Newer Older
Roman Haefeli's avatar
Roman Haefeli committed
1
2
3
4
5
6
#!/bin/bash

# DEFAULTS
SCRIPTNAME=$(basename $0)
NUMOFCHANNELS=2
BITRES=16
7
SAMPLERATE=48000
Roman Haefeli's avatar
Roman Haefeli committed
8
9
10
BLOCKSIZE=128
NUMOFINSTANCES=1
CLIENTOF="telematic.zhdk.ch"
11
DURATION=10
Roman Haefeli's avatar
Roman Haefeli committed
12
13
14
15
16
17

VALIDBITRESLIST="8 16 24 32"
VALIDSAMPLERATELIST="22050 32000 44100 48000 88200 96000 192000"
VALIDBLOCKSIZELIST="64 128 256 512 1024 2048 4096"

# Parse cmdline arguments
Roman Haefeli's avatar
Roman Haefeli committed
18
help=false
Roman Haefeli's avatar
Roman Haefeli committed
19
20
21
22
23
24
25
26
27
while [ $# -gt 0 ]
do
  case "$1" in
    -n|--numofchannels)    NUMOFCHANNELS="$2"; shift;;
    -b|--bitres)           BITRES="$2"; shift;;
    -r|--samplerate)       SAMPLERATE="$2"; shift;;
    -s|--blocksize)        BLOCKSIZE="$2"; shift;;
    -i|--instances)        NUMOFINSTANCES="$2"; shift;;
    -c|--client)           CLIENTOF="$2"; shift;;
28
    -d|--duration)         DURATION="$2"; shift;;
Roman Haefeli's avatar
Roman Haefeli committed
29
    -h|--help)             help=true;;
Roman Haefeli's avatar
Roman Haefeli committed
30
31
32
33
34
35
36
37
    -*) printerr "$SCRIPTNAME: error - unrecognized option '$1'"
        printerr "use '$SCRIPTNAME --help' to get a list of available options"
        exit 1;;
    *)  break;;
  esac
  shift
done

Roman Haefeli's avatar
Roman Haefeli committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# show help
if $help
then
  cat << EOF

$SCRIPTNAME
------------

Tool for testing network connection for Telematic Performances. It's
basically a wrapper around iperf3.

The tool emulates the payload of one or many jacktrip connections
and reports jitter and lost packages.

For a given number of channels and bitres, you may want to tweak
the buffersize and test what works best for the current network
connection.

CMDLINE OPTIONS:

    -n|--numofchannels INT    number of channels
    -b|--bitres INT           bit resolution (8, 16, 24, 32)
    -r|--samplerate INT       samplerate
    -s|--blocksize INT        blocksize
    -i|--instances INT        run INT number of clients simultaneously
    -c|--client HOST          set the host to connect to
    -d|--duration INT         duration of a test in seconds
    -h|--help                 show this help

EOF
  exit

fi

Roman Haefeli's avatar
Roman Haefeli committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# check BITRES
if [[ ! $VALIDBITRESLIST =~ (^|[[:space:]])$BITRES($|[[:space:]]) ]]
then
  echo "Given bitres ('$BITRES') is not valid."
  echo "Valid bitres values are: $VALIDBITRESLIST"
  exit 1
fi

# check SAMPLERATE
if [[ ! $VALIDSAMPLERATELIST =~ (^|[[:space:]])$SAMPLERATE($|[[:space:]]) ]]
then
  echo "Given samplerate ('$SAMPLERATE') is not valid."
  echo "Valid samplerate values are: $VALIDSAMPLERATELIST"
  exit 1
fi

# check BLOCKSIZE
if [[ ! $VALIDBLOCKSIZELIST =~ (^|[[:space:]])$BLOCKSIZE($|[[:space:]]) ]]
then
  echo "Given samplerate ('$BLOCKSIZE') is not valid."
  echo "Valid samplerate values are: $VALIDBLOCKSIZELIST"
  exit 1
fi

# check NUMOFCHANNELS
if  (( NUMOFCHANNELS < 2 )) || (( NUMOFCHANNELS > 64 ))
then
  echo "Given number of channels ('$NUMOFCHANNELS') is not valid."
  echo "Valid range is: 2-64"
  exit 1
fi

# Calculate UDP packetsize (in bytes)
# The jacktrip header size is 16 bytes
PACKETSIZE=$(( BLOCKSIZE * NUMOFCHANNELS * BITRES / 8 + 16 ))

# Calculate packet rate
PACKETRATE=$(bc <<< "scale=2; $SAMPLERATE/$BLOCKSIZE")

# Calculate bandwidth
BANDWIDTH=$(bc <<< "scale=3; $PACKETRATE*$PACKETSIZE*8/1000000")

echo "BITRES:       $BITRES"
echo "SAMPLERATE:   $SAMPLERATE"
echo "BLOCKSIZE:    $BLOCKSIZE"
echo "CHANNELS:     $NUMOFCHANNELS"
echo "PACKETSIZE:   ${PACKETSIZE} bytes"
echo "PACKETRATE:   ${PACKETRATE}/s"
echo "BANDWIDTH:    ${BANDWIDTH}Mb/s"
121
echo "DURATION:     ${DURATION}s"
Roman Haefeli's avatar
Roman Haefeli committed
122

123
124
125
echo "-------------------------------------------------------------------"
echo "Now running test:"
echo "LOCAL >>>>>>>>>>>>>>> TELEMATIC server"
Roman Haefeli's avatar
Roman Haefeli committed
126

127
128
129
130
131
iperf3 -u -c telematic.zhdk.ch    -p 6000 -l ${PACKETSIZE} -b ${BANDWIDTH}M -i 2 -t ${DURATION} -P ${NUMOFINSTANCES}

echo "LOCAL <<<<<<<<<<<<<<< TELEMATIC server"

iperf3 -u -c telematic.zhdk.ch -R -p 6000 -l ${PACKETSIZE} -b ${BANDWIDTH}M -i 2 -t ${DURATION} -P ${NUMOFINSTANCES}