• Stars
    star
    293
  • Rank 141,748 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

simple Global Network Topology Emulator

GNTE

GNTE(Global Network Topology Emulator) is a docker-based all-in-one unstable global network emulator. It emulates functionality such as random delay and packet loss.

Before Use

Install docker

Build and Run

1. build docker image

Clone this repo and run build.sh. There should be an image named ns in your docker environment.

2. modify network definition file

Edit example.yaml to fit your requirements. The rules of this file are described in the bottom section.

3. generate and launch network emulator

Run the following command:

./generate.sh

Once all CovenantSQL testnet dockers are running, you can use docker ps -a to see all container nodes:

You can also find a graph of the network in graph.png under your root folder:

4. stop random one node or all nodes

Run the following command:

./generate.sh stopone filter

will stop randon one node. If filter is not empty, it will stop node name contains filter.

And there is also a command to stop all:

./generate.sh stopall filter

Also a command for restart all stopped nodes:

./generate.sh startall

5. run your own program in testnet

Containers are referenced by group_name+ip. For example, given containers 10.250.1.2 and 10.250.8.2, you can run docker exec -it china10.250.1.2 ping 10.250.8.2 to test the connection between these two networks.

You can replace the cmd in the group section of yaml to run your own command. The scripts dir will be "volumed" to containers. docker run --rm -it -v $DIR/scripts:/scripts you can put your own binaries or scripts here and put your self defined scripts/my.yaml:

group:
  - 
    name: china
    nodes:
      - 
        ip: 10.250.1.2
        cmd: "cd /scripts && ./YourBin args"
      - 
        ip: 10.250.1.3
        cmd: "cd /scripts && ./YourBin args"
    delay: "100ms 10ms 30%"
    loss: "1% 10%"
  - 
    name: us
    nodes:
      - 
        ip: 10.250.2.2
        cmd: "cd /scripts && ./YourBin args"
      - 
        ip: 10.250.2.3
        cmd: "cd /scripts && ./YourBin args"
    delay: "1000ms 10ms 30%"
    loss: "1% 10%"
    
network:
  -
    groups:
      - china
      - us
    delay: "200ms 10ms 1%"
    corrupt: "0.2%"
    rate: "10mbit"

and run

./generate.sh scripts/my.yaml

5. [optional] clean network

Run ./scripts/clean.sh

Modify Network Definition

A sample network description is provided in example.yaml, which you can edit directly.

sample

# Only support 10.250.0.2 ~ 10.250.254.254
group:
  -
    name: china
    nodes:
      -
        ip: 10.250.1.2/32
        cmd: "ping -c3 g.cn"
      -
        ip: 10.250.2.2/32
        cmd: "ping -c3 g.cn"
      -
        ip: 10.250.3.2/32
        cmd: "ping -c3 g.cn"
      -
        ip: 10.250.4.2/32
        cmd: "ping -c3 g.cn"
    delay: "100ms 10ms 30%"
    loss: "1% 10%"
  -
    name: eu
    nodes:
      -
        ip: 10.250.5.2/32
        cmd: "ping -c3 g.cn"
      -
        ip: 10.250.6.2/32
        cmd: "ping -c3 g.cn"
      -
        ip: 10.250.7.2/32
        cmd: "ping -c3 g.cn"
    delay: "10ms 5ms 30%"
    loss: "1% 10%"
  -
    name: jpn
    nodes:
      -
        ip: 10.250.8.2/32
        cmd: "ping -c3 g.cn"
      -
        ip: 10.250.9.2/32
        cmd: "ping -c3 g.cn"
    delay: "100ms 10ms 30%"
    duplicate: "1%"
    rate: "100mbit"

network:
  -
    groups:
      - china
      - eu
    delay: "200ms 10ms 1%"
    corrupt: "0.2%"
    rate: "10mbit"

  -
    groups:
      - china
      - jpn
    delay: "100ms 10ms 1%"
    rate: "10mbit"

  -
    groups:
      - jpn
      - eu
    delay: "30ms 5ms 1%"
    rate: "100mbit"

Description

The network definition contains two sections: group and network. Group defines ips and describes network info between them. Network describes network info between groups.

group

  • name: unique name of the group

  • nodes: list of node in the network.

node

  • ip: Node IP must be between "10.250.0.2 ~ 10.250.254.254" and written in CIDR format, eg. 10.250.1.2/32.

  • cmd: Node command to run. Blocking or Non-blocking are both ok.

  • network params: The following 6 tc network limit parameters are supported:

    delay
    loss
    duplicate
    corrupt
    reorder
    rate
    

The values of these parameters are exactly like those of the tc command.

  • delay: "100ms 10ms 30%" means 100ms delay in network and 30% packets +-10ms.
  • duplicate: "1%" means 1% packets is duplicated.
  • rate: "100mbit" means network transmit rate is 100mbit.
  • corrupt: "0.2%" means 0.2% packets are randomly modified.

network

  • groups: list of group names

  • network params: same as group

More Repositories

1

CovenantSQL

A decentralized, trusted, high performance, SQL database with blockchain features
Go
1,492
star
2

CookieScanner

Cookie Scanner for GDPR compliance
Go
182
star
3

CovenantForum

CovenantForum is a simple Decentralized forum powered by CovenantSQL.
Go
117
star
4

HashStablePack

Serialization code generator for QUICK struct content comparison
Go
95
star
5

blockchain-papers

区块链相关的有价值的文献
19
star
6

data-sharing-demo

Data sharing demo built on CovenantSQL
JavaScript
14
star
7

beacon

store public data in the open Internet
Go
10
star
8

cql-python-driver

Python driver for CovenantSQL
Python
7
star
9

research

HTML
6
star
10

node-covenantsql

NodeJS driver for CovenantSQL base on HTTP(s) proxy, now moved to =>
TypeScript
5
star
11

cql-js-driver

Interact with CovenantSQL via proxy in web and node
TypeScript
5
star
12

cql-cloud-fe

☁️CovenantSQL Cloud front-end portal, wallet managements, PTC faucet, database managements and more.
JavaScript
4
star
13

docs

CovenantSQL docs
JavaScript
4
star
14

python-demos

CovenantSQL python demos
Python
3
star
15

EthStargate

💫 Smart contract that connects Ethereum to CovenantSQL
JavaScript
2
star
16

php-covenantsql

PHP connector for CovenantSQL
2
star
17

cql-java-driver

Java Driver for CovenantSQL
Java
2
star
18

btc-regtest

A simple regression test environment for bitcoin
Shell
2
star
19

cql.js

General purpose library for CovenantSQL blockchain
TypeScript
2
star
20

covenant-scan

CovenantSQL main chain explorer
Vue
1
star
21

keyvenant

🗝Keyvenant facilitates CovenantSQL keys generation and management
TypeScript
1
star