Welcome to gossip’s documentation!

Contents:

Indices and tables

Getting Started

Other

  1. gossip-python requires python 3 or higher!

Installation

  1. Install gossip
    pip install gossip-python
    
  2. See Usage for more!

Usage

Run gossip

  • To start a new gossip instance on your machine, you first need to create a new directory called config at the same level of your python script.
  • Second, you need to add at least two files to that directory. The first file, called logging_config.ini is needed to specify the log level of this gossip instance
[loggers]
keys=root

[handlers]
keys=consoleHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG   # Replace this with the log level you want, for production we recommend ERROR
formatter=simpleFormatter
args=(sys.stdout,)

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=%d.%m.%Y %H:%M:%S
  • Third, create a file called config.ini :

[GLOBAL]
HOSTKEY = /hostkey.pem
[GOSSIP]
# Max number of messages this peer can cache
cache_size = 50
# Max number of peer connections this peer can hold
max_connections = 30
# The bootstrapping gossip instance (leave empty if you want to act as the bootstrapper)
bootstrapper = 192.168.1.100:6001
# The address this machine listens for peer connections
listen_address = 192.168.1.99:6001
# The address this machine listens for api connections
api_address = 192.168.2.99:7001
# Used for messages that are sent through the api
max_ttl = 0

Note that you should replace the listen_address and api_address with the ip address of your machine. If you want your machine to be the bootstrapping machine, leave bootstrapper empty. If not replace this with the list_address of the machine you want to use as the bootstrapper. eg (192.168.1.100:6001) For an example of a api application see this repository: ChatNow! - Repository If you want to test your gossip network you can download the latest ChatNow! Client from ChatNow! - Downloads

  • Once you created these files you can create a python script like this to run your gossip instance
from gossip.gossip_main import main as run_gossip

if __name__ == "__main__":
    run_gossip()

Run simulation

The simulation script generates a network based on the same algorithms that are used in gossip-python. This can especially useful if you want to see how the network behaves using different configuration paremeters. Note that you need to install the following requirements yourself to get the simulation running:

pip install networkx
pip install matplotlib

To run the simulation, which creates a network diagram, see following code.

from examples.connections_simulation import Simulation

if __name__ == "__main__":
    sim = Simulation(number_clients=30, number_connections_per_client=5)
    sim.run()