mrnes

package module
v0.0.0-...-93ca82c Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 18 Imported by: 1

README

mrnes

Multi-resolution network emulation-simulation

Package mrnes implements library used building network topologies used in running Multi-Resolution-Network Emulation-Simulation models. It is designed and implemented to be transparent and orthogonal to some other model for traffic generation, e.g., the MrNesbits model.

An important thing to remember about mrnes is that it does all of its referencing to hosts and networks using text labels that are defined within input files. IP addressing does not at this time play a role, although in principle formalisms for textually describing addresses and ranges of address could be used as labels but without interpretation as references to IP. Another important assumption is that routing is based on shortest-number-of-hops. mrnes in its present form does not support running of different routing protocols.

mrnes represents both wired and wireless networks. When a path across a network is explicitly identified in terms of hops involving hosts, switches, and routers the latency across the network is a function of

  • time a packet takes to traverse an egress interface, t
  • ime to traverse a wire between two interfaces,
  • time through an ingress interface,
  • time for a device (switch or router) to execute its operation.
    The end-to-end latency of a packet through a network adds up all of these costs in the interfaces, wires, and devices it encounters on its path. Sometimes the passage across a network is not so detailed, and is given just the existence of a connection between routers that both face that network. In this case the latency is model based on configuration of the network, and in principle (but not yet implemented) on the overall traffic load on the network.

The latency between devices in a wireless network is based on a configuration parameter given for the network. In principle it too may be dependent on traffic load.

The model for end-to-end bandwidth of a flow is based on the observation that long-term, the bandwidth observed by the flow destination is defined by some bottleneck: source, device, network, or interface along the path. The mrnes model for estimating bandwidth between two hosts looks at all of the connections that make up its path, each of which has a maximum bandwidth, and computes the flow’s bandwidth as the minimum of all these.

The package current has three files

  • mrnes.go has functions for transforming input files that describe a network topology into a run-time representation of that topology. It provides an interface for a program that builds a simulation model, and an interface for an application traffic generator.
  • route.go provides the logic for computing and storing the end-to-end routes followed by messages
  • net.go holds the event-oriented logic for moving a message between devices
  • desc-topo.go implements an API for defining, creating, and reading mrnes topologies.

Copyright 2024 Board of Trustees of the University of Illinois. See the license for details.

Documentation

Index

Constants

View Source
const (
	LAN networkScale = iota
	WAN
	T3
	T2
	T1
	GeneralNet
)

Variables

View Source
var DevConnected map[string][]string = make(map[string][]string)

DevConnected gives for each NetDev device a list of the other NetDev devices it connects to through wired interfaces

View Source
var ExpAttributes map[string][]string
View Source
var ExpParamObjs []string

ExpParamObjs, ExpAttributes, and ExpParams hold descriptions of the types of objects that are initialized by an exp file, for each the attributes of the object that can be tested for to determine whether the object is to receive the configuration parameter, and the parameter types defined for each object type

View Source
var ExpParams map[string][]string
View Source
var NumIds int = 0

utility function for generating unique integer ids on demand

View Source
var QkNetSim bool = false

QkNetSim is set from the command line, when selected uses 'quick' form of network simulation

Functions

func BuildExperimentNet

func BuildExperimentNet(syn map[string]string, useYAML bool, idCounter int, traceMgr *TraceManager)

BuildExperimentNet is called from the module that creates and runs a simulation. Its inputs identify the names of input files, which it uses to assemble and initialize the model (and experiment) data structures.

func CableIntrfcFrames

func CableIntrfcFrames(intrfc1, intrfc2 *IntrfcFrame)

CableIntrfcFrames links two interfaces through their 'Cable' attributes

func CarryIntrfcFrames

func CarryIntrfcFrames(intrfc1, intrfc2 *IntrfcFrame)

CableIntrfcFrames links two interfaces through their 'Cable' attributes

func CheckDirectories

func CheckDirectories(dirs []string) (bool, error)

CheckDirectories probes the file system for the existence of every directory listed in the list of files. Returns a boolean indicating whether all dirs are valid, and returns an aggregated error if any checks failed.

func CheckFiles

func CheckFiles(names []string, checkExistence bool) (bool, error)

CheckFiles probes the file system for permitted access to all the argument filenames, optionally checking also for the existence of those files for the purposes of reading them.

func CheckOutputFiles

func CheckOutputFiles(names []string) (bool, error)

CheckOpututFileNames probles the file system to ensure that every argument filename can be written.

func CheckReadableFiles

func CheckReadableFiles(names []string) (bool, error)

CheckReadableFileNames probles the file system to ensure that every one of the argument filenames exists and is readable

func CompareAttrbs

func CompareAttrbs(attrbs1, attrbs2 []AttrbStruct) int

CompareAttrbs returns -1 if the first argument is strictly more general than the second, returns 1 if the second argument is strictly more general than the first, and 0 otherwise

func ConnectDevs

func ConnectDevs(dev1, dev2 NetDevice, cable bool, faces string)

ConnectDevs establishes a 'cabled' or 'carry' connection (creating interfaces if needed) between devices dev1 and dev2 (recall that NetDevice is an interface satisified by Endpt, Router, Switch, Filter)

func DefaultEndptName

func DefaultEndptName(name string) string

DefaultEndptName returns unique name for a endpt

func DefaultFilterName

func DefaultFilterName(name string) string

