mrnesbits

package module
v0.0.0-...-9b76104 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

package mrnesbits implements a discrete-event simulator of computations distributed across a network, according to the MrNesbits design (Multiresolution Network and Emulation Simulator for BITS)

Index

Constants

This section is empty.

Variables

View Source
var Algorithms []string = []string{"rsa", "aes", "rsa-3072", "rsa-2048", "rsa-1024"}
View Source
var CmpPtnInstByID map[int]*CmpPtnInst = make(map[int]*CmpPtnInst)
View Source
var CmpPtnInstByName map[string]*CmpPtnInst = make(map[string]*CmpPtnInst)

CmpPtnInstByName and CmpPtnInstByID take the the name (alt., id) of an instance of a CompPattern, and associate a pointer to its struct

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

ExpParamObjs holds 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 FuncClassNames map[string][]string = map[string][]string{"SelectDst": {"return-op", "initiate-op"}, "CryptoSrvr": {"encrypt-op", "decrypt-op"},
	"PassThru": {"process-op"}, "FlowEndpt": {"initiate-op", "genflow-op", "sink-op"},
	"GenPckt": {"initiate-op", "return-op"}, "PcktProcess": {"process-op"}}
View Source
var FuncClasses map[string]FuncClass = make(map[string]FuncClass)

FuncClasses is a map that takes us from the name of a FuncClass

View Source
var NumIDs int = 0

NumIDs holds value that utility function used for generating unique integer ids on demand

Functions

func BuildExperimentCP

func BuildExperimentCP(syn map[string]string, useYAML bool, idCounter int, tm TraceManager) (*evtm.EventManager, error)

BuildExperimentCP 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. It returns a pointer to an EventManager data structure used to coordinate the execution of events in the simulation.

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)

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

func CheckReadableFiles

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

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

func ClassCreateCryptoSrvr

func ClassCreateCryptoSrvr() *cryptoSrvr

func ClassCreateGenPckt

func ClassCreateGenPckt() *genPckt

func ClassCreatePcktProcess

func ClassCreatePcktProcess() *pcktProcess

func CmpPtnFuncHost

func CmpPtnFuncHost(cpfi *CmpPtnFuncInst) string

func CmpPtnFuncInstHost

func CmpPtnFuncInstHost(cpfi *CmpPtnFuncInst) string

CmpPtnFuncInstHost returns the name of the host to which the CmpPtnFuncInst given as argument is mapped.

func EmptyInitFunc

func EmptyInitFunc(evtMgr *evtm.EventManager, cpFunc any, cpMsg any) any

EmptyInitFunc exists to detect when there is actually an initialization event handler

func EnterFunc

func EnterFunc(evtMgr *evtm.EventManager, cpFunc any, cpMsg any) any

EnterFunc is an event-handling routine, scheduled by an evtm.EventManager to execute and simulate the results of a message arrival to a CmpPtnInst function. The particular CmpPtnInst and particular message are given as arguments to the function. A type-unspecified return is provided.

func ExitFunc

func ExitFunc(evtMgr *evtm.EventManager, cpFunc any, cpMsg any) any

ExitFunc is an event handling routine that implements the scheduling of messages which result from the completed (simulated) execution of a CmpPtnFuncInst. The CmpPtnFuncInst and the message that triggered the execution are given as arguments to ExitFunc. This routine calls the CmpPtnFuncInst's function that computes the effect of doing the simulation, a routine which (by the CmpPtnFuncInst interface definition) returns a slice of CmpPtnMsgs which are then pushed further along the CompPattern chain.

func FuncExecTime

func FuncExecTime(cpfi *CmpPtnFuncInst, op string, hardware string, msg *CmpPtnMsg) float64

FuncExecTime returns the increase in execution time resulting from executing the CmpPtnFuncInst offered as argument, to the message also offered as argument. If the pcktlen of the message does not exactly match the pcktlen parameter of a func timing entry, an interpolation or extrapolation of existing entries is performed.

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 GetExperimentCPDicts

func GetExperimentCPDicts(syn map[string]string) (*CompPatternDict, *CPInitListDict, *FuncExecList, *CompPatternMapDict)

GetExperimentCPDicts accepts a map that holds the names of the input files used to define an experiment, creates internal representations of the information they hold, and returns those structs.

func LostCmpPtnMsg

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

LostCmpPtnMsg is scheduled from the mrnes side to report the loss of a comp pattern message

