Project Structure

Learn about the project structure and get ready to extend it.


The /src folder contains all the necessary source files that built up the Bitcoin Simulator. The tables below present all the files along with a high level description.


File Description
bitcoin.h/.c Contains definitions of block, chunk and blockchain classes.
bitcoin-node.h/.c It contains the BitcoinNode class, which implements a regular Bitcoin node. It describes how the regular nodes receive, process and respond to protocol messages, and how they validate and advertise blocks to their peers.
bitcoin-miner.h/.c It contains the BitcoinMiner class, which inherits from the BitcoinNode class, but it extends it by adding mining functionality.
bitcoin-selfish-miner.h/.c Implements the BitcoinSelfishMiner class, which follows the optimal adversarial strategy combining selfish mining and double-spending attacks.


File Description
bitcoin-node-helper.h/.cc It is common practice in ns3 to have helper classes setting up class objects. The BitcoinNodeHelper class defined in this file instantiates objects of BitcoinNode class and configures all the necessary information, such as peer addresses, downloading/uploading speeds, information dissemination protocol etc...
bitcoin-miner-helper.h/.cc It defines the BitcoinMinerHelper class, which extends the BitcoinNodeHelper class, and helps instantiating BitcoinMiner objects. Except for the necessary information configured by its parent class, this class also sets up the type of the miner (regular miner or selfish miner) and the information propagation protocol it uses to inform other miners and regular nodes (e.g. standard, unsolicited, relay network)
bitcoin-topology-helper.h/.cc It contains the BitcoinTopology class, which is responsible for constructing the Bitcoin topology by creating the nodes, setting up their location and configuring their interconnections, latencies and bandwidth speeds.


File Description
ipv4-address-helper-custom.h/.cc It encloses the Ipv4AddressHelperCustom class, which is a simple modification of the integrated Ipv4AddressHelper, used to speed up the assignment of IPv4 addresses to the Bitcoin nodes.