DefaultFilterName returns unique name for a filter

func DefaultIntrfcName

func DefaultIntrfcName(device string) string

DefaultIntrfcName generates a unique string to use as a name for an interface. That name includes the name of the device endpting the interface and a counter

func DefaultRouterName

func DefaultRouterName() string

DefaultRouterName returns a unique name for a router

func DefaultSwitchName

func DefaultSwitchName(name string) string

DefaultSwitchName returns a unique name for a switch

func DevNetworks

func DevNetworks(dev NetDevice) string

func EndptPresent

func EndptPresent(endptList []*EndptFrame, endpt *EndptFrame) bool

func EqAttrbs

func EqAttrbs(attrbs1, attrbs2 []AttrbStruct) bool

EqAttrbs determines whether the two attribute lists are exactly the same

func FilterPresent

func FilterPresent(filterList []*FilterFrame, filter *FilterFrame) bool

func GetExpParamDesc

func GetExpParamDesc() ([]string, map[string][]string, map[string][]string)

GetExpParamDesc returns ExpParamObjs, ExpAttributes, and ExpParams after ensuring that they have been build

func GetExperimentNetDicts

func GetExperimentNetDicts(syn map[string]string) (*TopoCfg, *DevExecList, *ExpCfg, *ExpCfg)

GetExperimentNetDicts accepts a map that holds the names of the input files used for the network part of an experiment creates internal representations of the information they hold, and returns those structs.

func IsConnected

func IsConnected(id1, id2 string) bool

IsConnect is part of a set of functions and data structures useful in managing construction of a communication network. It indicates whether two devices whose identities are given are already connected through their interfaces, by Cable, Carry, or Wireless

func MarkConnected

func MarkConnected(id1, id2 string)

MarkConnected modifes the DevConnected data structure to reflect that the devices whose identities are the arguments have been connected.

func NullHandler

func NullHandler(evtMgr *evtm.EventManager, context any, msg any) any

NullHandler exists to provide as a link for data fields that call for an event handler, but no event handler is actually needed

func ReportErrs

func ReportErrs(errs []error) error

ReportErrs transforms a list of errors and transforms the non-nil ones into a single error with comma-separated report of all the constituent errors, and returns it.

func RouterPresent

func RouterPresent(rtrList []*RouterFrame, rtr *RouterFrame) bool

func ShowPath

func ShowPath(src int, dest int, idToName map[int]string, thru map[int]int,
	forwardDirection bool) string

ShowPath returns a string that lists the names of all the network devices on a path. The input arguments are the source and destination device ids, a dictionary holding string names as a function of device id, representation the path, and a flag indicating whether the path is from src to dst, or vice-versa

func SwitchPresent

func SwitchPresent(swtchList []*SwitchFrame, swtch *SwitchFrame) bool

func UpdateExpCfg

func UpdateExpCfg(orgfile, updatefile string, useYAML bool, dict []byte)

func ValidateAttribute

func ValidateAttribute(paramObj, attrbName string) bool

ValidateAttrb checks that the attribute named is one that associates with the parameter object type named

func ValidateParameter

func ValidateParameter(paramObj string, attributes []AttrbStruct, param string) error

ValidateParameter returns an error if the paramObj, attributes, and param values don't make sense taken together within an ExpParameter.

Types

type AttrbStruct

type AttrbStruct struct {
	AttrbName, AttrbValue string
}

An AttrbStruct holds the name of an attribute and a value for it

func CreateAttrbStruct

func CreateAttrbStruct(attrbName, attrbValue string) *AttrbStruct

CreateAttrb is a constructor

type BuildExpCfgFuncType

type BuildExpCfgFuncType func(any) *ExpCfg

type BuildTopoCfgFuncType

type BuildTopoCfgFuncType func(any) *TopoCfg

types used in linking to code that generates the starting structures rather than read from file

type DevExecDesc

type DevExecDesc struct {
	DevOp    string  `json:"devop" yaml:"devop"`
	Model    string  `json:"model" yaml:"model"`
	ExecTime float64 `json:"exectime" yaml:"exectime"`
}

A DevExecDesc struct holds a description of a device operation timing. ExecTime is the time (in seconds), it depends on attribute Model

type DevExecList

type DevExecList struct {
	// ListName is an identifier for this collection of timings
	ListName string `json:"listname" yaml:"listname"`

	// key is the device operation.  Each has a list
	// of descriptions of the timing of that operation, as a function of device model
	Times map[string][]DevExecDesc `json:"times" yaml:"times"`
}

A DevExecList holds a map (Times) whose key is the operation of a device, and whose value is a list of DevExecDescs associated with that operation.

func CreateDevExecList

func CreateDevExecList(listname string) *DevExecList

CreateDevExecList is an initialization constructor. Its output struct has methods for integrating data.

func ReadDevExecList

func ReadDevExecList(filename string, useYAML bool, dict []byte) (*DevExecList, error)

ReadDevExecList deserializes a byte slice holding a representation of an DevExecList struct. If the input argument of dict (those bytes) is empty, the file whose name is given is read to acquire them. A deserialized representation is returned, or an error if one is generated from a file read or the deserialization.

func (*DevExecList) AddTiming

func (del *DevExecList) AddTiming(devOp, model string, execTime float64)

AddTiming takes the parameters of a DevExecDesc, creates one, and adds it to the FuncExecList

func (*DevExecList) WriteToFile

