A Rust library for network simulation, isolation, and packet inspection to test networking code.
netsim is a Rust library for network simulation and testing that allows developers to run tests in isolated network environments, simulate network conditions, and inspect network packets. It solves the problem of testing networking code that requires specific network configurations or isolation from the host system.
Rust developers building networking applications, libraries, or services who need to test network behavior in isolated or simulated environments.
Developers choose netsim because it provides a lightweight, programmatic way to simulate networks and isolate tests without requiring complex infrastructure or single-threaded test execution, making it ideal for validating networking code in CI/CD pipelines.
Network simulation in Rust
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows tests to run in isolated network threads without requiring single-threaded execution, as shown with the #[netsim::isolate] attribute in Example 1.
Enables capturing and validating network packets directly in code, demonstrated in Example 2 where UDP packet data is asserted.
Uses Linux containerization APIs for isolation, providing a efficient simulation without heavy virtualization, per the philosophy section.
Supports adding IP interfaces with customizable addresses and routes, as seen in the machine setup with ipv4_addr and ipv4_default_route.
Relies exclusively on Linux containerization APIs, making it unusable on other operating systems and restricting cross-platform testing workflows.
Requires manual coding for advanced scenarios like packet injection and network routing, which can be more involved than using higher-level tools.
Focuses on low-level packet handling; lacks out-of-the-box simulations for common network conditions like latency, jitter, or bandwidth throttling.