blob: 4a19ead7aff4fa1f3017dd0afbd1d824276f1c85 (
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
#!/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
start () {
NUM_CLIENTS=3
ip netns add srv
ip netns add br
ip netns add c1
ip netns add c2
ip netns add c3
ip netns add c4
ip netns add c5
ip netns add c6
ip netns add c7
ip netns add c8
ip netns add c9
ip netns add c10
ip netns add c11
ip netns add c12
ip netns add c13
ip netns add c14
ip netns add c15
ip netns add c16
ip netns add c17
ip netns add c18
ip link add veth0 netns srv type veth peer name veth0 netns br
ip link add veth1 netns br type veth peer name veth0 netns c1
ip link add veth2 netns br type veth peer name veth0 netns c2
ip link add veth3 netns br type veth peer name veth0 netns c3
ip link add veth4 netns br type veth peer name veth0 netns c4
ip link add veth5 netns br type veth peer name veth0 netns c5
ip link add veth6 netns br type veth peer name veth0 netns c6
ip link add veth7 netns br type veth peer name veth0 netns c7
ip link add veth8 netns br type veth peer name veth0 netns c8
ip link add veth9 netns br type veth peer name veth0 netns c9
ip link add veth10 netns br type veth peer name veth0 netns c10
ip link add veth11 netns br type veth peer name veth0 netns c11
ip link add veth12 netns br type veth peer name veth0 netns c12
ip link add veth13 netns br type veth peer name veth0 netns c13
ip link add veth14 netns br type veth peer name veth0 netns c14
ip link add veth15 netns br type veth peer name veth0 netns c15
ip link add veth16 netns br type veth peer name veth0 netns c16
ip link add veth17 netns br type veth peer name veth0 netns c17
ip link add veth18 netns br type veth peer name veth0 netns c18
ip -net br link set up dev veth0
ip -net br link set up dev veth1
ip -net br link set up dev veth2
ip -net br link set up dev veth3
ip -net br link set up dev veth4
ip -net br link set up dev veth5
ip -net br link set up dev veth6
ip -net br link set up dev veth7
ip -net br link set up dev veth8
ip -net br link set up dev veth9
ip -net br link set up dev veth10
ip -net br link set up dev veth11
ip -net br link set up dev veth12
ip -net br link set up dev veth13
ip -net br link set up dev veth14
ip -net br link set up dev veth15
ip -net br link set up dev veth16
ip -net br link set up dev veth17
ip -net br link set up dev veth18
ip -net br link add name br0 type bridge
ip -net br link set dev veth0 master br0
ip -net br link set dev veth1 master br0
ip -net br link set dev veth2 master br0
ip -net br link set dev veth3 master br0
ip -net br link set dev veth4 master br0
ip -net br link set dev veth5 master br0
ip -net br link set dev veth6 master br0
ip -net br link set dev veth7 master br0
ip -net br link set dev veth8 master br0
ip -net br link set dev veth9 master br0
ip -net br link set dev veth10 master br0
ip -net br link set dev veth11 master br0
ip -net br link set dev veth12 master br0
ip -net br link set dev veth13 master br0
ip -net br link set dev veth14 master br0
ip -net br link set dev veth15 master br0
ip -net br link set dev veth16 master br0
ip -net br link set dev veth17 master br0
ip -net br link set dev veth18 master br0
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 .././tiptorrent --max-clients $NUM_CLIENTS --redirect --root . &
ip -net c1 addr add 10.141.10.2/24 dev veth0
ip -net c1 link set up dev veth0
ip netns exec c1 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c2 addr add 10.141.10.3/24 dev veth0
ip -net c2 link set up dev veth0
ip netns exec c2 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c3 addr add 10.141.10.4/24 dev veth0
ip -net c3 link set up dev veth0
ip netns exec c3 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c4 addr add 10.141.10.5/24 dev veth0
ip -net c4 link set up dev veth0
ip netns exec c4 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c5 addr add 10.141.10.6/24 dev veth0
ip -net c5 link set up dev veth0
ip netns exec c5 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c6 addr add 10.141.10.7/24 dev veth0
ip -net c6 link set up dev veth0
ip netns exec c6 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c7 addr add 10.141.10.8/24 dev veth0
ip -net c7 link set up dev veth0
ip netns exec c7 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c8 addr add 10.141.10.9/24 dev veth0
ip -net c8 link set up dev veth0
ip netns exec c8 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c9 addr add 10.141.10.10/24 dev veth0
ip -net c9 link set up dev veth0
ip netns exec c9 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c10 addr add 10.141.10.11/24 dev veth0
ip -net c10 link set up dev veth0
ip netns exec c10 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c11 addr add 10.141.10.12/24 dev veth0
ip -net c11 link set up dev veth0
ip netns exec c11 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c12 addr add 10.141.10.13/24 dev veth0
ip -net c12 link set up dev veth0
ip netns exec c12 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c13 addr add 10.141.10.14/24 dev veth0
ip -net c13 link set up dev veth0
ip netns exec c13 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c14 addr add 10.141.10.15/24 dev veth0
ip -net c14 link set up dev veth0
ip netns exec c14 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c15 addr add 10.141.10.16/24 dev veth0
ip -net c15 link set up dev veth0
ip netns exec c15 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c16 addr add 10.141.10.17/24 dev veth0
ip -net c16 link set up dev veth0
ip netns exec c16 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c17 addr add 10.141.10.18/24 dev veth0
ip -net c17 link set up dev veth0
ip netns exec c17 .././tiptorrent --max-clients $NUM_CLIENTS &
ip -net c18 addr add 10.141.10.19/24 dev veth0
ip -net c18 link set up dev veth0
ip netns exec c18 .././tiptorrent --max-clients $NUM_CLIENTS &
}
stop () {
ip netns del srv
ip netns del br
ip netns del c1
ip netns del c2
ip netns del c3
ip netns del c4
ip netns del c5
ip netns del c6
ip netns del c7
ip netns del c8
ip netns del c9
ip netns del c10
ip netns del c11
ip netns del c12
ip netns del c13
ip netns del c14
ip netns del c15
ip netns del c16
ip netns del c17
ip netns del c18
killall -15 tiptorrent
}
case $1 in
start)
start
;;
stop)
stop
;;
*)
echo "$0 [start|stop]"
;;
esac
exit 0
|