func (del *DevExecList) WriteToFile(filename string) error

WriteToFile stores the DevExecList struct to the file whose name is given. Serialization to json or to yaml is selected based on the extension of this name.

type EndptDesc

type EndptDesc struct {
	Name       string       `json:"name" yaml:"name"`
	Groups     []string     `json:"groups" yaml:"groups"`
	Model      string       `json:"model" yaml:"model"`
	CPU        string       `json:"cpu" yaml:"cpu"`
	EUD        bool         `json:"eud" yaml:"eud"`
	Cores      int          `json:"cores" yaml:"cores"`
	Interfaces []IntrfcDesc `json:"interfaces" yaml:"interfaces"`
}

FilterDesc defines serializable representation of a Filter.

type EndptDescSlice

type EndptDescSlice []EndptDesc

type EndptFrame

type EndptFrame struct {
	Name       string // unique string identifier
	Groups     []string
	CPU        string
	Model      string
	EUD        bool
	Cores      int
	EndptType  string         // parameter used to index into execution time tables
	Interfaces []*IntrfcFrame // list of interfaces that describe the networks the endpt connects to
}

EndptFrame defines pre-serialization representation of a Endpt

func CreateEUD

func CreateEUD(name, model string, cores int) *EndptFrame

CreateEUD is a constructor. It creates an endpoint frame with the EUD flag set to true

func CreateEndpt

func CreateEndpt(name, model string, cores int) *EndptFrame

CreateEndptFrame is a constructor. It saves (or creates) the endpt name, and saves the optional endpt type (which has use in run-time configuration)

func CreateHost

func CreateHost(name, model string, cores int) *EndptFrame

CreateHost is a constructor. It creates an endpoint frame with the EUD flag set to false

func (*EndptFrame) AddGroup

func (epf *EndptFrame) AddGroup(groupName string)

func (*EndptFrame) AddIntrfc

func (epf *EndptFrame) AddIntrfc(iff *IntrfcFrame) error

AddIntrfc includes a new interface frame for the endpt. An error is reported if this specific (by pointer value or by name) interface is already connected.

func (*EndptFrame) DevAddIntrfc

func (epf *EndptFrame) DevAddIntrfc(iff *IntrfcFrame) error

devAddIntrfc includes an IntrfcFrame to a NetDevice's list of IntrfcFrames

func (*EndptFrame) DevId

func (epf *EndptFrame) DevId() string

devId returns the NetDevice unique identifier

func (*EndptFrame) DevInterfaces

func (epf *EndptFrame) DevInterfaces() []*IntrfcFrame

devInterfaces returns the NetDevice list of IntrfcFrames, if any

func (*EndptFrame) DevName

func (epf *EndptFrame) DevName() string

DevName returns the NetDevice name

func (*EndptFrame) DevType

func (epf *EndptFrame) DevType() string

devType returns the NetDevice Type

func (*EndptFrame) SetCores

func (epf *EndptFrame) SetCores(cores int)

func (*EndptFrame) SetEUD

func (epf *EndptFrame) SetEUD()

func (*EndptFrame) Transform

func (epf *EndptFrame) Transform() EndptDesc

Transform returns a serializable EndptDesc, transformed from a EndptFrame.

type ExpCfg

type ExpCfg struct {
	// Name is an identifier for a group of [ExpParameters].  No particular interpretation of this string is
	// used, except as a referencing label when moving an ExpCfg into or out of a dictionary
	Name string `json:"expname" yaml:"expname"`

	// Parameters is a list of all the [ExpParameter] objects presented to the simulator for an experiment.
	Parameters []ExpParameter `json:"parameters" yaml:"parameters"`
}

An ExpCfg structure holds all of the ExpParameters for a named experiment

func CreateExpCfg

func CreateExpCfg(name string) *ExpCfg

CreateExpCfg is a constructor. Saves the offered Name and initializes the slice of ExpParameters.

func ReadExpCfg

func ReadExpCfg(filename string, useYAML bool, dict []byte) (*ExpCfg, error)

ReadExpCfg deserializes a byte slice holding a representation of an ExpCfg struct. If the input argument of dict (those bytes) is empty, the file whose name is given is read to acquire them. A deserialized representation is returned, or an error if one is generated from a file read or the deserialization.

func (*ExpCfg) AddExpParameter

func (excg *ExpCfg) AddExpParameter(exparam *ExpParameter)

func (*ExpCfg) AddParameter

func (expcfg *ExpCfg) AddParameter(paramObj string, attributes []AttrbStruct, param, value string) error

AddParameter accepts the four values in an ExpParameter, creates one, and adds to the ExpCfg's list. Returns an error if the parameters are not validated.

func (*ExpCfg) WriteToFile

func (dict *ExpCfg) WriteToFile(filename string) error

WriteToFile stores the ExpCfg struct to the file whose name is given. Serialization to json or to yaml is selected based on the extension of this name.

type ExpCfgDict

type ExpCfgDict struct {
	DictName string            `json:"dictname" yaml:"dictname"`
	Cfgs     map[string]ExpCfg `json:"cfgs" yaml:"cfgs"`
}

An ExpCfgDict is a dictionary that holds ExpCfg objects in a map indexed by their Name.

func CreateExpCfgDict

func CreateExpCfgDict(name string) *ExpCfgDict

CreateExpCfgDict is a constructor. Saves a name for the dictionary, and initializes the slice of ExpCfg objects

