Skip to main content
SerenityOS includes a fully functional network stack built from scratch, supporting modern networking protocols and standards.

Overview

The SerenityOS network stack provides comprehensive networking capabilities with support for multiple protocols, network interfaces, and socket types.

TCP/IP Stack

Full IPv4 and IPv6 protocol implementation

Socket API

POSIX-compliant socket interface

Network Drivers

Hardware and virtual network adapters

Protocol Support

TCP, UDP, ICMP, ARP, and more

Network Protocols

Internet Protocol (IP)

IPv4 Support

Complete IPv4 implementation with:
  • IP packet forwarding
  • Fragmentation and reassembly
  • Time-to-live (TTL) handling
  • IP options processing
  • Checksum validation
  • Source routing
  • ICMP integration

IPv6 Support

Growing IPv6 capabilities including:
  • IPv6 addressing and routing
  • Neighbor Discovery Protocol
  • ICMPv6 support
  • IPv6 extension headers
  • Dual-stack operation (IPv4/IPv6)
  • Stateless address autoconfiguration (SLAAC)
Both IPv4 and IPv6 can be used simultaneously, with proper dual-stack support for modern network environments.

Transport Layer Protocols

Full-featured TCP implementation:Features:
  • Three-way handshake
  • Reliable, ordered delivery
  • Flow control (sliding window)
  • Congestion control
  • Retransmission on packet loss
  • Connection state management
  • Graceful connection termination
  • TCP options support (MSS, window scaling, timestamps)
  • Keep-alive mechanism
TCP States:
  • LISTEN, SYN_SENT, SYN_RECEIVED
  • ESTABLISHED
  • FIN_WAIT_1, FIN_WAIT_2
  • CLOSE_WAIT, CLOSING
  • LAST_ACK, TIME_WAIT, CLOSED
Lightweight datagram protocol:Features:
  • Connectionless communication
  • Low overhead
  • Broadcast and multicast support
  • Port multiplexing
  • Checksum validation (optional)
  • No delivery guarantees
Use Cases:
  • DNS queries
  • DHCP
  • NTP time synchronization
  • Streaming media
  • Real-time applications

Network Layer Protocols

ICMP (Internet Control Message Protocol)

ICMP implementation for network diagnostics: Message Types:
  • Echo Request/Reply (ping)
  • Destination Unreachable
  • Time Exceeded
  • Redirect
  • Source Quench
  • Parameter Problem
ICMPv6:
  • Echo Request/Reply
  • Neighbor Solicitation/Advertisement
  • Router Solicitation/Advertisement
  • Packet Too Big
  • Time Exceeded

ARP (Address Resolution Protocol)

MAC address resolution for IPv4:
  • ARP request/reply handling
  • ARP cache management
  • Gratuitous ARP
  • ARP cache timeout
  • Proxy ARP support

Ethernet

Ethernet frame handling:
  • Frame parsing and validation
  • MAC address filtering
  • EtherType identification
  • VLAN tagging support (802.1Q)
  • Jumbo frames
Supported EtherTypes:
  • IPv4 (0x0800)
  • IPv6 (0x86DD)
  • ARP (0x0806)
  • VLAN (0x8100)

Application Layer Protocols

SerenityOS includes implementations of common application protocols:

HTTP/HTTPS

Web protocol with TLS encryption

DNS

Domain name resolution

DHCP

Dynamic IP configuration

NTP

Network time synchronization

IMAP

Email retrieval protocol

Gemini

Alternative internet protocol

Telnet

Remote terminal access

WebSocket

Bidirectional web communication

HTTP/HTTPS

HTTP Features:
  • HTTP/1.0 and HTTP/1.1
  • Keep-alive connections
  • Chunked transfer encoding
  • Content negotiation
  • Cookie management
  • Redirect handling
  • Compression (gzip, deflate)
HTTPS/TLS:
  • TLS 1.2 and 1.3
  • Modern cipher suites
  • Certificate validation
  • Perfect Forward Secrecy
  • SNI (Server Name Indication)
  • ALPN (Application-Layer Protocol Negotiation)

DNS

Domain Name System implementation via LookupServer: Features:
  • A and AAAA record queries
  • CNAME resolution
  • MX records for mail
  • PTR records (reverse DNS)
  • NS records
  • SOA records
  • Query caching
  • Multiple nameserver support
  • /etc/hosts file integration
  • Recursive resolution

DHCP

Dynamic Host Configuration Protocol client:
  • Automatic IP address assignment
  • Network parameter configuration (gateway, DNS)
  • Lease management and renewal
  • DHCP discovery and negotiation
  • DHCP release on shutdown

Socket API

SerenityOS provides a POSIX-compliant socket API for network programming:

