model

package
v0.0.0-...-2f116a2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Raw = iota
	Ack
	Wit
	Catchup
)
View Source
const ChanLen = 500

Variables

View Source
var Logger1 *log.Logger

Functions

This section is empty.

Types

type CommunicationInterface

type CommunicationInterface interface {
	Send([]byte, int) // Send a message to a specific node
	Broadcast([]byte) // Broadcast messages to other nodes
	Receive() *[]byte // Blocking receive
	Disconnect()      // Disconnect node
	Reconnect(string) // Reconnect node
	BroadcastMsg(message Message)
}

CommunicationInterface is a interface used for communicating with transport layer.

type Message

type Message struct {
	Source  int       // NodeID of message's source
	Step    int       // Time step of message
	MsgType MsgType   // Type of message
	History []Message // History of messages. Sent to ensure causality, But in an inefficient way.
}

type MessageInterface

type MessageInterface interface {
	MessageToBytes(Message) *[]byte
	BytesToModelMessage([]byte) *Message
}

type MsgType

type MsgType int

type Node

type Node struct {
	Id           int                    // Id of the node
	TimeStep     int                    // Node's local time step
	ThresholdAck int                    // Threshold on number of messages
	ThresholdWit int                    // Threshold on number of witnessed messages
	Acks         int                    // Number of acknowledges
	Wits         int                    // Number of witnesses
	Comm         CommunicationInterface // interface for communicating with other nodes
	ConvertMsg   MessageInterface
	CurrentMsg   Message   // Message which the node is waiting for acks
	History      []Message // History of received messages by a node

}

Node is the struct used for keeping everything related to a node in TLC.

func (*Node) Advance

func (node *Node) Advance(step int)

Advance will change the step of the node to a new one and then broadcast a message to the network.

func (*Node) WaitForMsg

func (node *Node) WaitForMsg(stop int)

waitForMsg waits for upcoming messages and then decides the next action with respect to msg's contents.

Jump to

Keyboard shortcuts

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