SimBlock仿真工具

zhenxi
2023-09-21 / 1 评论 / 2 阅读 / 正在检测是否收录...

1 项目地址

github地址:https://github.com/dsg-titech/simblock

文档地址(英文版):https://github.com/dsg-titech/simblock/blob/master/docs/en/usage.md

git地址:git clone git@github.com:dsg-titech/simblock.git

image-20230921200604226

2 项目运行

解压完毕之后如下图所示,输入cmd按下回车。

image-20230921200802690

2.1 Gradle问题

输入gradle -v查看gradle版本信息。

image-20230921200915865

注意:我尝试了高版本8.3,但是由于我的JDK版本低会出现问题,如果不想出现问题可以就安装7左右的版本。出现问题如下:

image-20230921201800739

如果没有配置Gradle,Windows用户可以尝试一下点击gradlew.bat文件。在官方文档中说明这是一个叫Gradlewrapper的程序,如果没有安装的话会自动安装Gradle并调用它。但是!我尝试了,没有用。

image-20230921201432359

手动安装Gradle:

下载地址:https://gradle.org/releases/ 最好选择一个低版本的,不要选最新的。

image-20230921202351009

下载完后解压到一个英文目录中。打开 查看高级系统设置,添加环境变量:

GRADLE_HOME
%GRADLE_HOME%\bin

image-20230921202136074

image-20230921202249752

配置完毕,输入gradle -v查看gradle版本信息。

image-20230921200915865

2.2 项目启动

gradlew build

image-20230921202558575

进入simblock-0.8.0\simulator\build目录发现多了几个文件:

image-20230921202637932

运行SimBlock:

还在这个cmd窗口输入以下命令:

gradle :simulator:run

image-20230921202937887

进入simblock-0.8.0\simulator\src\dist\output目录发现多了几个文件:

image-20230921203058570

输出内容如下:

  • Standard output and out.txt

    • The following is listed under block ID

      • <node ID, propagation time>

        • Propagation time: The time from when the block of the block ID is generated to when the node of the node ID is reached.
    • 下面列出了块 ID 下的内容

      • <节点ID、传播时间>

        • 传播时间:从生成该区块ID的区块到到达该节点ID的节点的时间。
  • Blocklist.txt

    • <fork information, block height, block ID>

      • Fork information: One of "OnChain" and "Orphan". "OnChain" denote block is on Main chain. "Orphan" denote block is an orphan block.
    • <分叉信息、区块高度、区块ID>

      • 分叉信息:“OnChain”和“Orphan”之一。 “OnChain”表示区块位于主链上。 “孤儿”表示块是孤儿块。
  • graph/

    • ${number}.txt

      : Network information when block height is ${number}

      • <node ID, node ID>

        • Connection from left node ID to right node ID.

      :区块高度为${number}时的网络信息

      • <节点ID,节点ID>

        • 从左节点 ID 到右节点 ID 的连接。
  • output.json

    • This file is listing occurred events. By uploading this file into SimBlock Visualizer, you can see the visualization.
    • 该文件列出了发生的事件。 通过将此文件上传到 SimBlock Visualizer,您可以看到可视化效果。

      • <event, content>
      • <活动、内容>
      • Event

        • add-link: Add a node to neighbor nodes.
        • add-link:添加一个节点到邻居节点。
        • remove-link: Remove a node from neighbor nodes.
        • remove-link:从邻居节点中删除一个节点。
        • flow-block: Block transmmission.
        • flow-block:块传输。
        • simulation-end: Simulation end.
        • simulation-end:模拟结束。
      • content

        • timestamp: Order of events.
        • timestamp:事件的顺序。
        • block-id: Block id.
        • block-id:块 ID。
        • transmission-timestamp: Timestamp when a block is transmitted.
        • Transmission-timestamp:块传输时的时间戳。
        • reception-timestamp: Timestamp when a block is recieved.
        • receive-timestamp:接收到块时的时间戳。
        • begin-node-id: Source node.
        • begin-node-id:源节点。
        • end-node-id: End node.
        • end-node-id:结束节点。

2.3 项目可视化

github地址:https://github.com/dsg-titech/simblock-visualizer

在线网站地址:https://dsg-titech.github.io/simblock-visualizer/

打开在线网站:

image-20230921204750924

把刚才生成的output.json文件上传即可。

GIF 2023-9-21 20-48-49

2.4 导入IDEA

gradlew idea

image-20230921210253896

image-20230921211054517

image-20230921210339274

从项目结构的工具窗口中选择<ROOT_DIR>/simulator/src/main/java/SimBlock/simulator/Main.java ,右键单击并执行Run 'Main.main ()'。输出文件将存储在<ROOT_DIR>/simulator/src/dist/output中。

0

评论

博主关闭了所有页面的评论