func ReEnter

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

ReEnter is scheduled from the mrnes side to report the delivery

func RegisterFuncClass

func RegisterFuncClass(fc FuncClass) bool

RegisterFuncClass is called to tell the system that a particular function class exists, and gives a point to its description. The idea is to register only those function classes actually used, or at least, provide clear separation between classes. Return of bool allows call to RegisterFuncClass as part of a variable assignment outside of a function body

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 ReportStatistics

func ReportStatistics()

func UpdateMsg

func UpdateMsg(msg *CmpPtnMsg, srcLabel, msgType, dstLabel, edgeLabel string)

func ValidateParameter

func ValidateParameter(paramObj, attribute, param string) error

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

Types

type CPInitList

type CPInitList struct {
	// label of the Computation Pattern whose Funcs are being initialized
	Name string `json:"name" yaml:"name"`

	// CPType of CP being initialized
	CPType string `json:"cptype" yaml:"cptype"`

	// UseYAML flags whether to interpret the seriaized initialization structure using json or yaml
	UseYAML bool `json:"useyaml" yaml:"useyaml"`

	// Params is indexed by Func label, mapping to a serialized representation of a struct
	Params map[string]string `json:"params" yaml:"params"`

	// Params is indexed by Func label, mapping to a serialized representation of a struct
	State map[string]string `json:"state" yaml:"state"`

	// Msgs holds a list of CompPatternMsgs used between Funcs in a CompPattern
	Msgs []CompPatternMsg `json:"msgs" yaml:"msgs"`
}

CPInitList describes configuration parameters for the Funcs of a CompPattern

func CreateCPInitList

func CreateCPInitList(name string, cptype string, useYAML bool) *CPInitList

CreateCPInitList constructs a CPInitList and initializes it with a name and flag indicating whether YAML is used

func ReadCPInitList

func ReadCPInitList(filename string, useYAML bool, dict []byte) (*CPInitList, error)

ReadCPInitList returns a deserialized slice of bytes into a CPInitList. Bytes are either provided, or are read from a file whose name is given.

func (*CPInitList) AddMsg

func (cpil *CPInitList) AddMsg(msg *CompPatternMsg) error

AddMsg appends description of a ComPatternMsg to the CPInitList's slice of messages used by the CompPattern. An error is returned if the msg's type already exists in the Msgs list

func (*CPInitList) AddParam

func (cpil *CPInitList) AddParam(label, param string)

AddParam puts a serialized initialization struct in the dictionary indexed by Func label

func (*CPInitList) AddState

func (cpil *CPInitList) AddState(label, state string)

AddState puts a serialized initialization struct in the dictionary indexed by Func label

func (*CPInitList) WriteToFile

func (cpil *CPInitList) WriteToFile(filename string) error

WriteToFile serializes the CPInitList and writes it to a file. Output file extension identifies whether serialization is to json or to yaml

type CPInitListDict

type CPInitListDict struct {
	Prebuilt bool   `json:"prebuilt" yaml:"prebuilt"`
	DictName string `json:"dictname" yaml:"dictname"`

	// indexed by name of comp pattern
	InitList map[string]CPInitList `json:"initlist" yaml:"initlist"`
}

CPInitListDict holds CPInitList structures in a dictionary that may hold prebuilt versions (in which case InitList is indexed by CompPattern type) or is holding init lists for CPs to be part of an experiment, so the CP name is known is used as the key

func CreateCPInitListDict

func CreateCPInitListDict(name string, preblt bool) *CPInitListDict

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

func ReadCPInitListDict

func ReadCPInitListDict(filename string, useYAML bool, dict []byte) (*CPInitListDict, error)

ReadCPInitListDict deserializes a slice of bytes and returns a CPInitListDict. Bytes are either provided, or are read from a file whose name is given.

func (*CPInitListDict) AddCPInitList

func (cpild *CPInitListDict) AddCPInitList(cpil *CPInitList, overwrite bool) error

AddCPInitList puts a CPInitList into the dictionary, selectively warning if this would overwrite

func (*CPInitListDict) RecoverCPInitList

func (cpild *CPInitListDict) RecoverCPInitList(cptype string, cpname string) (*CPInitList, bool)

RecoverCPInitList returns a copy of a CPInitList from the dictionary, using the Prebuilt flag to choose index key, and applys a name

func (*CPInitListDict) WriteToFile

func (cpild *CPInitListDict) WriteToFile(filename string) error

