Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrDeviceNotRegistered = errors.New("device not registered with the ether")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Logger logr.Logger Clock clockwork.Clock PacketTransform PacketTransform }
Config configures the behaviour of the Ether
type Ether ¶
type Ether struct {
// contains filtered or unexported fields
}
Ether allows for modelling a radio transmission medium when using fake.Device to simulate radio devices
func (*Ether) RegisterDevice ¶
RegisterDevice connects a fake device to the ether so that its transmissions are propagated, and it may receive transmissions from other connected fake devices
func (*Ether) UnregisterDevice ¶
UnregisterDevice removes a fake device from the ether, preventing further transmissions from reaching this device
type PacketTransform ¶
type PacketTransform func(transmitter, receiver *fake.Device, packet []byte) TransformOutcome
A PacketTransform is both a predicate and map function for packets transmitted through the Ether: - If the resulting outcome has a nil packet then no packet will be delivered to the receiver - Otherwise the resulting packet will be scheduled to arrive after a specified delay
By providing custom PacketTransform functions, callers can add in logic to more accurately represent their transmission medium: adding in delays, corrupting the received packet, preventing receipt, etc.
func AddPacketDeliveryDelay ¶
func AddPacketDeliveryDelay(transform PacketTransform, delay time.Duration) PacketTransform
AddPacketDeliveryDelay takes a PacketTransform and adds a delay to the resulting TransformOutcome
type TransformOutcome ¶
TransformOutcome describes a packet that will be delivered to a receiver, created by a PacketTransform
func PerfectPacketTransform ¶
func PerfectPacketTransform(_, _ *fake.Device, packet []byte) TransformOutcome
PerfectPacketTransform is a simple PacketTransform that always delivers all packets with no arrival delay