lneto

package module
v0.4.0-hopos.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

README

lneto

go.dev reference Go Report Card codecov Go sourcegraph

Userspace networking primitives.

lneto is pronounced "L-net-oh", a.k.a. "El Neto"; a.k.a. "Don Networkio"; a.k.a "Neto, connector of worlds".

Features

lneto provides the following features:

  • Zero Operating System required. Zero. All protocols (including TCP, excepting NTP) are time-independent.
    • Explicit HAL needed. Lneto performs no time.Sleep nor time.Now calls unless configured by user.
    • Zero scheduling required. No goroutines/channels use in Lneto. Can be run in event loop.
  • Heapless packet processing
    • httpraw is likely the most performant HTTP/1.1 processing package in the Go ecosystem. Based on fasthttp but simpler and more thoughtful memory use.
    • httφ - Heapless HTTP router and zero-copy response writing with Go's standard library API.
  • Lean memory footprint
    • HTTP header struct is 80 bytes with no runtime usage nor heap usage other than buffer
    • Entire Ethernet+IPv4+UDP+DHCP+DNS+NTP stack in ~2kB RAM.
  • Empty go.mod file. No dependencies except for basic standard library packages such as bytes, errors, io.
    • net only imported for net.ErrClosed.
    • Can produce very small binaries. Ideal for embedded systems.
  • Extremely simple networking stack construction. Can be used to teach basics of networking
    • Only one networking interface fulfilled by all implementations. See abstractions.
  • Stack can be fuzz tested efficiently, see benchmarks below:
    • go test ./x/xnet/ -run FuzzStackAsyncHTTP -fuzz=. fuzzes Ethernet/IP/TCP/HTTP stack with 170k HTTP exchanges per second on 12 core machine: fuzz: elapsed: 4m9s, execs: 42649941 (169428/sec), new interesting: 5 (total: 52)

min-working-example - Quick lneto showcase

Get a quick showcase of how lneto can be configured and how to get a TCP listening server up and running.

Binary size comparisons

All examples include IPv4, ARP, ICMP, TCP and UDP functionality. Go and TinyGo default build flags used. DNC= Does Not Compile.

go run ./examples/gen/gen-binary-bench # generate table
Program Extra Protocols Packet capture printing amd64 Go WASM Go amd64 TinyGo WASM TinyGo Pico TinyGo
Lneto MWE DNS,NTP,DHCP 3.9MB 4.5MB 1.6MB 1.2MB 192kB
Gvisor MWE w/ go-net None 6.6MB 7.5MB DNC DNC DNC

xcurl example

You may try lneto out on linux with the xcurl example which gets an HTTP page by doing all the low-level networking part using absolutely no standard library.

  • DHCP client address lease
  • ARP address resolution
  • DNS address resolution of requested host
  • HTTP over TCP/IPv4/Ethernet connection using
  • NTP time check (optional)
  • Print packet captures using lneto's internet/pcap package
  • Optional fixed TCP source port with -port, useful when debugging raw-socket interactions with the host OS

See Developing section below for more information.

Users

lneto is currently being used primarily by embedded developers and those who need a lighter alternative to gVisor in terms of memory usage and binary size.

Why run Go on a Raspberry Pi Pico instead of on a fully OS features Raspberry Pi 3/4/5? I answer this question in my talk at Gophercon.

Benchmarks

Go and TinyGo compiler tested with ARP and TCP exchanges with all Ethernet/IPv4 stack functionality:

go test -bench=. -benchmem ./x/xnet
goos: linux
goarch: amd64
pkg: github.com/soypat/lneto/x/xnet
cpu: 12th Gen Intel(R) Core(TM) i5-12400F
BenchmarkARPExchange-12          6122306               177.1 ns/op             0 B/op          0 allocs/op
BenchmarkTCPHandshake-12          987534              1200 ns/op               0 B/op          0 allocs/op
PASS
ok      github.com/soypat/lneto/x/xnet  2.589s

tinygo test -opt=2 -bench=. -benchmem ./x/xnet      
BenchmarkARPExchange     2729166               435.9 ns/op           144 B/op          0 allocs/op
BenchmarkTCPHandshake    1000000              1174 ns/op             192 B/op          0 allocs/op
PASS
ok      github.com/soypat/lneto/x/xnet  2.926s

Protocol Support Matrix

Generated 2026-04-27. This table may not always reflect the current state of the codebase. Allocation figures are derived from benchmark tests run on amd64. denotes no standalone benchmark exists for that protocol; those packages follow the same zero-allocation design principle documented in the codebase.

