(libpcap for Linux/Unix, and WinPcap for Windows) can selectively capture packets based on filtering rules expressed in BPF (berkely packet filter). The BPF-based filter can capture packets with specific source/destination IP addresses/prefixes, protocols (IP/ICMP/UDP/TCP), port numbers, ...
Tcpdump command is a famous network packet analyzing tool that is used to display TCP IP & ...