Networking
A small stack with one receiver owner.
The NIC and the protocol stack live in the kernel; ring-3 commands
drive them through SYS_NET_* and SYS_TCP_*.
Only one process may own the receiver at a time, which keeps the
polled drivers and the single TCP connection simple.
Protocol stack
NebOS does not expose sockets. A ring-3 program asks the kernel for info and configuration, acquires the receiver, then uses raw frame paths or the single TCP connection. HTTP and TLS are libraries linked into the command, not kernel services.
NIC drivers
netdev.c keeps a registry of
struct netdev drivers; the first one whose probe succeeds
becomes active. All drivers are polled and share the same transmit,
receive, register-dump and reset interface. netdev with
no argument shows the active driver; netdev asix switches
to a named one, leaving the current driver untouched if the probe
fails.
| Driver | Hardware | Transport | Notes |
|---|---|---|---|
| e1000e.c | Intel 82540EM, 82577LM, 82578, 82579 | PCI MMIO | PCI INTx disabled before MMIO; PCH D0; skips the global MAC reset while the link is up. |
| r8168.c | RTL8111/8168 | PCIe MMIO | C+ mode, 64-entry RX ring, polled. |
| ne2000.c | RTL8029 | ISA / QEMU PCI | Simple DP8390 path used by make run-net. |
| asix.c | AX88772 | USB bulk | Runs over the USB core; usable on EHCI/xHCI dongles. |
The management NIC used by netlog and netkexec prefers the ASIX dongle
so a direct debug link survives netdev e1000e; otherwise
it falls back to the active driver. netregs dumps registers
and decoded interrupt status; netloop runs a PHY loopback
self-test; netreset re-initialises the active NIC.
Link & IP layer
- Ethernet decode recognises IPv4, ARP and IPv6 frame types (IPv6 is not implemented).
- ARP resolves a next hop with three tries, one second apart;
net_arp_resolve()polls the active NIC and the caller must own it. - Routing sends off-subnet traffic to the gateway when one is known;
net_next_hop()is shared by ping, DNS and TCP. - ICMP echo backs
ping, with ARP resolution and round-trip timing. - UDP has send and parse helpers; DNS, DHCP, NTP and netlog are its users.
- Checksums use the Internet one's-complement sum, with a TCP pseudo-header variant.
The static default address is 192.168.178.240. At boot,
with a NIC present, a DHCP client runs with a 4-second budget
(requesting the current address); if no server answers, the static
address stays. The idle WM loop answers ARP/ICMP for the board's IP
even when no command is running, so the board is reachable and
MAC-resolvable.
DHCP, DNS & NTP
DHCP
dhcp.c is a minimal client:
DISCOVER → OFFER → REQUEST → ACK. It learns the mask, gateway and DNS
server (option 6), and dhcp re-runs it on demand. The
configuration is retained across kexec through the boot-info
BOOTINFO_FLAG_NET fields.
DNS
dns.c sends one recursive A query over UDP
and handles name compression in the response. netdns
shows or sets the server; host <name> resolves.
Numeric hosts skip DNS entirely.
NTP
ntp.c is a minimal SNTP (RFC 4330)
client: one 48-byte request to UDP port 123, three one-second
tries, DNS unless the server is a dotted address, and the shared
ARP/router path. An empty name uses pool.ntp.org.
A reply is accepted only when it comes from the
resolved server to the ephemeral source port, is a server/broadcast
reply with a valid stratum, and echoes the request's origin
timestamp; the transmit timestamp is converted from NTP's 1900 epoch
to a UTC struct sys_datetime (with the 2036 era wrap
handled). SYS_NTP_SYNC returns that value to ring 3;
the Date & Time editor then writes it through
SYS_RTC_SET. The service owns the receiver for the
duration, so it reports SYS_NTP_EBUSY while another
network command owns the NIC.
NTP is unauthenticated. The origin-timestamp check rejects unrelated datagrams but does not authenticate the server; anyone who can answer for the configured name can set the board's clock. There is no NTS, no leap-second handling and no delay/dispersion estimation — the CMOS RTC only resolves seconds.
TCP
tcp.c deliberately implements one client connection, not a general socket layer: connect, send, receive and close. An 8 KB receive queue lets data arriving during a send survive; the window update is sent whenever the application drains the queue, so a full queue cannot deadlock until the peer's zero-window probe.
- MSS / window. Our MSS is 1460 bytes and the advertised window is 4 KB.
- Retransmit. A 500 ms retry timer with a small retry count carries the connection through loss; there is no full congestion-control state machine.
- Listener. The server side has one active connection plus three backlog/closing slots. SYN-ACK advertises a zero window while queued; a queued connection may hold 1 KB of early request, and the window opens when
tcp_srv_accept()runs. - Bursts. Responses go out in up to four-segment bursts with a cumulative ACK, rather than one segment per ACK.
- No keep-alive. With one active connection, an idle persistent connection would block the parallel connections Nautilus opens.
New SYNs and data are also handed to tcp_srv_input() from
the active connection's receive/send poll loops, not only between
requests, so parallel gvfs clients make progress.
TLS 1.3
tls.c is a ring-3 client with a deliberately
narrow cipher suite: TLS_CHACHA20_POLY1305_SHA256 and
X25519 only. It is stream-oriented over the existing TCP connection
and prints the leaf SHA-256 fingerprint for manual comparison.
- Not verified. Phase A provides encryption without authentication; a MITM is undetected.
curlwarns, and the browser marks HTTPS as unverified. - Weak DRBG. tls_rng.c mixes RDTSC jitter, ticks and the MAC; it is not a hardware-backed CSPRNG.
- Host tests. The crypto files are pure freestanding C with host vectors (
make test-crypto,tls_test.c).
Do not treat HTTPS as secure authentication. The cipher suite is real, but without certificate verification the connection authenticates nothing. Use it for confidentiality on a trusted network, not for secrets against an active attacker.
sys_net ABI & ownership
sys_net.c exposes NIC info, MAC/IP/mask/ gateway/DNS getters and setters, raw frame TX/RX, decode, reply, loopback, register dump, reset, speed and MAC overrides. It also exposes the DNS, DHCP and NTP clients and the TCP/HTTP helpers.
- One owner.
SYS_NET_ACQUIREtakes the receiver for the calling process; the background kexec watcher pauses while a command owns it. - Reaper safety. If the owner dies,
sys_net_reapforce-releases the receiver throughnetdev_release_all(). - Wait semantics. ARP, DNS, DHCP, NTP and TCP waits re-enable interrupts for their duration and spin on
get_ticks_ms(); the syscall stub enters with interrupts off. - No sockets. The connection state lives in the kernel, one connection at a time; this is why the browser opens a fresh connection per fetch job.
Netconsole & netkexec
netlog.c mirrors the serial console and
terminal output to UDP port 19290. The mirror is on by default and
broadcasts; netconsole host <laptop-ip> narrows it,
netconsole off/on toggles it, and
netlog <text> sends an ad-hoc line. The producer
never blocks: a full buffer drops characters and reports it.
netkexec.c receives a new kernel/rootfs over
UDP port 19288 using KXN2, and a runtime command pack
using KXNP. Datagrams are acknowledged with the next
expected offset and verified with a 32-bit checksum before the jump
or pack swap. On the host, make netmon and
make net-dev wrap these protocols.
HTTP clients
- curl —
http://orhttps://GET with DNS, ARP, redirects (up to five hops), chunked decoding, status/headers/body dump and a TLS warning. - uhttp — shared ring-3 HTTP/1.1 client used by curl and the browser: URL parsing, redirects, chunked decoding, timeouts and TLS.
- browser — runs network fetches in a headless
curl __fetchhelper that writes the body and metadata under/share, so the UI keeps drawing and scrolling. Each fetch opens a fresh connection. - websrv — the server side, speaking HTTP/1.1 + WebDAV over the TCP listener; see Filesystems → WebDAV.
The browser's helper requests identity encoding because inflating multi-megabyte pages in the UI process stalled. If a server still sends gzip, the browser's inflate hook pumps the UI while decoding.
Security posture
| Surface | State | Consequence |
|---|---|---|
| TLS certificates | Not verified | Encryption without authentication; MITM is undetected. |
| TLS DRBG | Weak (RDTSC/ticks/MAC) | Not suitable for high-value secrets. |
| WebDAV | No authentication | Anyone on the LAN can read mounts and write /share. |
| NTP | Unauthenticated SNTP | Anyone who can answer for the server name can set the clock. |
| NIC ownership | One process at a time | Packet-level commands are mutually exclusive; a killed owner is force-released. |
| Kernel/user isolation | None (identity map) | A ring-3 bug can reach any mapped kernel page. |
Source map
netdev.c,netdev.h— registrye1000e.c,r8168.c,ne2000.c,asix.cnet.c,net.h— ARP/ICMP/UDP/IPdhcp.c,dns.c,ntp.ctcp.c,tcp.h— client + listenertls.c,tls_*.c— TLS 1.3sys_net.c— ring-3 servicenetlog.c,netkexec.cuhttp.c,ucmd_curl.c,ucmd_websrv.c