dispatcher

package
v0.0.0-...-03c5170 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProcessEventTimeErrorUs = 0
	MaxSimulateSpeed        = 1000000
)
View Source
const (
	Ever uint64 = math.MaxUint64 / 2
)

Variables

View Source
var (
	NonFailTime = FailTime{0, 0}
)

Functions

This section is empty.

Types

type CallbackHandler

type CallbackHandler interface {
	OnNodeFail(nodeid NodeId)
	OnNodeRecover(nodeid NodeId)

	// Notifies that the node's UART was written with data.
	OnUartWrite(nodeid NodeId, data []byte)
}

type CoapCode

type CoapCode int

type CoapMessage

type CoapMessage struct {
	Timestamp uint64                `yaml:"time"`
	SrcNode   NodeId                `yaml:"src"`
	ID        int                   `yaml:"id"`
	Type      CoapType              `yaml:"type"`
	Code      CoapCode              `yaml:"code"`
	URI       string                `yaml:"uri,omitempty"`
	DstAddr   string                `yaml:"dst_addr"`
	DstPort   int                   `yaml:"dst_port"`
	Error     string                `yaml:"error,omitempty"`
	Receivers []CoapMessageRecvInfo `yaml:"receivers,flow"`
}

type CoapMessageRecvInfo

type CoapMessageRecvInfo struct {
	Timestamp uint64 `yaml:"time"`
	DstNode   NodeId `yaml:"dst"`
	SrcAddr   string `yaml:"src_addr"`
	SrcPort   int    `yaml:"src_port"`
}

type CoapType

type CoapType int
const (
	CoapTypeConfirmable    CoapType = 0
	CoapTypeNonConfirmable CoapType = 1
	CoapTypeAcknowledgment CoapType = 2
	CoapTypeReset          CoapType = 3
)

type Config

type Config struct {
	Speed       float64
	Real        bool
	Host        string
	Port        int
	DumpPackets bool
	NoPcap      bool
}

func DefaultConfig

func DefaultConfig() *Config

type Dispatcher

