TCP and Network Infrastructure
What is it?
This is the base of the Impossible OS network stack: the Ethernet, ARP, IPv4, ICMP, UDP and DHCP code that runs today, and the TCP, interface manager, loopback and connection tracking that the roadmap adds on top. Today a booted system gets an address from a DHCP server and answers ping, but it cannot open a TCP connection, so no program can talk to a web server, a mail server or a remote shell yet. Every later networking roadmap (DNS and sockets, HTTP and TLS, the firewall, the browser and the other clients) waits on the TCP work here. None of its seven sections has started.
How does it work?
The stack that exists. Six small files in src/kernel/net/ form a minimal IPv4 host with one network card and one global configuration:
- Ethernet (
ethernet.c).net_init()copies the card's MAC address intonet_cfg,eth_send()pads a frame to the 60-byte minimum and hands it to the RTL8139 driver, andnet_rx()passes ARP and IPv4 frames up and drops every other EtherType. - ARP (
arp.c). A 32-entry table filled from every ARP packet seen, with round-robin replacement and no expiry. It answers requests for the machine's own address once DHCP has configured one. - IPv4 (
ip.c).ipv4_send()builds a 20-byte header with TTL 64, sends broadcasts directly, routes off-subnet traffic to the gateway and resolves the next hop with ARP. On an ARP miss it sends a request and drops the packet, so the first packet to a new host is lost. There is no fragmentation: anything larger than the 1500-byte MTU is dropped.ipv4_handle()passes ICMP and UDP up; theIP_PROTO_TCPcase exists and silently drops. - ICMP (
icmp.c). Answers echo requests and records echo replies, printing[ICMP] Echo reply from a.b.c.d seq=Nto the log. - UDP (
udp.c).udp_handle()delivers only port 68 (the DHCP client) and drops everything else.udp_send()sends with a zero checksum, which IPv4 allows, and nothing checks the checksum on receive. - DHCP (
dhcp.c). A one-shot DISCOVER, OFFER, REQUEST, ACK exchange that fills in the address, subnet mask, gateway and first DNS server. It never retries, never renews its lease and ignores a NAK.
All of it shares one struct net_config net_cfg (net.h) with no locking. The boot path brings the card up, then the stack, then sends the DHCP DISCOVER; the card itself is described in Network Drivers.
flowchart LR
NIC[RTL8139] --> RX[net_rx]
RX --> ARP[ARP table]
RX --> IP[ipv4_handle]
IP --> ICMP[ICMP echo]
IP --> UDP[udp_handle]
UDP --> DHCP[DHCP client, port 68]
IP -. TCP: dropped today .-> X[planned tcp_handle]
What the roadmap adds. The planned order is interface manager first, then loopback, then TCP, then connection tracking:
- A
struct net_interfaceandnetif_*API that replaces the singlenet_cfg, with anetif_get_default()shim for existing callers. - A loopback interface for
127.0.0.1/8that never leaves the kernel. - TCP: the header and pseudo-header checksum, the RFC 793 state machine, a
tcp_connect(),tcp_send(),tcp_recv()andtcp_close()API, then retransmission, Nagle's algorithm and slow-start congestion control. - Stateful connection tracking keyed on the address and port 4-tuple, which the firewall uses to let reply traffic back in.
A decision comes before any TCP code: the roadmap records that lwIP is BSD-3-Clause, and so compatible with this project's GPL-3.0-only licence, and requires a written vendor-or-build verdict first.
What are its interfaces?
| Interface | Purpose |
|---|---|
net_init(), eth_send(), net_rx() |
Ethernet entry points (net.h) |
arp_resolve(), arp_request() |
Next-hop address lookup |
ipv4_send(), ipv4_handle(), ipv4_checksum() |
IPv4 send and receive |
icmp_send_echo() |
Send an echo request (used by ping) |
udp_send(), udp_handle() |
UDP send and the port-68-only receive path |
dhcp_discover() |
Start address configuration |
net_cfg |
The one interface's MAC, IP, subnet, gateway and DNS server |
None of the planned tcp_*, netif_* or connection-tracking functions exist yet.
How do I use it?
Boot under QEMU with the repository launchers, which attach an RTL8139 card on QEMU user networking (-netdev user). The serial log shows DHCP: IP a.b.c.d, GW a.b.c.d, DNS a.b.c.d when the lease arrives. At the command prompt:
ifconfig(oripconfig) prints the MAC, IP, subnet, gateway and DNS server ofeth0, or(not configured, DHCP pending).ping <ip>sends four echo requests. It printsSent echo request seq=Nfor each and does not wait for or report replies; a reply shows up only as the kernel log line above.
The addresses are dotted IPv4 numbers; there is no name lookup.
What is not implemented yet?
- Interfaces: Network Interface Manager and Loopback Interface.
- TCP: TCP Header + Checksum, TCP Connection State Machine, TCP API and TCP Robustness.
- Firewall backing: Stateful Connection Tracking.
- Receive-path hardening:
ipv4_handle()does not check the header length field or the header checksum, andudp_handle()trusts the UDP length field, so a malformed packet can make the stack read past the frame. The fix is filed under TCP Header + Checksum, which rewrites that path.
No unit test covers the network stack today.
How does it compare with Windows 11 and Linux?
Windows 11 implements all of this in tcpip.sys behind NDIS, and Linux in net/ipv4/ with net_device, the loopback driver and nf_conntrack. Both have had a hardened TCP for decades. Impossible OS today matches only their smallest piece: one card, IPv4, ping and a DHCP lease. The roadmap aims for the same layering, with connection tracking shared between TCP and the firewall.