要求用 C 和 libpcap 编写抓包分析器:过滤捕获、协议解码、流量统计及 PCAP/CSV 导出。
使用 libpcap 在 C 语言中创建一个命令行网络数据包分析器。实现从网络接口捕获数据包,并支持过滤选项。为常见协议(TCP、UDP、HTTP、DNS 等)添加协议分析功能。包含流量统计信息,如带宽使用量和连接数。实现数据包解码,并提供详细的头部信息。添加以 PCAP 和 CSV 格式导出数据包的功能。包含针对可疑流量模式的告警系统。实现连接跟踪,并提供连接状态信息。添加 IP 地址的地理定位查询功能。为所有选项提供命令行参数,并设置合理的默认值。实现彩色编码输出,以提升可读性。
Create a command-line network packet analyzer in C using libpcap. Implement packet capture from network interfaces with filtering options. Add protocol analysis for common protocols (TCP, UDP, HTTP, DNS, etc.). Include traffic statistics with bandwidth usage and connection counts. Implement packet decoding with detailed header information. Add export functionality in PCAP and CSV formats. Include alert system for suspicious traffic patterns. Implement connection tracking with state information. Add geolocation lookup for IP addresses. Include command-line arguments for all options with sensible defaults. Implement color-coded output for better readability.