WriteToFile serializes the CPInitListDict and writes it to a file. Output file extension identifies whether serialization is to json or to yaml

type CmpPtnFuncInst

type CmpPtnFuncInst struct {
	InitFunc evtm.EventHandlerFunction // if not 'emptyInitFunc' call this to initialize the function
	InitMsg  *CmpPtnMsg                // message that is copied when this instance is used to initiate a chain of func evaluations

	Label string // an identifier for this func, unique within the instance of CompPattern holding it.

	PtnName string // name of the instantiated CompPattern holding this function

	State            any     // holds string-coded state for string-code state variable names
	Reflect          bool    // whether the direction of the cmpHdr be return
	InterarrivalDist string  // for self-initiation
	InterarrivalMean float64 // for self-initiation

	// at run-time start-up this function is initialized with its responses
	// the set of potential output edges may be constrained, but not statefulermined solely by the input edge as with the static model.
	// Here, for a given input edge, 'resp' holds a slice of possible responses.
	Resp map[InEdge][]funcOutEdge
	// contains filtered or unexported fields
}

The CmpPtnFuncInst struct represents an instantiated instance of a function

constrained to the 'statefulerminisitc' execution model.

func (*CmpPtnFuncInst) AddEndMethod

func (cpfi *CmpPtnFuncInst) AddEndMethod(methodCode string, end evtm.EventHandlerFunction) bool

AddEndMethod includes a customized End method to a previously defined respMethod

func (*CmpPtnFuncInst) AddResponse

func (cpfi *CmpPtnFuncInst) AddResponse(execID int, resp []*CmpPtnMsg)

AddResponse stores the selected out message response from executing the function, to be released later. Saving through cpfi.Resp[execID] to account for concurrent overlapping executions

func (*CmpPtnFuncInst) AddStartMethod

func (cpfi *CmpPtnFuncInst) AddStartMethod(methodCode string, start StartMethod) bool

AddStartMethod associates a string response 'name' with a pair of methods used to represent the start and end of the function's execution. The default method for the end method is ExitFunc Return of bool allows call to RegisterFuncClass as part of a variable assignment outside of a function body

func (*CmpPtnFuncInst) GlobalName

func (cpfi *CmpPtnFuncInst) GlobalName() string

func (*CmpPtnFuncInst) InitMsgParams

func (cpfi *CmpPtnFuncInst) InitMsgParams(msgType string, msgLen, pcktLen int, rate float64)

type CmpPtnGraph

type CmpPtnGraph struct {

	// every instance a function has a string 'label', used here to index to
	// data structure that describes it and the connections it has with other funcs
	Nodes map[string]*CmpPtnGraphNode
}

A CmpPtnGraph is the run-time description of a CompPattern

type CmpPtnGraphEdge

type CmpPtnGraphEdge struct {
	SrcLabel  string
	MsgType   string
	DstLabel  string
	EdgeLabel string
}

CmpPtnGraphEdge declares the possibility that a function with label srcLabel might send a message of type msgType to the function (in the same CPG) with label dstLabel

func CreateCmpPtnGraphEdge

func CreateCmpPtnGraphEdge(srcLabel, msgType, dstLabel, edgeLabel string) CmpPtnGraphEdge

type CmpPtnGraphNode

type CmpPtnGraphNode struct {
	Label    string
	InEdges  []*CmpPtnGraphEdge
	OutEdges []*CmpPtnGraphEdge
}

A CmpPtnGraphNode names a function with its label, and describes the edges for which it is a destination (inEdges) and edges for which it is a source (outEdges)

type CmpPtnInst

type CmpPtnInst struct {
	Rngs  *rngstream.RngStream
	Graph *CmpPtnGraph // graph describing structure of funcs and edges
	// contains filtered or unexported fields
}

CmpPtnInst describes a particular instance of a CompPattern, built from information read in from CompPatternDesc struct and used at runtime

func (*CmpPtnInst) EndRecExec

func (cpi *CmpPtnInst) EndRecExec(execID int, time float64, completed bool) float64

EndRecExec computes the completed execution time of the execution identified, given the ending time, incorporates its statistics into the CmpPtnInst statistics summary

func (*CmpPtnInst) ExecReport

func (cpi *CmpPtnInst) ExecReport()

ExecReport computes and reports 95% confidence intervals on the execution time of an exection trace initiated at a labeled source on the cpi

type CmpPtnMsg