Socket Types

// Stream socket (TCP)
int sock = socket(AF_INET, SOCK_STREAM, 0);

// Datagram socket (UDP)
int sock = socket(AF_INET, SOCK_DGRAM, 0);

// Raw socket (requires privileges)
int sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);

Address Families

  • AF_INET - IPv4 addressing
  • AF_INET6 - IPv6 addressing
  • AF_LOCAL (AF_UNIX) - Local/Unix domain sockets

Socket Operations

Full socket API support:
  • socket() - Create socket
  • bind() - Bind to address/port
  • listen() - Listen for connections
  • accept() - Accept incoming connection
  • connect() - Establish connection
  • send() / recv() - Send/receive data
  • sendto() / recvfrom() - Datagram operations
  • close() - Close socket
  • shutdown() - Shut down part of connection
  • getsockopt() / setsockopt() - Socket options

Non-blocking and Async I/O

  • Non-blocking socket mode
  • select() for multiplexing
  • poll() for event notification
  • epoll() for scalable event handling

Network Adapters

Support for various network interface types:

Hardware Adapters

E1000 and E1000E network adapter drivers:
  • PCI and PCIe variants
  • Interrupt and polling modes
  • Transmit and receive queues
  • Hardware checksums
  • Link state detection
Modern Intel Ethernet controllers with:
  • Multi-gigabit support
  • Advanced features
  • Energy efficient operation

Virtual Adapters

Standard loopback (127.0.0.1/::1):
  • Local communication
  • No hardware required
  • Testing and development
  • Perfect reliability
Paravirtualized network for virtual machines:
  • KVM/QEMU support
  • High performance in VMs
  • Low overhead
  • Modern virtqueue interface

Network Configuration

Static Configuration

Manual network setup:
# Configure IP address
ifconfig eth0 192.168.1.100 netmask 255.255.255.0

# Set default gateway
route add default gw 192.168.1.1

# Configure DNS
echo "nameserver 8.8.8.8" > /etc/resolv.conf

Dynamic Configuration (DHCP)

Automatic configuration via DHCPClient service:
  • Automatic IP assignment
  • Default gateway configuration
  • DNS server configuration
  • Network interface activation

Network Settings Application

GUI application for network configuration:
  • Interface management
  • IP address configuration
  • Gateway and DNS setup
  • Connection status monitoring

Network Tools

SerenityOS includes standard network utilities:

Diagnostic Tools

  • ping - Test connectivity with ICMP echo
  • ifconfig - Configure network interfaces
  • route - View and modify routing table
  • netstat - Network statistics and connections
  • arp - View and modify ARP cache
  • traceroute - Trace packet route to destination
  • nslookup - DNS query tool
  • host - DNS lookup utility

Network Applications

  • fetch - Download files via HTTP/HTTPS
  • telnet - Telnet client
  • nc (netcat) - Network Swiss Army knife
  • wget - Non-interactive file downloader

Network Security

Firewall & Filtering

Packet filtering capabilities:
  • Connection state tracking
  • Port-based filtering
  • Protocol filtering
  • Network address translation (NAT) in development

TLS/SSL

Secure communication with LibTLS: Cipher Suites:
  • RSA and ECDHE key exchange
  • AES-GCM, ChaCha20-Poly1305 encryption
  • SHA-256, SHA-384 hashing
  • Modern, secure algorithms only
Certificate Validation:
  • X.509 certificate parsing
  • Certificate chain validation
  • Hostname verification
  • Certificate expiration checking
  • Revocation checking (in development)

Security Features

  • TCP SYN cookies for DoS protection
  • Rate limiting for ICMP
  • Randomized port allocation
  • Sequence number randomization
  • Path MTU discovery
Network services are sandboxed using pledge() and unveil() to limit potential security exposure.

Performance Features

Optimizations

  • Zero-copy networking where possible
  • Scatter-gather I/O
  • TCP window scaling
  • Selective acknowledgment (SACK)
  • Fast retransmit and recovery
  • Nagle’s algorithm
  • Delayed ACK

Buffer Management

  • Efficient mbuf (memory buffer) system
  • Buffer pooling
  • Dynamic buffer allocation
  • Memory pressure handling

Routing

Routing table management:
  • Static routes
  • Default gateway
  • Network-specific routes
  • Host-specific routes
  • Route metrics and preferences
  • Multiple routing tables (in development)

Network Monitoring

Tools for monitoring network activity:
  • Real-time connection monitoring
  • Packet statistics
  • Interface statistics (bytes, packets, errors)
  • Protocol-specific counters
  • SystemMonitor integration
The network stack is continuously being improved with new features, better performance, and enhanced protocol support.

Build docs developers (and LLMs) love