use crate::time::Duration;
mod process;
pub use process::{Process, ProcessId, ProcessLogic};
mod link;
pub use link::Link;
pub type Latency = Duration;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Bandwidth(u64);
impl Bandwidth {
pub fn from_megabits_per_second(mbps: u64) -> Self {
Self(mbps * 1024 * 1024)
}
pub fn into_bits_per_second(self) -> u64 {
self.0
}
}
pub trait NetworkMessage: 'static + Send {
fn get_size(&self) -> u64;
}
pub fn get_size_delay(size: u64, bandwidth: Bandwidth) -> Duration {
let micros = (size * 8 * 1000 * 1000) / bandwidth.into_bits_per_second();
Duration::from_micros(micros)
}