blob: 68f4fcdb26c90f89833f0358fcae2403da27e7c4 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/bin/bash
if [ $UID -ne 0 ]
then
echo "You must be root to run this test script"
exit 0
fi
# / c1
# /- c2
# srv ----- br -- c3
# \- c4
TOTAL_CLIENTS=18
start () {
NUM_CLIENTS=3
NUM_REDIRECT=3
SERVER_LINK=1000
CLIENT_LINK=1000
LATENCY=20
ip netns add srv
ip netns add br
for ((i=1; i<=TOTAL_CLIENTS; i++)); do
ip netns add c$i
done
ip link add veth0 netns srv type veth peer name veth0 netns br
for ((i=1; i<=TOTAL_CLIENTS; i++)); do
ip link add veth$i netns br type veth peer name veth0 netns c$i
done
for ((i=0; i<=TOTAL_CLIENTS; i++)); do
ip -net br link set up dev veth$i
done
ip -net br link add name br0 type bridge
for ((i=0; i<=TOTAL_CLIENTS; i++)); do
ip -net br link set dev veth$i master br0
done
ip -net br link set up dev br0
ip -net srv addr add 10.141.10.1/24 dev veth0
ip -net srv link set up dev veth0
ip netns exec srv tc qdisc add dev veth0 handle 10: root tbf rate "$SERVER_LINK"mbit burst 5kb latency "$LATENCY"ms
ip netns exec srv tc qdisc add dev veth0 parent 10:1 handle 100: sfq
ip netns exec srv .././tiptorrent --max-clients $NUM_CLIENTS --redirect $NUM_REDIRECT --root . &
for ((i=1; i<=TOTAL_CLIENTS; i++)); do
ip -net c$i addr add 10.141.10.$((i+1))/24 dev veth0
ip -net c$i link set up dev veth0
ip netns exec c$i tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms
ip netns exec c$i tc qdisc add dev veth0 parent 10:1 handle 100: sfq
ip netns exec c$i .././tiptorrent --max-clients $NUM_CLIENTS &
done
}
stop () {
ip netns del srv
ip netns del br
for ((i=1; i<=TOTAL_CLIENTS; i++)); do
ip netns del c$i
done
killall -15 tiptorrent
}
case $1 in
start)
start
;;
stop)
stop
;;
*)
echo "$0 [start|stop]"
;;
esac
exit 0
|