Protocol RFC / Spec Status Package Allocs/op Notes
Ethernet II IEEE 802.3 ethernet 0 ¹ Frame parsing, CRC-32
ARP RFC 826 arp 0 ¹ Request/reply, hardware address cache
IPv4 RFC 791 ipv4 0 ² Frame parsing, ones-complement checksum
ICMPv4 RFC 792 ipv4/icmpv4 Echo (ping) client handler
UDP RFC 768 udp Handler + thread-safe Conn
TCP RFC 9293 tcp 0 ²³ Full state machine, SYN cookies, retransmit queue, Conn/Listener
DNS RFC 1035 dns Client (A/AAAA query)
DHCPv4 RFC 2131 dhcp/dhcpv4 Client + Server
IPv4 Link-Local (APIPA) RFC 3927 ipv4/linklocal4 0 Heapless claim-and-defend state machine for 169.254.x.x
NTP RFC 5905 ntp Client
NTS RFC 8915 x/nts Client + Server; key exchange over TLS 1.3, authenticated NTP. Requires caller-supplied AEAD_AES_SIV_CMAC_256
mDNS RFC 6762 dns/mdns Client (service announcement + query)
HTTP/1.1 headers RFC 9110, RFC 9112 http/httpraw 2 ⁴ Header parse/format; no field normalization
Ethernet PHY/MDIO IEEE 802.3 cl.22/45 phy Bare-metal PHY management via MDIO
IPv6 RFC 8200 ipv6 Frame parsing and stack handling
ICMPv6 RFC 4443 ipv6/icmpv6 Echo+NDP frame parsing and stack handling
DHCPv6 DNS Configuration RFC 3646 🟡 dhcp/dhcpv6 Recursive DNS server and domain search options parsed and exposed
DHCPv6 NTP Configuration RFC 5908 dhcp/dhcpv6 NTP server address, multicast address, and FQDN suboptions parsed and exposed
DHCPv6 RFC 8415 🟡 dhcp/dhcpv6 Client IA_NA/IA_PD request handling and reconfigure-renew; no relay agent or dynamic server pools
TLS 1.3 RFC 8446 Not implemented

¹ BenchmarkARPExchange — full ARP request/response exchange over Ethernet: 0 B/op, 0 allocs/op ² BenchmarkTCPHandshake — TCP 3-way handshake over Ethernet/IPv4: 0 B/op, 0 allocs/op ³ BenchmarkSYNCookie_Generate / BenchmarkSYNCookie_Validate — SYN cookie generation and validation: 0 B/op, 0 allocs/op eachBenchmarkParseBytes — HTTP/1.1 request header + body parsing: 240 B/op, 2 allocs/op

Packages

  • lneto: Low-level Networking Operations, or "El Neto", the networking package. Zero copy network frame marshalling and unmarshalling.
  • lneto/internet: Userspace IP/TCP networking stack. This is where the magic happens. Integrates many of the listed packages.
  • lneto/http/httpraw: Heapless HTTP header processing and validation. Does no implement header normalization.
  • lneto/tcp: TCP implementation and low level logic.
  • lneto/ipv4/linklocal4: RFC 3927 IPv4 link-local (APIPA) address autoconfiguration. Heapless claim-and-defend state machine for self-assigned 169.254.x.x addresses when no DHCP server is available.
  • lneto/dhcpv4: DHCP version 4 protocol implementation and low level logic.
  • lneto/dns: DNS protocol implementation and low level logic.
  • lneto/ntp: NTP implementation and low level logic. Includes NTP time primitives manipulation and conversion to Go native types.
  • lneto/internal: Lightweight and flexible ring buffer implementation and debugging primitives.
  • lneto/x: Experimental packages.
    • lneto/x/xnet: net package like abstractions of stack implementations for ease of reuse. Still in testing phase and likely subject to breaking API change.
    • lneto/x/nts: Network Time Security (RFC 8915). NTS-KE key exchange over TLS 1.3 and AEAD-authenticated NTP client/server. Ships no cryptography itself; the caller supplies the mandated AEAD_AES_SIV_CMAC_256 cipher.AEAD implementation.
Abstractions

The following interface is implemented by networking stack nodes and the stack themselves.

type StackNode interface {
    // Encapsulate receives a buffer the receiver must fill with data.
    // The receiver's start byte is at carrierData[offsetToFrame].
	Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (int, error)
	// Demux receives a buffer the receiver must decode and pass on to corresponding child StackNode(s).
    // The receiver's start byte is at carrierData[offsetToFrame].
	Demux(carrierData []byte, offsetToFrame int) error
    // LocalPort returns the port of the node if applicable or zero. Used for UDP/TCP nodes.
	LocalPort() uint16
    // Protocol returns the protocol of this node if applicable or zero. Usually either a ethernet.Type (EtherType) or lneto.IPProto (IP Protocol number).
	Protocol() uint64
    // ConnectionID returns a pointer to the connection ID of the StackNode.
    // A change in the ID means the node is no longer valid and should be discarded.
    // A change in the ID could mean the connection was closed by the user or that the node will not send nor receive any more data over said connection ID.
	ConnectionID() *uint64
}

Install

How to install package with newer versions of Go (+1.16):

go mod download github.com/soypat/lneto@latest

Developing (linux)

When testing lneto through a Linux network interface, disable receive offloading if packets are unexpectedly dropped with checksum errors. Generic receive offload (GRO) can merge TCP frames before delivery to raw sockets without recalculating the full checksum.

sudo ethtool -K <network-interface> gro off

Depending on the interface and driver, other offloading features may also need to be disabled.

When running xcurl directly on a normal Linux interface (for example -i wlan0 or -i eth0), lneto shares the host interface IP and MAC address. The Linux TCP stack also sees incoming packets for that IP. If xcurl's TCP handshake succeeds but the HTTP request is followed by a TCP RST from the server, the host kernel may have sent its own outbound RST for xcurl's raw TCP flow because no kernel socket owns that source port.

