diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-02-19 16:49:48 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-19 16:49:53 +0100 |
commit | 0fe3e352f2e96ef677ea588480413a3893665d63 (patch) | |
tree | 70d0e2ab6a10ae93a69031031ce5328153c4a4bf | |
parent | bd732208f68a9199189813b336e9f40d33b9de68 (diff) | |
download | gnunet-0fe3e352f2e96ef677ea588480413a3893665d63.tar.gz gnunet-0fe3e352f2e96ef677ea588480413a3893665d63.zip |
-add scripts to deploy DHT tests with DHTU
-rw-r--r-- | src/dht/Makefile.am | 5 | ||||
-rwxr-xr-x | src/dht/dhtu_testbed_connect.sh | 31 | ||||
-rw-r--r-- | src/dht/dhtu_testbed_deploy.conf | 26 | ||||
-rwxr-xr-x | src/dht/dhtu_testbed_deploy.sh | 84 |
4 files changed, 145 insertions, 1 deletions
diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index 6d1090901..f9cd26094 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am | |||
@@ -213,7 +213,10 @@ EXTRA_DIST = \ | |||
213 | test_dht_line.conf \ | 213 | test_dht_line.conf \ |
214 | test_dht_tools.conf \ | 214 | test_dht_tools.conf \ |
215 | test_dht_tools.py.in \ | 215 | test_dht_tools.py.in \ |
216 | test_dht_multipeer_topology.dat | 216 | test_dht_multipeer_topology.dat \ |
217 | dhtu_testbed_connect.sh \ | ||
218 | dhtu_testbed_deploy.conf \ | ||
219 | dhtu_testbed_deploy.sh | ||
217 | 220 | ||
218 | if HAVE_PYTHON | 221 | if HAVE_PYTHON |
219 | check_SCRIPTS = \ | 222 | check_SCRIPTS = \ |
diff --git a/src/dht/dhtu_testbed_connect.sh b/src/dht/dhtu_testbed_connect.sh new file mode 100755 index 000000000..871e9eb1b --- /dev/null +++ b/src/dht/dhtu_testbed_connect.sh | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/bin/bash | ||
2 | # This file is in the public domain. | ||
3 | |||
4 | # Helper script for dhtu_testbed_deploy.sh. | ||
5 | # Do not invoke directly. | ||
6 | |||
7 | n=$1 | ||
8 | CFG="/tmp/deployment/${n}.conf" | ||
9 | HELLO=`gnunet-dht-hello -c $CFG` | ||
10 | |||
11 | # Create dense topology: | ||
12 | #for OFF in `seq 1 $MAX` | ||
13 | #do | ||
14 | # TCFG="/tmp/deployment/${OFF}.conf" | ||
15 | # gnunet-dht-hello -c $TCFG $HELLO | ||
16 | #done | ||
17 | #exit 0 | ||
18 | |||
19 | # Create sparse topology: | ||
20 | R=1 | ||
21 | while test `expr $R \* $R \* $R` -lt $MAX | ||
22 | do | ||
23 | END=`expr $R \* $R` | ||
24 | for M in `seq $R $R $END` | ||
25 | do | ||
26 | OFF=`expr \( $n + $M \) % $MAX` | ||
27 | TCFG="/tmp/deployment/${OFF}.conf" | ||
28 | gnunet-dht-hello -c $TCFG $HELLO | ||
29 | done | ||
30 | R=`expr $R + 1` | ||
31 | done | ||
diff --git a/src/dht/dhtu_testbed_deploy.conf b/src/dht/dhtu_testbed_deploy.conf new file mode 100644 index 000000000..59d69894a --- /dev/null +++ b/src/dht/dhtu_testbed_deploy.conf | |||
@@ -0,0 +1,26 @@ | |||
1 | # This file is in the public domain. | ||
2 | |||
3 | # Simple configuration template to deploy a DHT testbed | ||
4 | # with peers using the IP underlay. | ||
5 | |||
6 | [paths] | ||
7 | GNUNET_DATA_HOME=/tmp/%N% | ||
8 | |||
9 | [dht] | ||
10 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-dht-%N%.sock | ||
11 | |||
12 | [dhtu-ip] | ||
13 | ENABLED = YES | ||
14 | NSE = 10 | ||
15 | UDP_PORT = %N% | ||
16 | |||
17 | [dhtu-gnunet] | ||
18 | ENABLED = NO | ||
19 | |||
20 | [statistics] | ||
21 | DISABLE = YES | ||
22 | |||
23 | [dhtcache] | ||
24 | DATABASE = heap | ||
25 | QUOTA = 50 MB | ||
26 | DISABLE_BF_RC = YES | ||
diff --git a/src/dht/dhtu_testbed_deploy.sh b/src/dht/dhtu_testbed_deploy.sh new file mode 100755 index 000000000..908bbf685 --- /dev/null +++ b/src/dht/dhtu_testbed_deploy.sh | |||
@@ -0,0 +1,84 @@ | |||
1 | #!/bin/bash | ||
2 | # This file is in the public domain. | ||
3 | |||
4 | # We will use UDP ports above this number. | ||
5 | MINPORT=10000 | ||
6 | |||
7 | # Cleanup to run whenever we exit | ||
8 | function cleanup() | ||
9 | { | ||
10 | for n in `jobs -p` | ||
11 | do | ||
12 | kill $n 2> /dev/null || true | ||
13 | done | ||
14 | wait | ||
15 | } | ||
16 | |||
17 | # Install cleanup handler (except for kill -9) | ||
18 | trap cleanup EXIT | ||
19 | |||
20 | if test -z "$1" | ||
21 | then | ||
22 | echo "Call with the number of peers to launch." | ||
23 | exit 1 | ||
24 | fi | ||
25 | |||
26 | if test ! -x `which parallel` | ||
27 | then | ||
28 | echo "This script requires GNU parallel" | ||
29 | exit 1 | ||
30 | fi | ||
31 | |||
32 | if test ! -x `which gnunet-service-dht` | ||
33 | then | ||
34 | echo "This script requires gnunet-service-dht in \$PATH" | ||
35 | exit 1 | ||
36 | fi | ||
37 | |||
38 | if test ! -x `which gnunet-dht-hello` | ||
39 | then | ||
40 | echo "This script requires gnunet-dht-hello in \$PATH" | ||
41 | exit 1 | ||
42 | fi | ||
43 | |||
44 | MAX=`expr $1 - 1` | ||
45 | |||
46 | # export GNUNET_FORCE_LOG="dht*;;;;DEBUG" | ||
47 | |||
48 | echo -n "Starting $1 peers " | ||
49 | mkdir -p /tmp/deployment | ||
50 | for n in `seq 0 $MAX` | ||
51 | do | ||
52 | PORT=`expr $MINPORT + $n` | ||
53 | CFG="/tmp/deployment/${n}.conf" | ||
54 | cat dhtu_testbed_deploy.conf | sed -e "s/%N%/$PORT/" > $CFG | ||
55 | gnunet-service-dht -c $CFG &> /tmp/deployment/$n.log & | ||
56 | echo -n "." | ||
57 | done | ||
58 | |||
59 | echo "" | ||
60 | echo "$1 peers ready". | ||
61 | |||
62 | unset GNUNET_FORCE_LOG | ||
63 | |||
64 | function connect() | ||
65 | { | ||
66 | n=$1 | ||
67 | } | ||
68 | |||
69 | echo -n "Connecting peers ..." | ||
70 | |||
71 | export MAX | ||
72 | if test 0 != $MAX | ||
73 | then | ||
74 | seq 0 $MAX | parallel ./dhtu_testbed_connect.sh ::: | ||
75 | fi | ||
76 | |||
77 | |||
78 | echo "" | ||
79 | echo "Network ready. Press ENTER to terminate the testbed!" | ||
80 | echo "Interact with peers using '-c /tmp/deployment/\$N.conf'" | ||
81 | |||
82 | read | ||
83 | |||
84 | exit 0 | ||