simulation

package
v0.0.0-...-b9d447c Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: BSD-3-Clause Imports: 35 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DefaultCommandTimeout = time.Second * 10
	NodeExitTimeout       = time.Second * 3
	SendCoapResourceName  = "t"
	SendMcastPrefix       = "ff13::deed"
	SendUdpPort           = 10000
)
View Source
const (
	DefaultCslPeriod   = 3 * 1000               // in units of 160 us
	DefaultCslPeriodUs = 160 * DefaultCslPeriod // MUST be multiple of 160 us

)
View Source
const (
	DefaultChannel         = 11
	DefaultExtPanid        = "dead00beef00cafe"
	DefaultMeshLocalPrefix = "fdde:ad00:beef:0::"
	DefaultNetworkKey      = "00112233445566778899aabbccddeeff"
	DefaultNetworkName     = "otns"
	DefaultPanid           = 0xface
	DefaultPskc            = "3aa55f91ca47d1e4e71a08cb35e91591"
)

Variables

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

type ConnId struct {
	NodeIp6Addr netip.Addr
	ExtIp6Addr  netip.Addr
	NodePort    uint16
	ExtPort     uint16
}

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 KpiChannel struct {
	TxTimeUs     uint64  `json:"tx_time_us"`
	TxPercentage float64 `json:"tx_percent"`
	NumFrames    uint64  `json:"tx_frames"`
	AvgFps       float64 `json:"tx_avg_fps"`
}

type KpiCoap

type KpiCoap struct {
	Uri map[string]*KpiCoapUri `json:"uri"`
}

type KpiCoapUri

type KpiCoapUri struct {
	Count     uint64  `json:"tx"`
	CountLost uint64  `json:"tx_lost"`
	LatencyMs float64 `json:"avg_latency_ms"`
}

type KpiMac

type KpiMac struct {
	NoAckPercentage map[NodeId]float64 `json:"noack_percent"`
}

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 KpiTimeSec struct {
	StartTimeSec float64 `json:"start"`
	EndTimeSec   float64 `json:"end"`
	PeriodSec    float64 `json:"duration"`
}

type KpiTimeUs

type KpiTimeUs struct {
	StartTimeUs uint64 `json:"start"`
	EndTimeUs   uint64 `json:"end"`
	PeriodUs    uint64 `json:"duration"`
}

type LeaderData

type LeaderData struct {
	PartitionID       int
	Weighting         int
	DataVersion       int
	StableDataVersion int
	LeaderRouterID    int
}

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 *Node) CoapPostTestData(addr string, uri string, confirmable bool, dataSize int) error

func (*Node) Command

func (node *Node) Command(cmd string) []string

Command executes the command and waits for 'Done', or an 'Error', at end of output.

func (*Node) CommandChecked

func (node *Node) CommandChecked(cmd string) error

CommandChecked executes a command, does not provide any output lines, but returns error resulting from the cmd.

func (*Node) CommandExpectEnabledOrDisabled

func (node *Node) CommandExpectEnabledOrDisabled(cmd string) bool

func (*Node) CommandExpectHex

func (node *Node) CommandExpectHex(cmd string) int

func (*Node) CommandExpectInt

func (node *Node) CommandExpectInt(cmd string) int

func (*Node) CommandExpectString

func (node *Node) CommandExpectString(cmd string) string

func (*Node) CommandNoDone

func (node *Node) CommandNoDone(cmd string) ([]string, bool)

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

func (node *Node) CommandResult() error

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

func (node *Node) DumpStat() string

func (*Node) FactoryReset

func (node *Node) FactoryReset()

func (*Node) GetCcaThreshold

func (node *Node) GetCcaThreshold() RfSimParamValue

func (*Node) GetChannel

func (node *Node) GetChannel() int

func (*Node) GetChildList

func (node *Node) GetChildList() (childlist []int)

func (*Node) GetChildTimeout

func (node *Node) GetChildTimeout() int

func (*Node) GetContextReuseDelay

func (node *Node) GetContextReuseDelay() int

func (*Node) GetCounters

func (node *Node) GetCounters(counterType string, keyPrefix string) NodeCounters

func (*Node) GetCslAccuracy

func (node *Node) GetCslAccuracy() uint8

func (*Node) GetCslUncertainty

func (node *Node) GetCslUncertainty() uint8

func (*Node) GetEui64

func (node *Node) GetEui64() string

func (*Node) GetExecutableName

func (node *Node) GetExecutableName() string

func (*Node) GetExecutablePath

func (node *Node) GetExecutablePath() string

func (*Node) GetExtAddr

func (node *Node) GetExtAddr() uint64

func (*Node) GetExtPanid

func (node *Node) GetExtPanid() string

func (*Node) GetIfconfig

func (node *Node) GetIfconfig() string

func (*Node) GetIpAddr

func (node *Node) GetIpAddr() []string

func (*Node) GetIpAddrLinkLocal

func (node *Node) GetIpAddrLinkLocal() []string

func (*Node) GetIpAddrMleid

func (node *Node) GetIpAddrMleid() []string

func (*Node) GetIpAddrRloc

func (node *Node) GetIpAddrRloc() []string

func (*Node) GetIpAddrSlaac

func (node *Node) GetIpAddrSlaac() []string

func (*Node) GetIpMaddr

func (node *Node) GetIpMaddr() []string

func (*Node) GetIpMaddrPromiscuous

func (node *Node) GetIpMaddrPromiscuous() bool

func (*Node) GetJoinerPort

func (node *Node) GetJoinerPort() int

