diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-03 13:02:36 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-03 13:02:36 -0700 |
commit | 5fc3c0812a5b2e4c97c196929a5142e471c86258 (patch) | |
tree | 8988bc95a9027737b1f606455741691a9658da9a | |
parent | 67aa23530b7e051709002b521aa6e93cb6350918 (diff) | |
download | infinitytier-5fc3c0812a5b2e4c97c196929a5142e471c86258.tar.gz infinitytier-5fc3c0812a5b2e4c97c196929a5142e471c86258.zip |
run-local-testnet script
-rw-r--r-- | testnet/TestEthernetTap.hpp | 8 | ||||
-rwxr-xr-x | testnet/run-local-testnet.sh | 58 |
2 files changed, 66 insertions, 0 deletions
diff --git a/testnet/TestEthernetTap.hpp b/testnet/TestEthernetTap.hpp index 93eb4c5b..8b7a5e87 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<TestEthernetTap>; diff --git a/testnet/run-local-testnet.sh b/testnet/run-local-testnet.sh new file mode 100755 index 00000000..91132c01 --- /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 <number of regular nodes to create>" + 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 |