Days
Components

Schedulers

Per-port queueing, drop/ECN, and link serialization.

Schedulers live in src/schedulers/ and model:

  • queueing (single queue or multiple classes/queues),
  • drop/mark behavior when congested,
  • serialization delay at a given link rate,
  • periodic reporting to CSV.

The topology builder creates one scheduler per directed edge in the topology graph (see Topology::connect_neighbours in src/topos/topo.rs).

Common structure

Most schedulers share these ideas:

  • rate: f64: output bit rate (bits/s).
  • busy_until: f64: time until which the server/link is “sending”.
  • a queue (or set of queues) of Packet.
  • a drop_strategy: Box<dyn PacketDrop> controlling enqueue/drop/ECN marking.

The typical control flow:

  1. packet_received(packet) decides DropAction:
    • Drop: drop the packet
    • MarkEcn: attempt packet.mark_ce() (drop if not ECN-capable)
    • Enqueue: enqueue
  2. If the server is idle (packet.time >= busy_until), start run(...).
  3. run(...) pops a packet, updates queueing delay, computes a send timeout, schedules:
    • send(packet) after the timeout
    • another run(...) after the timeout (to keep draining the queue)

Scheduling disciplines

Configured via switch.discipline:

  • FIFO: Port (src/schedulers/port.rs) — single FIFO queue
  • DRR: DRRServer (src/schedulers/drr.rs) — deficit round-robin over classes
  • WRR: WRRServer (src/schedulers/wrr.rs) — weighted round-robin over classes
  • WFQ: WFQServer (src/schedulers/wfq.rs) — packet tagging + min-heap by finish time
  • SP: SPServer (src/schedulers/sp.rs) — strict priority over classes
  • VirtualClock: VirtualClockServer (src/schedulers/vc.rs) — virtual-clock tagging + min-heap

“Class” is defined by a closure flow_classes: Fn(flow_id) -> class_id. In the topology builder, this is commonly flow_id % num_classes where num_classes is weights.len() / priorities.len() / vticks.len().

Drop and ECN policies

Configured via switch.drop (src/schedulers/drop.rs):

  • TailDrop: drop when capacity is exceeded
  • RED: random early drop (RFC 2309)
  • RED_ECN: RED, but marks ECN instead of dropping when possible
  • ECN_THRESHOLD: mark CE when occupancy exceeds a configurable threshold, else enqueue

The switch config also supports:

  • switch.ecn_threshold: a fraction in [0, 1] used by ECN_THRESHOLD (default: 0.8)

PFC integration (queue state)

When built with --features l2_pfc and run with link.mode="Pfc", schedulers expose a shared QueueState (src/schedulers/state.rs) that tracks current queued bytes/packets. This is used by the PFC ingress port to decide whether a packet can be forwarded downstream without causing drops.

On this page