netconf

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package netconf provides the basic functionality for the simulation of network conditions across nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(client *ssh.Client, netconf Netconf, serverID int) error

Apply applies the given network config.

func ApplyAll

func ApplyAll(netconfs []Netconf, nodes []db.Node) error

ApplyAll applies all of the given netconfs

func ApplyToAll

func ApplyToAll(netconf Netconf, nodes []db.Node) error

ApplyToAll applies the given netconf to `nodes` nodes in the network on the given server

func CalculatePartitions

func CalculatePartitions(nodes []db.Node) ([][]int, error)

CalculatePartitions calculates the current partitions in the network

func CreateCommands

func CreateCommands(netconf Netconf, serverID int) []string

CreateCommands generates the commands needed to obtain the desired network conditions

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

func CreatePartitionOutage(side1 []db.Node, side2 []db.Node)

CreatePartitionOutage causes the two sides to be unable to communicate with one and the other

func MakeOutage

func MakeOutage(node1 db.Node, node2 db.Node) error

MakeOutage removes the ability for the given nodes to connect

func RemoveAll

func RemoveAll(nodes []db.Node) error

RemoveAll removes network conditions from the given nodes

func RemoveAllOnServer

func RemoveAllOnServer(client *ssh.Client, nodes int)

RemoveAllOnServer removes network conditions from the given number of nodes on the given client

func RemoveAllOutages

func RemoveAllOutages(client *ssh.Client) error

RemoveAllOutages removes all blocked connections on a server via the given client

func RemoveOutage

func RemoveOutage(node1 db.Node, node2 db.Node) error

RemoveOutage returns the ability for the given nodes to connect

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

type Connection struct {
	To   int `json:"to"`
	From int `json:"from"`
}

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 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

func GetConfigOnServer

func GetConfigOnServer(client *ssh.Client) ([]Netconf, error)

GetConfigOnServer gets the network impairments present on a server

Jump to

Keyboard shortcuts

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