conn

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package conn implements overlay sockets with additional metadata on reads.

Index

Constants

View Source
const ReceiveBufferSize = 1 << 20

ReceiveBufferSize is the default size, in bytes, of receive buffers for opened sockets.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.4.0

type Config struct {
	// ReceiveBufferSize is the size of the operating system receive buffer, in
	// bytes. If 0, the package constant is used instead.
	ReceiveBufferSize int
}

Config customizes the behavior of an overlay socket.

type Conn

type Conn interface {
	Read(common.RawBytes) (int, *ReadMeta, error)
	ReadBatch(Messages, []ReadMeta) (int, error)
	Write(common.RawBytes) (int, error)
	WriteTo(common.RawBytes, *overlay.OverlayAddr) (int, error)
	WriteBatch(Messages) (int, error)
	LocalAddr() *overlay.OverlayAddr
	RemoteAddr() *overlay.OverlayAddr
	SetReadDeadline(time.Time) error
	SetWriteDeadline(time.Time) error
	SetDeadline(time.Time) error
	Close() error
}

Conn describes the API for an overlay socket with additional metadata on reads.

func New

func New(listen, remote *overlay.OverlayAddr, cfg *Config) (Conn, error)

New opens a new overlay socket on the specified addresses.

The config can be used to customize socket behavior. If config is nil, default values are used.

type Messages added in v0.4.0

type Messages []ipv4.Message

Messages is a list of ipX.Messages. It is necessary to hide the type alias between ipv4.Message, ipv6.Message and socket.Message.

func NewReadMessages

func NewReadMessages(n int) Messages

NewReadMessages allocates memory for reading IPv4 Linux network stack messages.

func NewWriteMessages

func NewWriteMessages(n int) Messages

NewWriteMessages allocates memory for writing IPv4 Linux network stack messages.

type ReadMeta

type ReadMeta struct {
	// Src is the remote address from which the datagram was received
	Src *overlay.OverlayAddr
	// Local is the address on which the datagram was received
	Local *overlay.OverlayAddr
	// RcvOvfl is the total number of packets that were dropped by the OS due
	// to the receive buffers being full.
	RcvOvfl uint32
	// Recvd is the timestamp when the kernel placed the packet in the socket's
	// receive buffer.
	Recvd time.Time
	// ReadDelay is the time elapsed between the kernel adding a packet to the
	// socket's receive buffer, and the application reading it from the Go
	// network stack (i.e., kernel to application latency).
	ReadDelay time.Duration
}

ReadMeta contains extra information about socket reads.

Directories

Path Synopsis
Package mock_conn is a generated GoMock package.
Package mock_conn is a generated GoMock package.

Jump to

Keyboard shortcuts

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