For a short validation test, use a fixed xcurl source port and temporarily drop kernel-generated outbound RSTs for that port:

go build -o examples/xcurl/xcurl ./examples/xcurl
sudo iptables -I OUTPUT -p tcp --sport 2300 --tcp-flags RST RST -j DROP
sudo ./examples/xcurl/xcurl -i <network-interface> -port 2300 -host example.com
sudo iptables -D OUTPUT -p tcp --sport 2300 --tcp-flags RST RST -j DROP

This is a debugging workaround, not the preferred operating mode. Prefer -ihttp, a TAP interface, a network namespace, or an otherwise isolated interface/IP when testing xcurl without host TCP stack interference.

  • examples/httptap (linux only, root privilidges required) Program opens a TAP interface and assigns an IP address to it and exposes the interface via a HTTP interface. This program is run with root privilidges to facilitate debugging of lneto since no root privilidges are required to interact with the HTTP interface exposed.

    • POST http://127.0.0.1:7070/send: Receives a POST with request body containing JSON string of data to send over TAP interface. Response contains only status code.
    • GET http://127.0.0.1:7070/recv: Receives a GET request. Response contains a JSON string of oldest unread TAP interface packet. If string is empty then there is no more data to read.
  • xcurl Contains example of a application that uses lneto and can attach to a linux tap/bridge interface or a httptap(with -ihttp flag) to work. When using httptap can be run as non-root user to be debugged comfortably.

    • Example: go run ./examples/xcurl -host google.com -ihttp
LLM Policy / AI Policy

LLMs are a tool. As such they should be used carefully. The policy for this project is covered in Oxide's RFD576.

Examples of LLM contribution in lneto:

Quick run xcurl

Run xcurl over httptap interface. Requires running two programs in separate shell/consoles in linux:

# Build+Run HTTP Tap server from one shell, this will expose the `tap0` TAP interface over an HTTP interface at http://127.0.0.1:7070 on /recv and /send endpoints.
go build ./examples/httptap && sudo ./httpap

No privilidge escalation required for xcurl using -ihttp flag which taps using httptap:

go run ./examples/xcurl -host google.com -ihttp
Wireshark and Packet Capture API

Using the provided method of interfacing mean's you'll always be able to easily reach the TAP interface on your machine over HTTP from any process, be it Python or Go. To visualize the packets over the interface we suggest using Wireshark and selecting the tap0 interface which will show all activity over the HTTP TAP interface created with ./examples/httptap.

Alternatively there's the internet/pcap package that does the same thing as Wireshark but as a Go API. Here's the result of running xcurl example with pcap logging:

