From 5fc3c0812a5b2e4c97c196929a5142e471c86258 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 3 Oct 2014 13:02:36 -0700 Subject: [PATCH] run-local-testnet script --- testnet/TestEthernetTap.hpp | 8 +++++ testnet/run-local-testnet.sh | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100755 testnet/run-local-testnet.sh diff --git a/testnet/TestEthernetTap.hpp b/testnet/TestEthernetTap.hpp index 93eb4c5bb..8b7a5e879 100644 --- a/testnet/TestEthernetTap.hpp +++ b/testnet/TestEthernetTap.hpp @@ -48,6 +48,14 @@ namespace ZeroTier { class TestEthernetTapFactory; +/** + * Dummy Ethernet tap + * + * This tap device prints the contents of packets it receives on stdout + * and also prints outgoing packets when they are injected. It does not + * connect to any real tap or other interface. It's useful for running + * test networks. + */ class TestEthernetTap : public EthernetTap { friend class SharedPtr; diff --git a/testnet/run-local-testnet.sh b/testnet/run-local-testnet.sh new file mode 100755 index 000000000..91132c01c --- /dev/null +++ b/testnet/run-local-testnet.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +export PATH=/bin:/usr/bin:/usr/local/bin + +#if [ ! -x ../zerotier-one ]; then +# echo "$0: ../zerotier-one not found; build first" +# exit 1 +#fi + +if [ $# -lt 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +if [ ! -d ./local-testnet ]; then + echo "$0: cannot find local-testnet/ base for nodes" + exit 1 +fi + +cd local-testnet +supernodes=`echo sn????` +cd .. + +create_nodes=$1 +node_num=0 + +echo "Starting supernodes: $supernodes" +echo + +for sn in $supernodes; do + node_path=local-testnet/$sn + node_port=2`echo $sn | cut -d n -f 2` + + echo zerotier-one -T../root-topology/local-testnet/root-topology -p$node_port -u $node_path + ../zerotier-one -T../root-topology/local-testnet/root-topology -p$node_port -u $node_path +done + +echo +echo "Starting $create_nodes regular nodes..." +echo + +while [ $node_num -lt $create_nodes ]; do + node_path=local-testnet/`printf n%.4d $node_num` + node_port=`printf 3%.4d $node_num` + + mkdir -p $node_path + + echo zerotier-one -T../root-topology/local-testnet/root-topology -p$node_port -u $node_path + ../zerotier-one -T../root-topology/local-testnet/root-topology -p$node_port -u $node_path + + node_num=`expr $node_num + 1` +done + +echo +echo "Nodes are now running. Waiting for all nodes to exit." +echo + +wait