7 releases

0.2.2 Nov 29, 2024
0.2.1 Nov 29, 2024
0.1.3 Sep 26, 2024

#1721 in Network programming

Download history 499/week @ 2024-09-02 203/week @ 2024-09-09 88/week @ 2024-09-16 377/week @ 2024-09-23 53/week @ 2024-09-30 68/week @ 2024-10-07 15/week @ 2024-10-14 40/week @ 2024-10-21 14/week @ 2024-10-28 14/week @ 2024-11-04 6/week @ 2024-11-11 181/week @ 2024-11-18 498/week @ 2024-11-25 56/week @ 2024-12-02

742 downloads per month

MIT/Apache

43KB
876 lines

Coverage Status Average time to resolve an issue Percentage of issues still open Maintenance

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
  • macOS
  • Windows
  • FreeBSD
  • NetBSD
  • OpenBSD

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.3–7MB
~56K SLoC