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:
packet_received(packet)decidesDropAction:Drop: drop the packetMarkEcn: attemptpacket.mark_ce()(drop if not ECN-capable)Enqueue: enqueue
- If the server is idle (
packet.time >= busy_until), startrun(...). 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 queueDRR:DRRServer(src/schedulers/drr.rs) — deficit round-robin over classesWRR:WRRServer(src/schedulers/wrr.rs) — weighted round-robin over classesWFQ:WFQServer(src/schedulers/wfq.rs) — packet tagging + min-heap by finish timeSP:SPServer(src/schedulers/sp.rs) — strict priority over classesVirtualClock: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 exceededRED: random early drop (RFC 2309)RED_ECN: RED, but marks ECN instead of dropping when possibleECN_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 byECN_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.