FISCO technical documentation provides a 4-node network example. These 4 nodes form a strongly connected graph. Strongly connected graphs usually do not exist in reality. This article uses FISCO to set up a network, which consists of 100 nodes to form a scale-free network, as shown in the figure below.
1 Use FISCO tools to build an initial network of 100 nodes
FISCO provides a Shell script for building the initial network. The complete script is as follows.
./build_chain.sh -l localhost:100 -p 30300,20200,8545 -o ./scalefree
After executing the above script, a new directory scalefree is generated, as shown in the figure below. Two of the freeScaleNetwork files are not generated by FISCO. They are scale-free networks created in this article and can be downloaded from the network disk resources. You can follow the prompts in the picture to verify the FISCO version and the number of nodes.
Let's take a look at the node connectivity of the FISCO initial network. Open the configuration file config.ini of any node, as shown in the figure below. Obviously, it is another strongly connected graph, and each node is connected to 99 other nodes.
2 Build a scale-free network
Download the file from the network disk resource, as shown in the figure below. The most critical ones are 1 and 3.
1: Scale-free network profile
2: Scale-free network configuration file, which is the same as the one above. This is an adjacency matrix representation.
3: The script of this article modifies the P2P network connection of 100 nodes to form a scale-free network.
4: FISCO builds a script to initialize the network
Execute this script in the specified directory, as shown in the figure below. The script code is as follows.
#!/bin/bash
LINE=$'\n'
SEMICOLON=";"
OLD_IFS="$IFS"
i=1
listen_port=30300
IFS=$LINE
for line in `cat ./freeScaleNetwork.csv`
do
sed -i '11,110d' ./localhost/node$[$i-1]/config.ini
IFS=$SEMICOLON
neighbor=""
nblist=$neighbor
j=11
for item in $line
do
neighbor=" node.$[$item-1]=localhost:$[$item-1+$listen_port]"
nblist=$nblist$neighbor
sed -i "$[$j]i $neighbor" ./localhost/node$[$i-1]/config.ini
sed -i ''"$j"'s/^/& /g' ./localhost/node$[$i-1]/config.ini
let "j=$j+1"
done
let "i=$i+1"
IFS=$LINE
done
IFS="$OLD_IFS"
After the execution is completed, take a look at the node's configuration file config.ini. Obviously, it is no longer a strongly connected graph.
Next, start this scale-free network, see the figure below. Since there are 100 nodes, there are 100 processes, and the fans are roaring. This virtual machine is configured with 8G of memory.