simulation

package
v0.0.0-...-565450b Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: BSD-3-Clause Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DefaultChannel         = 11
	DefaultChannelMask     = 0x07fff800
	DefaultExtPanid        = "dead00beef00cafe"
	DefaultMeshLocalPrefix = "fdde:ad00:beef:0::"
	DefaultNetworkKey      = "00112233445566778899aabbccddeeff"
	DefaultNetworkName     = "otns"
	DefaultPanid           = 0xface
	DefaultPskc            = "3aa55f91ca47d1e4e71a08cb35e91591"
	DefaultSecurityPolicy  = "672 onrc"
)
View Source
const (
	DefaultCommandTimeout = time.Second * 10
)

Variables

View Source
var (
	DoneOrErrorRegexp = regexp.MustCompile(`(Done|Error \d+: .*)`)
)

Functions

func NewSimulationController

func NewSimulationController(sim *Simulation) visualize.SimulationController

Types

type CmdRunner

type CmdRunner interface {
	RunCommand(cmd string, output io.Writer) error
}

type Config

type Config struct {
	NetworkKey     string
	Panid          uint16
	Channel        int
	OtCliPath      string
	Speed          float64
	ReadOnly       bool
	RawMode        bool
	Real           bool
	DispatcherHost string
	DispatcherPort int
	DumpPackets    bool
}

func DefaultConfig

func DefaultConfig() *Config

type LeaderData

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

type Node

type Node struct {
	S  *Simulation
	Id int
	// contains filtered or unexported fields
}

func (*Node) AssurePrompt

func (node *Node) AssurePrompt()

func (*Node) Command

func (node *Node) Command(cmd string, timeout time.Duration) []string

func (*Node) CommandExpectEnabledOrDisabled

func (node *Node) CommandExpectEnabledOrDisabled(cmd string, timeout time.Duration) bool

func (*Node) CommandExpectHex

func (node *Node) CommandExpectHex(cmd string, timeout time.Duration) int

func (*Node) CommandExpectInt

func (node *Node) CommandExpectInt(cmd string, timeout time.Duration) int

func (*Node) CommandExpectNone

func (node *Node) CommandExpectNone(cmd string, timeout time.Duration)

func (*Node) CommandExpectString

func (node *Node) CommandExpectString(cmd string, timeout time.Duration) string

func (*Node) ConfigActiveDataset

func (node *Node) ConfigActiveDataset(channel int, networkkey string, panid uint16)

func (*Node) DumpStat

func (node *Node) DumpStat() string

func (*Node) Exit

func (node *Node) Exit() error

func (*Node) FactoryReset

func (node *Node) FactoryReset()

func (*Node) GetChannel

func (node *Node) GetChannel() int

func (*Node) GetChildList

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

func (*Node) GetChildTable

func (node *Node) GetChildTable()

func (*Node) GetChildTimeout

func (node *Node) GetChildTimeout() int

func (*Node) GetContextReuseDelay

func (node *Node) GetContextReuseDelay() int

func (*Node) GetEui64

func (node *Node) GetEui64() 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) 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) GetLeaderPartitionId

func (node *Node) GetLeaderPartitionId() int

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

func (node *Node) GetSingleton() bool

func (*Node) GetState

func (node *Node) GetState() string

func (*Node) GetVersion

func (node *Node) GetVersion() string

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

func (node *Node) IsFED() bool

func (*Node) Ping

func (node *Node) Ping(addr string, payloadSize int, count int, interval int, 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) SetChannel

func (node *Node) SetChannel(ch int)

func (*Node) SetChildTimeout

func (node *Node) SetChildTimeout(timeout int)

func (*Node) SetContextReuseDelay

func (node *Node) SetContextReuseDelay(delay int)

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

func (node *Node) SetLeaderPartitionId(partitionid 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) 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) SetupNetworkParameters

func (node *Node) SetupNetworkParameters(sim *Simulation)

func (*Node) Start

func (node *Node) Start()

func (*Node) Stop

func (node *Node) Stop()

func (*Node) String

func (node *Node) String() string

func (*Node) ThreadStart

func (node *Node) ThreadStart()

func (*Node) ThreadStop

func (node *Node) ThreadStop()

func (*Node) TryExpectLine

func (node *Node) TryExpectLine(line interface{}, timeout time.Duration) (bool, []string)

type NodeConfig

type NodeConfig struct {
	ID             int
	X, Y           int
	IsMtd          bool
	IsRouter       bool
	RxOffWhenIdle  bool
	RadioRange     int
	ExecutablePath string
	Restore        bool
}

func DefaultNodeConfig

func DefaultNodeConfig() *NodeConfig

type NodeUartType

type NodeUartType int
const (
	NodeUartTypeUndefined   NodeUartType = iota
	NodeUartTypeRealTime    NodeUartType = iota
	NodeUartTypeVirtualTime NodeUartType = iota
)

type Simulation

type Simulation 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)

func (*Simulation) Channel

func (s *Simulation) Channel() int

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

func (s *Simulation) GetNetworkInfo() visualize.NetworkInfo

func (*Simulation) GetSpeed

func (s *Simulation) GetSpeed() float64

func (*Simulation) Go

func (s *Simulation) Go(duration time.Duration) <-chan struct{}

func (*Simulation) IsStopped

func (s *Simulation) IsStopped() bool

IsStopped returns if the simulation is already stopped.

func (*Simulation) MoveNodeTo

func (s *Simulation) MoveNodeTo(nodeid NodeId, x, y int)

func (*Simulation) NetworkKey

func (s *Simulation) NetworkKey() string

func (*Simulation) Nodes

func (s *Simulation) Nodes() map[NodeId]*Node

func (*Simulation) OnNodeFail

func (s *Simulation) OnNodeFail(nodeid NodeId)

func (*Simulation) OnNodeRecover

func (s *Simulation) OnNodeRecover(nodeid NodeId)

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

func (s *Simulation) Panid() uint16

func (*Simulation) PostAsync

func (s *Simulation) PostAsync(trivial bool, f func())

func (*Simulation) Run

func (s *Simulation) Run()

func (*Simulation) SetCmdRunner

func (s *Simulation) SetCmdRunner(cmdRunner CmdRunner)

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

func (s *Simulation) Stop()

func (*Simulation) VisitNodesInOrder

func (s *Simulation) VisitNodesInOrder(cb func(node *Node))

Jump to

Keyboard shortcuts

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