pub struct Router { /* private fields */ }Expand description
A Router routes PacketRcs between PacketDevices and the
simulated network, enforcing configured send/receive rate limits on the
interfaces and the upstream/downstream links to a modeled network provider.
For more information, see the module docs for crate::network::router.
Implementations§
Source§impl Router
impl Router
Sourcepub fn new(tx_rate: RateLimit, rx_rate: RateLimit) -> Self
pub fn new(tx_rate: RateLimit, rx_rate: RateLimit) -> Self
Creates a new Router instance with the given rate limits set on its
global transmit and receive queues.
Sourcepub fn attach_packet_device(
&mut self,
addr: Ipv4Addr,
tx_rate: RateLimit,
rx_rate: RateLimit,
)
pub fn attach_packet_device( &mut self, addr: Ipv4Addr, tx_rate: RateLimit, rx_rate: RateLimit, )
Add a new device at the given address, and assign the given rate limits to the associated transmit and receive queues.
It is assumed that the router will be able to obtain a reference to the
underlying device implementing the PacketDevice trait when it calls
RouterContext::get_packet_device_fn and passes the address provided here. It
is up to the caller to set the correct router context and addressing.
Sourcepub fn run<T>(
&self,
ctx: &Context<'_, T>,
event: RouterEvent,
) -> Option<EmulatedTime>
pub fn run<T>( &self, ctx: &Context<'_, T>, event: RouterEvent, ) -> Option<EmulatedTime>
Run the router with the given context to handle the provided RouterEvent.
If this function returns Some, the caller must ensure that
Router::run is called again with the RouterEvent::Wakeup event
at the contained EmulatedTime.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Router
impl !RefUnwindSafe for Router
impl !UnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin for Router
Blanket Implementations§
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<T> Host for T
impl<T> Host for T
impl<T> Host for T
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