go run ./examples/xcurl -host google.com -ihttp -ntp
softrand 1767229198
NIC hardware address: d8:5e:d3:43:03:eb bridgeHW: d8:5e:d3:43:03:eb mtu: 1500 addr: 192.168.1.53/24
OUT 328 [Ethernet len=14; destination=ff:ff:ff:ff:ff:ff; source=us | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=us; destination=255.255.255.255 | UDP [RFC768] len=8; (Source port)=68; (Destination port)=67 | DHCPv4 len=285; op=1; Flags=0x0000; (Client Address)=us; (Offered Address)=us; (Server Next Address)=255.255.255.255; (Relay Agent Address)=us; (Client Hardware Address)=d85e:d343:3eb::]
IN   98 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=192.168.1.53 | ICMP [RFC792] len=64]
IN   98 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=192.168.1.53 | ICMP [RFC792] len=64]
IN   98 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=192.168.1.53 | ICMP [RFC792] len=64]
IN   98 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=192.168.1.53 | ICMP [RFC792] len=64]
IN   98 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=192.168.1.53 | ICMP [RFC792] len=64]
IN   98 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=192.168.1.53 | ICMP [RFC792] len=64]
IN   60 [Ethernet len=14; destination=ff:ff:ff:ff:ff:ff; source=e8:4d:74:9f:61:4a | ARP len=28; op=1; (Sender hardware address)=e8:4d:74:9f:61:4a; (Sender protocol address)=192.168.1.1; (Target hardware address)=00:00:00:00:00:00; (Target protocol address)=192.168.1.53]
IN  590 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x0000; source=192.168.1.1; destination=192.168.1.53 | UDP [RFC768] len=8; (Source port)=67; (Destination port)=68 | DHCPv4 len=273; op=2; Flags=0x0000; (Client Address)=us; (Offered Address)=192.168.1.53; (Server Next Address)=us; (Relay Agent Address)=us; (Client Hardware Address)=d85e:d343:3eb::]
OUT 326 [Ethernet len=14; destination=ff:ff:ff:ff:ff:ff; source=us | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=us; destination=255.255.255.255 | UDP [RFC768] len=8; (Source port)=68; (Destination port)=67 | DHCPv4 len=283; op=1; Flags=0x0000; (Client Address)=us; (Offered Address)=192.168.1.53; (Server Next Address)=us; (Relay Agent Address)=us; (Client Hardware Address)=d85e:d343:3eb::]
IN  590 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x0000; source=192.168.1.1; destination=192.168.1.53 | UDP [RFC768] len=8; (Source port)=67; (Destination port)=68 | DHCPv4 len=273; op=2; Flags=0x0000; (Client Address)=us; (Offered Address)=192.168.1.53; (Server Next Address)=us; (Relay Agent Address)=us; (Client Hardware Address)=d85e:d343:3eb::]
[119ms] DHCP request completed
2025/12/31 21:59:58 INFO dhcp-complete assignedIP=192.168.1.53 routerIP=192.168.1.1 DNS=[192.168.1.1] subnet=192.168.1.0/24
OUT  42 [Ethernet len=14; destination=ff:ff:ff:ff:ff:ff; source=us | ARP len=28; op=1; (Sender hardware address)=us; (Sender protocol address)=us; (Target hardware address)=00:00:00:00:00:00; (Target protocol address)=192.168.1.1]
IN   60 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | ARP len=28; op=2; (Sender hardware address)=e8:4d:74:9f:61:4a; (Sender protocol address)=192.168.1.1; (Target hardware address)=us; (Target protocol address)=us]
[1.1s] Router ARP resolution
IN   60 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | ARP len=28; op=1; (Sender hardware address)=e8:4d:74:9f:61:4a; (Sender protocol address)=192.168.1.1; (Target hardware address)=00:00:00:00:00:00; (Target protocol address)=us]
OUT  42 [Ethernet len=14; destination=e8:4d:74:9f:61:4a; source=us | ARP len=28; op=2; (Sender hardware address)=us; (Sender protocol address)=us; (Target hardware address)=e8:4d:74:9f:61:4a; (Target protocol address)=192.168.1.1]
OUT  83 [Ethernet len=14; destination=e8:4d:74:9f:61:4a; source=us | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=us; destination=192.168.1.1 | UDP [RFC768] len=8; (Source port)=57216; (Destination port)=53 | DNS len=41]
IN  147 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=us | UDP [RFC768] len=8; (Source port)=53; (Destination port)=57216 | DNS len=105]
[3.5s] NTP IP lookup
OUT  90 [Ethernet len=14; destination=e8:4d:74:9f:61:4a; source=us | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=us; destination=170.210.222.10 | UDP [RFC768] len=8; (Source port)=1023; (Destination port)=123 | NTP len=48; (Reference Time)=1900-01-01T00:00:00; (Origin Time)=1900-01-01T00:00:00; (Receive Time)=1900-01-01T00:00:00; (Transit Time)=1900-01-01T00:00:00]
IN   90 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x0000; source=170.210.222.10; destination=us | UDP [RFC768] len=8; (Source port)=123; (Destination port)=1023 | NTP len=48; (Reference Time)=2026-01-01T00:43:04; (Origin Time)=1900-01-01T00:00:00; (Receive Time)=2026-01-01T01:00:03; (Transit Time)=2026-01-01T01:00:03]
[786ms] NTP exchange
NTP completed. You are 11.493283ms ahead of the NTP server
OUT  81 [Ethernet len=14; destination=e8:4d:74:9f:61:4a; source=us | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=us; destination=192.168.1.1 | UDP [RFC768] len=8; (Source port)=56316; (Destination port)=53 | DNS len=39]
IN   97 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=us | UDP [RFC768] len=8; (Source port)=53; (Destination port)=56316 | DNS len=55]
[1s] resolve google.com
DNS resolution of "google.com" complete and resolved to [142.251.129.142]
[10µs] create HTTP GET request
IN   98 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=us | ICMP [RFC792] len=64]
OUT  58 [Ethernet len=14; destination=e8:4d:74:9f:61:4a; source=us | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=us; destination=142.251.129.142 | TCP [RFC9293] len=24; (Source port)=51982; (Destination port)=80; flags=SYN]
IN   98 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=192.168.1.1; destination=us | ICMP [RFC792] len=64]
IN   60 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=142.251.129.142; destination=us | TCP [RFC9293] len=24; (Source port)=80; (Destination port)=51982; flags=SYN,ACK | payload? len=2]
OUT  54 [Ethernet len=14; destination=e8:4d:74:9f:61:4a; source=us | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=us; destination=142.251.129.142 | TCP [RFC9293] len=20; (Source port)=51982; (Destination port)=80; flags=ACK]
[646ms] TCP dial (handshake)
[5µs] send HTTP request
OUT 161 [Ethernet len=14; destination=e8:4d:74:9f:61:4a; source=us | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=us; destination=142.251.129.142 | TCP [RFC9293] len=20; (Source port)=51982; (Destination port)=80; flags=PSH,ACK | HTTP len=107]
IN   60 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x0000; source=142.251.129.142; destination=us | TCP [RFC9293] len=20; (Source port)=80; (Destination port)=51982; flags=ACK | payload? len=6]
IN  846 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x0000; source=142.251.129.142; destination=us | TCP [RFC9293] len=20; (Source port)=80; (Destination port)=51982; flags=PSH,ACK | HTTP len=792]
IN   60 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x0000; source=142.251.129.142; destination=us | TCP [RFC9293] len=20; (Source port)=80; (Destination port)=51982; flags=FIN,ACK | payload? len=6]
IN  804 [Ethernet len=14; destination=us; source=e8:4d:74:9f:61:4a | IPv4 len=20; (Type of Service)=0x00; flags=0x0000; source=142.251.129.142; destination=us | TCP [RFC9293] len=20; (Source port)=80; (Destination port)=51982; flags=ACK | HTTP len=750]
OUT  54 [Ethernet len=14; destination=e8:4d:74:9f:61:4a; source=us | IPv4 len=20; (Type of Service)=0x00; flags=0x4000; source=us; destination=142.251.129.142 | TCP [RFC9293] len=20; (Source port)=51982; (Destination port)=80; flags=ACK]
[2.9s] recv http request
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-v-ysoE0WjLlAMlo2ek5UrA' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
Date: Thu, 01 Jan 2026 01:00:08 GMT
Expires: Sat, 31 Jan 2026 01:00:08 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Connection: close

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
success

