forked from open-sdr/openwifi
-
Notifications
You must be signed in to change notification settings - Fork 8
/
link_perf_test.sh
executable file
·63 lines (50 loc) · 1.64 KB
/
link_perf_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
#!/bin/bash
# Author: Michael Mehari
# SPDX-FileCopyrightText: 2019 UGent
# SPDX-License-Identifier: AGPL-3.0-or-later
PL_MIN=100
PL_INC=100
PL_MAX=1500
PAYLOAD=( $(seq -s' ' $PL_MIN $PL_INC $PL_MAX) ) # paload size in bytes
MCS_BPS=( 6 9 12 18 24 36 48 54 )
MCS_IDX=( 4 5 6 7 8 9 10 11 )
INTERVAL=0.001 # Wait interval seconds between sending each packet
PKT_CNT=700 # Stop after sending count ECHO_REQUEST packets
DEADLINE=1 # Specify a timeout, in seconds, before ping exits regardless of how many packets have been sent or received
SDRCTL_EXEC="./sdrctl_src/sdrctl"
CLIENT_IP="192.168.13.2"
# Bandwidth = 1.4 MHz
printf "LINK PERFORMANCE TEST\n"
printf "=====================\n"
printf "RATE/PL\t"
for (( j = 0 ; j < ${#PAYLOAD[@]} ; j++ )) do
printf "%*s" 12 "${PAYLOAD[j]}"
done
printf "\n"
for (( i = 0 ; i < ${#MCS_IDX[@]} ; i++ )) do
# configure MCS
$SDRCTL_EXEC dev sdr0 set reg drv_tx 0 ${MCS_IDX[$i]} > /dev/null
printf "%sMbps\t" ${MCS_BPS[$i]}
for (( j = 0 ; j < ${#PAYLOAD[@]} ; j++ )) do
# Measure link performance
link_per_str=$(ping $CLIENT_IP -i $INTERVAL -c $PKT_CNT -w $DEADLINE -s ${PAYLOAD[$j]} -nq | while read line; do
# Skip non packet-loss and non rtt responses
[[ ! "$line" =~ "packet loss" ]] && [[ ! "$line" =~ "rtt" ]] && continue
# Extract packet loss
if [[ "$line" =~ "packet loss" ]]; then
PL=$(echo $line | grep 'packet loss' | cut -d' ' -f6)
if [[ $PL == "100%" ]]; then
printf "%s,INF" $PL
else
printf "%s," $PL
fi
# Extract rtt
else
RTT=$(echo $line | grep rtt | cut -d/ -f5)
printf "%s" $RTT
fi
done)
printf "%*s" 12 $link_per_str
done
printf "\n"
done