/PHP_GOSSIP_NODE

A PHP Project for running a Gossip protocol to sync gossip "DATA" across an shared network on an Eventual consistency bases

Primary LanguagePHPMIT LicenseMIT

PHP GOSSIP NODE

A PHP Project for running a Gossip protocol to sync gossip "DATA" across an shared network on an Eventual consistency bases

Gossip Protocol The protocol has no single point of failure like Centralized networks and removes the data overheads caused by a Fully connected network by only fetching missing data based on a shared ledger.

  • A node in the network randomly selects a peer with which it will exchange some information.
  • A data exchange process happens between these peers. Each node processes the data it received.
  • These steps are periodically repeated by the nodes in the network as a way to disseminate information.

"PHP GOSSIP NODE" Based on Gossip_protocol and Eventual_consistency of data.

The node could be extended to keep change tracking if you replace MSG & SHA2 with a Bock Chain but that will not be added to this project

Gossip Node Quick Start

  1. To get started you need at least 2 nodes.
  2. to register on the network you send a REGISTER_FUNCTION to any existing node with matching network and password
  3. The receiving node will call back after the property gossip_timer time ran out.
  4. As Part of the call back the remote node will do a HELLO_FUNCTION and DID_YOU_HERE function.
  5. the now registered node will loop thru its gossip list, and complete a TELL_ME_MORE_FUNCTION to reach state of consistency
  6. the now registered node will call 5 random other nodes after the property gossip_timer ran out, sending do a HELLO_FUNCTION and DID_YOU_HERE function to the 5 selected nodes creating an infinite update & discover loop.

Gossip Node Details


Node Properties

  • NODE_GUID
  • NODE_NAME
  • NETWORK_NAME
  • NETWORK_PASSWORD
  • IP
  • PORT
  • GOSSIP_TIMER
  • GOSSIP_MAX_PEER_COUNT
  • PEER_SELECT_TYPE
    • random peers (used for data distribution)
    • oldest first (used as a down detector)

DATA_SETS

  • PEER_NODE_LIST

    • GUID
    • NAME
    • IP
    • PORT
    • NETWORK_NAME
    • LAST_UPDATE
  • GOSSIP

    • GUID
    • DATE_TIME
    • WHO_NAME
    • MSG
    • SHA2

GOSSIP_PROTOCOL

  • SERVER_FILES_FUNCTION
    • update or create server.json to set server properties
  • REGISTER_FUNCTION
    • first time register this node to an remote node with network name and password manually
    • loop thru node_list and register this NODE
  • HELLO_FUNCTION
    • loop thru peer list sending all known NODEs & NETWORK_NAMEs without passwords
  • DID_YOU_HERE
    • loop thru peer list for my networks sending all GOSSIP_GUID
  • TELL_ME_MORE_FUNCTION
    • loop thru received GOSSIP_GUID, retrieving all data for from node that shared it using NODE_GUID
  • NETWORK_STATUS_FUNCTION
    • Show all NODES on this NETWORK_NAME that this nodes knows
  • GOSSIP_STATUS_FUNCTION
    • Show all GOSSIP and include SHA2 if data complete

Node Build

CLI CLIENT / SERVER

  • CLIENT:

     - CREATE_GOSSIP
     - GET_GOSSIP
     - NETWORK_STATUS_FUNCTION
     - GOSSIP_STATUS_FUNCTION
    
  • PROCESSOR:

    - CREATE_SERVER_FUNCTION
    - REGISTER_FUNCTION
    - START_PROCESS
    	- HELLO_FUNCTION
    	- DID_YOU_HERE_FUNCTION
    	- TELL_ME_MORE_FUNCTION
    

WEB CLIENT / SERVER

  • CLIENT

     - CREATE_GOSSIP
     - GET_GOSSIP
     - NETWORK_STATUS_FUNCTION
     - GOSSIP_STATUS_FUNCTION
    
  • SERVER

     - RECEIVE_NETWORK_STATUS
     - RECEIVE_GOSSIP_STATUS
     - RECEIVE_REGISTER
     - RECEIVE_HELLO
     - RECEIVE_DID_YOU_HERE
     - RECEIVE_TELL_ME_MORE
    

To Do

  • add version control to network auth before gossip
  • add network auth function
  • consider adding a can reach property to Node list based on last update with max fail to protect against dead node traffic lock/spam
  • on processor::register validate server.json
  • on server::start validate server.json
  • add server::start with params ignore json