Documentation

Index

Constants

View Source
const (
	BackoffFlagGosched = time.Duration(-1)
	BackoffFlagNop     = time.Duration(-2)
)

Flag return values for a BackoffStrategy.

View Source
const (
	ErrBug             errGeneric // lneto-bug(use build tag "debugheaplog")
	ErrPacketDrop                 // packet dropped
	ErrBadCRC                     // incorrect checksum
	ErrZeroSource                 // zero source(port/addr)
	ErrZeroDestination            // zero destination(port/addr)
	ErrShortBuffer                // short buffer
	ErrBufferFull                 // buffer full
	ErrInvalidAddr                // invalid address
	ErrUnsupported                // unsupported
	ErrMismatch                   // mismatch
	ErrMismatchLen                // mismatched length
	ErrInvalidConfig              // invalid configuration

	ErrInvalidField       // invalid field
	ErrInvalidLengthField // invalid length field
	ErrExhausted          // resource exhausted
	ErrAlreadyRegistered  // protocol already registered
	ErrTruncatedFrame     // truncated frame
	ErrMissingHALConfig   // missing HAL configuration
	ErrBadState           // operation invalid in current state

)

Generic errors common to internet functioning.

Variables

This section is empty.

Functions

func NeverZeroSum

func NeverZeroSum(sum16 uint16) uint16

NonZeroChecksum ensures that the given checksum is not zero, by returning 0xffff instead.

Types

type BackoffStrategy

type BackoffStrategy func(consecutiveBackoffs uint) (sleepOrFlag time.Duration)

BackoffStrategy is the abstraction of a backoff strategy for retrying an operation. It returns the amount of time to sleep for or a flag value:

Despite the name(changes welcome) consecutiveBackoffs starts at 0 and increments by 1 every time the operation is retried. See internal/backoff.go for a implementation example.

func (BackoffStrategy) Do

func (backoff BackoffStrategy) Do(consecutiveBackoffs uint)

Do applies the backoff strategy by calling backoff(consecutiveBackoffs) and then the corresponding yield function for the returned value. See BackoffStrategy.

type BitPosErr

type BitPosErr struct {
	BitStart int
	BitLen   int
	Err      error
}

func (*BitPosErr) AppendError

func (bpe *BitPosErr) AppendError(dst []byte) []byte

func (*BitPosErr) Error

func (bpe *BitPosErr) Error() string

type CRC791

type CRC791 struct {
	// contains filtered or unexported fields
}

CRC791 function as defined by RFC 791. The Checksum field for TCP+IP is the 16-bit ones' complement of the ones' complement sum of all 16-bit words in the header. In case of uneven number of octet the last word is LSB padded with zeros.

The zero value of CRC791 is ready to use.

func (*CRC791) AddUint16

func (c *CRC791) AddUint16(value uint16)

Add16 adds a 16 bit value to the running checksum interpreted as BigEndian (network order).

func (*CRC791) AddUint32

func (c *CRC791) AddUint32(value uint32)

AddUint32 adds a 32 bit value to the running checksum interpreted as BigEndian (network order).

func (*CRC791) PayloadSum16

func (c *CRC791) PayloadSum16(buff []byte) uint16

PayloadSum16 returns the checksum resulting by adding the bytes in p to the running checksum.

func (*CRC791) Reset

func (c *CRC791) Reset()

Reset zeros out the CRC791, resetting it to the initial state.

func (*CRC791) Sum16

func (c *CRC791) Sum16() uint16

Sum16 calculates the checksum with the data written to c thus far.

func (*CRC791) WriteEven

func (c *CRC791) WriteEven(buff []byte)

Write adds the bytes in p to the running checksum. The buffer size must be even or the function will panic.

type IPProto

type IPProto uint8

IPProto represents the IP protocol number.

