graph

package
v0.0.0-...-c2b3dc6 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

TODO: better name? network topology?

TODO: better name? network topology?

TODO: better name? network topology?

Index

Constants

View Source
const (
	Up graphState = iota
	Suspect
	Down
)
View Source
const UNKNOWN_PATH = "*"

Variables

This section is empty.

Functions

func CreatePuzzle

func CreatePuzzle(paths ...[]string) map[int]*pathMergePuzzlePiece

Create a "puzzle" for the N constrained list of paths

func FillPath

func FillPath(path []string)

TODO: tests for this take a list of strings, and replace all the "*" with the appropriate placeholder key

func MergeRoutePath

func MergeRoutePath(o []string, n []string) ([]string, error)

Given 2 paths, see if we can resolve them into a single list

Types

type Event

type Event struct {
	E eventType
	// Pointer to the thing that changed
	Item interface{}
}

func (Event) Data

func (e Event) Data() string

func (Event) Event

func (e Event) Event() string

func (Event) Id

func (e Event) Id() string

type NetworkGraph

type NetworkGraph struct {
	// nodeName -> Node
	NodesMap  map[string]*NetworkNode `json:"nodes"`
	NodesLock *sync.RWMutex           `json:"-"`

	// nodeName,nodeName -> NetworkLink
	LinksMap  map[string]*NetworkLink `json:"edges"`
	LinksLock *sync.RWMutex           `json:"-"`

	RoutesMap  map[string]*NetworkRoute `json:"routes"`
	RoutesLock *sync.RWMutex            `json:"-"`
	// contains filtered or unexported fields
}

func Create

func Create() *NetworkGraph
func (g *NetworkGraph) DecrLink(src, dst string) (*NetworkLink, bool)

func (*NetworkGraph) DecrNode

func (g *NetworkGraph) DecrNode(name string) (*NetworkNode, bool)

func (*NetworkGraph) DecrRoute

func (g *NetworkGraph) DecrRoute(hops []string) (*NetworkRoute, bool)

func (*NetworkGraph) EventDumpChannel

func (g *NetworkGraph) EventDumpChannel() chan *Event

TODO: locking here Dump everything in the NetworkGraph into a channel

func (g *NetworkGraph) GetLink(key string) *NetworkLink

func (*NetworkGraph) GetLinkCount

func (g *NetworkGraph) GetLinkCount() int

func (*NetworkGraph) GetNode

func (g *NetworkGraph) GetNode(name string) *NetworkNode

func (*NetworkGraph) GetNodeCount

func (g *NetworkGraph) GetNodeCount() int

func (*NetworkGraph) GetRoute

func (g *NetworkGraph) GetRoute(hops []string) *NetworkRoute

func (*NetworkGraph) GetRouteCount

func (g *NetworkGraph) GetRouteCount() int
func (g *NetworkGraph) IncrLink(src, dst string, newLink *NetworkLink) (*NetworkLink, bool)

func (*NetworkGraph) IncrNode

func (g *NetworkGraph) IncrNode(name string, newNode *NetworkNode) (*NetworkNode, bool)

func (*NetworkGraph) IncrRoute

func (g *NetworkGraph) IncrRoute(hops []string, newRoute *NetworkRoute) (*NetworkRoute, bool)

func (*NetworkGraph) Subscribe

func (g *NetworkGraph) Subscribe(c chan *Event)

add subscriber to our events

type NetworkLink struct {
	SrcName string `json:"src"`

	DstName string `json:"dst"`
	// contains filtered or unexported fields
}

type NetworkNode

type NetworkNode struct {
	Name string `json:"name"`

	// asynchronously loaded
	DNSNames []string `json:"dns_names"`
	// contains filtered or unexported fields
}

TODO: differentiate between peers and L3devices in the middle TODO: handle addr '*' -- to compensate maybe we can just use a compound of the node on either side? so something like A -> * -> * -> B would become A*_B (for the second *) TODO: maintain pointers to NetworkLink for traversal

func NewNetworkNode

func NewNetworkNode(name string, updateChan chan *Event) *NetworkNode

func (*NetworkNode) MarshalJSON

func (n *NetworkNode) MarshalJSON() ([]byte, error)

Fancy marshal method

func (*NetworkNode) UnmarshalJSON

func (n *NetworkNode) UnmarshalJSON(data []byte) error

Fancy unmashal method

type NetworkRoute

type NetworkRoute struct {
	Path []string `json:"path"`

	// Network statistics
	State graphState `json:"state"` // TODO: better handle in the serialization
	// contains filtered or unexported fields
}

TODO: RoundTripRoute? Right now the Route is a single direction since we only have one side of the traceroute. If the peers gossip about the reverse routes then we could potentially have both directions TODO: TTL for routes? If we just start up we don't want to have to re-ping the world before we are useful TODO: stats about route health

func (*NetworkRoute) HandleACK

func (r *NetworkRoute) HandleACK(pass bool, latency int64)

func (*NetworkRoute) Hops

func (r *NetworkRoute) Hops() []string

func (*NetworkRoute) Inherit

func (r *NetworkRoute) Inherit(o *NetworkRoute)

TODO: we make the assumption here that the other route goes away-- which since the only caller today is the merge stuff in mapper-- is safe. If that ever changes we'll need to be more careful here-- as we are just pointing at another ring-- which has its own pings going on

func (*NetworkRoute) Key

func (r *NetworkRoute) Key() string

func (*NetworkRoute) MarshalJSON

func (r *NetworkRoute) MarshalJSON() ([]byte, error)

Fancy marshal method

func (*NetworkRoute) SamePath

func (r *NetworkRoute) SamePath(path []string) bool

func (*NetworkRoute) SamePathReverse

func (r *NetworkRoute) SamePathReverse(path []string) bool

is this the same path, just in reverse?

func (*NetworkRoute) UnmarshalJSON

func (r *NetworkRoute) UnmarshalJSON(data []byte) error

Fancy unmashal method

type RoutePingResponse

type RoutePingResponse struct {
	Pass    bool  // Did it ack?
	Latency int64 // Latency (if it ackd)
}

TODO: measure jitter (diff between 2 packet sends)

Jump to

Keyboard shortcuts

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