Giter Club home page Giter Club logo

blockchain-simulator's Introduction

blockchain-simulator

Here are some simulations of blockchain consensus protocol based on NS3, which aims to simulate the relationship between blockchain performance and consensus protocol, network scale, block size, bandwidth, delay and other factors.

Quick start

1.Download ns3

The version 3.29 or 3.25 of NS3 is recommended.

2.Place code

Next, you need to place all the files from blockchain-simulator to the respective folders under ns-allinone-3.xx/ns-3.xx.

3.Update the wscript file

The path of the wscript file is ns-allinone-3.xx/ns-3.xx/src/applications/wscript

  • Add the following lines in module.source:
'model/raft-node.cc',
'helper/network-helper.cc',
  • Add the following lines in headers.source:
'model/raft-node.h', 
'helper/network-helper.h', 

4.Build and run the simulator

Under path ns-allinone-3.xx/ns-3.xx, execute the following commands in sequence:

CXXFLAGS="-std=c++11 -Wno-unused-parameter" ./waf configure
./waf
./waf --run scratch/blockchain-simulator

You can set the network scale and other factors in blockchain-simulator.cc.

More detailed usage use of NS3 can be found in https://github.com/arthurgervais/Bitcoin-Simulator

Switch consensus

There are three consensus protocols to choose from, including raft, paxos and pbft, The default is raft. If you need to switch the consensus protocol, such as from raft to pbft, You need to modify some files.

1.Update the blockchain-simulator.cc

Modify the class name "RaftNode" to "PbftNode":

LogComponentEnable ("PbftNode", LOG_LEVEL_INFO);

2.Update the network-helper.cc

Modify all "RaftNode" to "PbftNode", and switch the reference of the header file.

3.Update the wscript

Modify the "raft-node" to "pbft-node" in module.source and headers.source. The two cannot coexist, otherwise an error will be reported.

After modification, you need to recompile and run.

blockchain-simulator's People

Contributors

zhayujie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.