Documentation ¶
Index ¶
- type AdapterEvent
- type ConnectionAdapter
- type ConnectionAdapterOptions
- type ConnectionAdapterState
- func NewConnectedState(options ConnectionAdapterOptions, eventChannel chan<- AdapterEvent, ...) ConnectionAdapterState
- func NewConnectingInboundState(options ConnectionAdapterOptions, eventChannel chan<- AdapterEvent, ...) ConnectionAdapterState
- func NewConnectingOutboundState(options ConnectionAdapterOptions, eventChannel chan<- AdapterEvent, ...) ConnectionAdapterState
- type ConnectionMode
- type EventType
- type Forwarder
- type ForwarderOptions
- type Item
- type MessageHeap
- type MessageHeapOptions
- type PriorityQueue
- type Window
- type WindowOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdapterEvent ¶
type AdapterEvent struct { ConnectionId messages.ConnectionID Type EventType Message string Error error }
type ConnectionAdapter ¶
type ConnectionAdapter interface { // Start starts the connection Start() error // Stop stops the connection Close() error // Send sends a message to the connection Send(msg messages.Message) }
func NewInboundConnectionAdapter ¶
func NewInboundConnectionAdapter(options ConnectionAdapterOptions, uplink uplink.Uplink, eventChannel chan<- AdapterEvent) ConnectionAdapter
NewConnectionAdapter creates a new connection adapter for an inbound connection.
func NewOutboundConnectionAdapter ¶
func NewOutboundConnectionAdapter(options ConnectionAdapterOptions, connection net.Conn, uplink uplink.Uplink, eventChannel chan<- AdapterEvent) ConnectionAdapter
NewConnectionAdapter creates a new connection adapter for an outbound connection.
type ConnectionAdapterOptions ¶
type ConnectionAdapterOptions struct { // ConnectionID is the connection id ConnectionId messages.ConnectionID // LocalDeviceId is the id of the local device LocalDeviceId uuid.UUID // PeerDeviceId is the id of the peer device that this connection is bridged to/from PeerDeviceId uuid.UUID // PeerDevicePublicKey is the public key of the peer device that this connection is bridged to/from PeerDevicePublicKey string // BridgeOptions are the bridge options BridgeOptions messages.BridgeOptions // LocalPublicKey is the public key of the local device LocalPublicKey string // LocalPrivateKey is the private key of the local device LocalPrivateKey string // ResponseInterval is the interval in which the connection accept/failed message is sent ResponseInterval time.Duration // ConnectionReadTimeout is the read timeout for the connection ConnectionReadTimeout time.Duration // ThroughputLimit is the throughput limit for the connection in bytes per second ThroughputLimit int // ReadBufferSize is the size of the read buffer in bytes ReadBufferSize int }
type ConnectionAdapterState ¶
type ConnectionAdapterState interface { Start() error Stop() error Close() error HandleMessage(msg messages.Message) (ConnectionAdapterState, error) }
func NewConnectedState ¶
func NewConnectedState(options ConnectionAdapterOptions, eventChannel chan<- AdapterEvent, uplink uplink.Uplink, forwarder Forwarder) ConnectionAdapterState
func NewConnectingInboundState ¶
func NewConnectingInboundState(options ConnectionAdapterOptions, eventChannel chan<- AdapterEvent, uplink uplink.Uplink) ConnectionAdapterState
func NewConnectingOutboundState ¶
func NewConnectingOutboundState(options ConnectionAdapterOptions, eventChannel chan<- AdapterEvent, uplink uplink.Uplink, conn net.Conn) ConnectionAdapterState
type ConnectionMode ¶
type ConnectionMode string
const ( // Inbound is the inbound connection mode, i.e. the connection is bridged to this relay. Inbound ConnectionMode = "inbound" // Outbound is the outbound connection mode, i.e. the connection is bridged from this relay. Outbound ConnectionMode = "outbound" )
type Forwarder ¶
type Forwarder interface { // Start starts the forwarder, returns a channel to which messages can be sent Start() error // AsyncSend sends a message asynchronously, returns an error if the send buffer is full SendAsync(msg messages.Message) error // Ack acknowledges a message, returns an error if the message is not found Ack(seqNo uint64, re bool) error // Stop stops the forwarder, and closes the send channel and the underlying connection Close() error }
Forwarder controls the flow of messages from and to spider. It is responsible to acknowledge messages and to process acks.
func NewForwarder ¶
func NewForwarder(options ForwarderOptions, conn net.Conn, uplink uplink.Uplink, encryption encryption.Encryption, eventChannel chan<- AdapterEvent) Forwarder
NewForwarder creates a new forwarder.
type ForwarderOptions ¶
type ForwarderOptions struct { // Throughput is the maximum throughput in bytes per second Throughput int // LocalDeviceId is the id of the local device LocalDeviceID uuid.UUID // PeerDeviceId is the id of the peer device that this connection is bridged to/from PeerDeviceID uuid.UUID // ConnectionId is the connection id ConnectionID messages.ConnectionID // ReadTimeout is the read timeout ReadTimeout time.Duration // ReadBufferSize is the size of the read buffer in bytes ReadBufferSize int }
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
An Item is something we manage in a priority queue.
type MessageHeap ¶
type MessageHeap interface { // Test checks if the sequence number of msg is the next expected sequence number n_seq. // If it is, it returns a sequence of messages that are ready to be sent to the // port. The first message in the sequence is msg. // // The sequence is guaranteed to be in order, and contains no gaps, i.e. the // sequence number of the last message in the sequence is n_seq + len(sequence) - 1. // // If n_seq is not the next expected sequence number, it is kept in the queue until // a message with the next expected sequence number is received and a sequence // containing that message is returned. // // If the sequence number of msg is less than n_seq, it is considered an old message // and will be discarded. // // If the queue is full, or if the gap between n_seq and the sequence number of msg is // larger than MaxQueueGap, it returns an error. Test(msg messages.DataMessage) ([]messages.DataMessage, error) }
func NewMessageHeap ¶
func NewMessageHeap(options MessageHeapOptions) MessageHeap
type MessageHeapOptions ¶
type MessageHeapOptions struct { // MaxQueueSize is the maximum number of messages that can be queued MaxQueueSize int // MaxQueueGap is the maximum number of messages that can be missing from the queue MaxQueueGap int }
func NewDefaultMessageHeapOptions ¶
func NewDefaultMessageHeapOptions() MessageHeapOptions
type PriorityQueue ¶
type PriorityQueue []*Item
A PriorityQueue implements heap.Interface and holds Items.
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() any
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x any)
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)
type Window ¶
type Window interface {
// contains filtered or unexported methods
}
func NewWindow ¶
func NewWindow(ctx context.Context, options WindowOptions, uplink uplink.Uplink, encoderDecoder encoder.EncoderDecoder, encryption encryption.Encryption) Window
type WindowOptions ¶
type WindowOptions struct { // initial size of the window in bytes InitialCap float64 // minimum rtt variance of the window in microseconds MinRTTVAR float64 // minimum rto of the window in microseconds MinRTO float64 // maximum rto of the window in microseconds MaxRTO float64 // initial rto of the window in microseconds InitialRTO float64 // rtt factor for calculating the rto RTTFactor float64 // 4.0 // ewma alpha EWMAAlpha float64 // 0.125 // ewma beta EWMABeta float64 // 0.25 // MaxCap is the maximum size of the window in bytes MaxCap float64 // WindowDownscaleFactor is the factor by which the window is downscaled when a retransmission is detected WindowDownscaleFactor float64 // WindowUpscaleFactor is the factor by which the window is upscaled when a retransmission is not detected WindowUpscaleFactor float64 // HistSize is the size of the sliding window histogram RTTHistSize int }
func NewDefaultWindowOptions ¶
func NewDefaultWindowOptions() WindowOptions
Source Files ¶
Click to show internal directories.
Click to hide internal directories.