bimodal-multicast

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2019 License: Apache-2.0

README

Bimodal Multicast Protocol

Build Status

This is an implementation of the Bimodal Multicast Protocol written in GO.

You can synchronize all types of messages: bool, string, int, complex structs, etc.

Overview

The Bimodal Multicast Protocol runs in a series of rounds. At the beginning of each round, every node randomly chooses another node and sends it a digest of its message histories. The message is called gossip message. The node that receive the gossip message compares the given digest with the messages in its own message buffer. If the digest differs from its message histories, then it send a message back to the original sender to request the missing messages. This message is called solicitation.

Usage

  • Imports
import (
    "github.com/rstefan1/bimodal-multicast/pkg/bmmc"
)
  • Configure the protocol
    cfg := bmmc.Config{
        Addr:      "localhost",
        Port:      "14999",
        Callbacks: map[string]func (interface{}, *log.Logger) (bool, error) {
            "awesome-callback":
            func (msg interface{}, logger *log.Logger) (bool, error) {
                fmt.Println("The message is:", msg)
                return true, nil
            },
        },
    }

The buffer will be updated only if the callback function call returns true.

  • Create an instance for protocol
    p, err := bmmc.New(cfg)
  • Start the protocol
    p.Start()
  • Stop the protocol
    p.Stop()
  • Add a new string message in buffer
    err := p.AddMessage("awesome message", "awesome-callback")
    
    err := p.AddMessage(12345, "awesome-callback")

For messages without callback, you can use bmmc.NOCALLBACK as callback type.

  • Get all messages from the buffer
    messages := p.GetMessages()
  • Add a new peer in peers buffer
    err := p.AddPeer("localhost", "18999")
  • Remove a peer from peers buffer
    err := p.RemovePeer("localhost", "18999")

Performance

When beta is 0.5 and loss is 30% (after 20 retries):

Alt text

Roadmap to v0.2

  • create an instance of Bimodal Multicast Protocol, start it, stop it, add message and retrieve all messages
  • metrics
  • register callbacks for each messages
  • add and remove peers via protocol
  • synchronize all types of messages (bool, string, int, complex structs, etc.)

Contributing

We welcome all contributions in the form of new issues for feature requests, bugs or even pull requests.

License

This project is licensed under Apache 2.0 license. Read the LICENSE file in the top distribution directory for the full license text.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL