Skip to main content

Module adaptive_bandwidth_allocator

Module adaptive_bandwidth_allocator 

Source
Expand description

Adaptive bandwidth allocator for peer-to-peer networks.

Provides dynamic bandwidth management across peers using configurable allocation policies, congestion detection, rolling measurement windows, and event history.

§Policies

§Example

use ipfrs_network::adaptive_bandwidth_allocator::{
    AdaptiveBandwidthAllocator, AllocatorConfig, AllocationPolicy, BandwidthClass,
};

let config = AllocatorConfig {
    total_capacity_bps: 100_000_000,
    min_allocation_bps: 1_000_000,
    max_allocation_bps: 50_000_000,
    policy: AllocationPolicy::WeightedFair,
    rebalance_interval_secs: 30,
    congestion_threshold_ppm: 10_000,
};
let mut allocator = AdaptiveBandwidthAllocator::new(config);
allocator.add_peer("peer-1".to_string(), BandwidthClass::High, 10_000_000).unwrap();

Structs§

AdaptiveBandwidthAllocator
Adaptive bandwidth manager that dynamically allocates bandwidth across peers.
AllocatorConfig
Configuration for AdaptiveBandwidthAllocator.
BandwidthStats
Aggregate bandwidth statistics across all tracked peers.
BandwidthWindow
Rolling 10-sample window of bandwidth measurements.
PeerBandwidthProfile
Complete bandwidth state for a single peer.

Enums§

AllocationPolicy
Strategy used by AdaptiveBandwidthAllocator::reallocate to distribute the total available bandwidth across peers.
AllocatorError
Error variants returned by AdaptiveBandwidthAllocator methods.
BandwidthClass
Priority classification for a peer, used to drive weighted-fair allocation.
BandwidthEvent
Events emitted by the allocator for observability and history queries.