Module protocol_stack

Module protocol_stack 

Source
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 Device

Each layer can:

  • Register protocol handlers for upper layers
  • Send packets to multiple lower layers
  • Route based on protocol numbers

Structs§

LayerContext
Context passed between network layers for routing decisions
NetworkLayerStats
Statistics for a network layer
ProtocolStackManager
Protocol stack manager
ProtocolStackStats
Protocol stack statistics
SocketConfig
Configuration for socket creation and layer binding

Traits§

NetworkLayer
Network layer trait for composable protocol stacks
ProtocolStack
Protocol stack trait for network protocols

Functions§

get_network_manager
Network layer manager