Module network_simulator

Module network_simulator 

Source
Expand description

Network Simulator - Simulate various network conditions for testing

This module provides utilities to simulate different network conditions such as:

  • Latency injection (constant, variable, spike patterns)
  • Packet loss simulation
  • Bandwidth throttling
  • Network partitions
  • Connection drops
  • Jitter and congestion

Useful for testing application behavior under adverse network conditions.

§Example

use ipfrs_network::{NetworkSimulator, SimulatorConfig, NetworkCondition};

// Create a simulator with high latency
let config = SimulatorConfig {
    base_latency_ms: 200,
    latency_variance_ms: 50,
    packet_loss_rate: 0.05, // 5% packet loss
    ..Default::default()
};

let simulator = NetworkSimulator::new(config);

// Apply network conditions
simulator.start().await?;

// Your network operations here will experience the simulated conditions

// Get statistics
let stats = simulator.stats();
println!("Packets dropped: {}", stats.packets_dropped);

simulator.stop().await?;

Structs§

NetworkSimulator
Network simulator for testing
SimulatorConfig
Configuration for the network simulator
SimulatorStats
Statistics tracked by the simulator

Enums§

NetworkCondition
Network condition profiles
SimulatorError
Errors that can occur during network simulation