shadow_rs/network/
mod.rs

1//! The network simulation.
2//!
3//! This contains code that simulates the Internet and upstream routers. It does not contain any
4//! emulation of Linux networking behaviour, which exists in the [`crate::host`] module.
5
6use std::net::Ipv4Addr;
7
8use crate::network::packet::PacketRc;
9
10pub mod dns;
11pub mod graph;
12pub mod packet;
13pub mod relay;
14pub mod router;
15
16pub trait PacketDevice {
17    fn get_address(&self) -> Ipv4Addr;
18    fn pop(&self) -> Option<PacketRc>;
19    fn push(&self, packet: PacketRc);
20}
21
22#[cfg(test)]
23mod tests {
24    use shadow_shim_helper_rs::{emulated_time::EmulatedTime, simulation_time::SimulationTime};
25
26    pub fn mock_time_millis(millis_since_sim_start: u64) -> EmulatedTime {
27        let simtime = SimulationTime::from_millis(millis_since_sim_start);
28        EmulatedTime::from_abs_simtime(simtime)
29    }
30}