const (
	IPProtoHopByHop        IPProto = 0   // IPv6 Hop-by-Hop Option [RFC8200]
	IPProtoICMP            IPProto = 1   // ICMP [RFC792]
	IPProtoIGMP            IPProto = 2   // IGMP [RFC1112]
	IPProtoGGP             IPProto = 3   // Gateway-to-Gateway [RFC823]
	IPProtoIPv4            IPProto = 4   // IPv4 encapsulation [RFC2003]
	IPProtoST              IPProto = 5   // Stream [RFC1190, RFC1819]
	IPProtoTCP             IPProto = 6   // TCP [RFC9293]
	IPProtoCBT             IPProto = 7   // CBT [Ballardie]
	IPProtoEGP             IPProto = 8   // Exterior Gateway Protocol [RFC888]
	IPProtoIGP             IPProto = 9   // any private interior gateway (used by Cisco for their IGRP)
	IPProtoBBNRCCMON       IPProto = 10  // BBN RCC Monitoring
	IPProtoNVP             IPProto = 11  // Network Voice Protocol [RFC741]
	IPProtoPUP             IPProto = 12  // PUP
	IPProtoARGUS           IPProto = 13  // ARGUS
	IPProtoEMCON           IPProto = 14  // EMCON
	IPProtoXNET            IPProto = 15  // Cross Net Debugger
	IPProtoCHAOS           IPProto = 16  // Chaos
	IPProtoUDP             IPProto = 17  // UDP [RFC768]
	IPProtoMUX             IPProto = 18  // Multiplexing
	IPProtoDCNMEAS         IPProto = 19  // DCN Measurement Subsystems
	IPProtoHMP             IPProto = 20  // Host Monitoring [RFC869]
	IPProtoPRM             IPProto = 21  // Packet Radio Measurement
	IPProtoXNSIDP          IPProto = 22  // XEROX NS IDP
	IPProtoTRUNK1          IPProto = 23  // Trunk-1
	IPProtoTRUNK2          IPProto = 24  // Trunk-2
	IPProtoLEAF1           IPProto = 25  // Leaf-1
	IPProtoLEAF2           IPProto = 26  // Leaf-2
	IPProtoRDP             IPProto = 27  // Reliable Data Protocol [RFC908]
	IPProtoIRTP            IPProto = 28  // Internet Reliable Transaction [RFC938]
	IPProtoISO_TP4         IPProto = 29  // ISO Transport Protocol Class 4 [RFC905]
	IPProtoNETBLT          IPProto = 30  // Bulk Data Transfer Protocol [RFC998]
	IPProtoMFE_NSP         IPProto = 31  // MFE Network Services Protocol
	IPProtoMERIT_INP       IPProto = 32  // MERIT Internodal Protocol
	IPProtoDCCP            IPProto = 33  // Datagram Congestion Control Protocol [RFC4340]
	IPProto3PC             IPProto = 34  // Third Party Connect Protocol
	IPProtoIDPR            IPProto = 35  // Inter-Domain Policy Routing Protocol
	IPProtoXTP             IPProto = 36  // XTP
	IPProtoDDP             IPProto = 37  // Datagram Delivery Protocol
	IPProtoIDPRCMTP        IPProto = 38  // IDPR Control Message Transport Proto
	IPProtoTPPLUSPLUS      IPProto = 39  // TP++ Transport Protocol
	IPProtoIL              IPProto = 40  // IL Transport Protocol
	IPProtoIPv6            IPProto = 41  // IPv6 encapsulation [RFC2473]
	IPProtoSDRP            IPProto = 42  // Source Demand Routing Protocol
	IPProtoIPv6Route       IPProto = 43  // Routing Header for IPv6 [RFC8200]
	IPProtoIPv6Frag        IPProto = 44  // Fragment Header for IPv6 [RFC8200]
	IPProtoIDRP            IPProto = 45  // Inter-Domain Routing Protocol
	IPProtoRSVP            IPProto = 46  // Reservation Protocol [RFC2205]
	IPProtoGRE             IPProto = 47  // Generic Routing Encapsulation [RFC2784]
	IPProtoDSR             IPProto = 48  // Dynamic Source Routing Protocol
	IPProtoBNA             IPProto = 49  // BNA
	IPProtoESP             IPProto = 50  // Encap Security Payload [RFC4303]
	IPProtoAH              IPProto = 51  // Authentication Header [RFC4302]
	IPProtoINLSP           IPProto = 52  // Integrated Net Layer Security TUBA
	IPProtoSWIPE           IPProto = 53  // IP with Encryption
	IPProtoNARP            IPProto = 54  // NBMA Address Resolution Protocol
	IPProtoMOBILE          IPProto = 55  // IP Mobility
	IPProtoTLSP            IPProto = 56  // Transport Layer Security Protocol using Kryptonet key management
	IPProtoSKIP            IPProto = 57  // SKIP
	IPProtoIPv6ICMP        IPProto = 58  // ICMP for IPv6 [RFC8200]
	IPProtoIPv6NoNxt       IPProto = 59  // No Next Header for IPv6 [RFC8200]
	IPProtoIPv6Opts        IPProto = 60  // Destination Options for IPv6 [RFC8200]
	IPProtoCFTP            IPProto = 62  // CFTP
	IPProtoSATEXPAK        IPProto = 64  // SATNET and Backroom EXPAK
	IPProtoKRYPTOLAN       IPProto = 65  // Kryptolan
	IPProtoRVD             IPProto = 66  // MIT Remote Virtual Disk Protocol
	IPProtoIPPC            IPProto = 67  // Internet Pluribus Packet Core
	IPProtoSATMON          IPProto = 69  // SATNET Monitoring
	IPProtoVISA            IPProto = 70  // VISA Protocol
	IPProtoIPCV            IPProto = 71  // Internet Packet Core Utility
	IPProtoCPNX            IPProto = 72  // Computer Protocol Network Executive
	IPProtoCPHB            IPProto = 73  // Computer Protocol Heart Beat
	IPProtoWSN             IPProto = 74  // Wang Span Network
	IPProtoPVP             IPProto = 75  // Packet Video Protocol
	IPProtoBRSATMON        IPProto = 76  // Backroom SATNET Monitoring
	IPProtoSUNND           IPProto = 77  // SUN ND PROTOCOL-Temporary
	IPProtoWBMON           IPProto = 78  // WIDEBAND Monitoring
	IPProtoWBEXPAK         IPProto = 79  // WIDEBAND EXPAK
	IPProtoISOIP           IPProto = 80  // ISO Internet Protocol
	IPProtoVMTP            IPProto = 81  // VMTP
	IPProtoSECUREVMTP      IPProto = 82  // SECURE-VMTP
	IPProtoVINES           IPProto = 83  // VINES
	IPProtoTTP             IPProto = 84  // TTP
	IPProtoNSFNETIGP       IPProto = 85  // NSFNET-IGP
	IPProtoDGP             IPProto = 86  // Dissimilar Gateway Protocol
	IPProtoTCF             IPProto = 87  // TCF
	IPProtoEIGRP           IPProto = 88  // EIGRP
	IPProtoOSPFIGP         IPProto = 89  // OSPFIGP
	IPProtoSpriteRPC       IPProto = 90  // Sprite RPC Protocol
	IPProtoLARP            IPProto = 91  // Locus Address Resolution Protocol
	IPProtoMTP             IPProto = 92  // Multicast Transport Protocol
	IPProtoAX25            IPProto = 93  // AX.25 Frames
	IPProtoIPIP            IPProto = 94  // IP-within-IP Encapsulation Protocol
	IPProtoMICP            IPProto = 95  // Mobile Internetworking Control Pro.
	IPProtoSCCSP           IPProto = 96  // Semaphore Communications Sec. Pro.
	IPProtoETHERIP         IPProto = 97  // Ethernet-within-IP Encapsulation
	IPProtoENCAP           IPProto = 98  // Encapsulation Header
	IPProtoGMTP            IPProto = 100 // GMTP
	IPProtoIFMP            IPProto = 101 // Ipsilon Flow Management Protocol
	IPProtoPNNI            IPProto = 102 // PNNI over IP
	IPProtoPIM             IPProto = 103 // Protocol Independent Multicast
	IPProtoARIS            IPProto = 104 // ARIS
	IPProtoSCPS            IPProto = 105 // SCPS
	IPProtoQNX             IPProto = 106 // QNX
	IPProtoAN              IPProto = 107 // Active Networks
	IPProtoIPComp          IPProto = 108 // IP Payload Compression Protocol
	IPProtoSNP             IPProto = 109 // Sitara Networks Protocol
	IPProtoCompaqPeer      IPProto = 110 // Compaq Peer Protocol
	IPProtoIPXInIP         IPProto = 111 // IPX in IP
	IPProtoVRRP            IPProto = 112 // Virtual Router Redundancy Protocol
	IPProtoPGM             IPProto = 113 // PGM Reliable Transport Protocol
	IPProtoL2TP            IPProto = 115 // Layer Two Tunneling Protocol v3
	IPProtoDDX             IPProto = 116 // D-II Data Exchange (DDX)
	IPProtoIATP            IPProto = 117 // Interactive Agent Transfer Protocol
	IPProtoSTP             IPProto = 118 // Schedule Transfer Protocol
	IPProtoSRP             IPProto = 119 // SpectraLink Radio Protocol
	IPProtoUTI             IPProto = 120 // UTI
	IPProtoSMP             IPProto = 121 // Simple Message Protocol
	IPProtoSM              IPProto = 122 // SM
	IPProtoPTP             IPProto = 123 // Performance Transparency Protocol
	IPProtoISIS            IPProto = 124 // ISIS over IPv4
	IPProtoFIRE            IPProto = 125 // FIRE
	IPProtoCRTP            IPProto = 126 // Combat Radio Transport Protocol
	IPProtoCRUDP           IPProto = 127 // Combat Radio User Datagram
	IPProtoSSCOPMCE        IPProto = 128 // SSCOPMCE
	IPProtoIPLT            IPProto = 129 // IPLT
	IPProtoSPS             IPProto = 130 // Secure Packet Shield
	IPProtoPIPE            IPProto = 131 // Private IP Encapsulation within IP
	IPProtoSCTP            IPProto = 132 // Stream Control Transmission Protocol
	IPProtoFC              IPProto = 133 // Fibre Channel
	IPProtoRSVP_E2E_IGNORE IPProto = 134 // RSVP-E2E-IGNORE
	IPProtoMobilityHeader  IPProto = 135 // Mobility Header
	IPProtoUDPLite         IPProto = 136 // UDP-Lite [RFC3828]
	IPProtoMPLSInIP        IPProto = 137 // MPLS-in-IP
	IPProtoMANET           IPProto = 138 // MANET Protocols
	IPProtoHIP             IPProto = 139 // Host Identity Protocol
	IPProtoShim6           IPProto = 140 // Shim6 Protocol
	IPProtoWESP            IPProto = 141 // Wrapped Encapsulating Security Payload
	IPProtoROHC            IPProto = 142 // Robust Header Compression
	IPProtoEthernet        IPProto = 143 // Ethernet
	IPProtoAGGFRAG         IPProto = 144 // AGGFRAG Encapsulation payload for ESP
	IPProtoNSH             IPProto = 145 // Network Service Header
)

