diff options
Diffstat (limited to 'tests/network-setup.sh')
-rwxr-xr-x | tests/network-setup.sh | 223 |
1 files changed, 24 insertions, 199 deletions
diff --git a/tests/network-setup.sh b/tests/network-setup.sh index 27a6bd0..68f4fcd 100755 --- a/tests/network-setup.sh +++ b/tests/network-setup.sh @@ -11,6 +11,8 @@ fi # srv ----- br -- c3 # \- c4 +TOTAL_CLIENTS=18 + start () { NUM_CLIENTS=3 NUM_REDIRECT=3 @@ -20,85 +22,23 @@ start () { 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 + 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 - 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 + for ((i=1; i<=TOTAL_CLIENTS; i++)); do + ip link add veth$i netns br type veth peer name veth0 netns c$i + done - 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 + 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 - 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 + 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 @@ -108,136 +48,21 @@ start () { 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 . & - ip -net c1 addr add 10.141.10.2/24 dev veth0 - ip -net c1 link set up dev veth0 - ip netns exec c1 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c1 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c2 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c3 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c4 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c5 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c6 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c7 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c8 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c9 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c10 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c11 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c12 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c13 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c14 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c15 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c16 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c17 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - 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 tc qdisc add dev veth0 handle 10: root tbf rate "$CLIENT_LINK"mbit burst 5kb latency "$LATENCY"ms - ip netns exec c18 tc qdisc add dev veth0 parent 10:1 handle 100: sfq - ip netns exec c18 .././tiptorrent --max-clients $NUM_CLIENTS & + 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 - 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 + for ((i=1; i<=TOTAL_CLIENTS; i++)); do + ip netns del c$i + done killall -15 tiptorrent } |