-
Notifications
You must be signed in to change notification settings - Fork 7
/
nattorture.sh
executable file
·53 lines (41 loc) · 1.06 KB
/
nattorture.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
#!/bin/bash
#usage ./nattorture.sh [interface[] [ip] [number of runs] [outfile]
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
interface="eth0"
ip=""
runs=10
output_file="out.csv"
test_name="test"
lockfile=nattorture.lock
touch $lockfile
while getopts "h?i:f:r:o:t:" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
r) runs=$OPTARG
;;
i) interface=$OPTARG
;;
f) output_file=$OPTARG
;;
t) test_name=$OPTARG
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
ip=$@
echo "interface=$interface, output_file='$output_file',runs='$runs', ip: $ip"
rm output_file
printf "Name, run, Start, stop, transactions, failed, max rtt, min rtt, avg rtt, retries, client sent, server sent, start port, stop port\n" > $output_file
for (( i=1; i<=$runs; i++ ))
do
echo "Run $i"
printf "$test_name, $i, " >> $output_file
build/dist/bin/stunclient -i $interface $ip -j 60 --csv >> $output_file
done
rm $lockfile