9

I am looking for a way to simulate a 1000 node bitcoin network on my private LAN/Wifi network.

I read the developer's guide: https://bitcoin.org/en/developer-examples#regtest-mode which mentions the regtest mode that works primarily for single nodes or specified nodes and not random nodes like the actual network.

Some people might suggest using the testnet mode but that is not useful for me as I want to check a new protocol for bitcoins that wont be supported by the unknown nodes over the testnet network.

To put it simply, I am looking to simulate a complete bitcoin network within my LAN/Wifi network.

Aymen
  • 1,476
  • 18
  • 28
bawejakunal
  • 1,678
  • 2
  • 25
  • 54
  • You can model the whatever network you wish to using the regtest mode right..What other aspect of the network are you looking out for? – everconfusedGuy Oct 22 '15 at 14:12
  • @everconfusedGuy What I want is exact simulation of `testnet` or `main` net on a private network. That means, I want to start a new blockchain for nodes on my LAN, they should connect only within themselves via the peer discovery method that is exactly like the actual bitcoin network. First time a node joins this custom network, it should connect to custom hardcoded nodes(as I have disabled DNS discovery in my code) by sending `version` and `verack` messages and then exchange `getaddr` and `addr` messages to discover other nodes on the network. – bawejakunal Oct 22 '15 at 14:58
  • Despite the fact that this question should probably be moved to the bitcoin site, it's an interesting one. Did you ever figure this out? According to https://en.bitcoin.it/wiki/Satoshi_Client_Node_Discovery#Command_Line_Provided_Addresses , the addresses provided via command line (addnode) are not advertised in response to a getaddr request. It seems chicken vs egg: if they are not advertised, then how will the network grow? Or is it simply not part of the regtest mode? – Michael Jan 31 '18 at 21:35
  • did you figure a way out to form this network? I am using docker containers in regtest mode, but need to find a way to automatically detect and connect to some peers. – thenakulchawla Mar 23 '18 at 23:43

1 Answers1

0

The trick is to sandbox them if you are trying to connect on a LAN.

  • specify a unique port (if listening) and rpcport (if using rpc) for each node
  • specify a unique data directory for each node

Use mkdir to create directories the first time

mkdir $HOME/regtest/A/
mkdir $HOME/regtest/B/
mkdir $HOME/regtest/C/

Modify & run this bash script(note the port numbers, there are 9 of them in this example) to connect to each other in round-robin.

#!/bin/bash
bitcoind -server -listen -port=17590 -rpcuser=<user> -rpcpassword=<pass> -rpcport=16590 -datadir=$HOME/regtest/A/ -addnode=localhost:17591 -regtest -pid=$HOME/regtest/A/ -daemon -debug
bitcoind -server -listen -port=17591 -rpcuser=<user> -rpcpassword=<pass> -rpcport=16591 -datadir=$HOME/regtest/B/ -addnode=localhost:17592 -regtest -pid=$HOME/regtest/B/ -daemon -debug
bitcoind -server -listen -port=17592 -rpcuser=<user> -rpcpassword=<pass> -rpcport=16592 -datadir=$HOME/regtest/C/ -addnode=localhost:17590 -regtest -pid=$HOME/regtest/A/ -daemon -debug

Since you want to research peer discovery you might want to look at the difference between trying -connect instead of -addnode

skang404
  • 301
  • 1
  • 8