underlay

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package underlay holds the facts of the UDP/IP network beneath SCION that the data plane shares with the node's sockets: the end-host port, the largest datagram, the underlay types, the resolution of underlay addresses, and the socket source the node's sites bind through — the kernel's the default. A shared library: no loops of its own, no policy.

Index

Constants

View Source
const (
	UDPIPv4Name  = "UDP/IPv4"
	UDPIPv6Name  = "UDP/IPv6"
	UDPIPv46Name = "UDP/IPv4+6"
)
View Source
const BufferSize = 9000

BufferSize is the largest datagram the underlay carries, a jumbo frame: the data plane's packet buffers and the SCION sockets' reads are this size.

View Source
const (
	// EndhostPort is the underlay port that SCION binds to on non-routers. Subject to
	// change during standardisation.
	EndhostPort = 30041
)

Variables

View Source
var Kernel = Sockets{}

Kernel is the kernel socket source: the sockets the sites opened before the seam.

Functions

func ResolveAddrPort

func ResolveAddrPort(s string) (netip.AddrPort, error)

ResolveAddrPort resolves a "host:port" address whose host names an address. IPv4 addresses in the v4-mapped IPv6 form are normalized to plain IPv4.

func ResolveAddrPortDefault added in v0.0.2

func ResolveAddrPortDefault(s string, defaultPort uint16) (netip.AddrPort, error)

ResolveAddrPortDefault resolves an address as ResolveAddrPort does, a form without a port naming the given default port instead.

func ResolveLocalAddr

func ResolveLocalAddr(s string) (*net.UDPAddr, error)

ResolveLocalAddr resolves a local address of the form "host:port". The host part may be empty, meaning any address. IPv4 addresses in the v4-mapped IPv6 form are normalized to plain IPv4.

Types

type Sockets added in v0.0.4

type Sockets struct {
	// ListenUDP binds an unconnected UDP socket on listen. A valid
	// remoteHint names the family a wildcard listen host binds under —
	// the kernel implementation's own selection; an implementation that
	// owns its port space binds the address it is given.
	ListenUDP func(listen *net.UDPAddr, remoteHint netip.AddrPort) (UDPConn, error)
	// ListenTCP binds a TCP listener on the "host:port" address — the
	// founder's HTTPS bind.
	ListenTCP func(addr string) (net.Listener, error)
}

Sockets is the node's socket source: the seam the packages that bind underlay sockets construct through, so the whole node can boot on one network. The zero value is the kernel source — the sockets the sites opened before the seam — so a caller that names no network gets the kernel's own semantics.

func (Sockets) NewTCP added in v0.0.4

func (s Sockets) NewTCP(addr string) (net.Listener, error)

NewTCP binds a TCP listener through the source, the kernel's where the source names none.

func (Sockets) NewUDP added in v0.0.4

func (s Sockets) NewUDP(listen *net.UDPAddr, remoteHint netip.AddrPort) (UDPConn, error)

NewUDP binds an unconnected UDP socket through the source, the kernel's where the source names none.

type Type

type Type int
const (
	Invalid Type = iota
	UDPIPv4
	UDPIPv6
	UDPIPv46
)

func TypeFromString

func TypeFromString(s string) (Type, error)

func (Type) IsUDP

func (ot Type) IsUDP() bool

func (Type) MarshalJSON

func (ot Type) MarshalJSON() ([]byte, error)

func (Type) String

func (ot Type) String() string

func (*Type) UnmarshalJSON

func (ot *Type) UnmarshalJSON(data []byte) error

type UDPConn added in v0.0.4

type UDPConn interface {
	// ReadFromUDP reads the next datagram, returning it with the sender's
	// address.
	ReadFromUDP(b []byte) (int, *net.UDPAddr, error)
	// WriteToUDP sends one datagram to the given destination.
	WriteToUDP(b []byte, addr *net.UDPAddr) (int, error)
	// ReadBatch reads datagrams into msgs until one lands or the wait
	// elapses, then fills whatever is immediately ready — the shape
	// MSG_WAITFORONE gives the kernel's own.
	ReadBatch(msgs []ipv4.Message) (int, error)
	// WriteBatch sends the msgs' datagrams, reporting how many left.
	WriteBatch(msgs []ipv4.Message) (int, error)
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
	// LocalAddr returns the socket's bound address, a concrete port after
	// a bind that named none.
	LocalAddr() *net.UDPAddr
	// SetReadBuffer and SetWriteBuffer size the socket's buffers; best
	// effort, for not every backing socket honors them.
	SetReadBuffer(bytes int) error
	SetWriteBuffer(bytes int) error
	Close() error
}

UDPConn is a UDP socket with the operations the node's sites use: the datagram pair the control plane and the rendezvous exchange read and write beside the batch pair the data plane's connections run, the deadlines, the bound address, buffer sizing, and Close. ipv4.Message and ipv6.Message are aliases of one underlying type, so one message slice serves both address families.

Jump to

Keyboard shortcuts

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