pub struct NetRouter { /* private fields */ }Expand description
Net Router
Implementations§
Source§impl NetRouter
impl NetRouter
Sourcepub async fn new(config: RouterConfig) -> Result<Self>
pub async fn new(config: RouterConfig) -> Result<Self>
Create a new router
Sourcepub fn set_test_drop_every_n(&self, n: u64)
pub fn set_test_drop_every_n(&self, n: u64)
Test-only: drop every nth dequeued (scheduled) packet in the
send loop to simulate link loss. 0 disables. Used by reliability
/ retransmit tests; has no effect on the default (0) path.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Get local address
Sourcepub fn routing_table(&self) -> &Arc<RoutingTable> ⓘ
pub fn routing_table(&self) -> &Arc<RoutingTable> ⓘ
Get routing table
Sourcepub fn scheduler(&self) -> &Arc<FairScheduler> ⓘ
pub fn scheduler(&self) -> &Arc<FairScheduler> ⓘ
Get the fair scheduler. Exposed so MeshNode::open_stream can
propagate a stream’s fairness_weight to the forwarding path.
Sourcepub fn add_route(&self, dest_id: u64, next_hop: SocketAddr)
pub fn add_route(&self, dest_id: u64, next_hop: SocketAddr)
Add a route
Sourcepub fn remove_route(&self, dest_id: u64)
pub fn remove_route(&self, dest_id: u64)
Remove a route
Sourcepub fn route_packet(
&self,
data: Bytes,
_from: SocketAddr,
) -> Result<RouteAction, RouterError>
pub fn route_packet( &self, data: Bytes, _from: SocketAddr, ) -> Result<RouteAction, RouterError>
Route a packet (called from receive loop)
Sourcepub async fn send_to(&self, data: &[u8], dest: SocketAddr) -> Result<usize>
pub async fn send_to(&self, data: &[u8], dest: SocketAddr) -> Result<usize>
Send a packet directly (bypassing routing)
Sourcepub fn start(&self) -> Option<JoinHandle<()>>
pub fn start(&self) -> Option<JoinHandle<()>>
Start the router (spawns send loop). Returns None if a
dispatch loop is already running for this router; calling
twice would otherwise spawn a second loop racing the first
one’s scheduler.dequeue(), producing reordered or
duplicate sends.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if running
Sourcepub fn stats(&self) -> RouterStats
pub fn stats(&self) -> RouterStats
Get statistics
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics