Expand description
Protocol stack abstraction for network protocols
This module provides the infrastructure for protocol stacks (TCP/IP, UDP, etc.) to be integrated with Scarlet’s socket system.
§Design
Protocol stacks bridge between high-level SocketObject and low-level network devices. They handle protocol-specific operations like:
- Packet encapsulation/decapsulation
- Connection state management
- Error handling and retransmission
- Flow control and congestion control
§Architecture
Application
↓
SocketObject (ABI-specific, e.g., Linux TCP socket)
↓
ProtocolStack (TCP/IP, UDP, etc.)
↓
NetworkDevice (Ethernet, WiFi, etc.)§Layered Protocol Architecture
The new NetworkLayer trait provides a flexible, composable protocol stack:
Socket Layer
↓
Transport Layer (TCP=6, UDP=17)
↓ (register_protocol)
Network Layer (IP)
↓ (register_protocol)
Link Layer (Ethernet, InfiniBand)
↓
Physical DeviceEach layer can:
- Register protocol handlers for upper layers
- Send packets to multiple lower layers
- Route based on protocol numbers
Structs§
- Layer
Context - Context passed between network layers for routing decisions
- Network
Layer Stats - Statistics for a network layer
- Protocol
Stack Manager - Protocol stack manager
- Protocol
Stack Stats - Protocol stack statistics
- Socket
Config - Configuration for socket creation and layer binding
Traits§
- Network
Layer - Network layer trait for composable protocol stacks
- Protocol
Stack - Protocol stack trait for network protocols
Functions§
- get_
network_ manager - Network layer manager