func ReadExpCfgDict

func ReadExpCfgDict(filename string, useYAML bool, dict []byte) (*ExpCfgDict, error)

ReadExpCfgDict deserializes a byte slice holding a representation of an ExpCfgDict struct. If the input argument of dict (those bytes) is empty, the file whose name is given is read to acquire them. A deserialized representation is returned, or an error if one is generated from a file read or the deserialization.

func (*ExpCfgDict) AddExpCfg

func (ecd *ExpCfgDict) AddExpCfg(ec *ExpCfg, overwrite bool) error

AddExpCfg adds the offered ExpCfg to the dictionary, optionally returning an error if an ExpCfg with the same Name is already saved.

func (*ExpCfgDict) RecoverExpCfg

func (ecd *ExpCfgDict) RecoverExpCfg(name string) (*ExpCfg, bool)

RecoverExpCfg returns an ExpCfg from the dictionary, with name equal to the input parameter. It returns also a flag denoting whether the identified ExpCfg has an entry in the dictionary.

func (*ExpCfgDict) WriteToFile

func (ecd *ExpCfgDict) WriteToFile(filename string) error

WriteToFile stores the ExpCfgDict struct to the file whose name is given. Serialization to json or to yaml is selected based on the extension of this name.

type ExpParameter

type ExpParameter struct {
	// Type of thing being configured
	ParamObj string `json:"paramObj" yaml:"paramObj"`

	// attribute identifier for this parameter
	// Attribute string `json:"attribute" yaml:"attribute"`
	Attributes []AttrbStruct `json:"attributes" yaml:"attributes"`

	// ParameterType, e.g., "Bandwidth", "WiredLatency", "CPU"
	Param string `json:"param" yaml:"param"`

	// string-encoded value associated with type
	Value string `json:"value" yaml:"value"`
}

An ExpParameter struct describes an input to experiment configuration at run-time. It specifies

  • ParamObj identifies the kind of thing being configured : Switch, Router, Endpt, Filter, Interface, or Network
  • Attributes is a list of attributes, each of which are required for the parameter value to be applied.

func CreateExpParameter

func CreateExpParameter(paramObj string, attributes []AttrbStruct, param, value string) *ExpParameter

CreateExpParameter is a constructor. Completely fills in the struct with the ExpParameter attributes.

func (*ExpParameter) AddAttribute

func (epp *ExpParameter) AddAttribute(attrbName, attrbValue string) error

AddAttribute includes another attribute to those associated with the ExpParameter. An error is returned if the attribute name (other than 'group') already exists

func (*ExpParameter) Eq

func (ep1 *ExpParameter) Eq(ep2 *ExpParameter) bool

type FilterDesc

type FilterDesc struct {
	Name       string       `json:"name" yaml:"name"`
	Groups     []string     `json:"groups" yaml:"groups"`
	CPU        string       `json:"cpu" yaml:"cpu"`
	Model      string       `json:"model" yaml:"model"`
	FilterType string       `json:"filtertype" yaml:"filtertype"`
	Network    string       `json:"network" yaml:"network"`
	Interfaces []IntrfcDesc `json:"interfaces" yaml:"interfaces"`
}

FilterDesc defines serializable representation of a Filter.

type FilterDescSlice

type FilterDescSlice []FilterDesc

type FilterFrame

type FilterFrame struct {
	Name       string // unique string identifier
	Groups     []string
	Model      string
	FilterType string         // parameter used to index into execution time tables
	Network    string         // name of network containing filter
	Interfaces []*IntrfcFrame // list of interfaces that describe the networks the filter connects to
}

FilterFrame defines pre-serialization representation of a Filter

func CreateFilter

func CreateFilter(name, filterType, attrib string) *FilterFrame

CreateFilter is a constructor. It saves (or creates) the filter name, and saves the optional filter type (which has use in run-time configuration)

func (*FilterFrame) AddGroup

func (ff *FilterFrame) AddGroup(groupName string)

func (*FilterFrame) AddIntrfc

func (ff *FilterFrame) AddIntrfc(iff *IntrfcFrame) error

AddIntrfc includes a new interface frame for the filter. An error is reported if this specific (by pointer value or by name) interface is already connected.

func (*FilterFrame) DevAddIntrfc

func (ff *FilterFrame) DevAddIntrfc(iff *IntrfcFrame) error

devAddIntrfc includes an IntrfcFrame to a NetDevice's list of IntrfcFrames

func (*FilterFrame) DevId

func (ff *FilterFrame) DevId() string

devId returns the NetDevice unique identifier

func (*FilterFrame) DevInterfaces

func (ff *FilterFrame) DevInterfaces() []*IntrfcFrame

devInterfaces returns the NetDevice list of IntrfcFrames, if any

func (*FilterFrame) DevName

func (ff *FilterFrame) DevName() string

DevName returns the NetDevice name

func (*FilterFrame) DevType

func (ff *FilterFrame) DevType() string

devType returns the NetDevice Type

func (*FilterFrame) Transform

func (ff *FilterFrame) Transform() FilterDesc

Transform returns a serializable FilterDesc, transformed from a FilterFrame.

type IntrfcDesc

