-
Notifications
You must be signed in to change notification settings - Fork 0
Home
vthglyk edited this page Apr 25, 2016
·
43 revisions
- Installation of ns3 (https://www.nsnam.org/wiki/Installation). The project has been tested with versions 3.24 and 3.25.
- Download rapidjson (https://github.com/miloyip/rapidjson).
- Create a new directory named rapidjson under ns-allinone-3.xx/ns-3.xx.
- Copy the contents of the directory include/rapidjson (from the downloaded rapidjson project in step 2) to the newly created rapidjson folder.
- Update the ns-allinone-3.xx/ns-3.xx/src/applications/wscript.
- Add the following lines in module.source:
'model/bitcoin.cc',
'model/bitcoin-node.cc',
'model/bitcoin-miner.cc',
'model/bitcoin-simple-attacker.cc',
'model/bitcoin-selfish-miner.cc',
'model/bitcoin-selfish-miner-trials.cc',
'helper/bitcoin-topology-helper.cc',
'helper/bitcoin-node-helper.cc',
'helper/bitcoin-miner-helper.cc'
- Add the following lines in headers.source:
'model/bitcoin.h',
'model/bitcoin-node.h',
'model/bitcoin-miner.h',
'model/bitcoin-simple-attacker.h',
'model/bitcoin-selfish-miner.h',
'model/bitcoin-selfish-miner-trials.h',
'helper/bitcoin-topology-helper.h',
'helper/bitcoin-node-helper.h',
'helper/bitcoin-miner-helper.h'
- Add the following lines in module.source:
- Update the ns-allinone-3.xx/ns-3.xx/src/internet/wscript.
- Add the following line in module.source:
'helper/ipv4-address-helper-custom.cc'
- Add the following lines in headers.source:
'helper/ipv4-address-helper-custom.h'
- Add the following line in module.source:
- Copy all the files from Bitcoin-Simulation/src to the respective folder under ns-allinone-3.xx/ns-3.xx/src/
- Configure ns3 with the follow command to ensure compatibility and maximum performance.
CXXFLAGS="-std=c++11" ./waf configure --build-profile=optimized --out=build/optimized --with-pybindgen=/home/bill/Desktop/workspace/ns-allinone-3.24/pybindgen-0.17.0.post41+ngd10fa60 --enable-mpi --enable-static
- Rebuild ns3 using the
./waf
command
/src/applications/model folder: (the most important files containing all the logic)
- bitcoin.h/.c: definitions of block class and blockchain class
- bitcoin-node.h/.c: implementation of a simple bitcoin node
- bitcoin-miner.h/.c: implementation of the miner (inherits from bitcoin-node)
/src/applications/helper folder:
- bitcoin-node-helper/bicoin-miner-helper.h/.c : it helps setting up each bitcoin node/miner (it is a common practice in ns3 to have helper classes). So, for example it creates the object and propagates to it information regarding the addresses of peers, downloading/uploading speeds, protocol etc..
- bitcoin-topology-helper : constructs the bitcoin topology (creates the nodes, the links between them, sets up the location of the nodes/miners, latencies and downloading/uploading speeds (some of these are later used from the bitcoin-node-helper/bicoin-miner-helper to set up the applications).
/src/scratch/bitcoin-test.c The actual simulation file which just uses the above helpers to set up the simulation and collect the stats.