func (*Node) GetKeySequenceCounter

func (node *Node) GetKeySequenceCounter() int

func (*Node) GetKeySequenceGuardTime

func (node *Node) GetKeySequenceGuardTime() int

func (*Node) GetLeaderData

func (node *Node) GetLeaderData() (leaderData LeaderData)

func (*Node) GetLeaderWeight

func (node *Node) GetLeaderWeight() int

func (*Node) GetMode

func (node *Node) GetMode() string

func (*Node) GetNetworkKey

func (node *Node) GetNetworkKey() string

func (*Node) GetNetworkName

func (node *Node) GetNetworkName() string

func (*Node) GetPanid

func (node *Node) GetPanid() uint16

func (*Node) GetPromiscuous

func (node *Node) GetPromiscuous() bool

func (*Node) GetRfSimParam

func (node *Node) GetRfSimParam(param RfSimParam) RfSimParamValue

func (*Node) GetRloc16

func (node *Node) GetRloc16() uint16

func (*Node) GetRouterDowngradeThreshold

func (node *Node) GetRouterDowngradeThreshold() int

func (*Node) GetRouterEligible

func (node *Node) GetRouterEligible() bool

func (*Node) GetRouterSelectionJitter

func (node *Node) GetRouterSelectionJitter() int

func (*Node) GetRouterUpgradeThreshold

func (node *Node) GetRouterUpgradeThreshold() int

func (*Node) GetRxSensitivity

func (node *Node) GetRxSensitivity() int8

func (*Node) GetSingleton

func (node *Node) GetSingleton() bool

func (*Node) GetState

func (node *Node) GetState() string

func (*Node) GetThreadVersion

func (node *Node) GetThreadVersion() uint16

GetThreadVersion gets the Thread version integer of the OpenThread node.

func (*Node) GetVersion

func (node *Node) GetVersion() string

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

func (node *Node) Ping(addr string, payloadSize int, count int, interval float64, hopLimit int)

func (*Node) PromiscuousDisable

func (node *Node) PromiscuousDisable()

func (*Node) PromiscuousEnable

func (node *Node) PromiscuousEnable()

func (*Node) Reset

func (node *Node) Reset()

func (*Node) RouterEligibleDisable

func (node *Node) RouterEligibleDisable()

func (*Node) RouterEligibleEnable

func (node *Node) RouterEligibleEnable()

func (*Node) SendGroupMembership

func (node *Node) SendGroupMembership(groupId int, isMember bool) error

SendGroupMembership modifies multicast group membership for the groups used by the OTNS 'send' command.

func (*Node) SendInit

func (node *Node) SendInit() error

SendInit inits the node to participate in OTNS 'send' command sending or receiving.

func (*Node) SendReset

func (node *Node) SendReset() error

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 *Node) SetChildTimeout(timeout int)

func (*Node) SetContextReuseDelay

func (node *Node) SetContextReuseDelay(delay int)

func (*Node) SetCslAccuracy

func (node *Node) SetCslAccuracy(accPpm uint8)

func (*Node) SetCslUncertainty

func (node *Node) SetCslUncertainty(unc10us uint8)

func (*Node) SetEui64

func (node *Node) SetEui64(eui64 string)

func (*Node) SetExtAddr

func (node *Node) SetExtAddr(extaddr uint64)

func (*Node) SetExtPanid

func (node *Node) SetExtPanid(extpanid string)

func (*Node) SetJoinerPort

func (node *Node) SetJoinerPort(port int)

func (*Node) SetKeySequenceCounter

func (node *Node) SetKeySequenceCounter(counter int)

func (*Node) SetKeySequenceGuardTime

func (node *Node) SetKeySequenceGuardTime(guardtime int)

func (*Node) SetLeaderWeight

func (node *Node) SetLeaderWeight(weight int)

func (*Node) SetMode

func (node *Node) SetMode(mode string)

func (*Node) SetNetworkKey

func (node *Node) SetNetworkKey(key string)

func (*Node) SetNetworkName

func (node *Node) SetNetworkName(name string)

func (*Node) SetPanid

func (node *Node) SetPanid(panid uint16)

func (*Node) SetRfSimParam

func (node *Node) SetRfSimParam(param RfSimParam, value RfSimParamValue)

func (*Node) SetRouterDowngradeThreshold

func (node *Node) SetRouterDowngradeThreshold(timeout int)

func (*Node) SetRouterSelectionJitter

func (node *Node) SetRouterSelectionJitter(timeout int)

func (*Node) SetRouterUpgradeThreshold

func (node *Node) SetRouterUpgradeThreshold(timeout int)

func (*Node) SetRxSensitivity

func (node *Node) SetRxSensitivity(rxSens int8)

func (*Node) String

func (node *Node) String() string

func (*Node) ThreadStart

func (node *Node) ThreadStart() error

func (*Node) ThreadStop

func (node *Node) ThreadStop() error

func (*Node) UdpBindAny

func (node *Node) UdpBindAny(port int) error

func (*Node) UdpSend

func (node *Node) UdpSend(addr string, port int, data []byte) error

func (*Node) UdpSendTestData

func (node *Node) UdpSendTestData(addr string, port int, dataSize int) error

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

type NodeCounters map[string]uint64

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

func (s *Simulation) CountDown(duration time.Duration, text string)

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 UdpHeader

type UdpHeader struct {
	SrcPort, DstPort uint16
	Length           uint16
	Checksum         uint16
}

UdpHeader represents the header of a UDP datagram.

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

Jump to

Keyboard shortcuts

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