type IntrfcDesc struct {
	// name for interface, unique among interfaces on endpting device.
	Name string `json:"name" yaml:"name"`

	Groups []string `json:"groups" yaml:"groups"`

	// type of device that is home to this interface, i.e., "Endpt", "Switch", "Router"
	DevType string `json:"devtype" yaml:"devtype"`

	// whether media used by interface is 'wired' or 'wireless' .... could put other kinds here, e.g., short-wave, satellite
	MediaType string `json:"mediatype" yaml:"mediatype"`

	// name of endpt, switch, or router on which this interface is resident
	Device string `json:"device" yaml:"device"`

	// name of interface (on a different device) to which this interface is directly (and singularly) connected
	Cable string `json:"cable" yaml:"cable"`

	// name of interface (on a different device) to which this interface is directly (and singularly) carried if wired and not on Cable
	Carry string `json:"carry" yaml:"carry"`

	// list of names of interface (on a different device) to which this interface is connected through wireless
	Wireless []string `json:"wireless" yaml:"wireless"`

	// name of the network the interface connects to. There is a tacit assumption then that interface reaches routers on the network
	Faces string `json:"faces" yaml:"faces"`
}

IntrfcDesc defines a serializable description of a network interface

type IntrfcFrame

type IntrfcFrame struct {
	// name for interface, unique among interfaces on endpting device.
	Name string

	Groups []string

	// type of device that is home to this interface, i.e., "Endpt", "Switch", "Router"
	DevType string

	// whether media used by interface is 'wired' or 'wireless' .... could put other kinds here, e.g., short-wave, satellite
	MediaType string

	// name of endpt, switch, or router on which this interface is resident
	Device string

	// pointer to interface (on a different device) to which this interface is directly (and singularly) connected.
	// this interface and the one pointed to need to have media type "wired"
	Cable *IntrfcFrame

	// pointer to interface (on a different device) to which this interface is directly if wired and not Cable.
	// this interface and the one pointed to need to have media type "wired", and have "Cable" be empty
	Carry *IntrfcFrame

	// A wireless interface may connect to may devices, this slice points to those that can be reached
	Wireless []*IntrfcFrame

	// name of the network the interface connects to. We do not require that the media type of the interface be the same
	// as the media type of the network.
	Faces string
}

IntrfcFrame gives a pre-serializable description of an interface, used in model construction. 'Almost' the same as IntrfcDesc, with the exception of one pointer

func CreateIntrfc

func CreateIntrfc(device, name, devType, mediaType, faces string) *IntrfcFrame

CreateIntrfcDesc is a constructor for IntrfcFrame that fills in most of the attributes except Cable. Arguments name the device holding the interface and its type, the type of communication fabric the interface uses, and the name of the network the interface connects to

func (*IntrfcFrame) AddGroup

func (iff *IntrfcFrame) AddGroup(groupName string)

func (*IntrfcFrame) Transform

func (ifs *IntrfcFrame) Transform() IntrfcDesc

Transform converts an IntrfcFrame and returns an IntrfcDesc, for serialization.

type MrnesApp

type MrnesApp interface {

	// a globally unique name for the application
	GlobalName() string

	// an event handler to call to present a message to an app
	ArrivalFunc() evtm.EventHandlerFunction
}

intfrastructure for inter-func addressing (including x-compPattern addressing)

type NameType

type NameType struct {
	Name string
	Type string
}

NameType is a an entry in a dictionary created for a trace that maps object id numbers to a (name,type) pair

type NetDevice

type NetDevice interface {
	DevName() string                 // returns the .Name field of the struct
	DevId() string                   // returns a unique (string) identifier for the struct
	DevType() string                 // returns the type ("Switch","Router","Endpt","Network", "Filter")
	DevInterfaces() []*IntrfcFrame   // list of interfaces attached to the NetDevice, if any
	DevAddIntrfc(*IntrfcFrame) error // function to add another interface to the netDevic3
}

The NetDevice interface lets us use common code when network objects (endpt, switch, router, network) are involved in model construction.

type NetworkDesc

type NetworkDesc struct {
	Name      string   `json:"name" yaml:"name"`
	Groups    []string `json:"groups" yaml:"groups"`
	NetScale  string   `json:"netscale" yaml:"netscale"`
	MediaType string   `json:"mediatype" yaml:"mediatype"`
	Endpts    []string `json:"endpts" yaml:"endpts"`
	Routers   []string `json:"routers" yaml:"routers"`
	Filters   []string `json:"filters" yaml:"filters"`
	Switches  []string `json:"switches" yaml:"switches"`
}

NetworkDesc is a serializable version of the Network information, where the pointers to routers, filters, and switches are replaced by the string names of those entities

type NetworkDescSlice

type NetworkDescSlice []NetworkDesc

type NetworkFrame

type NetworkFrame struct {
	// Name is a unique name across all objects in the simulation. It is used universally to reference this network
	Name string

	Groups []string

	// NetScale describes role of network, e.g., LAN, WAN, T3, T2, T1.  Used as an attribute when doing experimental configuration
	NetScale string

	// for now the network is either "wired" or "wireless"
	MediaType string

	// any router with an interface that faces this network is in this list
	Routers []*RouterFrame

	// any endpt with an interface that faces this network is in this list
	Endpts []*EndptFrame

	// any endpt with an interface that faces this network is in this list
	Switches []*SwitchFrame

	// any endpt with an interface that faces this network is in this list
	Filters []*FilterFrame
}

A NetworkFrame holds the attributes of a network during the model construction phase

func CreateNetwork

func CreateNetwork(name, NetScale string, MediaType string) *NetworkFrame

