gossipsampling

Gossip Peer Sampling Service (GPSS)

A Gossip Peer Sampling Service (GPSS) creates a dynamic, random, self-healing overlay network and provides peers for communication within that topology. This library is designed to be a general-purpose implementation of GPSS, making it useful for a variety of large-scale distributed systems.

Check out a walk through and tutorial here

Features

Future Ideas

Getting Started:

Building for C++

Building for Python

Examples

Once the project has been built, there are examples for both Python and C++ located in the example/ directory. The behavior is the same for both languages:

gossip_entry_server_example.*

gossip_client_example.*

Emulating a Network over LAN

To emulate a network over a local area network (LAN), you can:

  1. Start an entry server.
  2. Run multiple instances of the client, ensuring that each client is assigned a unique port number.

Network Simulation in Python

Follow the notebook /example/python/simulation_example.ipynb that runs network simulations, calculates statistics, and compares them to the original paper.




Simulation Documentation

Only documentation for the simulator is recorded as using the main library is quite simple unless you want to implement custom views or entry and exit protocols. At which point your best bet is just looking at the codebase anyways (start with view.h and peer_samping_service.h).

NodeSchema

Defines a schema for creating simulation nodes with configurable parameters.

Parameters

Methods

gen_node(address, entry_times, exit_times, entry_points=[]) Generates a SimNode based on the schema configuration. Parameters

Example Usage

The gen_node() method is generally only called with the Simulator object

schema = NodeSchema(
    name="GossipNode",
    push=True,
    pull=True,
    wait_time=1,
    timeout=5,
    func=custom_node_function,
    view_type=NetworkView,
    selector_type=RandomSelector,
    size=20, 
    healing=0,
    swap=10 
)


Simulator

The Simulator class manages and executes simulations involving multiple network nodes, events, and data logging. It integrates node schemas, handles node lifecycle events, and supports configurable event-driven simulations

Parameters

Methods

There are many internal methods, if not for being in Python all but the below would be ‘private’ run(stats_interval: int = -1, save: bool = True) -> None

Example Usage

schema_registry = {
    "GossipNode": gossip.NodeSchema(
        name="GossipNode",
        push=True,
        pull=True,
        wait_time=1,
        timeout=5,
        func=custom_node_function,
        view_type=gossip.URView,
        selector_type=gossip.SelectorType.TAIL,
        view_args={'max_size': 10}
    )
}

# Define events
events=[gossip.AddEntryServers(entry_nodes={"GossipNode": 4}),
        gossip.AddRate(run_time=100, add_rates={"GossipNode": (10, 1)}),
        gossip.AddDelay(delay_time=10),
        gossip.ChurnRate(run_time=1000, add_rates={"GossipNode": (3, 1)}, rem_rates={"GossipNode": (3, 1)})
]

# Initialize the simulator
sim = Simulator(schema=schema_registry, events=events, name="ExampleSimulation")

# Run the simulation
sim.run(stats_interval=2000)


Simulation Topology Constructors

These topology constructors allow you to dynamically modify the network topology during a simulation by adding, removing, or delaying nodes.


RemoveRate

Removes nodes from the simulation at specified rates.

Parameters

Example Usage

remove_config = RemoveRate(
    run_time=60,
    rem_rates={'Echo': (4, 1), 'Database': (1, 2)},  # Remove 4 Echo Type Nodes per 1 second and 1 Database Type Node per 2 seconds
    entry_rem_rates={'BootStrap': (2, 1)}  # Remove 2 Bootstrap Type Entry Nodes per 1 second
)


ChurnRate

Allows both adding and removing nodes during the simulation.

Parameters

Example Usage

churn_config = ChurnRate(
    run_time=120,
    rem_rates={'Echo': (2, 1), 'Database': (1, 2)},  # Remove 2 Echo Nodes per 1 second, 1 Database Node per 2 seconds
    add_rates={'Worker': (3, 1)},  # Add 3 Worker Nodes per 1 second
    entry_rem_rates={'BootStrap': (1, 1)},  # Remove 1 Bootstrap Entry Node per 1 second
    entry_add_rates={'Aggregator': (2, 1)}  # Add 2 Aggregator Entry Nodes per 1 second
)


AddRate

Allows adding nodes during the simulation.

Parameters

Example Usage

churn_config = ChurnRate(
    run_time=120,
    add_rates={'Worker': (3, 1)},  # Add 3 Worker Nodes per 1 second
    entry_add_rates={'Aggregator': (2, 1)}  # Add 2 Aggregator Entry Nodes per 1 second
)


AddDelay

Introduces a delay in the simulation. Use to allow existing network to run without interference.

Parameters

Example Usage

churn_config = ChurnRate(
    delay_time=120,
)


AddLattice (Ring)

Creates a lattice topology by adding nodes with connections predefined upon entry.

Parameters


Example Usage

lattice_config = AddLattice(
    entry_nodes={'BootStrap': 2},  # Add 2 Bootstrap Entry Nodes
    nodes={'Worker': 5, 'Database': 2}  # Add 5 Worker Nodes and 2 Database Nodes
)


AddEntryServers

Adds entry nodes to the simulation.

Parameters

Example Usage

entry_config = AddEntryServers(
    entry_nodes={'Client': 3, 'BootStrap': 2}  # Add 3 Client Entry Nodes and 2 Bootstrap Entry Nodes
)


AddErdosRenyi

Creates a random graph topology using the Erdős-Rényi model

Parameters

Example Usage

erdos_config = AddErdosRenyi(
    entry_nodes={'BootStrap': 2},  # Add 2 Bootstrap Entry Nodes
    nodes={'Worker': 5, 'Database': 2},  # Add 5 Worker Nodes and 2 Database Nodes
    edge_prob=0.3  # 30% chance of an edge between any two nodes
)

AddUniformRandom

Creates a random graph topology using the Erdős-Rényi model

Parameters

Example Usage

erdos_config = AddErdosRenyi(
    entry_nodes={'BootStrap': 2},  # Add 2 Bootstrap Entry Nodes
    nodes={'Worker': 5, 'Database': 2},  # Add 5 Worker Nodes and 2 Database Nodes
    edge_prob=0.3  # 30% chance of an edge between any two nodes
)



Notice

This product uses gRPC which is licensed under the Apache License, Version 2.0