simulator

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIMessageID added in v0.6.0

type APIMessageID int
const (
	UnknownMessage APIMessageID = iota
	SimInitialState
	SimUpdate
)

type APIUpdateID added in v0.6.0

type APIUpdateID int
const (
	UnknownUpdate APIUpdateID = iota
	SimNodeAdded
	SimNodeRemoved
	SimPeerAdded
	SimPeerRemoved
	SimTreeParentUpdated
	SimSnakeAscUpdated
	SimSnakeDescUpdated
	SimTreeRootAnnUpdated
)

type Distance

type Distance struct {
	Real         int64
	ObservedTree int64
	ObservedSNEK int64
}

type InitialNodeState added in v0.6.0

type InitialNodeState struct {
	PublicKey     string
	RootState     RootState
	Peers         []PeerInfo
	TreeParent    string
	SnakeAsc      string
	SnakeAscPath  string
	SnakeDesc     string
	SnakeDescPath string
}

type InitialStateMsg added in v0.6.0

type InitialStateMsg struct {
	MsgID APIMessageID
	Nodes map[string]InitialNodeState
	End   bool
}

type Node

type Node struct {
	*router.Router

	ListenAddr *net.TCPAddr
	// contains filtered or unexported fields
}

type NodeAdded added in v0.6.0

type NodeAdded struct {
	Node      string
	PublicKey string
}

type NodeRemoved added in v0.6.0

type NodeRemoved struct {
	Node string
}

type NodeState added in v0.6.0

type NodeState struct {
	PeerID           string
	Connections      map[int]string
	Parent           string
	Coords           []uint64
	Announcement     RootAnnouncement
	AscendingPeer    string
	AscendingPathID  string
	DescendingPeer   string
	DescendingPathID string
}

func NewNodeState added in v0.6.0

func NewNodeState(peerID string) *NodeState

type PeerAdded added in v0.6.0

type PeerAdded struct {
	Node string
	Peer string
	Port uint64
}

type PeerInfo added in v0.6.0

type PeerInfo struct {
	ID   string
	Port int
}

type PeerRemoved added in v0.6.0

type PeerRemoved struct {
	Node string
	Peer string
}

type RootAnnouncement added in v0.6.0

type RootAnnouncement struct {
	Root     string
	Sequence uint64
	Time     uint64
}

type RootState added in v0.6.0

type RootState struct {
	Root        string
	AnnSequence uint64
	AnnTime     uint64
	Coords      []uint64
}

type SimEvent added in v0.6.0

type SimEvent interface {
	// contains filtered or unexported methods
}

type SimEventMsg added in v0.6.0

type SimEventMsg struct {
	UpdateID APIUpdateID
	Event    SimEvent
}

type Simulator

type Simulator struct {
	State *StateAccessor
	// contains filtered or unexported fields
}

func NewSimulator

func NewSimulator(log *log.Logger, sockets, ping bool) *Simulator

func (*Simulator) CalculateShortestPaths

func (sim *Simulator) CalculateShortestPaths(nodes map[string]struct{}, wires map[string]map[string]bool)

func (*Simulator) ConnectNodes

func (sim *Simulator) ConnectNodes(a, b string) error

func (*Simulator) CreateNode

func (sim *Simulator) CreateNode(t string) error

func (*Simulator) DisconnectNodes

func (sim *Simulator) DisconnectNodes(a, b string) error

func (*Simulator) Distances

func (sim *Simulator) Distances() map[string]map[string]*Distance

func (*Simulator) Node

func (sim *Simulator) Node(t string) *Node

func (*Simulator) Nodes

func (sim *Simulator) Nodes() map[string]*Node

func (*Simulator) PingSNEK added in v0.4.0

func (sim *Simulator) PingSNEK(from, to string) (uint16, time.Duration, error)

func (*Simulator) PingTree added in v0.4.0

func (sim *Simulator) PingTree(from, to string) (uint16, time.Duration, error)

func (*Simulator) PingingEnabled added in v0.4.0

func (sim *Simulator) PingingEnabled() bool

func (*Simulator) ReportDistance

func (sim *Simulator) ReportDistance(a, b string, l int64, snek bool)

func (*Simulator) SNEKPathConvergence added in v0.2.0

func (sim *Simulator) SNEKPathConvergence() map[string]map[string]bool

func (*Simulator) StartNodeEventHandler added in v0.6.0

func (sim *Simulator) StartNodeEventHandler(t string)

func (*Simulator) TreePathConvergence added in v0.2.0

func (sim *Simulator) TreePathConvergence() map[string]map[string]bool

func (*Simulator) Uptime added in v0.4.0

func (sim *Simulator) Uptime() time.Duration

type SnakeAscUpdate added in v0.6.0

type SnakeAscUpdate struct {
	Node   string
	Peer   string
	Prev   string
	PathID string
}

type SnakeDescUpdate added in v0.6.0

type SnakeDescUpdate struct {
	Node   string
	Peer   string
	Prev   string
	PathID string
}

type State added in v0.6.0

type State struct {
	Nodes map[string]*NodeState
}

func NewState added in v0.6.0

func NewState() *State

type StateAccessor added in v0.6.0

type StateAccessor struct {
	phony.Inbox
	// contains filtered or unexported fields
}

func NewStateAccessor added in v0.6.0

func NewStateAccessor() *StateAccessor

func (*StateAccessor) GetLinkCount added in v0.6.0

func (s *StateAccessor) GetLinkCount() float64

func (*StateAccessor) GetNodeCoords added in v0.6.0

func (s *StateAccessor) GetNodeCoords(name string) []uint64

func (*StateAccessor) GetNodeName added in v0.6.0

func (s *StateAccessor) GetNodeName(peerID string) (string, error)

func (*StateAccessor) Subscribe added in v0.6.0

func (s *StateAccessor) Subscribe(ch chan<- SimEvent) State

type StateUpdateMsg added in v0.6.0

type StateUpdateMsg struct {
	MsgID APIMessageID
	Event SimEventMsg
}

type TreeParentUpdate added in v0.6.0

type TreeParentUpdate struct {
	Node string
	Peer string
	Prev string
}

type TreeRootAnnUpdate added in v0.6.0

type TreeRootAnnUpdate struct {
	Node     string
	Root     string // Root Public Key
	Sequence uint64
	Time     uint64 // Unix Time
	Coords   []uint64
}

Jump to

Keyboard shortcuts

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