type CmpPtnMsg struct {
	ExecID int    // initialize when with an initating comp pattern message.  Carried by every resulting message.
	SrcCP  string // name of comp pattern instance from which the message originates
	DstCP  string // name of comp pattern instance to which the message is directed

	// what essential role does 'Edge' convey?
	Edge CmpPtnGraphEdge

	// do we need/want CmpHdr?
	CmpHdr EndPts

	MsgType string  // describes function of message
	MsgLen  int     // number of bytes
	PcktLen int     // parameter impacting execution time
	Rate    float64 // when non-zero, a rate limiting attribute that might used, e.g., in modeling IO
	Payload any     // free for "something else" to carry along and be used in decision logic
}

A CmpPtnMsg struct describes a message going from one CompPattern function to another. It carries ancillary information about the message that is included for referencing.

func CreateCmpPtnMsg

func CreateCmpPtnMsg(edge CmpPtnGraphEdge, srt, end string, msgType string, msgLen int, pcktLen int, rate float64, SrcCP, DstCP string,
	payload any, execID int) *CmpPtnMsg

CreateCmpPtnMsg is a constructor whose arguments are all the attributes needed to make a CmpPtnMsg. One is created and returnedl

type CompPattern

type CompPattern struct {
	// a model may use a number of instances of CompPatterns that have the same CPType
	CPType string `json:"cptype" yaml:"cptype"`

	// per-instance name of the pattern template
	Name string `json:"name" yaml:"name"`

	// instances of functions indexed by unique-to-pattern label
	Funcs []Func `json:"funcs" yaml:"funcs"`

	// description of edges in Pattern graph
	Edges []PatternEdge `json:"edges" yaml:"edges"`
}

CompPattern is a directed graph that describes the data flow among functions that implement an end-to-end computation

func CreateCompPattern

func CreateCompPattern(cmptnType string) *CompPattern

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

func (*CompPattern) AddEdge

func (cpt *CompPattern) AddEdge(srcFuncLabel, dstFuncLabel string, msgType string, edgeLabel string)

AddEdge creates an edge that describes message flow from one Func to another in the same comp pattern and adds it to the CompPattern's list of edges

func (*CompPattern) AddFunc

func (cpt *CompPattern) AddFunc(fs *Func)

AddFunc includes a function specification to a CompPattern

func (*CompPattern) GetInEdges

func (cpt *CompPattern) GetInEdges(srcLabel, dstLabel string) []InEdge

GetInEdges returns a list of InEdges that match the specified source and destination

func (*CompPattern) GetOutEdges

func (cpt *CompPattern) GetOutEdges(srcLabel, dstLabel string) []OutEdge

GetOutEdges returns a list of OutEdges that match the specified source and destination

type CompPatternDict

type CompPatternDict struct {
	Prebuilt bool                   `json:"prebuilt" yaml:"prebuilt"`
	DictName string                 `json:"dictname" yaml:"dictname"`
	Patterns map[string]CompPattern `json:"patterns" yaml:"patterns"`
}

CompPatternDict holds pattern descriptions, is serializable

func CreateCompPatternDict

func CreateCompPatternDict(name string, preblt bool) *CompPatternDict

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

func ReadCompPatternDict

func ReadCompPatternDict(filename string, useYAML bool, dict []byte) (*CompPatternDict, error)

ReadCompPatternDict returns the transformation of a slice of bytes into a CompPatternDict, reading these from file if necessary.

func (*CompPatternDict) AddCompPattern

func (cpd *CompPatternDict) AddCompPattern(ptn *CompPattern, prb bool, overwrite bool) error

AddCompPattern amends a CompPattern dictionary with another CompPattern. The prb flag indicates this is saved to a 'pre-built' dictionary from which selected CompPatterns are recovered when building a model. CP names are not created until build time, so the key used to read/write a CompPattern from the Patterns dictionary is the CompPattern cptype when accessing a prb dictionary, and the name otherwise so the CP type is used as a key when true, otherwise the CP name is known and used. If requested, and error is returned if the comp pattern being added is a duplicate.

func (*CompPatternDict) RecoverCompPattern

func (cpd *CompPatternDict) RecoverCompPattern(cptype string, cpname string) (*CompPattern, bool)

RecoverCompPattern returns a copy of a CompPattern from the dictionary, indexing by type, and applying a name

func (*CompPatternDict) WriteToFile

func (cpd *CompPatternDict) WriteToFile(filename string) error