IP protocol numbers.

func (IPProto) String

func (i IPProto) String() string

type StackNode

type StackNode interface {
	// Encapsulate writes the stack node's frame into carrierData[offsetToFrame:]
	// along with any other frame or payload the stack node encapsulates.
	// The returned integer is amount of bytes written such that carrierData[offsetToFrame:offsetToFrame+n]
	// contains written data. Data inside carrierData[:offsetToFrame] usually contains data necessary for
	// a StackNode to correctly emit valid frame data: such is the case for TCP packets which require IP
	// frame data for checksum calculation. Thus StackNodes must provide fields in their own frame
	// required by sub-stacknodes for correct encapsulation; in the case of IPv4/6 this means including fields
	// used in pseudo-header checksum like local IP (see [ipv4.CRCWriteUDPPseudo]).
	//
	// offsetToIP is the offset to the IP frame, if present, else its value should be -1.
	// The relation offsetToIP<=offsetToFrame MUST hold.
	//
	// When [net.ErrClosed] is returned the StackNode should be discarded and any written data passed up normally.
	// Errors returned by Encapsulate are "extraordinary" and should not be returned unless the StackNode is receiving invalid carrierData/frameOffset.
	Encapsulate(carrierData []byte, offsetToIP, offsetToFrame int) (int, error)
	// Demux reads from the argument buffer where frameOffset is the offset of this StackNode's frame first byte.
	// The stack node then dispatches(demuxes) the encapsulated frames to its corresponding substack or subnode.
	Demux(carrierData []byte, frameOffset int) error
	// LocalPort returns the local port of this StackNode or zero if not set/relevant.
	LocalPort() uint16
	// Protocol returns a number identifying the protocol used by this [StackNode].
	// Can be an [IPProto] among other types of protocols, i.e: ethernet.Protocol for a link layer [StackNode].
	Protocol() uint64
	// ConnectionID returns the pointer to the connection context number or ConnectionID.
	// Stacks should store the original value of ConnectionID (dereference the pointer) on
	// registering a [StackNode]. When the value changes this means the registered [StackNode]
	// should be discarded since its lifetime has terminated.
	ConnectionID() *uint64
}

