Components
Packet
The core message type, carrying time, size, priority, and control signals.
The simulator’s primary message is Packet (src/flows/packet.rs). Packets are plain structs (no payload modeling) that carry:
- Timestamp:
Packet.timeis the current simulation time associated with the packet. - Creation time:
Packet.creation_timeis the time the source first created the packet. - Size:
Packet.size(bytes) determines serialization delay at schedulers/links. - Identifiers:
packet_idis per-flow,flow_ididentifies the flow globally. - Accumulated queueing delay:
queueing_delaytracks time spent waiting in scheduler queues. - Priority (PCP):
priorityis an 802.1Q priority code point (0–7). - End-of-flow marker:
last_packetis used for dependency wiring and “flow finished” events.
Packets also model minimal transport/control signals:
- TCP acks:
ack: Option<TCPAck>is used by the TCP source/sink pair. - Control packets:
control: Option<ControlPacket>currently includes DCQCN’s CNP (DcqcnCnp). - ECN:
ecn: EcnFieldcan beNotEct,Ect0,Ect1, orCe. - TCP CWR:
cwr: boolis used for ECN-CWR signaling in TCP.
Time updates
Two helper methods encode the intended invariants:
queueing_delay_update(now)addsnow - packet.timetoqueueing_delay. Call this when a packet leaves a queue.departure_update(now)setspacket.time = now. Call this when a packet departs a component and is scheduled for delivery downstream.
Schedulers follow the pattern:
- Pop packet at time
now packet.queueing_delay_update(now)- Compute serialization delay
timeout = size_bits / rate_bps packet.departure_update(now + timeout)- Schedule downstream delivery after
timeout
ECN marking
Drop/mark policies can call packet.mark_ce():
- If
packet.ecn == NotEct,mark_ce()returnsfalse(cannot be ECN-marked). - If ECN-capable (
Ect0/Ect1),mark_ce()setsecn = Ceand returnstrue.
Schedulers that “mark ECN” will drop packets that are not ECN-capable.