Documentation ¶
Overview ¶
Package netconf provides the basic functionality for the simulation of network conditions accross nodes.
Index ¶
- func Apply(client *ssh.Client, netconf Netconf, serverID int) error
- func ApplyAll(netconfs []Netconf, nodes []db.Node) error
- func ApplyToAll(netconf Netconf, nodes []db.Node) error
- func CalculatePartitions(nodes []db.Node) ([][]int, error)
- func CreateCommands(netconf Netconf, serverID int) []string
- func CreateLinks(pnts []util.Point, c *Calculator) [][]Link
- func CreatePartitionOutage(side1 []db.Node, side2 []db.Node)
- func MakeOutage(node1 db.Node, node2 db.Node) error
- func RemoveAll(nodes []db.Node) error
- func RemoveAllOnServer(client *ssh.Client, nodes int)
- func RemoveAllOutages(client *ssh.Client) error
- func RemoveOutage(node1 db.Node, node2 db.Node) error
- type Calculator
- type Connection
- type Connections
- type Link
- type Netconf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyToAll ¶
ApplyToAll applies the given netconf to `nodes` nodes in the network on the given server
func CalculatePartitions ¶
CalculatePartitions calculates the current partitions in the network
func CreateCommands ¶
CreateCommands generates the commands needed to obtain the desired network conditions
func CreateLinks ¶
func CreateLinks(pnts []util.Point, c *Calculator) [][]Link
CreateLinks generates a naive representation of a mesh network, which includes basic network impairments based on the distance between the points
func CreatePartitionOutage ¶
CreatePartitionOutage causes the two sides to be unable to communicate with one and the other
func MakeOutage ¶
MakeOutage removes the ability for the given nodes to connect
func RemoveAllOnServer ¶
RemoveAllOnServer removes network conditions from the given number of nodes on the given client
func RemoveAllOutages ¶
RemoveAllOutages removes all blocked connections on a server via the given client
Types ¶
type Calculator ¶
type Calculator struct { Loss func(float64) float64 Delay func(float64) int Rate func(float64) string Duplication func(float64) float64 Corrupt func(float64) float64 Reorder func(float64) float64 }
Calculator contains functions used to calculate network impairments based on a distance
func GetDefaultCalculator ¶
func GetDefaultCalculator() *Calculator
GetDefaultCalculator creates a calculator which can be used to calculate latency
type Connection ¶
Connection represents a uni-directional connection
func GetCutConnections ¶
func GetCutConnections(client *ssh.Client) ([]Connection, error)
GetCutConnections fetches the cut connections on a server TODO: Naive Implementation, does not yet take multiple servers into account
type Connections ¶
type Connections struct {
// contains filtered or unexported fields
}
Connections represents a graph of the network connections
func NewConnections ¶
func NewConnections(nodes int) *Connections
NewConnections creates a Connections object with all connections marked as open
func (*Connections) Networks ¶
func (mesh *Connections) Networks() [][]int
Networks calculates the distinct, completely separate partitions in the network
func (*Connections) RemoveAll ¶
func (mesh *Connections) RemoveAll(conns []Connection)
RemoveAll will mark all of the given connections as not connected
type Link ¶
type Link struct { EgressNode int `json:"egressNode"` //redundant info IngressNode int `json:"ingressNode"` //redundant info Loss float64 `json:"loss"` //Loss % ie 100% = 100 Delay int `json:"delay"` Rate string `json:"rate"` Duplication float64 `json:"duplicate"` Corrupt float64 `json:"corrupt"` Reorder float64 `json:"reorder"` }
Link is a naive representation of a network link
type Netconf ¶
type Netconf struct { Node int `json:"node"` Limit int `json:"limit"` Loss float64 `json:"loss"` //Loss % ie 100% = 100 Delay int `json:"delay"` Rate string `json:"rate"` Duplication float64 `json:"duplicate"` Corrupt float64 `json:"corrupt"` Reorder float64 `json:"reorder"` }
Netconf is a representation of the impairments applied to a node