WriteToFile serializes the comp pattern, and saves to the named file. Output file extension determines whether serialization is to json or yaml

type CompPatternMap

type CompPatternMap struct {
	// PatternName identifies the name of the pattern instantiation being mapped
	PatternName string `json:"patternname" yaml:"patternname"`

	// mapping of func labels to hosts. Key is Label attribute of Func
	FuncMap map[string]string `json:"funcmap" yaml:"funcmap"`
}

A CompPatternMap describes how funcs in an instantiated CompPattern are mapped to hosts

func CreateCompPatternMap

func CreateCompPatternMap(ptnName string) *CompPatternMap

CreateCompPatternMap is a constructor.

func ReadCompPatternMap

func ReadCompPatternMap(filename string, useYAML bool, dict []byte) (*CompPatternMap, error)

ReadCompPatternMap deserializes a byte slice holding a representation of an CompPatternMap 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 (*CompPatternMap) AddMapping

func (cpm *CompPatternMap) AddMapping(funcLabel string, hostname string, overwrite bool) error

AddMapping inserts into the CompPatternMap a binding of Func label to a host. Optionally, an error might be returned if a binding of that Func has already been made, and is different.

func (*CompPatternMap) WriteToFile

func (cpm *CompPatternMap) WriteToFile(filename string) error

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

type CompPatternMapDict

type CompPatternMapDict struct {
	DictName string                    `json:"dictname" yaml:"dictname"`
	Map      map[string]CompPatternMap `json:"map" yaml:"map"`
}

A CompPatternMapDict holds copies of CompPatternMap structs in a map that is indexed by the PatternName of resident CompPatternMaps

var CmpPtnMapDict *CompPatternMapDict

func CreateCompPatternMapDict

func CreateCompPatternMapDict(name string) *CompPatternMapDict

CreateCompPatternMapDict is a constructor. Saves the dictionary name and initializes the map of CompPatternMaps to-be-stored.

func ReadCompPatternMapDict

func ReadCompPatternMapDict(filename string, useYAML bool, dict []byte) (*CompPatternMapDict, error)

ReadCompPatternMapDict deserializes a byte slice holding a representation of an CompPatternMapDict 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 (*CompPatternMapDict) AddCompPatternMap

func (cpmd *CompPatternMapDict) AddCompPatternMap(cpm *CompPatternMap, overwrite bool) error

AddCompPatternMap includes in the dictionary a CompPatternMap that is provided as input. Optionally an error may be returned if an entry for the associated CompPattern exists already.

func (*CompPatternMapDict) RecoverCompPatternMap

func (cpmd *CompPatternMapDict) RecoverCompPatternMap(pattern string) (*CompPatternMap, bool)

RecoverCompPatternMap returns a CompPatternMap associated with the CompPattern named in the input parameters. It returns also a flag denoting whether the identified CompPattern has an entry in the dictionary.

func (*CompPatternMapDict) WriteToFile

func (cpmd *CompPatternMapDict) WriteToFile(filename string) error

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

type CompPatternMsg

type CompPatternMsg struct {
	// edges in the CompPattern graph are labeled with MsgType, which means that a message across the edge must match in this attribute
	MsgType string `json:"msgtype" yaml:"msgtype"`

	// a message may be a packet or a flow
	IsPckt bool `json:"ispckt" yaml:"ispckt"`

	// PcktLen is a parameter used by some functions to select their execution time.  Not the same as the length of the message carrying the packet
	PcktLen int `json:"pcktlen" yaml:"pcktlen"`

	// MsgLen is the total length of the message c
	MsgLen int `json:"msglen" yaml:"msglen"`
}

CompPatternMsg defines the structure of identification of messages that pass between Funcs in a CompPattern. Structures of this sort are transformed by a simulation run into a form that include experiment-defined payloads, and so representation of payload is absent here,

func CreateCompPatternMsg

func CreateCompPatternMsg(msgType string, pcktLen int, msgLen int) *CompPatternMsg

CreateCompPatternMsg is a constructer.

type EndPts

type EndPts struct {
	SrtLabel string
	EndLabel string
}

EndPts carries information on a CmpPtnMsg about where the execution thread started, and holds a place for a destination

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

