net package provides comprehensive network monitoring capabilities including I/O statistics, connection tracking, interface information, and protocol counters.
Key Features
I/O Counters
Track bytes, packets, errors, and drops for network interfaces
Connections
Monitor active network connections and their states
Interfaces
Get detailed information about network interfaces
Protocol Stats
Access protocol-specific network statistics
Main Functions
IOCounters
Retrieves network I/O statistics for all network interfaces.pernic- If true, returns statistics per interface; if false, returns aggregated statistics
Connections
Retrieves a list of active network connections.kind- Connection type filter (e.g., “tcp”, “udp”, “inet”, “inet4”, “inet6”, “unix”, “all”)
Interfaces
Retrieves information about all network interfaces.ProtoCounters
Retrieves network protocol statistics.protocols- List of protocols to query (e.g., “ip”, “icmp”, “tcp”, “udp”). Empty list returns all protocols
Additional Functions
Connection Filtering
Conntrack Statistics
Usage Example
Platform Support
Most functions are supported across all platforms, with these exceptions:ProtoCounters: Not available on FreeBSD, Windows, OpenBSD, DarwinFilterCountersandConntrackStats: Linux-specific featuresConnectionsWithoutUidsvariants: Implementation-specific, may vary by platform
See Also
- I/O Counters - Detailed network I/O statistics
- Connections - Network connection monitoring
- Interfaces - Network interface information
- Protocol Stats - Protocol-level statistics