type Dispatcher struct {
	CurTime uint64

	Counters struct {
		// Event counters
		AlarmEvents      uint64
		RadioEvents      uint64
		StatusPushEvents uint64
		UartWriteEvents  uint64
		// Packet dispatching counters
		DispatchByExtAddrSucc   uint64
		DispatchByExtAddrFail   uint64
		DispatchByShortAddrSucc uint64
		DispatchByShortAddrFail uint64
		DispatchAllInRange      uint64
	}
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(ctx *progctx.ProgCtx, cfg *Config, cbHandler CallbackHandler) *Dispatcher

func (*Dispatcher) AddNode

func (d *Dispatcher) AddNode(nodeid NodeId, x, y int, radioRange int)

func (*Dispatcher) CollectCoapMessages

func (d *Dispatcher) CollectCoapMessages() []*CoapMessage

func (*Dispatcher) DeleteNode

func (d *Dispatcher) DeleteNode(id NodeId)

func (*Dispatcher) EnableCoaps

func (d *Dispatcher) EnableCoaps()

func (*Dispatcher) GetAliveCount

func (d *Dispatcher) GetAliveCount() int

func (*Dispatcher) GetFailedCount

func (d *Dispatcher) GetFailedCount() int

func (*Dispatcher) GetGlobalMessageDropRatio

func (d *Dispatcher) GetGlobalMessageDropRatio() float64

func (*Dispatcher) GetNode

func (d *Dispatcher) GetNode(id NodeId) *Node

func (*Dispatcher) GetSpeed

func (d *Dispatcher) GetSpeed() float64

func (*Dispatcher) GetVisualizationOptions

func (d *Dispatcher) GetVisualizationOptions() VisualizationOptions

func (*Dispatcher) GetVisualizer

func (d *Dispatcher) GetVisualizer() visualize.Visualizer

func (*Dispatcher) Go

func (d *Dispatcher) Go(duration time.Duration) <-chan struct{}

func (*Dispatcher) Nodes

func (d *Dispatcher) Nodes() map[NodeId]*Node

func (*Dispatcher) NotifyCommand

func (d *Dispatcher) NotifyCommand(nodeid NodeId)

func (*Dispatcher) NotifyExit

func (d *Dispatcher) NotifyExit(nodeid NodeId)

NotifyExit notifies the dispatcher that the node process has exited.

func (*Dispatcher) PostAsync

func (d *Dispatcher) PostAsync(trivial bool, task func())

func (*Dispatcher) RecvEvents

func (d *Dispatcher) RecvEvents() int

RecvEvents receives events from nodes until there is no more alive node.

func (*Dispatcher) Run

func (d *Dispatcher) Run()

func (*Dispatcher) SendToUART

func (d *Dispatcher) SendToUART(id NodeId, data []byte)

SendToUART sends data to virtual time UART of the target node.

func (*Dispatcher) SetGlobalPacketLossRatio

func (d *Dispatcher) SetGlobalPacketLossRatio(plr float64)

func (*Dispatcher) SetNodeFailed

func (d *Dispatcher) SetNodeFailed(id NodeId, fail bool)

func (*Dispatcher) SetNodePos

func (d *Dispatcher) SetNodePos(id NodeId, x, y int)

func (*Dispatcher) SetSpeed

func (d *Dispatcher) SetSpeed(f float64)

func (*Dispatcher) SetVisualizationOptions

func (d *Dispatcher) SetVisualizationOptions(opts VisualizationOptions)

func (*Dispatcher) SetVisualizer

func (d *Dispatcher) SetVisualizer(vis visualize.Visualizer)

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

func (*Dispatcher) UnwatchNode

func (d *Dispatcher) UnwatchNode(nodeid NodeId)

func (*Dispatcher) WatchNode

func (d *Dispatcher) WatchNode(nodeid NodeId)

type FailTime

type FailTime struct {
	FailDuration uint64
	FailInterval uint64
}

func (FailTime) CanFail

func (ft FailTime) CanFail() bool

type FailureCtrl

type FailureCtrl struct {
	// contains filtered or unexported fields
}

func (*FailureCtrl) OnTimeAdvanced

func (fc *FailureCtrl) OnTimeAdvanced(oldTime uint64)

func (*FailureCtrl) SetFailTime

func (fc *FailureCtrl) SetFailTime(failTime FailTime)

type JoinResult

type JoinResult struct {
	JoinDuration    uint64
	SessionDuration uint64
}

type Node

type Node struct {
	D           *Dispatcher
	Id          NodeId
	X, Y        int
	PartitionId uint32
	ExtAddr     uint64
	Rloc16      uint16
	CreateTime  uint64
	CurTime     uint64
	Role        OtDeviceRole
	// contains filtered or unexported fields
}

func (*Node) CollectJoins

func (node *Node) CollectJoins() []*JoinResult

func (*Node) CollectPings

func (node *Node) CollectPings() []*PingResult

func (*Node) DumpStat

func (node *Node) DumpStat() string

func (*Node) Fail

func (node *Node) Fail()

func (*Node) GetDistanceTo

func (node *Node) GetDistanceTo(other *Node) (dist int)

func (*Node) IsFailed

func (node *Node) IsFailed() bool

func (*Node) Recover

func (node *Node) Recover()

func (*Node) Send

func (node *Node) Send(elapsed uint64, data []byte)

func (*Node) SendMessage

func (node *Node) SendMessage(msg []byte)

func (*Node) SetFailTime

func (node *Node) SetFailTime(failTime FailTime)

func (*Node) String

func (node *Node) String() string

type OtJoinerState

type OtJoinerState int
const (
	OtJoinerStateIdle      OtJoinerState = 0
	OtJoinerStateDiscover  OtJoinerState = 1
	OtJoinerStateConnect   OtJoinerState = 2
	OtJoinerStateConnected OtJoinerState = 3
	OtJoinerStateEntrust   OtJoinerState = 4
	OtJoinerStateJoined    OtJoinerState = 5
)

type PingResult

type PingResult struct {
	Dst      string
	DataSize int
	Delay    uint64
}

type VisualizationOptions

type VisualizationOptions struct {
	BroadcastMessage bool
	UnicastMessage   bool
	AckMessage       bool
	RouterTable      bool
	ChildTable       bool
}

Jump to

Keyboard shortcuts

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