pub struct NetworkQoSManager {
pub config: QoSConfig,
pub queues: HashMap<u8, VecDeque<QoSPacket>>,
pub metrics: HashMap<u8, QueueMetrics>,
pub violations: VecDeque<SLAViolation>,
pub total_enqueued: u64,
pub total_dequeued: u64,
pub total_dropped: u64,
/* private fields */
}Expand description
Quality-of-Service manager: priority queuing, SLA enforcement, and bandwidth-share scheduling for the IPFRS network layer.
Fields§
§config: QoSConfigUser-supplied configuration.
queues: HashMap<u8, VecDeque<QoSPacket>>Priority queues keyed by TrafficClass::priority() (1..=4).
metrics: HashMap<u8, QueueMetrics>Per-priority queue metrics keyed by priority (1..=4).
violations: VecDeque<SLAViolation>Bounded log of observed SLA violations (max 1 000 entries).
total_enqueued: u64Lifetime counter of successfully enqueued packets.
total_dequeued: u64Lifetime counter of successfully dequeued packets.
total_dropped: u64Lifetime counter of dropped packets.
Implementations§
Source§impl NetworkQoSManager
impl NetworkQoSManager
Sourcepub fn new(config: QoSConfig) -> Self
pub fn new(config: QoSConfig) -> Self
Create a new manager with the given configuration.
Initialises four priority queues (keyed 1..=4) and pre-fills WRR
quanta proportional to each class’s bandwidth_share.
Sourcepub fn enqueue(&mut self, packet: QoSPacket, _now: u64) -> bool
pub fn enqueue(&mut self, packet: QoSPacket, _now: u64) -> bool
Enqueue a packet into the priority queue determined by its class.
If the total queue occupancy is at or above max_queue_size:
- Try to drop the oldest Background packet (priority 1).
- If Background is already empty, drop the newest Background packet (i.e. the one just being enqueued is discarded instead).
- If neither relieves enough space, return
false.
Returns true when the packet was successfully enqueued.
Sourcepub fn drop_packet(&mut self, priority: u8) -> bool
pub fn drop_packet(&mut self, priority: u8) -> bool
Drop the oldest packet from the queue at priority.
Returns true if a packet was removed, false if the queue was empty.
Sourcepub fn dequeue(&mut self, now: u64) -> Option<QoSPacket>
pub fn dequeue(&mut self, now: u64) -> Option<QoSPacket>
Dequeue the next packet according to the configured scheduling policy.
- Strict priority (
enable_strict_priority = true): always pick from the highest non-empty priority queue. - Weighted round-robin (
enable_strict_priority = false): iterate round-robin through classes; addquantumcredits each visit and dequeue when credits ≥ packet size. Falls back to the highest non-empty queue if no class accumulates enough credits.
Returns None if all queues are empty.
Sourcepub fn check_sla(&mut self, now: u64) -> Vec<SLAViolation>
pub fn check_sla(&mut self, now: u64) -> Vec<SLAViolation>
Check every configured SLA spec against current queue metrics.
Any violation is appended to the internal violations log (bounded to 1 000 entries, oldest evicted on overflow). The set of violations discovered during this call is returned.
Sourcepub fn queue_metrics(&self, class: &TrafficClass) -> Option<&QueueMetrics>
pub fn queue_metrics(&self, class: &TrafficClass) -> Option<&QueueMetrics>
Return queue metrics for a specific traffic class, or None if the
class is not tracked (should not happen with a correctly initialised
manager).
Sourcepub fn all_metrics(&self) -> Vec<&QueueMetrics>
pub fn all_metrics(&self) -> Vec<&QueueMetrics>
Return metrics for all four priority queues ordered highest-first.
Sourcepub fn total_queued_bytes(&self) -> usize
pub fn total_queued_bytes(&self) -> usize
Total byte count across all queued packets.
Sourcepub fn violations_log(&self) -> &VecDeque<SLAViolation>
pub fn violations_log(&self) -> &VecDeque<SLAViolation>
Immutable reference to the bounded violations log.
Sourcepub fn reset_metrics(&mut self)
pub fn reset_metrics(&mut self)
Reset all per-class EWMA wait metrics to zero (useful for test isolation or after a reconfiguration event).
Auto Trait Implementations§
impl Freeze for NetworkQoSManager
impl RefUnwindSafe for NetworkQoSManager
impl Send for NetworkQoSManager
impl Sync for NetworkQoSManager
impl Unpin for NetworkQoSManager
impl UnsafeUnpin for NetworkQoSManager
impl UnwindSafe for NetworkQoSManager
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more