network

package
v0.3.11-0...-4fdaadb Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: BSD-3-Clause Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// MaxSize is the maximum size allowed for a topology.
	MaxSize = 5000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Area

type Area struct {
	N       int
	Latency Delay
	X       float64
	Y       float64
	// contains filtered or unexported fields
}

Area is a subset of the topology that have a given number of nodes inside it and a global location. A latency can be set for the members of the area and the latency for outsiders is computed based on the distance to other areas.

type AreaTopology

type AreaTopology struct {
	// contains filtered or unexported fields
}

AreaTopology is a network topology with multiple areas. Each members of an area have the same latency inside the area, and the same latency to members of other areas, case by case depending on the location. A unit of distance is 1ms thus coordinates can be adapted to fit a given latency.

func NewAreaTopology

func NewAreaTopology(areas ...*Area) *AreaTopology

NewAreaTopology creates a topology based on multiple areas.

func (*AreaTopology) GetNodes

func (t *AreaTopology) GetNodes() []Node

GetNodes returns the list of identifiers for the nodes.

func (*AreaTopology) Len

func (t *AreaTopology) Len() int

Len returns the number of nodes inside the topology.

func (*AreaTopology) Rules

func (t *AreaTopology) Rules(target NodeID, mapping map[NodeID]string) []Rule

Rules returns the list of rules for a given node in the topology.

type CloudTopology

type CloudTopology struct {
	NodeSelectorKey string
	// contains filtered or unexported fields
}

CloudTopology is a topology that will create a node on each of the regions provided so that the topology will have latencies from the real world.

func NewCloudTopology

func NewCloudTopology(key string, values []string) CloudTopology

NewCloudTopology returns a new cloud topology from the list of regions.

func (CloudTopology) GetNodes

func (t CloudTopology) GetNodes() []Node

GetNodes returns the list of nodes.

func (CloudTopology) Len

func (t CloudTopology) Len() int

Len returns the length of the topology.

func (CloudTopology) Rules

func (t CloudTopology) Rules(NodeID, map[NodeID]string) []Rule

Rules always returns nil as there is no rule in a cloud topology.

type Delay

type Delay struct {
	Value  time.Duration
	Leeway time.Duration
}

Delay is a parameter of a rule that will add a delay to the outgoing traffic.

func (Delay) String

func (d Delay) String() string

type FullInput

type FullInput struct {
	From    string
	To      string
	Latency time.Duration
}

FullInput is a wrapper for parameters to create a full topology.

type FullTopology

type FullTopology struct {
	SimpleTopology
}

FullTopology is a topology where the links are defined one by one.

func NewFullTopology

func NewFullTopology(inputs ...FullInput) FullTopology

NewFullTopology creates a new topology.

type Link struct {
	Distant Node
	Delay   Delay
	Loss    Loss
}

Link is a network link from the host to the node. It defines the properties of the link like a delay or a percentage of loss.

type Loss

type Loss struct {
	Value float64
}

Loss is a parameter of a rule that will induce a percentage of loss to the outgoing traffic.

func (Loss) String

func (l Loss) String() string

type Node

type Node struct {
	Name         NodeID
	NodeSelector string
}

Node is a peer of the topology.

func (Node) String

func (n Node) String() string

type NodeID

type NodeID string

NodeID is the type to define a unique identifier for the node.

type Rule

type Rule struct {
	IP    string
	Delay Delay
	Loss  Loss
}

Rule is a set of parameters to apply to a topology link to change the properties like the RRT, bandwidth and so on.

func NewDelayRule

func NewDelayRule(ip string, delay time.Duration) Rule

NewDelayRule creates a rule that only adds delay to the link.

func NewLossRule

func NewLossRule(ip string, loss float64) Rule

NewLossRule creates a rule that only adds loss to the link.

func (Rule) MatchAddr

func (r Rule) MatchAddr() string

MatchAddr returns the match filter for the rule.

type SimpleTopology

type SimpleTopology struct {
	// contains filtered or unexported fields
}

SimpleTopology represents a network map where the links between nodes have defined properties.

func NewSimpleTopology

func NewSimpleTopology(n int, delay time.Duration) SimpleTopology

NewSimpleTopology creates a simple topology with a delay for traffic going to node0.

func (SimpleTopology) GetNodes

func (t SimpleTopology) GetNodes() []Node

GetNodes returns the nodes.

func (SimpleTopology) Len

func (t SimpleTopology) Len() int

Len returns the number of nodes in the topology.

func (SimpleTopology) Rules

func (t SimpleTopology) Rules(node NodeID, mapping map[NodeID]string) []Rule

Rules generate the rules associated to the node. It relies on the mapping provided to associate a node with an IP.

type Topology

type Topology interface {
	Len() int
	GetNodes() []Node
	Rules(NodeID, map[NodeID]string) []Rule
}

Topology provides the primitive to get information about the mapping of multiple nodes connected together and the properties of their links.

Jump to

Keyboard shortcuts

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