-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload.sh
executable file
·50 lines (42 loc) · 909 Bytes
/
load.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
#!/bin/sh
# checking command line arguments
if [ "$#" -lt 1 ]; then
echo "error!"
echo "Usage: $0 <ip-address1> <ip-address2> ..." >&2
exit 1
fi
# command line arguments
PORT=8888
# $1 -> ip, $2 -> rate
set_rate() {
bash -c "echo \"cset rate $2\" >/dev/udp/$1/$PORT"
echo "set rate to $2 for $1:$PORT"
}
# $1 -> ip -> rate
stop() {
bash -c "echo \"q\" >/dev/udp/$1/$PORT"
echo "stopping client"
}
# following scenario is emulated here
# <---20s--> <---20s--> <---20s-->
# 2000 __________
# | |
# 1000 __________| |__________
# | |
# 0 __| |__
#
for ip in "$@"; do
set_rate $ip 1000
done
sleep 30s
for ip in "$@"; do
set_rate $ip 2000
done
sleep 30s
for ip in "$@"; do
set_rate $ip 1000
done
sleep 30s
for ip in "$@"; do
stop $ip
done