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
TCP (Transmission Control Protocol)
TCP (Transmission Control Protocol)
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
- LISTEN, SYN_SENT, SYN_RECEIVED
- ESTABLISHED
- FIN_WAIT_1, FIN_WAIT_2
- CLOSE_WAIT, CLOSING
- LAST_ACK, TIME_WAIT, CLOSED
UDP (User Datagram Protocol)
UDP (User Datagram Protocol)
Lightweight datagram protocol:Features:
- Connectionless communication
- Low overhead
- Broadcast and multicast support
- Port multiplexing
- Checksum validation (optional)
- No delivery guarantees
- 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
- 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
Link Layer
Ethernet
Ethernet frame handling:- Frame parsing and validation
- MAC address filtering
- EtherType identification
- VLAN tagging support (802.1Q)
- Jumbo frames
- 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)
- 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
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 socketbind()- Bind to address/portlisten()- Listen for connectionsaccept()- Accept incoming connectionconnect()- Establish connectionsend()/recv()- Send/receive datasendto()/recvfrom()- Datagram operationsclose()- Close socketshutdown()- Shut down part of connectiongetsockopt()/setsockopt()- Socket options
Non-blocking and Async I/O
- Non-blocking socket mode
select()for multiplexingpoll()for event notificationepoll()for scalable event handling
Network Adapters
Support for various network interface types:Hardware Adapters
Intel E1000 Family
Intel E1000 Family
E1000 and E1000E network adapter drivers:
- PCI and PCIe variants
- Interrupt and polling modes
- Transmit and receive queues
- Hardware checksums
- Link state detection
Intel i225 Series
Intel i225 Series
Modern Intel Ethernet controllers with:
- Multi-gigabit support
- Advanced features
- Energy efficient operation
Virtual Adapters
Loopback Interface
Loopback Interface
Standard loopback (127.0.0.1/::1):
- Local communication
- No hardware required
- Testing and development
- Perfect reliability
VirtIO Network
VirtIO Network
Paravirtualized network for virtual machines:
- KVM/QEMU support
- High performance in VMs
- Low overhead
- Modern virtqueue interface
Network Configuration
Static Configuration
Manual network setup: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
- 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.