CreateNetworkFrame is a constructor, with all the inherent attributes specified

func (*NetworkFrame) AddGroup

func (nf *NetworkFrame) AddGroup(groupName string)

func (*NetworkFrame) AddRouter

func (nf *NetworkFrame) AddRouter(rtrf *RouterFrame)

AddRouter includes the argument router into the network, throws an error if already present

func (*NetworkFrame) AddSwitch

func (nf *NetworkFrame) AddSwitch(swtch *SwitchFrame)

AddRouter includes the argument router into the network, throws an error if already present

func (*NetworkFrame) FacedBy

func (nf *NetworkFrame) FacedBy(dev NetDevice) bool

FacedBy determines whether the device offered as an input argument has an interface whose 'Faces' component references this network

func (*NetworkFrame) IncludeDev

func (nf *NetworkFrame) IncludeDev(dev NetDevice, intrfcType string, chkIntrfc bool)

IncludeDev makes sure that the network device being offered

a) has an interface facing the network
b) is included in the network's list of those kind of devices

func (*NetworkFrame) Transform

func (nf *NetworkFrame) Transform() NetworkDesc

Transform converts a network frame into a network description. It copies string attributes, and converts pointers to routers, filters, and switches to strings with the names of those entities

type NetworkPortal

type NetworkPortal struct {
	QkNetSim bool
	// contains filtered or unexported fields
}

a NetworkPortal implements the mrnesbits interface used to pass traffic between the application layer and the network sim

func CreateNetworkPortal

func CreateNetworkPortal() *NetworkPortal

CreateNetworkPortal is a constructor, passed a flag indicating which of two network simulation modes to use, passes a flag indicating whether packets should be passed whole, and writes the NetworkPortal pointer into a global variable

func (*NetworkPortal) Arrive

func (np *NetworkPortal) Arrive(rtnCxt any, rtnFunc evtm.EventHandlerFunction,
	lossCxt any, lossFunc evtm.EventHandlerFunction) int

Arrive is called at the point an application message is received by the network and a new connectId is created to track it. It saves information needed to re-integrate the application message into the application layer when the message arrives at its destination

func (*NetworkPortal) Depart

func (np *NetworkPortal) Depart(evtMgr *evtm.EventManager, nm networkMsg)

Depart is called to return an application message being carried through the network back to the application layer

func (*NetworkPortal) EndptCPU

func (np *NetworkPortal) EndptCPU(devName string) string

EndptCPU helps NetworkPortal implement the mrnesbits NetworkPortal interface, returning the CPU type associated with a named endpt. Present because the application layer does not otherwise have visibility into the network topology

func (*NetworkPortal) EnterNetwork

func (np *NetworkPortal) EnterNetwork(evtMgr *evtm.EventManager, srcDev, dstDev string, msgLen int,
	execId int, isPckt bool, rate float64, msg any, rtnCxt any, rtnFunc evtm.EventHandlerFunction,
	lossCxt any, lossFunc evtm.EventHandlerFunction) any

