Expand description
Network interfaces, download and upload, and connection counts.
sys-lib never sends a packet, never lists connections or their addresses, and never says which program owns a socket: it reports interfaces and counts.
use sys_lib as sys;
for i in sys::net::interfaces()? {
println!("{} {:?} up={} speed={:?}", i.name, i.kind, i.running, i.speed_mbps);
}Structs§
- Connections
- How many network connections the machine has open, as counts. A value an
OS does not report is
None. - Counters
- One interface’s cumulative counters.
- Interface
- One network interface.
- Interface
Options - Which interfaces
interfaces_withreturns, and in how much detail. - Interface
Traffic - One interface’s traffic.
- IpNet
- An address with its prefix length.
- Mac
- A hardware (MAC) address. An identifier: for device identity use the
devicemodule (0.5), never a raw MAC. - Sampler
- Measures download and upload between samples. Owned by the caller: two
samplers never disturb each other.
samplenever blocks and allocates nothing. - Totals
- Bytes and packets moved since boot, every interface but loopback.
- Traffic
- Download and upload over an interval.
Enums§
- Interface
Kind - What kind of network interface.
- MacKind
- Whether a MAC address is the hardware’s own (E-54).
Constants§
- DEFAULT_
WINDOW - The interval
trafficmeasures over: 1 s.
Functions§
- addresses
- The addresses of the interfaces that are up, without loopback and link-local addresses (E-57).
- connections
- How many network connections the machine has open: counts only, never addresses, ports, or owners. Inside a container they are the container’s network namespace.
- counters
- Each interface’s cumulative counters, loopback included (Tier 2).
- interfaces
- Every network interface, sorted by index, then name.
- interfaces_
with - The interfaces
optionsselects, sorted by index, then name. A Kubernetes node with thousands ofvethinterfaces lists them quickly withdetails: false(E-56). - totals
- Bytes and packets moved since boot, every interface but loopback: one read, no waiting. Counters are 64-bit on every platform. Inside a container they are the container’s network namespace.
- traffic
- Download and upload over the next second. Blocks for
DEFAULT_WINDOW; a monitor keeps aSampler. - traffic_
over - Download and upload over
window, clamped to 100 ms ..= 60 s. Blocks for the window.