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
AllocationPolicy::EqualShare: divide total capacity equally among all peersAllocationPolicy::WeightedFair: weight byBandwidthClass(High=4, Normal=2, Low=1, Background=0.5)AllocationPolicy::MinGuarantee: each peer gets at leastnbps, remainder distributed equallyAllocationPolicy::MaxCapacity: each peer gets at mostnbpsAllocationPolicy::PriorityQueue: high-priority peers allocated first until capacity exhausted
§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§
- Adaptive
Bandwidth Allocator - Adaptive bandwidth manager that dynamically allocates bandwidth across peers.
- Allocator
Config - Configuration for
AdaptiveBandwidthAllocator. - Bandwidth
Stats - Aggregate bandwidth statistics across all tracked peers.
- Bandwidth
Window - Rolling 10-sample window of bandwidth measurements.
- Peer
Bandwidth Profile - Complete bandwidth state for a single peer.
Enums§
- Allocation
Policy - Strategy used by
AdaptiveBandwidthAllocator::reallocateto distribute the total available bandwidth across peers. - Allocator
Error - Error variants returned by
AdaptiveBandwidthAllocatormethods. - Bandwidth
Class - Priority classification for a peer, used to drive weighted-fair allocation.
- Bandwidth
Event - Events emitted by the allocator for observability and history queries.