class

RNS::Channel(TPacket)

Inherits Reference < Object

Provides ordered, reliable, bidirectional message delivery over a ChannelOutletBase transport (typically a Link).

Messages are assigned monotonically increasing 16-bit sequence numbers, transmitted with automatic retry on timeout, and delivered to registered callbacks in sequence order. A sliding window controls how many unacknowledged messages may be in flight; the window size adapts dynamically based on measured RTT.

Constants

FAST_RATE_THRESHOLD = 10
RTT_FAST = 0.18
RTT_MEDIUM = 0.75
RTT_SLOW = 1.45
SEQ_MAX = 65535_u16
SEQ_MODULUS = 65536_u32
WINDOW = 2

─── Window constants ───────────────────────────────────────

WINDOW_FLEXIBILITY = 4
WINDOW_MAX = WINDOW_MAX_FAST
WINDOW_MAX_FAST = 48
WINDOW_MAX_MEDIUM = 12
WINDOW_MAX_SLOW = 5
WINDOW_MIN = 2
WINDOW_MIN_LIMIT_FAST = 16
WINDOW_MIN_LIMIT_MEDIUM = 5
WINDOW_MIN_LIMIT_SLOW = 2

Constructors

new(outlet : ChannelOutletBase(TPacket))
Source

Instance methods

_get_packet_timeout_time(tries : Int32) : Float64

Compute packet timeout based on tries, RTT, and tx_ring size.

Source
_receive(raw : Bytes)

Process incoming raw bytes as a channel message.

Source
_register_message_type(message_class : MessageBase.class, *, is_system_type : Bool = false)
Source
_set_next_sequence(seq : UInt16)

Test helper: set the next outbound sequence number.

Source
add_message_handler(callback : MessageBase -> Bool)

Adds a callback invoked for each incoming message, in registration order. Return true from the callback to consume the message and stop further handler dispatch; return false to pass it along.

Source
fast_rate_rounds
Source
fast_rate_rounds=(fast_rate_rounds : Int32)
Source
is_ready_to_send?

Returns true when the channel can accept another outbound message. This requires the underlying outlet to be usable and the number of outstanding (undelivered) messages to be below the current window size.

Source
mdu

Returns the Maximum Data Unit available for message payloads, which is the outlet's MDU minus the 6-byte envelope header (2 bytes each for msgtype, sequence, and length). Capped at 0xFFFF.

Source
medium_rate_rounds
Source
medium_rate_rounds=(medium_rate_rounds : Int32)
Source
register_message_type(message_class : MessageBase.class)

Registers a MessageBase subclass so the channel can instantiate it when a matching msgtype is received. The class must have a msgtype value below 0xf000; system-reserved types are rejected.

Source
remove_message_handler(callback : MessageBase -> Bool)

Removes a previously registered message handler. No-op if the callback is not currently registered.

Source
send(message : MessageBase) : Envelope(TPacket)

Packs and transmits a message over the channel. The message is assigned the next sequence number, serialized via Envelope#pack, and handed to the outlet. Delivery and timeout callbacks are installed for automatic retry.

Raises ChannelException (ME_LINK_NOT_READY) if the channel is not ready, or (ME_TOO_BIG) if the packed message exceeds the outlet's MDU.

Source
shutdown

Shut down the channel, clearing callbacks and rings.

Source
window

─── Instance state ─────────────────────────────────────────

Source
window=(window : Int32)

─── Instance state ─────────────────────────────────────────

Source
window_flexibility
Source
window_flexibility=(window_flexibility : Int32)
Source
window_max
Source
window_max=(window_max : Int32)
Source
window_min
Source
window_min=(window_min : Int32)
Source