summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xvnet/build.sh89
-rwxr-xr-xvnet/clean.sh49
-rwxr-xr-xvnet/everywhere.sh8
-rwxr-xr-xvnet/run.sh45
-rwxr-xr-xvnet/screen-everywhere.sh21
-rwxr-xr-xvnet/screen-shell.sh14
-rwxr-xr-xvnet/show-links.sh2
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
3wire() {
4 ip link add $1 \
5 type veth \
6 peer name $2
7}
8
9set -x
10
11# Not using this...
12buildhub() {
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...
53buildtaps() {
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
72buildtaps
73
74ip addr add 80.99.99.99 dev ep0
75ip addr add 81.99.99.99 dev ep1
76ip addr add 82.99.99.99 dev ep2
77ip addr add 83.99.99.99 dev ep3
78ip addr add 84.99.99.99 dev ep4
79ip addr add 85.99.99.99 dev ep5
80ip addr add 86.99.99.99 dev ep6
81ip addr add 87.99.99.99 dev ep7
82ip addr add 88.99.99.99 dev ep8
83ip addr add 89.99.99.99 dev ep9
84ip addr add 90.99.99.99 dev epA
85ip addr add 91.99.99.99 dev epB
86ip addr add 92.99.99.99 dev epC
87ip addr add 93.99.99.99 dev epD
88ip addr add 94.99.99.99 dev epE
89ip 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
3cleanhub() {
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
25cleantaps()
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
46cleantaps
47
48rm -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
2cmd="$@"
3for ep in ep?
4do
5 ( cd $ep
6 $cmd
7 )
8done
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
5mkdir -p ep0 ep1 ep2 ep3 ep4 ep5 ep6 ep7 \
6 ep8 ep9 epA epB epC epD epE epF
7
8rm -f window-count
9echo detach > detached
10
11screen -S test -s ./screen-shell.sh -c detached
12sleep 0.5
13screen -S test -X screen
14sleep 0.5
15screen -S test -X screen
16sleep 0.5
17screen -S test -X screen
18sleep 0.5
19
20screen -S test -X screen
21sleep 0.5
22screen -S test -X screen
23sleep 0.5
24screen -S test -X screen
25sleep 0.5
26screen -S test -X screen
27sleep 0.5
28
29screen -S test -X screen
30sleep 0.5
31screen -S test -X screen
32sleep 0.5
33screen -S test -X screen
34sleep 0.5
35screen -S test -X screen
36sleep 0.5
37
38screen -S test -X screen
39sleep 0.5
40screen -S test -X screen
41sleep 0.5
42screen -S test -X screen
43sleep 0.5
44screen -S test -X screen
45sleep 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
2cmd="$@"
3echo "$cmd" > /tmp/screen-exchange
4screen -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
2ifaddr() {
3 ip -o address show dev $1 | sed -n 's#.* inet \([^ /]*\).*#\1#p'
4}
5touch window-count
6count=$(cat window-count)
7count=${count:-(-1)}
8count=$(( $count + 1 ))
9echo $count > window-count
10digit=$(printf '%X' $count)
11cd ep$digit
12port=$(( 33400 + $count ))
13pwd
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
2ip -o link | sed 's/\([^:]*:[^:]*:*\).*/\1/'