Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultNodeConfig() NodeConfig
- func NewSimulationController(sim *Simulation) visualize.SimulationController
- type CmdRunner
- type Config
- type ConnId
- type ExecutableConfig
- type Kpi
- type KpiChannel
- type KpiCoap
- type KpiCoapUri
- type KpiMac
- type KpiManager
- type KpiTimeSec
- type KpiTimeUs
- type LeaderData
- type Node
- func (node *Node) CoapPostTestData(addr string, uri string, confirmable bool, dataSize int) error
- func (node *Node) Command(cmd string) []string
- func (node *Node) CommandChecked(cmd string) error
- func (node *Node) CommandExpectEnabledOrDisabled(cmd string) bool
- func (node *Node) CommandExpectHex(cmd string) int
- func (node *Node) CommandExpectInt(cmd string) int
- func (node *Node) CommandExpectString(cmd string) string
- func (node *Node) CommandNoDone(cmd string) ([]string, bool)
- func (node *Node) CommandResult() error
- func (node *Node) DisplayPendingLines()
- func (node *Node) DisplayPendingLogEntries()
- func (node *Node) DumpStat() string
- func (node *Node) FactoryReset()
- func (node *Node) GetCcaThreshold() RfSimParamValue
- func (node *Node) GetChannel() int
- func (node *Node) GetChildList() (childlist []int)
- func (node *Node) GetChildTimeout() int
- func (node *Node) GetContextReuseDelay() int
- func (node *Node) GetCounters(counterType string, keyPrefix string) NodeCounters
- func (node *Node) GetCslAccuracy() uint8
- func (node *Node) GetCslUncertainty() uint8
- func (node *Node) GetEui64() string
- func (node *Node) GetExecutableName() string
- func (node *Node) GetExecutablePath() string
- func (node *Node) GetExtAddr() uint64
- func (node *Node) GetExtPanid() string
- func (node *Node) GetIfconfig() string
- func (node *Node) GetIpAddr() []string
- func (node *Node) GetIpAddrLinkLocal() []string
- func (node *Node) GetIpAddrMleid() []string
- func (node *Node) GetIpAddrRloc() []string
- func (node *Node) GetIpAddrSlaac() []string
- func (node *Node) GetIpMaddr() []string
- func (node *Node) GetIpMaddrPromiscuous() bool
- func (node *Node) GetJoinerPort() int
- func (node *Node) GetKeySequenceCounter() int
- func (node *Node) GetKeySequenceGuardTime() int
- func (node *Node) GetLeaderData() (leaderData LeaderData)
- func (node *Node) GetLeaderWeight() int
- func (node *Node) GetMode() string
- func (node *Node) GetNetworkKey() string
- func (node *Node) GetNetworkName() string
- func (node *Node) GetPanid() uint16
- func (node *Node) GetPromiscuous() bool
- func (node *Node) GetRfSimParam(param RfSimParam) RfSimParamValue
- func (node *Node) GetRloc16() uint16
- func (node *Node) GetRouterDowngradeThreshold() int
- func (node *Node) GetRouterEligible() bool
- func (node *Node) GetRouterSelectionJitter() int
- func (node *Node) GetRouterUpgradeThreshold() int
- func (node *Node) GetRxSensitivity() int8
- func (node *Node) GetSingleton() bool
- func (node *Node) GetState() string
- func (node *Node) GetThreadVersion() uint16
- func (node *Node) GetVersion() string
- func (node *Node) IfconfigDown()
- func (node *Node) IfconfigUp()
- func (node *Node) IpMaddrPromiscuousDisable()
- func (node *Node) IpMaddrPromiscuousEnable()
- func (node *Node) Ping(addr string, payloadSize int, count int, interval float64, hopLimit int)
- func (node *Node) PromiscuousDisable()
- func (node *Node) PromiscuousEnable()
- func (node *Node) Reset()
- func (node *Node) RouterEligibleDisable()
- func (node *Node) RouterEligibleEnable()
- func (node *Node) SendGroupMembership(groupId int, isMember bool) error
- func (node *Node) SendInit() error
- func (node *Node) SendReset() error
- func (node *Node) SetCcaThreshold(thresh RfSimParamValue)
- func (node *Node) SetChannel(ch ChannelId)
- func (node *Node) SetChildTimeout(timeout int)
- func (node *Node) SetContextReuseDelay(delay int)
- func (node *Node) SetCslAccuracy(accPpm uint8)
- func (node *Node) SetCslUncertainty(unc10us uint8)
- func (node *Node) SetEui64(eui64 string)
- func (node *Node) SetExtAddr(extaddr uint64)
- func (node *Node) SetExtPanid(extpanid string)
- func (node *Node) SetJoinerPort(port int)
- func (node *Node) SetKeySequenceCounter(counter int)
- func (node *Node) SetKeySequenceGuardTime(guardtime int)
- func (node *Node) SetLeaderWeight(weight int)
- func (node *Node) SetMode(mode string)
- func (node *Node) SetNetworkKey(key string)
- func (node *Node) SetNetworkName(name string)
- func (node *Node) SetPanid(panid uint16)
- func (node *Node) SetRfSimParam(param RfSimParam, value RfSimParamValue)
- func (node *Node) SetRouterDowngradeThreshold(timeout int)
- func (node *Node) SetRouterSelectionJitter(timeout int)
- func (node *Node) SetRouterUpgradeThreshold(timeout int)
- func (node *Node) SetRxSensitivity(rxSens int8)
- func (node *Node) String() string
- func (node *Node) ThreadStart() error
- func (node *Node) ThreadStop() error
- func (node *Node) UdpBindAny(port int) error
- func (node *Node) UdpSend(addr string, port int, data []byte) error
- func (node *Node) UdpSendTestData(addr string, port int, dataSize int) error
- type NodeAutoPlacer
- type NodeCounters
- type NodeCountersStore
- type NodeUartType
- type RadioStatsStore
- type SimConn
- type SimHostEndpoint
- type SimHosts
- type Simulation
- func (s *Simulation) AddNode(cfg *NodeConfig) (*Node, error)
- func (s *Simulation) AutoGo() bool
- func (s *Simulation) AutoGoRoutine(ctx *progctx.ProgCtx, sim *Simulation)
- func (s *Simulation) CountDown(duration time.Duration, text string)
- func (s *Simulation) DeleteNode(nodeid NodeId) error
- func (s *Simulation) Dispatcher() *dispatcher.Dispatcher
- func (s *Simulation) ExportNetwork() YamlNetworkConfig
- func (s *Simulation) ExportNodes(nwConfig *YamlNetworkConfig) []YamlNodeConfig
- func (s *Simulation) GetConfig() *Config
- func (s *Simulation) GetEnergyAnalyser() *energy.EnergyAnalyser
- func (s *Simulation) GetKpiManager() *KpiManager
- func (s *Simulation) GetLogLevel() logger.Level
- func (s *Simulation) GetNetworkInfo() visualize.NetworkInfo
- func (s *Simulation) GetNodes() []NodeId
- func (s *Simulation) GetSpeed() float64
- func (s *Simulation) Go(duration time.Duration) <-chan error
- func (s *Simulation) GoAtSpeed(duration time.Duration, speed float64) <-chan error
- func (s *Simulation) ImportNodes(nwConfig YamlNetworkConfig, nodes []YamlNodeConfig) error
- func (s *Simulation) IsStopping() bool
- func (s *Simulation) MaxNodeId() NodeId
- func (s *Simulation) MoveNodeTo(nodeid NodeId, x, y int, z *int) error
- func (s *Simulation) NodeConfigFinalize(nodeCfg *NodeConfig)
- func (s *Simulation) Nodes() map[NodeId]*Node
- func (s *Simulation) OnLogWrite(nodeid NodeId, data []byte)
- func (s *Simulation) OnMsgToHost(nodeid NodeId, evt *event.Event)
- func (s *Simulation) OnNextEventTime(nextTs uint64)
- func (s *Simulation) OnRfSimEvent(nodeid NodeId, evt *event.Event)
- func (s *Simulation) OnUartWrite(nodeid NodeId, data []byte)
- func (s *Simulation) PostAsync(f func()) bool
- func (s *Simulation) Run()
- func (s *Simulation) SetAutoGo(isAuto bool)
- func (s *Simulation) SetCmdRunner(cmdRunner CmdRunner)
- func (s *Simulation) SetLogLevel(level logger.Level)
- func (s *Simulation) SetNetworkInfo(networkInfo visualize.NetworkInfo)
- func (s *Simulation) SetNodeFailed(id NodeId, failed bool)
- func (s *Simulation) SetSpeed(speed float64)
- func (s *Simulation) SetTitleInfo(titleInfo visualize.TitleInfo)
- func (s *Simulation) SetVisualizer(vis visualize.Visualizer)
- func (s *Simulation) ShowDemoLegend(x int, y int, title string)
- func (s *Simulation) SimHosts() *SimHosts
- func (s *Simulation) Stop()
- func (s *Simulation) VisitNodesInOrder(cb func(node *Node))
- type UdpHeader
- type YamlConfigFile
- type YamlNetworkConfig
- type YamlNodeConfig
- type YamlScriptConfig
Constants ¶
const ( DefaultCommandTimeout = time.Second * 10 NodeExitTimeout = time.Second * 3 SendCoapResourceName = "t" SendMcastPrefix = "ff13::deed" SendUdpPort = 10000 )
const ( DefaultCslPeriod = 3 * 1000 // in units of 160 us DefaultCslPeriodUs = 160 * DefaultCslPeriod // MUST be multiple of 160 us )
const ( DefaultChannel = 11 DefaultExtPanid = "dead00beef00cafe" DefaultMeshLocalPrefix = "fdde:ad00:beef:0::" DefaultNetworkKey = "00112233445566778899aabbccddeeff" DefaultNetworkName = "otns" DefaultPanid = 0xface DefaultPskc = "3aa55f91ca47d1e4e71a08cb35e91591" )
Variables ¶
var (
CommandInterruptedError = fmt.Errorf("command interrupted due to simulation exit")
)
Functions ¶
func DefaultNodeConfig ¶
func DefaultNodeConfig() NodeConfig
func NewSimulationController ¶
func NewSimulationController(sim *Simulation) visualize.SimulationController
Types ¶
type CmdRunner ¶
type CmdRunner interface {
// RunCommand will let the CmdRunner execute/run the user's CLI cmd. CLI output is sent to 'output'.
RunCommand(cmd string, output io.Writer) error
// GetNodeContext returns the current CLI context as selected by the user, or InvalidNodeId if none.
GetNodeContext() NodeId
}
CmdRunner will point to an external package that can run a user's CLI commands.
type Config ¶
type Config struct {
ExeConfig ExecutableConfig
ExeConfigDefault ExecutableConfig
NewNodeConfig NodeConfig
NewNodeScripts *YamlScriptConfig
Speed float64
ReadOnly bool
Realtime bool
AutoGo bool
DumpPackets bool
DispatcherHost string
DispatcherPort int
RadioModel string
Id int
Channel ChannelId
LogLevel logger.Level
LogFileLevel logger.Level
RandomSeed prng.RandomSeed
OutputDir string
}
func DefaultConfig ¶
func DefaultConfig() *Config
type ConnId ¶
ConnId is a unique identifier/tuple for a TCP or UDP connection between a node and a simulated host.
type ExecutableConfig ¶
type ExecutableConfig struct {
Version string
Ftd string
Mtd string
Br string
SearchPaths []string
}
var DefaultExecutableConfig ExecutableConfig = ExecutableConfig{ Version: "", Ftd: "ot-cli-ftd", Mtd: "ot-cli-mtd", Br: "ot-cli-ftd_br", SearchPaths: []string{".", "./ot-rfsim/ot-versions", "./build/bin"}, }
func (*ExecutableConfig) FindExecutable ¶
func (cfg *ExecutableConfig) FindExecutable(exeName string) string
FindExecutable returns a full path to the named executable, by searching in standard search paths if needed. If the given exeName is already a full path itself, it will be returned itself.
func (*ExecutableConfig) FindExecutableBasedOnConfig ¶
func (cfg *ExecutableConfig) FindExecutableBasedOnConfig(nodeCfg *NodeConfig) string
FindExecutableBasedOnConfig gets the executable based on NodeConfig information.
func (*ExecutableConfig) SearchPathsString ¶
func (cfg *ExecutableConfig) SearchPathsString() string
func (*ExecutableConfig) SetVersion ¶
func (cfg *ExecutableConfig) SetVersion(version string, defaultConfig *ExecutableConfig)
SetVersion sets all executables to the defaults associated to the given Thread version number. The given defaultConfig is used as a base to derive the versioned executables from.
type Kpi ¶
type Kpi struct {
FileTime string `json:"created"`
Status string `json:"status"`
TimeUs KpiTimeUs `json:"time_us"`
TimeSec KpiTimeSec `json:"time_sec"`
Channels map[ChannelId]KpiChannel `json:"channels"`
Mac KpiMac `json:"mac"`
Counters map[NodeId]NodeCounters `json:"counters"`
CountersSum NodeCounters `json:"counters_sum"`
Coap KpiCoap `json:"coap"`
}
type KpiChannel ¶
type KpiCoap ¶
type KpiCoap struct {
Uri map[string]*KpiCoapUri `json:"uri"`
}
type KpiCoapUri ¶
type KpiManager ¶
type KpiManager struct {
// contains filtered or unexported fields
}
func NewKpiManager ¶
func NewKpiManager() *KpiManager
NewKpiManager creates a new KPI manager/bookkeeper for a particular simulation.
func (*KpiManager) Init ¶
func (km *KpiManager) Init(sim *Simulation)
Init inits the KPI manager for the given simulation.
func (*KpiManager) IsRunning ¶
func (km *KpiManager) IsRunning() bool
func (*KpiManager) SaveDefaultFile ¶
func (km *KpiManager) SaveDefaultFile()
func (*KpiManager) SaveFile ¶
func (km *KpiManager) SaveFile(fn string)
func (*KpiManager) Start ¶
func (km *KpiManager) Start()
func (*KpiManager) Stop ¶
func (km *KpiManager) Stop()
type KpiTimeSec ¶
type LeaderData ¶
type Node ¶
type Node struct {
S *Simulation
Id int
DNode *dispatcher.Node
Logger *logger.NodeLogger
// contains filtered or unexported fields
}
func (*Node) CoapPostTestData ¶
func (*Node) Command ¶
Command executes the command and waits for 'Done', or an 'Error', at end of output.
func (*Node) CommandChecked ¶
CommandChecked executes a command, does not provide any output lines, but returns error resulting from the cmd.
func (*Node) CommandExpectEnabledOrDisabled ¶
func (*Node) CommandExpectHex ¶
func (*Node) CommandExpectInt ¶
func (*Node) CommandExpectString ¶
func (*Node) CommandNoDone ¶
CommandNoDone executes the command without necessarily expecting 'Done' (e.g. it's a background command). It just reads output lines until the node is asleep. If nevertheless 'Done' is received, it returns the flag hasDoneOutput = true.
func (*Node) CommandResult ¶
CommandResult gets the last result of any Command...() call, either nil or an Error.
func (*Node) DisplayPendingLines ¶
func (node *Node) DisplayPendingLines()
func (*Node) DisplayPendingLogEntries ¶
func (node *Node) DisplayPendingLogEntries()
func (*Node) FactoryReset ¶
func (node *Node) FactoryReset()
func (*Node) GetCcaThreshold ¶
func (node *Node) GetCcaThreshold() RfSimParamValue
func (*Node) GetChannel ¶
func (*Node) GetChildList ¶
func (*Node) GetChildTimeout ¶
func (*Node) GetContextReuseDelay ¶
func (*Node) GetCounters ¶
func (node *Node) GetCounters(counterType string, keyPrefix string) NodeCounters
func (*Node) GetCslAccuracy ¶
func (*Node) GetCslUncertainty ¶
func (*Node) GetExecutableName ¶
func (*Node) GetExecutablePath ¶
func (*Node) GetExtAddr ¶
func (*Node) GetExtPanid ¶
func (*Node) GetIfconfig ¶
func (*Node) GetIpAddrLinkLocal ¶
func (*Node) GetIpAddrMleid ¶
func (*Node) GetIpAddrRloc ¶
func (*Node) GetIpAddrSlaac ¶
func (*Node) GetIpMaddr ¶
func (*Node) GetIpMaddrPromiscuous ¶
func (*Node) GetJoinerPort ¶
func (*Node) GetKeySequenceCounter ¶
func (*Node) GetKeySequenceGuardTime ¶
func (*Node) GetLeaderData ¶
func (node *Node) GetLeaderData() (leaderData LeaderData)
func (*Node) GetLeaderWeight ¶
func (*Node) GetNetworkKey ¶
func (*Node) GetNetworkName ¶
func (*Node) GetPromiscuous ¶
func (*Node) GetRfSimParam ¶
func (node *Node) GetRfSimParam(param RfSimParam) RfSimParamValue
func (*Node) GetRouterDowngradeThreshold ¶
func (*Node) GetRouterEligible ¶
func (*Node) GetRouterSelectionJitter ¶
func (*Node) GetRouterUpgradeThreshold ¶
func (*Node) GetRxSensitivity ¶
func (*Node) GetSingleton ¶
func (*Node) GetThreadVersion ¶
GetThreadVersion gets the Thread version integer of the OpenThread node.
func (*Node) GetVersion ¶
GetVersion gets the version string of the OpenThread node.
func (*Node) IfconfigDown ¶
func (node *Node) IfconfigDown()
func (*Node) IfconfigUp ¶
func (node *Node) IfconfigUp()
func (*Node) IpMaddrPromiscuousDisable ¶
func (node *Node) IpMaddrPromiscuousDisable()
func (*Node) IpMaddrPromiscuousEnable ¶
func (node *Node) IpMaddrPromiscuousEnable()
func (*Node) PromiscuousDisable ¶
func (node *Node) PromiscuousDisable()
func (*Node) PromiscuousEnable ¶
func (node *Node) PromiscuousEnable()
func (*Node) RouterEligibleDisable ¶
func (node *Node) RouterEligibleDisable()
func (*Node) RouterEligibleEnable ¶
func (node *Node) RouterEligibleEnable()
func (*Node) SendGroupMembership ¶
SendGroupMembership modifies multicast group membership for the groups used by the OTNS 'send' command.
func (*Node) SendInit ¶
SendInit inits the node to participate in OTNS 'send' command sending or receiving.
func (*Node) SendReset ¶
SendReset resets the node after, or before, using a series of OTNS 'send' commands.
func (*Node) SetCcaThreshold ¶
func (node *Node) SetCcaThreshold(thresh RfSimParamValue)
func (*Node) SetChannel ¶
func (node *Node) SetChannel(ch ChannelId)
func (*Node) SetChildTimeout ¶
func (*Node) SetContextReuseDelay ¶
func (*Node) SetCslAccuracy ¶
func (*Node) SetCslUncertainty ¶
func (*Node) SetExtAddr ¶
func (*Node) SetExtPanid ¶
func (*Node) SetJoinerPort ¶
func (*Node) SetKeySequenceCounter ¶
func (*Node) SetKeySequenceGuardTime ¶
func (*Node) SetLeaderWeight ¶
func (*Node) SetNetworkKey ¶
func (*Node) SetNetworkName ¶
func (*Node) SetRfSimParam ¶
func (node *Node) SetRfSimParam(param RfSimParam, value RfSimParamValue)
func (*Node) SetRouterDowngradeThreshold ¶
func (*Node) SetRouterSelectionJitter ¶
func (*Node) SetRouterUpgradeThreshold ¶
func (*Node) SetRxSensitivity ¶
func (*Node) ThreadStart ¶
func (*Node) ThreadStop ¶
func (*Node) UdpBindAny ¶
type NodeAutoPlacer ¶
type NodeAutoPlacer struct {
X, Y, Z int
Xref, Yref int
Xmax int
NodeDeltaCoarse int
NodeDeltaFine int
// contains filtered or unexported fields
}
func NewNodeAutoPlacer ¶
func NewNodeAutoPlacer() *NodeAutoPlacer
func (*NodeAutoPlacer) NextNodePosition ¶
func (nap *NodeAutoPlacer) NextNodePosition(isBelowParent bool) (int, int, int)
NextNodePosition lets the autoplacer pick the next position for a new node to be placed.
func (*NodeAutoPlacer) ReuseNextNodePosition ¶
func (nap *NodeAutoPlacer) ReuseNextNodePosition()
ReuseNextNodePosition instructs the autoplacer to re-use the NextNodePosition() that was given out in the last call to this method.
func (*NodeAutoPlacer) UpdateReference ¶
func (nap *NodeAutoPlacer) UpdateReference(x, y, z int)
UpdateReference updates the reference position of the NodeAutoPlacer to 'x', 'y'. It starts placing from there.
func (*NodeAutoPlacer) UpdateXReference ¶
func (nap *NodeAutoPlacer) UpdateXReference(x int)
UpdateXReference updates the reference X position of the NodeAutoPlacer to 'x'. It starts placing from there.
func (*NodeAutoPlacer) UpdateYReference ¶
func (nap *NodeAutoPlacer) UpdateYReference(y int)
UpdateYReference updates the reference Y position of the NodeAutoPlacer to 'y'. It starts placing from there.
type NodeCounters ¶
NodeCounters keeps track of a node's internal diagnostic counters.
func (NodeCounters) Add ¶
func (nc NodeCounters) Add(other NodeCounters)
type NodeCountersStore ¶
type NodeCountersStore map[NodeId]NodeCounters
type NodeUartType ¶
type NodeUartType int
type RadioStatsStore ¶
type RadioStatsStore map[ChannelId]KpiChannel
type SimConn ¶
type SimConn struct {
Node *Node // assumes a single BR also handles the return traffic.
Conn net.Conn
Nat66State *event.MsgToHostEventData
PortMapped uint16 // real localhost ::1 port on simulator machine, on which sim-host's port is mapped.
UdpBytesUpstream uint64 // total bytes UDP payload from node to sim-host (across all BRs)
UdpBytesDownstream uint64 // total bytes UDP payload from sim-host to node (across all BRs)
}
SimConn is a two-way connection between a node's port and a sim-host's port.
type SimHostEndpoint ¶
type SimHostEndpoint struct {
HostName string
Ip6Addr netip.Addr
Port uint16 // destination UDP/TCP port as specified by the simulated node.
PortMapped uint16 // actual sim-host port on [::1] to which specified port is mapped.
}
SimHostEndpoint represents a single endpoint (port) of a sim-host, potentially interacting with N >= 0 nodes.
type SimHosts ¶
type SimHosts struct {
Hosts map[SimHostEndpoint]struct{}
Conns map[ConnId]*SimConn
// contains filtered or unexported fields
}
SimHosts manages all connections between nodes and simulated hosts.
func NewSimHosts ¶
func NewSimHosts() *SimHosts
func (*SimHosts) AddHost ¶
func (sh *SimHosts) AddHost(host SimHostEndpoint) error
func (*SimHosts) GetRxBytes ¶
func (sh *SimHosts) GetRxBytes(host *SimHostEndpoint) uint64
func (*SimHosts) GetTxBytes ¶
func (sh *SimHosts) GetTxBytes(host *SimHostEndpoint) uint64
func (*SimHosts) Init ¶
func (sh *SimHosts) Init(sim *Simulation)
func (*SimHosts) RemoveHost ¶
func (sh *SimHosts) RemoveHost(host SimHostEndpoint)
type Simulation ¶
type Simulation struct {
Started chan struct{}
Exited chan struct{}
// contains filtered or unexported fields
}
func NewSimulation ¶
func NewSimulation(ctx *progctx.ProgCtx, cfg *Config, dispatcherCfg *dispatcher.Config) (*Simulation, error)
func (*Simulation) AddNode ¶
func (s *Simulation) AddNode(cfg *NodeConfig) (*Node, error)
AddNode adds a node to the simulation as defined by the config cfg.
func (*Simulation) AutoGo ¶
func (s *Simulation) AutoGo() bool
func (*Simulation) AutoGoRoutine ¶
func (s *Simulation) AutoGoRoutine(ctx *progctx.ProgCtx, sim *Simulation)
func (*Simulation) DeleteNode ¶
func (s *Simulation) DeleteNode(nodeid NodeId) error
func (*Simulation) Dispatcher ¶
func (s *Simulation) Dispatcher() *dispatcher.Dispatcher
func (*Simulation) ExportNetwork ¶
func (s *Simulation) ExportNetwork() YamlNetworkConfig
ExportNetwork exports config info of network to a YAML-friendly object.
func (*Simulation) ExportNodes ¶
func (s *Simulation) ExportNodes(nwConfig *YamlNetworkConfig) []YamlNodeConfig
ExportNodes exports config/position info of all nodes to a YAML-friendly object.
func (*Simulation) GetConfig ¶
func (s *Simulation) GetConfig() *Config
func (*Simulation) GetEnergyAnalyser ¶
func (s *Simulation) GetEnergyAnalyser() *energy.EnergyAnalyser
func (*Simulation) GetKpiManager ¶
func (s *Simulation) GetKpiManager() *KpiManager
func (*Simulation) GetLogLevel ¶
func (s *Simulation) GetLogLevel() logger.Level
func (*Simulation) GetNetworkInfo ¶
func (s *Simulation) GetNetworkInfo() visualize.NetworkInfo
func (*Simulation) GetNodes ¶
func (s *Simulation) GetNodes() []NodeId
GetNodes returns a sorted array of NodeIds.
func (*Simulation) GetSpeed ¶
func (s *Simulation) GetSpeed() float64
func (*Simulation) Go ¶
func (s *Simulation) Go(duration time.Duration) <-chan error
Go runs the simulation for duration at Dispatcher's set speed.
func (*Simulation) GoAtSpeed ¶
func (s *Simulation) GoAtSpeed(duration time.Duration, speed float64) <-chan error
GoAtSpeed stops any ongoing (previous) 'go' period and then runs simulation for duration at given speed.
func (*Simulation) ImportNodes ¶
func (s *Simulation) ImportNodes(nwConfig YamlNetworkConfig, nodes []YamlNodeConfig) error
func (*Simulation) IsStopping ¶
func (s *Simulation) IsStopping() bool
func (*Simulation) MaxNodeId ¶
func (s *Simulation) MaxNodeId() NodeId
MaxNodeId gets the largest Node Id of current nodes in the simulation.
func (*Simulation) MoveNodeTo ¶
func (s *Simulation) MoveNodeTo(nodeid NodeId, x, y int, z *int) error
func (*Simulation) NodeConfigFinalize ¶
func (s *Simulation) NodeConfigFinalize(nodeCfg *NodeConfig)
NodeConfigFinalize finalizes the configuration for a new Node before it's used to create it. This is not mandatory to call, but a convenience method for the caller to avoid setting all details itself.
func (*Simulation) Nodes ¶
func (s *Simulation) Nodes() map[NodeId]*Node
func (*Simulation) OnLogWrite ¶
func (s *Simulation) OnLogWrite(nodeid NodeId, data []byte)
OnLogWrite notifies the simulation that a node has generated a new log line/item. It is part of implementation of dispatcher.CallbackHandler.
func (*Simulation) OnMsgToHost ¶
func (s *Simulation) OnMsgToHost(nodeid NodeId, evt *event.Event)
func (*Simulation) OnNextEventTime ¶
func (s *Simulation) OnNextEventTime(nextTs uint64)
func (*Simulation) OnRfSimEvent ¶
func (s *Simulation) OnRfSimEvent(nodeid NodeId, evt *event.Event)
func (*Simulation) OnUartWrite ¶
func (s *Simulation) OnUartWrite(nodeid NodeId, data []byte)
OnUartWrite notifies the simulation that a node has received some data from UART. It is part of implementation of dispatcher.CallbackHandler.
func (*Simulation) PostAsync ¶
func (s *Simulation) PostAsync(f func()) bool
PostAsync will post an asynchronous simulation task in the queue for execution @return true when post was successful, false if not (e.g. when sim exited)
func (*Simulation) Run ¶
func (s *Simulation) Run()
func (*Simulation) SetAutoGo ¶
func (s *Simulation) SetAutoGo(isAuto bool)
func (*Simulation) SetCmdRunner ¶
func (s *Simulation) SetCmdRunner(cmdRunner CmdRunner)
func (*Simulation) SetLogLevel ¶
func (s *Simulation) SetLogLevel(level logger.Level)
func (*Simulation) SetNetworkInfo ¶
func (s *Simulation) SetNetworkInfo(networkInfo visualize.NetworkInfo)
func (*Simulation) SetNodeFailed ¶
func (s *Simulation) SetNodeFailed(id NodeId, failed bool)
func (*Simulation) SetSpeed ¶
func (s *Simulation) SetSpeed(speed float64)
func (*Simulation) SetTitleInfo ¶
func (s *Simulation) SetTitleInfo(titleInfo visualize.TitleInfo)
func (*Simulation) SetVisualizer ¶
func (s *Simulation) SetVisualizer(vis visualize.Visualizer)
func (*Simulation) ShowDemoLegend ¶
func (s *Simulation) ShowDemoLegend(x int, y int, title string)
func (*Simulation) SimHosts ¶
func (s *Simulation) SimHosts() *SimHosts
func (*Simulation) Stop ¶
func (s *Simulation) Stop()
func (*Simulation) VisitNodesInOrder ¶
func (s *Simulation) VisitNodesInOrder(cb func(node *Node))
type YamlConfigFile ¶
type YamlConfigFile struct {
ScriptConfig YamlScriptConfig `yaml:"script"`
NetworkConfig YamlNetworkConfig `yaml:"network"`
NodesList []YamlNodeConfig `yaml:"nodes"`
}
YamlConfigFile is the complete YAML structure for a config file for load/save.
func (*YamlConfigFile) MinNodeId ¶
func (yc *YamlConfigFile) MinNodeId() NodeId
type YamlNetworkConfig ¶
type YamlNetworkConfig struct {
Position [3]int `yaml:"pos-shift,flow"` // provides an optional 3D position shift of all nodes.
RadioRange *int `yaml:"radio-range,omitempty"` // provides optional default radio-range.
BaseId *int `yaml:"base-id,omitempty"` // provides an optional node ID base (offset) for all nodes.
}
YamlNetworkConfig is a global network config that can be loaded/saved in YAML.
type YamlNodeConfig ¶
type YamlNodeConfig struct {
ID int `yaml:"id"`
Type string `yaml:"type"` // Node type (router, sed, fed, br, etc.)
Version *string `yaml:"version,omitempty"` // Thread version string or "" for default
Position [3]int `yaml:"pos,flow"`
RadioRange *int `yaml:"radio-range,omitempty"`
}
YamlNodeConfig is a node config that can be loaded/saved in YAML.
type YamlScriptConfig ¶
type YamlScriptConfig struct {
Mtd string `yaml:"mtd"`
Ftd string `yaml:"ftd"`
Br string `yaml:"br"`
All string `yaml:"all"`
}
YamlScriptConfig defines startup scripts for nodes, depending on node type.
func DefaultNodeScripts ¶
func DefaultNodeScripts() *YamlScriptConfig
func ReadNodeScript ¶
func ReadNodeScript(fn string) (*YamlScriptConfig, error)
func (*YamlScriptConfig) BuildBrScript ¶
func (ys *YamlScriptConfig) BuildBrScript() []string
func (*YamlScriptConfig) BuildFtdScript ¶
func (ys *YamlScriptConfig) BuildFtdScript() []string
func (*YamlScriptConfig) BuildMtdScript ¶
func (ys *YamlScriptConfig) BuildMtdScript() []string