Coder Social home page Coder Social logo

p2p's Introduction

* Requirement:
Implement seeder servers which store and maintain information of nodes in the network. New nodes can fetch a list of nodes from seeder servers and choose which nodes they want to connect to.
Implement simple client to test seeder servers

Main features:
1. Receive queries from clients and returns a list of available nodes.

2. Receive "hello" message from other clients which want to introduce themselves to the Seeder. The seeder will add such clients to the peer list.

3. Frequently ping existing nodes inthe database to update their information(e.g. check whether they are alive, which clients they are using).

4. Support queries like: which nodes are alive during the last 1hours, 2hours, 1 day.


* Prequisite for build:
    ubuntu18.04
    apt install cmake make g++ gcc automake libtool gdb valgrind libuv1-dev

    Or we can use my docker image:
        docker pull giangdo/ubuntu18.04

* How to test:
    + Prepare docker environment:
        $docker network create giang_net
        $docker run -d -it --net=giang_net -v ~/p2p:/root/p2p --name m1 giangdo/ubuntu18.04
        $docker run -d -it --net=giang_net -v ~/p2p:/root/p2p --name m2 giangdo/ubuntu18.04
        $docker run -d -it --net=giang_net -v ~/p2p:/root/p2p --name m3 giangdo/ubuntu18.04
        $docker run -d -it --net=giang_net -v ~/p2p:/root/p2p --name m4 giangdo/ubuntu18.04

    + Build and Run server in m1:
        $docker exec -it m1 bash
        #cd ~/p2p/server
        #make
        #./server
        #ip addr show |grep inet
        inet 172.18.0.2/16 brd 172.18.255.255 scope global eth0

    + Build and Run Client in m2:
        $docker exec -it m2 bash
        #cd ~/p2p/client
        #make
        #./client -i 172.18.0.2 -p 9090 -c hello

    + Run Client in m3:
        $docker exec -it m3 bash
        #cd ~/p2p/client
        #./client -i 172.18.0.2 -p 9090 -c hello

     + List and Query in m4:
        $docker exec -it m4 bash
        #cd ~/p2p/client
        #./client -i 172.18.0.2 -p 9090 -c list
        [
          "172.18.0.3",
          "172.18.0.4"
        ]

        #./client -i 172.18.0.2 -p 9090 -c query -d 1 -h 1
        {
          "172.18.0.3": "Mon Aug 13 09:34:26 2018\n",
          "172.18.0.4": "Mon Aug 13 09:34:22 2018\n"
        }

    + Then stop client process in m2
    + Then run List and Query in m4 (Expect -> don't see client infor in m2)

        #./client -i 172.18.0.2 -p 9090 -c list
        [
          "172.18.0.3",
        ]

        #./client -i 172.18.0.2 -p 9090 -c query -d 1 -h 1
        {
          "172.18.0.3": "Mon Aug 13 09:34:26 2018\n",
        }

p2p's People

Contributors

giangdo 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.