func (expcfg *ExpCfg) AddParameter(paramObj, attribute, 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 (expcfg *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"`

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

  • ParamObj identifies the kind of thing being configured : Switch, Router, Host, Interface, or Network
  • Attribute identifies a class of objects of that type to which the configuration parameter should apply. May be "*" for a wild-card, may be "name%%xxyy" where "xxyy" is the object's identifier, may be a comma-separated list of other attributes, documented [here]

func CreateExpParameter

func CreateExpParameter(paramObj, attribute, param, value string) *ExpParameter

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

type Func

type Func struct {
	// identifies function, e.g., encryptRSA, used to look up execution time
	Class string `json:"class" yaml:"class"`

	// particular name given to function instance within a CompPattern
	Label string `json:"label" yaml:"label"`

	// name that is globally unique within a model, used for addressing
	GblName string `json:"gblname" yaml:"gblname"`
}

A Func represents a function used within a CompPattern. Its 'Label' attribute is an identifier for an instance of the Func that is unique among all Funcs that make up a CompPattern which uses it, and the Class attribute is an identifier used when Func describes are stored in a dictionary before being copied and assembled as part of CompPattern construction. Class typically describes the computation the Func represents.

func CreateFunc

func CreateFunc(class, funcLabel string) *Func

CreateFunc is a constructor for a Func. All parameters are given:

  • Class, a string identifying what instances of this Func do. Like a variable type.
  • FuncLabel, a unique identifier (within an instance of a CompPattern) of an instance of this Func

func (*Func) SerializeParameters

func (fd *Func) SerializeParameters(params any, useYAML bool) (string, error)

SerializeParameters returns a serialization of the input parameter struct given as an argument.

type FuncClass

type FuncClass interface {
	Class() string
	InitState(*CmpPtnFuncInst, string, bool)
}

A FuncClass represents the methods used to simulate the effect of executing a function, different types of input generate different types of responses, so we use a map whose key selects the start, end pair of methods

type FuncExecDesc

type FuncExecDesc struct {
	Class    string  `json:"class" yaml:"class"`
	Hardware string  `json:"processortype" yaml:"processortype"`
	PcktLen  int     `json:"pcktlen" yaml:"pcktlen"`
	ExecTime float64 `json:"exectime" yaml:"exectime"`
}

A FuncExecDesc struct holds a description of a function timing. ExecTime is the time (in seconds), attributes it depends on are

	Hardware - the CPU,
 PcktLen - number of bytes in data packet being operated on

type FuncExecList

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

	// Times key is class of CompPattern function.
	// Value is list of function times for that type of function
	Times map[string][]FuncExecDesc `json:"times" yaml:"times"`
}

A FuncExecList holds a map (Times) whose key is the class of a Func, and whose value is a list of FuncExecDescs associated with all Funcs of that class

func CreateFuncExecList

func CreateFuncExecList(listname string) *FuncExecList

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

func ReadFuncExecList

func ReadFuncExecList(filename string, useYAML bool, dict []byte) (*FuncExecList, error)

ReadFuncExecList deserializes a byte slice holding a representation of an FuncExecList 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 (*FuncExecList) AddTiming

func (fel *FuncExecList) AddTiming(class, hardware string, pcktLen int, execTime float64)

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

func (*FuncExecList) WriteToFile

func (fel *FuncExecList) WriteToFile(filename string) error

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

type FuncParameters

type FuncParameters struct {
	// Pattern is name of the CompPattern holding labeled node these parameters modify
	PatternName string `json:"patternname" yaml:"patternname"`

	// Label of function whose parameters are specified
	Label string `json:"label" yaml:"label"`

	// Global name of function whose parameters are specified
	GblName string `json:"gblname" yaml:"gblname"`

	// State variables and their initial values (string-encoded)
	State string `json:"state" yaml:"state"`

	// Response holds a list of all responses the Func may make
	Response []FuncResp `json:"response" yaml:"response"`
}

A FuncParameters struct holds information for initializing a Func. It names the label of the Func within an instantiated CompPattern, and the name of that CompPattern. It holds a string-to-string map which when filled out carries to the Func representation a general vehicle for defining state variables and initializing them. The 'FuncSelect' attribute contains a code that the Func uses to select from among different (user pre-defined) behaviors in response to a message. 'Response' is a list of input-output edge responses associated with a Func. N.B. that a given input edge may be specified in multiple responses.

func CreateFuncParameters

func CreateFuncParameters(ptn, label, gblname string) *FuncParameters

CreateFuncParameters is a constructor. Its arguments initialize all the struct attributes except for the slice of responses, which it just initializes.

func DecodeFuncParameters

func DecodeFuncParameters(paramStr string, useYAML bool) (*FuncParameters, error)

DecodeFuncParameters deserializes and returns a "FuncParameters" structure from a string that encodes its serialization

func (*FuncParameters) AddResponse

func (fp *FuncParameters) AddResponse(inEdge InEdge, outEdge OutEdge, methodCode string)

AddResponse takes the parameters of a response, creates a FuncResp struct, and includes it in the struct's list of responses

func (*FuncParameters) AddResponseChoice

func (fp *FuncParameters) AddResponseChoice(inEdge InEdge, outEdge OutEdge, choice string)

AddResponseChoice finds the response associated with the InEdge/OutEdge and sets its choice

func (*FuncParameters) AddState

func (fp *FuncParameters) AddState(state string)

AddState includes a string that encodes a state initialization block for the function and includes it in the struct's list of responses

func (*FuncParameters) Serialize

func (fp *FuncParameters) Serialize(useYAML bool) (string, error)

Serialize returns a serialized representation of the FuncParameters struct, in either json or yaml form, depending on the input parameter 'useYAML'. If the serialization generates an error it is returned

with an empty string as the serialization result.

type FuncResp

type FuncResp struct {
	// input edge
	InEdge InEdge `json:"inedge" yaml:"inedge"`

	// potential output edge
	OutEdge OutEdge `json:"outedge" yaml:"outedge"`

	// operation performed on input
	MethodCode string

	// an identifier used by the logic which chooses an output edge.
	Choice string `json:"choice" yaml:"choice"`
}

A FuncResp maps an InEdge to an outEdgeStruct, which for a Func with static execution type means an input received on the InEdge _may_ generate in response a message on the OutEdge. 'Choice is an identifier used by the Func's logic for selecting an output edge.

type InEdge

type InEdge struct {
	SrcLabel string `json:"srclabel" yaml:"srclabel"`
	MsgType  string `json:"msgtype" yaml:"msgtype"`
}

An InEdge describes the source Func of an incoming edge, and the type of message it carries.

var EmptyInEdge InEdge

func InEdgeMsg

func InEdgeMsg(cmp *CmpPtnMsg) InEdge

InEdgeMsg returns the InEdge structure embedded in a CmpPtnMsg

type NetSimPortal

type NetSimPortal interface {
	HostCPU(string) string
	EnterNetwork(*evtm.EventManager, string, string, int, int, float64, any,
		any, evtm.EventHandlerFunction, any, evtm.EventHandlerFunction) any
}

NetSimPortal provides an interface to network simulator

type OutEdge

type OutEdge struct {
	MsgType  string `json:"msgtype" yaml:"msgtype"`
	DstLabel string `json:"dstlabel" yaml:"dstlabel"`
}

An OutEdge describes the destination Func of an outbound edge, and the type of message it carries.

var EmptyOutEdge OutEdge

type PatternEdge

type PatternEdge struct {
	SrcLabel  string `json:"srclabel" yaml:"srclabel"`
	DstLabel  string `json:"dstlabel" yaml:"dstlabel"`
	MsgType   string `json:"msgtype" yaml:"msgtype"`
	EdgeLabel string `json:"edgelabel" yaml:"edgelabel"`
}

A PatternEdge exists between the Funcs whose labels are given as SrcLabel and DstLabel. The edge is denoted to have a message type, and also a 'weight' whose use and interpretation depends on the Funcs whose labels are given

func CreatePatternEdge

func CreatePatternEdge(srcLabel, dstLabel, msgType, edgeLabel string) *PatternEdge

CreatePatternEdge is a constructor.

type RespMethod

type RespMethod struct {
	Start StartMethod
	End   evtm.EventHandlerFunction
}

RespMethod associates two RespFunc that implement a function's response, one when it starts, the other when it ends

type TraceManager

type TraceManager interface {

	// at creation a flag is set indicating whether the trace manager will be active
	Active() bool

	// add a trace event to the manager
	AddTrace(vrtime.Time, int, int, int, string, bool, float64)

	// include an id -> (name, type) pair in the trace manager dictionary
	AddName(int, string, string)

	// save the trace to file (if active) and return flag indicating whether file creatation actually happened
	WriteToFile(string) bool
}

The TraceManager interface helps integrate use of the mrnes functionality for managing traces in this (different) model

Jump to

Keyboard shortcuts

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