Skip to main content

NetworkQoSManager

Struct NetworkQoSManager 

Source
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: QoSConfig

User-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: u64

Lifetime counter of successfully enqueued packets.

§total_dequeued: u64

Lifetime counter of successfully dequeued packets.

§total_dropped: u64

Lifetime counter of dropped packets.

Implementations§

Source§

impl NetworkQoSManager

Source

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.

Source

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:

  1. Try to drop the oldest Background packet (priority 1).
  2. If Background is already empty, drop the newest Background packet (i.e. the one just being enqueued is discarded instead).
  3. If neither relieves enough space, return false.

Returns true when the packet was successfully enqueued.

Source

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.

Source

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; add quantum credits 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.

Source

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.

Source

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).

Source

pub fn all_metrics(&self) -> Vec<&QueueMetrics>

Return metrics for all four priority queues ordered highest-first.

Source

pub fn total_queued_bytes(&self) -> usize

Total byte count across all queued packets.

Source

pub fn violations_log(&self) -> &VecDeque<SLAViolation>

Immutable reference to the bounded violations log.

Source

pub fn qos_stats(&self) -> QoSStats

Aggregate statistics snapshot.

Source

pub fn reset_metrics(&mut self)

Reset all per-class EWMA wait metrics to zero (useful for test isolation or after a reconfiguration event).

Source

pub fn flush_all(&mut self) -> usize

Drain all packets from all queues and return the total count removed.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more