summaryrefslogtreecommitdiff
path: root/board/cem/start_eth_perf.sh
blob: c8d7174401f4d74f5f35030c9f544842743b93e5 (plain)
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
63
#!/bin/bash

iface=( 10.42.0.1
        10.42.2.1 )

DURATION=30
SLEEP_DURATION=7
SIZE_FILE="100MB"
TEST_FILE="/tmp/random_$SIZE_FILE"
MAIN_PID=$$
KILL_CMD="k"

exec > >(tee -a iperf_s.log)
exec 2>&1

# check if iperf exists
[ -x /usr/bin/iperf ] || exit 233

if [ ! -e $TEST_FILE ]
then
  echo "Error, $TEST_FILE not found, you need to run init.sh first!"
  # Read the README...
  exit 234
fi

# this run iperf client on a specified iface
load_iface()
{
  while true
  do
    /usr/bin/iperf -c $1 -d -y c -t $((RANDOM % $DURATION + 10))
    sleep 1
  done
}

scp_test_file()
{
  while true
  do
    time scp $TEST_FILE root@$1:/tmp/
    sleep $((RANDOM % SLEEP_DURATION))
  done
}

echo "== Starting, press \`$KILL_CMD' to stop =="

for i in "${iface[@]}"
do
  load_iface $i &
  scp_test_file $i &
done

# wait
while read i
do
  [ "$i" = "$KILL_CMD" ] && break
done

echo "Complete! Killing all child now"
sleep 1

kill -9 -$MAIN_PID