-
Notifications
You must be signed in to change notification settings - Fork 1
/
netperf.sh
executable file
·59 lines (48 loc) · 1.68 KB
/
netperf.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
#!/bin/bash
## $0 [/path/to/logdirectory]
## output
## Throughput[KB/s] Time[s]
##MIGRATED TCP STREAM TEST from :: (::) port 0 AF_INET6 to fdba:12:4174::1 () port 0 AF_INET6 : demo
##Interim result: 8605.39 10^3bits/s over 1.158 seconds ending at 1400269226.150
##Interim result: 8889.70 10^3bits/s over 1.076 seconds ending at 1400269227.226
PROTOS=${PROTOS:-"olsr1 bmx batadv babel olsr2"}
DATADIR=${DATADIR:-$1}
DATADIR=${DATADIR:-"."}
PROBES=0
for proto in ${PROTOS}; do
PROBES_=$(ls ${DATADIR}/netperf-${proto}-* | wc -w)
if [ "${PROBES_}" -gt "${PROBES}" ]; then PROBES=${PROBES_}; fi
done
## TODO build PROBES by scaning over PROTOS and selecting the longest; then if PROBES==0 ERROR
if [ "${PROBES}" -eq "0" ]; then echo "[$0] WARNING: no log files" >&2; fi
## header
LINE=""
for proto in ${PROTOS}; do
LINE="${LINE} ${proto}TP ${proto}T"
done
echo ${LINE}
for it in $(seq 1 ${PROBES}); do
LINE=""
for proto in ${PROTOS}; do
TP=0
TIME=0
if [ -f "${DATADIR}/netperf-${proto}-${it}.log" ]; then
while read INLINE; do
WORD1=$(echo ${INLINE} | awk '{print $1}')
if [ "${WORD1}" == "Interim" ]; then
iTIME=$(echo "${INLINE}" | awk '{print $6}')
iTP=$(echo "${iTIME}*$(echo ${INLINE} | awk '{print $3}')" | bc -l) ## [Kb/s]
TIME=$(echo ${TIME}+${iTIME} | bc -l)
TP=$(echo ${TP}+${iTP} | bc -l)
fi
done < "${DATADIR}/netperf-${proto}-${it}.log"
TP=$(echo "scale=3; ${TP}/8" | bc -l) ## [KB/s]
else
TIME="NA"
TP="NA"
fi
LINE="${LINE} ${TP} ${TIME}"
done
## strip 0 values (empty logfiles; node not reachable)
echo ${LINE} | sed -e 's/ 0 0 / NA NA /g'
done