StackNode is an abstraction of a packet exchanging protocol controller. This is the building block for all protocols, from Ethernet to IP to TCP, practically any protocol can be expressed as a StackNode and function completely. Today protocols represented by StackNode also include NTP, DNS, DHCP, ARP, ICMP, UDP, mDNS. Do note stream based protocols like HTTP are NOT well represented with a StackNode.

type ValidateFlags

type ValidateFlags uint64
const (
	ValidateEvilBit ValidateFlags
)

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func (*Validator) AddBitPosErr

func (v *Validator) AddBitPosErr(bitStart, bitLen int, err error)

func (*Validator) AddError

func (v *Validator) AddError(err error)

func (*Validator) ErrPop

func (v *Validator) ErrPop() (err error)

ErrPop returns the error(s) accumulated in the validator and clears them.

func (*Validator) Flags

func (v *Validator) Flags() ValidateFlags

func (*Validator) HasError

func (v *Validator) HasError() bool

func (*Validator) ResetErr

func (v *Validator) ResetErr()

Directories

Path Synopsis
dhcp
dns
examples
httphi-fuzz command
httphi-server command
httpraw-client command
httptap command
ntp-client command
Command ntp-client performs a two-exchange NTP clock synchronization against a remote server and prints the corrected time, clock offset, and round-trip delay.
Command ntp-client performs a two-exchange NTP clock synchronization against a remote server and prints the corrected time, clock offset, and round-trip delay.
ntp-server command
Command ntp-server is a minimal NTP server that listens for client requests on a UDP socket and responds with the current system time.
Command ntp-server is a minimal NTP server that listens for client requests on a UDP socket and responds with the current system time.
xcurl command
http
benchci command
Command benchci parses `go test -bench` output and renders a Markdown report.
Command benchci parses `go test -bench` output and renders a Markdown report.
linklocal4
Package linklocal4 implements dynamic configuration of IPv4 link-local addresses (a.k.a.
Package linklocal4 implements dynamic configuration of IPv4 link-local addresses (a.k.a.
package ntp implements the NTP protocol as described in RFC 5905.
package ntp implements the NTP protocol as described in RFC 5905.
Package phy provides Ethernet PHY management via MDIO.
Package phy provides Ethernet PHY management via MDIO.
package ltcp implements TCP control flow.
package ltcp implements TCP control flow.
x
nts
Package nts implements the Network Time Security (NTS) key exchange and authenticated NTP packet construction as specified in RFC 8915.
Package nts implements the Network Time Security (NTS) key exchange and authenticated NTP packet construction as specified in RFC 8915.
rawsock
Package rawsock listens and reads over Linux sockets through syscalls directly, without the net package.
Package rawsock listens and reads over Linux sockets through syscalls directly, without the net package.

Jump to

Keyboard shortcuts

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