16 unstable releases (3 breaking)
Uses new Rust 2024
| 0.4.1 | Apr 16, 2026 |
|---|---|
| 0.3.0 | Dec 19, 2025 |
| 0.2.9 | May 27, 2025 |
| 0.2.7 | Mar 11, 2025 |
| 0.2.2 | Nov 29, 2024 |
#320 in Network programming
14,342 downloads per month
105KB
2K
SLoC
mtu
A crate to return the name and maximum transmission unit (MTU) of the local network interface
towards a given destination SocketAddr, optionally from a given local SocketAddr.
Usage
This crate exports a single function interface_and_mtu that returns the name and
maximum transmission unit (MTU)
of the outgoing network interface towards a remote destination identified by an IpAddr.
Example
let destination = IpAddr::V4(Ipv4Addr::LOCALHOST);
let (name, mtu): (String, usize) = mtu::interface_and_mtu(destination).unwrap();
println!("MTU towards {destination} is {mtu} on {name}");
Supported Platforms
- Linux
- Android
- macOS
- Windows
- FreeBSD
- NetBSD
- OpenBSD
- Solaris
Notes
The returned MTU may exceed the maximum IP packet size of 65,535 bytes on some platforms for some remote destinations. (For example, loopback destinations on Windows.)
The returned interface name is obtained from the operating system.
Contributing
We're happy to receive PRs that improve this crate. Please take a look at our community guidelines beforehand.
License: MIT OR Apache-2.0
Dependencies
~0–28MB
~458K SLoC