EnterNetwork is called after the execution from the application layer It creates networkMsg structs to represent the start and end of the message, and schedules their arrival to the egress interface of the message source endpt func enterNetwork(evtMgr *evtm.EventManager, cpf cmpPtnFunc, cpm *cmpPtnMsg) any {

func (*NetworkPortal) SetQkNetSim

func (np *NetworkPortal) SetQkNetSim(qknetsim bool)

SetQkNetSim assigns a boolean to the network portal to indicate whether or not the 'quicksim' option should be applied

type RouterDesc

type RouterDesc struct {
	// Name is unique string identifier used to reference the router
	Name string `json:"name" yaml:"name"`

	Groups []string `json:"groups" yaml:"groups"`

	// Model is an attribute like "Cisco 6400". Used primarily in run-time configuration
	Model string `json:"model" yaml:"model"`

	// list of names interfaces that describe the ports of the router
	Interfaces []IntrfcDesc `json:"interfaces" yaml:"interfaces"`
}

RouterDesc describes parameters of a Router in the topology.

type RouterFrame

type RouterFrame struct {
	Name       string // identical to RouterDesc attribute
	Groups     []string
	Model      string         // identifical to RouterDesc attribute
	Interfaces []*IntrfcFrame // list of interface frames that describe the ports of the router
}

RouterDesc describes parameters of a Router in the topology in pre-serialized form

func ConnectNetworks

func ConnectNetworks(net1, net2 *NetworkFrame, newRtr bool) (*RouterFrame, error)

ConnectNetworks creates router that enables traffic to pass between the two argument networks. 'newRtr' input variable governs whether a new router is absolutely created (allowing for multiple connections), or only if there is no existing connection

func CreateRouter

func CreateRouter(name, model string) *RouterFrame

CreateRouter is a constructor, stores (possibly creates default) name, initializes slice of interface frames

func (*RouterFrame) AddGroup

func (rf *RouterFrame) AddGroup(groupName string)

AddGroup includes a group name to the router

func (*RouterFrame) AddIntrfc

func (rf *RouterFrame) AddIntrfc(intrfc *IntrfcFrame) error

AddIntrfc includes interface frame in router frame

func (*RouterFrame) DevAddIntrfc

func (rf *RouterFrame) DevAddIntrfc(iff *IntrfcFrame) error

devAddIntrfc includes an IntrfcFrame to the NetDevice

func (*RouterFrame) DevId

func (rf *RouterFrame) DevId() string

devId returns a unique identifier for the NetDevice

func (*RouterFrame) DevInterfaces

func (rf *RouterFrame) DevInterfaces() []*IntrfcFrame

devInterfaces returns the slice of IntrfcFrame held by the NetDevice, if any

func (*RouterFrame) DevModel

func (rf *RouterFrame) DevModel() string

devModel returns the NetDevice model code, if any

func (*RouterFrame) DevName

func (rf *RouterFrame) DevName() string

DevName returns the name of the NetDevice

func (*RouterFrame) DevType

func (rf *RouterFrame) DevType() string

devType returns network objec type (e.g., "Switch", "Router", "Endpt", "Network") for the NetDevice

func (*RouterFrame) Transform

func (rdf *RouterFrame) Transform() RouterDesc

Transform returns a serializable RouterDesc, transformed from a RouterFrame.

func (*RouterFrame) WirelessConnectTo

func (hub *RouterFrame) WirelessConnectTo(dev NetDevice, faces string)

ConnectTo establishes a wireless connection (creating interfaces if needed) between a hub and a device

type RtrDescSlice

type RtrDescSlice []RouterDesc

Type definitions for TopoCfg attributes

type SwitchDesc

type SwitchDesc struct {
	Name       string       `json:"name" yaml:"name"`
	Groups     []string     `json:"groups" yaml:"groups"`
	Model      string       `json:"model" yaml:"model"`
	Interfaces []IntrfcDesc `json:"interfaces" yaml:"interfaces"`
}

SwitchDesc holds a serializable representation of a switch.

type SwitchDescSlice

type SwitchDescSlice []SwitchDesc

type SwitchFrame

type SwitchFrame struct {
	Name       string // unique string identifier used to reference the router
	Groups     []string
	Model      string         // device model identifier
	Interfaces []*IntrfcFrame // interface frames that describe the ports of the router
}

SwitchFrame holds a pre-serialization representation of a Switch

func CreateSwitch

func CreateSwitch(name, model string) *SwitchFrame

CreateSwitchFrame constructs a switch frame. Saves (and possibly creates) the switch name,

func (*SwitchFrame) AddGroup

func (sf *SwitchFrame) AddGroup(groupName string)

func (*SwitchFrame) AddIntrfc

func (sf *SwitchFrame) AddIntrfc(iff *IntrfcFrame) error

AddIntrfc includes a new interface frame for the switch. Error is returned if the interface (or one with the same name) is already attached to the SwitchFrame

func (*SwitchFrame) DevAddIntrfc

func (sf *SwitchFrame) DevAddIntrfc(iff *IntrfcFrame) error

devAddIntrfc adds an IntrfcFrame to the NetDevice

func (*SwitchFrame) DevId

func (sf *SwitchFrame) DevId() string

devId returns unique identifier for NetDevice

func (*SwitchFrame) DevInterfaces

func (sf *SwitchFrame) DevInterfaces() []*IntrfcFrame

devInterfaces returns list of IntrfcFrames attached to the NetDevice, if any

func (*SwitchFrame) DevName

func (sf *SwitchFrame) DevName() string

DevName returns name for the NetDevice

func (*SwitchFrame) DevType

func (sf *SwitchFrame) DevType() string

devType returns the type of the NetDevice (e.g. "Switch","Router","Endpt","Network")

func (*SwitchFrame) Transform

func (sf *SwitchFrame) Transform() SwitchDesc

Transform returns a serializable SwitchDesc, transformed from a SwitchFrame.

type TopoCfg

type TopoCfg struct {
	Name     string           `json:"name" yaml:"name"`
	Networks NetworkDescSlice `json:"networks" yaml:"networks"`
	Routers  RtrDescSlice     `json:"routers" yaml:"routers"`
	Endpts   EndptDescSlice   `json:"endpts" yaml:"endpts"`
	Switches SwitchDescSlice  `json:"switches" yaml:"switches"`
	Filters  FilterDescSlice  `json:"filters" yaml:"filters"`
}

TopoCfg contains all of the networks, routers, and endpts, as they are listed in the json file.

func ReadTopoCfg

func ReadTopoCfg(topoFileName string, useYAML bool, dict []byte) (*TopoCfg, error)

ReadTopoCfg deserializes a slice of bytes into a TopoCfg. If the input arg of bytes is empty, the file whose name is given as an argument is read. Error returned if any part of the process generates the error.

func (*TopoCfg) WriteToFile

func (dict *TopoCfg) WriteToFile(filename string) error

WriteToFile serializes the TopoCfg and writes to the file whose name is given as an input argument. Extension of the file name selects whether serialization is to json or to yaml format.

type TopoCfgDict

type TopoCfgDict struct {
	DictName string             `json:"dictname" yaml:"dictname"`
	Cfgs     map[string]TopoCfg `json:"cfgs" yaml:"cfgs"`
}

A TopoCfgDict holds instances of TopoCfg structures, in a map whose key is a name for the topology. Used to store pre-built instances of networks

func CreateTopoCfgDict

func CreateTopoCfgDict(name string) *TopoCfgDict

CreateTopoCfgDict is a constructor. Saves the dictionary name, initializes the TopoCfg map.

func ReadTopoCfgDict

func ReadTopoCfgDict(topoCfgDictFileName string, useYAML bool, dict []byte) (*TopoCfgDict, error)

ReadTopoCfgDict deserializes a slice of bytes into a TopoCfgDict. If the input arg of bytes is empty, the file whose name is given as an argument is read. Error returned if any part of the process generates the error.

func (*TopoCfgDict) AddTopoCfg

func (tcd *TopoCfgDict) AddTopoCfg(tc *TopoCfg, overwrite bool) error

AddTopoCfg includes a TopoCfg into the dictionary, optionally returning an error if an TopoCfg with the same name has already been included

func (*TopoCfgDict) RecoverTopoCfg

func (tcd *TopoCfgDict) RecoverTopoCfg(name string) (*TopoCfg, bool)

RecoverTopoCfg returns a copy (if one exists) of the TopoCfg with name equal to the input argument name. Returns a boolean indicating whether the entry was actually found

func (*TopoCfgDict) WriteToFile

func (tcd *TopoCfgDict) WriteToFile(filename string) error

WriteToFile serializes the TopoCfgDict and writes to the file whose name is given as an input argument. Extension of the file name selects whether serialization is to json or to yaml format.

type TopoCfgFrame

type TopoCfgFrame struct {
	Name     string
	Endpts   []*EndptFrame
	Networks []*NetworkFrame
	Routers  []*RouterFrame
	Switches []*SwitchFrame
	Filters  []*FilterFrame
}

The TopoCfgFrame struc gives the highest level structure of the topology, is ultimately the encompassing dictionary in the serialization

func CreateTopoCfgFrame

func CreateTopoCfgFrame(name string) TopoCfgFrame

CreateTopoCfgFrame is a constructor.

func (*TopoCfgFrame) AddEndpt

func (tf *TopoCfgFrame) AddEndpt(endpt *EndptFrame)

AddEndpt adds a Endpt to the topology configuration (if it is not already present). Does not create an interface

func (*TopoCfgFrame) AddFilter

func (tf *TopoCfgFrame) AddFilter(filter *FilterFrame)

AddFilter adds a Filter to the topology configuration (if it is not already present)

func (*TopoCfgFrame) AddNetwork

func (tf *TopoCfgFrame) AddNetwork(net *NetworkFrame)

AddNetwork adds a Network to the topology configuration (if it is not already present)

func (*TopoCfgFrame) AddRouter

func (tf *TopoCfgFrame) AddRouter(rtr *RouterFrame)

AddRouter adds a Router to the topology configuration (if it is not already present)

func (*TopoCfgFrame) AddSwitch

func (tf *TopoCfgFrame) AddSwitch(swtch *SwitchFrame)

AddSwitch adds a Filter to the topology configuration (if it is not already present)

func (*TopoCfgFrame) Consolidate

func (tcf *TopoCfgFrame) Consolidate() error

Consolidate gathers endpts, switches, and routers from the networks added to the TopoCfgFrame, and make sure that all the devices referred to in the different components are exposed at the TopoCfgFrame level

func (*TopoCfgFrame) Transform

func (tf *TopoCfgFrame) Transform() TopoCfg

Transform transforms the slices of pointers to network objects into slices of instances of those objects, for serialization

type TraceManager

type TraceManager struct {
	// experiment uses trace
	InUse bool `json:"inuse" yaml:"inuse"`

	// name of experiment
	ExpName string `json:"expname" yaml:"expname"`

	// text name associated with each objId
	NameById map[int]NameType `json:"namebyid" yaml:"namebyid"`

	// all trace records for this experiment
	Traces map[int][]TraceRecord `json:"traces" yaml:"traces"`
}

TraceManger implements the mrnesbits TraceManager interface. It is use to gather information about a simulation model and an execution of that model

func CreateTraceManager

func CreateTraceManager(ExpName string, active bool) *TraceManager

CreateTraceManager is a constructor. It saves the name of the experiment and a flag indicating whether the trace manager is active. By testing this flag we can inhibit the activity of gathering a trace when we don't want it, while embedding calls to its methods everywhere we need them when it is

func (*TraceManager) Active

func (tm *TraceManager) Active() bool

Active tells the caller whether the Trace Manager is activelyl being used

func (*TraceManager) AddName

func (tm *TraceManager) AddName(id int, name string, objDesc string)

AddName is used to add an element to the id -> (name,type) dictionary for the trace file

func (*TraceManager) AddTrace

func (tm *TraceManager) AddTrace(vrt vrtime.Time, execId, connectId, objId int, op string,
	isPckt bool, rate float64)

AddTrace creates a record of the trace using its calling arguments, and stores it

func (*TraceManager) WriteToFile

func (tm *TraceManager) WriteToFile(filename string) bool

WriteToFile stores the Traces struct to the file whose name is given. Serialization to json or to yaml is selected based on the extension of this name.

type TraceRecord

type TraceRecord struct {
	Time      float64 // time in float64
	Ticks     int64   // ticks variable of time
	Priority  int64   // priority field of time-stamp
	ExecId    int     // integer identifier identifying the chain of traces this is part of
	ConnectId int     // integer identifier of the network connection
	ObjId     int     // integer id for object being referenced
	Op        string  // "start", "stop", "enter", "exit"
	Packet    bool    // true if the event marks the passage of a packet (rather than flow)
	Rate      float64 // rate associated with the connection
}

a TraceRecord saves information about the visitation of a message to some point in the simulation. saved for post-run analysis

Jump to

Keyboard shortcuts

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