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 ¶
const ( UDPIPv4Name = "UDP/IPv4" UDPIPv6Name = "UDP/IPv6" UDPIPv46Name = "UDP/IPv4+6" )
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.
const ( // EndhostPort is the underlay port that SCION binds to on non-routers. Subject to // change during standardisation. EndhostPort = 30041 )
Variables ¶
var Kernel = Sockets{}
Kernel is the kernel socket source: the sockets the sites opened before the seam.
Functions ¶
func ResolveAddrPort ¶
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
ResolveAddrPortDefault resolves an address as ResolveAddrPort does, a form without a port naming the given default port instead.
func ResolveLocalAddr ¶
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.
func RouteSource ¶ added in v0.0.9
RouteSource returns the local address the kernel's routing table sends from toward dst: dst itself where one of the host's interfaces carries it, else the address of the interface the route leaves through — behind an address translation, the inside address and never the translated one. A connected UDP socket asks the table; no datagram leaves.
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.
type Type ¶
type Type int
func TypeFromString ¶
func (Type) MarshalJSON ¶
func (*Type) UnmarshalJSON ¶
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.