diff options
author | joe <joe@jerkface.net> | 2017-11-04 04:51:16 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-11-04 04:51:16 -0400 |
commit | e6fef429fc3918eab6a35af202a101778c9abde3 (patch) | |
tree | 73fdb5fcb57594dbaea492fb838ce30d1a18bb38 /vnet | |
parent | a2ab874ed45dcaba3e063b0b55ab1d0a05a17158 (diff) |
Utility for testing 16 simultaneous nodes.
Diffstat (limited to 'vnet')
-rwxr-xr-x | vnet/build.sh | 89 | ||||
-rwxr-xr-x | vnet/clean.sh | 49 | ||||
-rwxr-xr-x | vnet/everywhere.sh | 8 | ||||
-rwxr-xr-x | vnet/run.sh | 45 | ||||
-rwxr-xr-x | vnet/screen-everywhere.sh | 21 | ||||
-rwxr-xr-x | vnet/screen-shell.sh | 14 | ||||
-rwxr-xr-x | vnet/show-links.sh | 2 |
7 files changed, 228 insertions, 0 deletions
diff --git a/vnet/build.sh b/vnet/build.sh new file mode 100755 index 00000000..36818611 --- /dev/null +++ b/vnet/build.sh | |||
@@ -0,0 +1,89 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | wire() { | ||
4 | ip link add $1 \ | ||
5 | type veth \ | ||
6 | peer name $2 | ||
7 | } | ||
8 | |||
9 | set -x | ||
10 | |||
11 | # Not using this... | ||
12 | buildhub() { | ||
13 | wire hub0 ep0 | ||
14 | wire hub1 ep1 | ||
15 | wire hub2 ep2 | ||
16 | wire hub3 ep3 | ||
17 | wire hub4 ep4 | ||
18 | wire hub5 ep5 | ||
19 | wire hub6 ep6 | ||
20 | wire hub7 ep7 | ||
21 | |||
22 | wire hub8 ep8 | ||
23 | wire hub9 ep9 | ||
24 | wire hubA epA | ||
25 | wire hubB epB | ||
26 | wire hubC epC | ||
27 | wire hubD epD | ||
28 | wire hubE epE | ||
29 | wire hubF epF | ||
30 | |||
31 | brctl addbr hub | ||
32 | brctl addif hub hub0 | ||
33 | brctl addif hub hub1 | ||
34 | brctl addif hub hub2 | ||
35 | brctl addif hub hub3 | ||
36 | brctl addif hub hub4 | ||
37 | brctl addif hub hub5 | ||
38 | brctl addif hub hub6 | ||
39 | brctl addif hub hub7 | ||
40 | brctl addif hub hub8 | ||
41 | brctl addif hub hub9 | ||
42 | brctl addif hub hubA | ||
43 | brctl addif hub hubB | ||
44 | brctl addif hub hubC | ||
45 | brctl addif hub hubD | ||
46 | brctl addif hub hubE | ||
47 | brctl addif hub hubF | ||
48 | |||
49 | ip addr add 222.0.0.1 dev hub | ||
50 | } | ||
51 | |||
52 | # This is simpler... | ||
53 | buildtaps() { | ||
54 | ip tuntap add ep0 mode tap | ||
55 | ip tuntap add ep1 mode tap | ||
56 | ip tuntap add ep2 mode tap | ||
57 | ip tuntap add ep3 mode tap | ||
58 | ip tuntap add ep4 mode tap | ||
59 | ip tuntap add ep5 mode tap | ||
60 | ip tuntap add ep6 mode tap | ||
61 | ip tuntap add ep7 mode tap | ||
62 | ip tuntap add ep8 mode tap | ||
63 | ip tuntap add ep9 mode tap | ||
64 | ip tuntap add epA mode tap | ||
65 | ip tuntap add epB mode tap | ||
66 | ip tuntap add epC mode tap | ||
67 | ip tuntap add epD mode tap | ||
68 | ip tuntap add epE mode tap | ||
69 | ip tuntap add epF mode tap | ||
70 | } | ||
71 | |||
72 | buildtaps | ||
73 | |||
74 | ip addr add 80.99.99.99 dev ep0 | ||
75 | ip addr add 81.99.99.99 dev ep1 | ||
76 | ip addr add 82.99.99.99 dev ep2 | ||
77 | ip addr add 83.99.99.99 dev ep3 | ||
78 | ip addr add 84.99.99.99 dev ep4 | ||
79 | ip addr add 85.99.99.99 dev ep5 | ||
80 | ip addr add 86.99.99.99 dev ep6 | ||
81 | ip addr add 87.99.99.99 dev ep7 | ||
82 | ip addr add 88.99.99.99 dev ep8 | ||
83 | ip addr add 89.99.99.99 dev ep9 | ||
84 | ip addr add 90.99.99.99 dev epA | ||
85 | ip addr add 91.99.99.99 dev epB | ||
86 | ip addr add 92.99.99.99 dev epC | ||
87 | ip addr add 93.99.99.99 dev epD | ||
88 | ip addr add 94.99.99.99 dev epE | ||
89 | ip addr add 95.99.99.99 dev epF | ||
diff --git a/vnet/clean.sh b/vnet/clean.sh new file mode 100755 index 00000000..3e0af1bd --- /dev/null +++ b/vnet/clean.sh | |||
@@ -0,0 +1,49 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | cleanhub() { | ||
4 | brctl delbr hub | ||
5 | |||
6 | ip link del hub0 | ||
7 | ip link del hub1 | ||
8 | ip link del hub2 | ||
9 | ip link del hub3 | ||
10 | ip link del hub4 | ||
11 | ip link del hub5 | ||
12 | ip link del hub6 | ||
13 | ip link del hub7 | ||
14 | |||
15 | ip link del hub8 | ||
16 | ip link del hub9 | ||
17 | ip link del hubA | ||
18 | ip link del hubB | ||
19 | ip link del hubC | ||
20 | ip link del hubD | ||
21 | ip link del hubE | ||
22 | ip link del hubF | ||
23 | } | ||
24 | |||
25 | cleantaps() | ||
26 | { | ||
27 | ip link del ep0 | ||
28 | ip link del ep1 | ||
29 | ip link del ep2 | ||
30 | ip link del ep3 | ||
31 | ip link del ep4 | ||
32 | ip link del ep5 | ||
33 | ip link del ep6 | ||
34 | ip link del ep7 | ||
35 | |||
36 | ip link del ep8 | ||
37 | ip link del ep9 | ||
38 | ip link del epA | ||
39 | ip link del epB | ||
40 | ip link del epC | ||
41 | ip link del epD | ||
42 | ip link del epE | ||
43 | ip link del epF | ||
44 | } | ||
45 | |||
46 | cleantaps | ||
47 | |||
48 | rm -rf ep0 ep1 ep2 ep3 ep4 ep5 ep6 ep7 \ | ||
49 | ep8 ep9 epA epB epC epD epE epF | ||
diff --git a/vnet/everywhere.sh b/vnet/everywhere.sh new file mode 100755 index 00000000..ebd4ca38 --- /dev/null +++ b/vnet/everywhere.sh | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | cmd="$@" | ||
3 | for ep in ep? | ||
4 | do | ||
5 | ( cd $ep | ||
6 | $cmd | ||
7 | ) | ||
8 | done | ||
diff --git a/vnet/run.sh b/vnet/run.sh new file mode 100755 index 00000000..0189b6b7 --- /dev/null +++ b/vnet/run.sh | |||
@@ -0,0 +1,45 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | [ -L ./dhtd ] || ( echo "Missing symbolic link to your build: ./dhtd" ; exit 1 ) | ||
4 | |||
5 | mkdir -p ep0 ep1 ep2 ep3 ep4 ep5 ep6 ep7 \ | ||
6 | ep8 ep9 epA epB epC epD epE epF | ||
7 | |||
8 | rm -f window-count | ||
9 | echo detach > detached | ||
10 | |||
11 | screen -S test -s ./screen-shell.sh -c detached | ||
12 | sleep 0.5 | ||
13 | screen -S test -X screen | ||
14 | sleep 0.5 | ||
15 | screen -S test -X screen | ||
16 | sleep 0.5 | ||
17 | screen -S test -X screen | ||
18 | sleep 0.5 | ||
19 | |||
20 | screen -S test -X screen | ||
21 | sleep 0.5 | ||
22 | screen -S test -X screen | ||
23 | sleep 0.5 | ||
24 | screen -S test -X screen | ||
25 | sleep 0.5 | ||
26 | screen -S test -X screen | ||
27 | sleep 0.5 | ||
28 | |||
29 | screen -S test -X screen | ||
30 | sleep 0.5 | ||
31 | screen -S test -X screen | ||
32 | sleep 0.5 | ||
33 | screen -S test -X screen | ||
34 | sleep 0.5 | ||
35 | screen -S test -X screen | ||
36 | sleep 0.5 | ||
37 | |||
38 | screen -S test -X screen | ||
39 | sleep 0.5 | ||
40 | screen -S test -X screen | ||
41 | sleep 0.5 | ||
42 | screen -S test -X screen | ||
43 | sleep 0.5 | ||
44 | screen -S test -X screen | ||
45 | sleep 0.5 | ||
diff --git a/vnet/screen-everywhere.sh b/vnet/screen-everywhere.sh new file mode 100755 index 00000000..e4f75374 --- /dev/null +++ b/vnet/screen-everywhere.sh | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/bin/sh | ||
2 | cmd="$@" | ||
3 | echo "$cmd" > /tmp/screen-exchange | ||
4 | screen -S test -X eval readbuf \ | ||
5 | "select 15" "paste ." \ | ||
6 | "select 14" "paste ." \ | ||
7 | "select 13" "paste ." \ | ||
8 | "select 12" "paste ." \ | ||
9 | "select 11" "paste ." \ | ||
10 | "select 10" "paste ." \ | ||
11 | "select 9" "paste ." \ | ||
12 | "select 8" "paste ." \ | ||
13 | "select 7" "paste ." \ | ||
14 | "select 6" "paste ." \ | ||
15 | "select 5" "paste ." \ | ||
16 | "select 5" "paste ." \ | ||
17 | "select 4" "paste ." \ | ||
18 | "select 3" "paste ." \ | ||
19 | "select 2" "paste ." \ | ||
20 | "select 1" "paste ." \ | ||
21 | "select 0" "paste ." | ||
diff --git a/vnet/screen-shell.sh b/vnet/screen-shell.sh new file mode 100755 index 00000000..6143c81d --- /dev/null +++ b/vnet/screen-shell.sh | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/bin/sh | ||
2 | ifaddr() { | ||
3 | ip -o address show dev $1 | sed -n 's#.* inet \([^ /]*\).*#\1#p' | ||
4 | } | ||
5 | touch window-count | ||
6 | count=$(cat window-count) | ||
7 | count=${count:-(-1)} | ||
8 | count=$(( $count + 1 )) | ||
9 | echo $count > window-count | ||
10 | digit=$(printf '%X' $count) | ||
11 | cd ep$digit | ||
12 | port=$(( 33400 + $count )) | ||
13 | pwd | ||
14 | ../dhtd tox=$(ifaddr ep$digit):$port,bt= | ||
diff --git a/vnet/show-links.sh b/vnet/show-links.sh new file mode 100755 index 00000000..d7115a0b --- /dev/null +++ b/vnet/show-links.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/sh | ||
2 | ip -o link | sed 's/\([^:]*:[^:]*:*\).*/\1/' | ||