A Simulation-Based Study of Blockchain Network Decentralization, Propagation and Fault Tolerance
A Computer Networks PBL implemented in Java 17 with an interactive React + Vite companion website. The Java program is the reference simulation and experiment engine; the web application explains the same concepts visually and presents Java-generated results.
Suggested GitHub repository name:
blockchain-network-simulationLive website: add the final Vercel URL here after deployment.
This project studies three questions about a blockchain peer-to-peer overlay network:
- Propagation: how network structure affects the time required for a newly mined block to spread through the network.
- Fault tolerance: how node crashes and network partitions affect block delivery and local chain agreement.
- Structural decentralization: how evenly peer connections are distributed across Ring, Erdős–Rényi, and Barabási–Albert network models.
The project connects these questions to Computer Networks concepts such as topology, forwarding, latency, application-level peer-to-peer communication, and fault/partition behaviour. It does not claim to implement a complete TCP/IP stack or a production cryptocurrency network.
- Java 17+
- Apache Maven
- JGraphT 1.5.2
- XChart 3.8.8
- JavaFX 21.0.2
- Jackson 2.17.1
- JUnit 5.10.2
- React 18
- Vite 5
- JavaScript / JSX
- Fraunces Variable, Source Sans 3 Variable, IBM Plex Mono
- Static deployment; no backend or database required
Block.java models block metadata including the index, previous hash, timestamp, transactions, difficulty, miner ID, nonce, and SHA-256 hash. Proof of Work increments the nonce until the block hash begins with the configured number of hexadecimal zero characters.
The project uses a simplified transaction root: transaction IDs are concatenated and hashed once. It is intentionally not presented as a full Bitcoin-style binary Merkle tree.
Chain.java and Node.java maintain local blockchain state and support reorganization toward a complete alternative branch with greater cumulative simulated work. Each block contributes work based on its configured difficulty; equal-work cases may be resolved using chain length.
GossipProtocol.java relays blocks and transactions to a configurable number of peers (fanout). It avoids immediate sender echo, respects node/partition reachability, and uses duplicate tracking so the same block is not repeatedly processed by the same node.
SimulationEngine.java uses a timestamp-ordered priority queue rather than wall-clock threads. Events include block mining/receipt, transaction creation/receipt, node crash/recovery, partition start/heal, and mining ticks. This makes the experiments reproducible under a virtual clock.
The project includes:
- Ring Lattice — regular local-neighbour connectivity.
- Erdős–Rényi Random Graph — probabilistic edges with a connectivity safeguard.
- Barabási–Albert Scale-Free Graph — preferential attachment that produces hubs.
NetworkTopology.java calculates structural metrics such as degree Gini, diameter, average path length, and degree distribution.
FaultInjector.java supports crash faults, network partitions, healing, and a simplified Byzantine state for custom simulation runs.
The website keeps the CN syllabus relationship focused on concepts that genuinely help explain the project:
- Network topology: the overlay graph changes hop counts and propagation behaviour.
- Forwarding vs gossip: IP routing selects paths toward destinations; blockchain gossip decides which peers receive application-level information next.
- Layering: the blockchain overlay runs above ordinary networking infrastructure; the Java simulator abstracts lower-layer protocol details into peer links, latency, and delivery events.
- Transport/latency abstraction: TCP/UDP are not implemented; the simulation models delivery timing directly.
- Basic cryptography: SHA-256 hashing supports integrity and Proof of Work; hashing is not encryption.
blockchain-network-simulation/
├── .gitignore
├── README.md
├── NEXUS_GIT_SETUP.md
├── pom.xml
├── run-cli.bat
├── run-experiments.bat
├── run-gui.bat
├── src/
│ ├── main/java/sim/
│ │ ├── Main.java
│ │ ├── blockchain/
│ │ ├── dashboard/
│ │ ├── engine/
│ │ ├── experiments/
│ │ ├── faults/
│ │ ├── gossip/
│ │ ├── metrics/
│ │ ├── network/
│ │ ├── node/
│ │ └── visualize/
│ └── test/java/sim/
├── output/
│ ├── *.json
│ └── *.png
└── website/
├── index.html
├── package.json
├── package-lock.json
├── vite.config.js
├── scripts/build-data.py
└── src/
├── App.jsx
├── Figures.jsx
├── Lab.jsx
├── Parts.jsx
├── data/
├── simulation/
└── styles/
output/ is intentionally committed because it contains the Java-generated experiment evidence used by the academic project and website.
- JDK 17 or newer
- Maven 3.8+
Verify:
java -version
mvn -versionmvn clean testmvn compile exec:java -Dexec.mainClass="sim.Main" -Dexec.args="--all"On Windows you can also run:
run-experiments.bat
mvn compile exec:java -Dexec.mainClass="sim.Main" -Dexec.args="--nodes 150 --topology scale_free --difficulty 3 --fanout 8 --fault partition"Supported custom options include node count, topology, Proof-of-Work difficulty, gossip fanout, fault type, and fault rate.
mvn javafx:runor on Windows:
run-gui.bat
cd website
npm ci
npm run devProduction validation:
npm run build
npm run previewThe production bundle is written to:
website/dist/
After regenerating the Java JSON files in output/:
cd website
npm run dataThis rebuilds src/data/experimentResults.js from the project outputs.
The current website is organized as an interactive research journey:
- Network overlay and traditional-network comparison
- Block construction
- Proof of Work and nonce
- Chain integrity and tampering
- Gossip propagation, latency, and discrete-event simulation
- Topology, path metrics, preferential attachment, and Gini
- Crashes, partitions, forks, and reorganization
- Combined simulation lab
- Java experiment recap
- Audit and limitations
- Java implementation map
Browser interactions are labelled as educational/live demonstrations. Java-generated JSON/plots remain the reference experiment evidence.
The committed output/ directory includes:
- propagation comparison chart and JSON reports for Ring, Random, and Scale-Free topologies;
- fault-tolerance study and partition JSON report;
- Gini-versus-network-size chart;
- Barabási–Albert degree-distribution chart;
- topology images.
Two reference tables used by the website are not currently emitted as dedicated JSON by the Java experiments, so they are retained here and in the website data generator.
| Crash rate | Online nodes | T50 (ms) | T90 (ms) | Canonical-tip agreement |
|---|---|---|---|---|
| 0% | 100 | 268 | 374 | 100.0% |
| 10% | 90 | 268 | 383 | 98.9% |
| 20% | 80 | 259 | 394 | 97.5% |
| 30% | 70 | 251 | 354 | 98.6% |
| 40% | 60 | 232 | 375 | 96.7% |
| 50% | 50 | 216 | 445 | 90.0% |
| Topology | N=20 | N=50 | N=100 | N=200 | N=300 | N=400 | N=500 |
|---|---|---|---|---|---|---|---|
| Ring | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 |
| Erdős–Rényi | 0.3079 | 0.2712 | 0.1718 | 0.1286 | 0.1092 | 0.0986 | 0.0855 |
| Barabási–Albert | 0.2944 | 0.3350 | 0.3557 | 0.3609 | 0.3641 | 0.3721 | 0.3648 |
The current generated outputs should be treated exactly as produced by the present Java implementation. In particular:
- the current partition JSON reports 73% canonical-tip agreement after the simulated healing run;
- the field named
partitionReconvergenceTimeMscurrently reports7500 ms, but the present implementation does not separately record the exact instant of full reconvergence, so this value should not be described as verified 100% reconvergence time; - propagation and orphan-rate metrics should be regenerated if their Java calculations are changed later.
Do not replace generated values with older README claims.
The website is designed for a static Vite deployment.
When importing this repository into Vercel, use:
Root Directory: website
Framework Preset: Vite
Build Command: npm run build
Output Directory: dist
After deployment, add the production *.vercel.app URL to this README and to website/README.md.
A complete copy-paste PowerShell workflow for creating the new Nexus GitHub repository is provided in:
Recommended repository name:
blockchain-network-simulation
Recommended description:
Simulation-based study of blockchain network decentralization, block propagation and fault tolerance using Java, graph algorithms and interactive web visualizations.
Suggested GitHub topics:
blockchain
computer-networks
java
network-simulation
gossip-protocol
graph-algorithms
fault-tolerance
react
vite
pbl
This is an undergraduate Computer Networks PBL and educational simulation. It is not a full Bitcoin/Ethereum implementation, production P2P stack, security proof, or complete model of real Internet transport/routing behaviour.