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.
使用 C 语言结合 libpcap 创建一个命令行网络数据包分析器。实现从网络接口捕获数据包并提供过滤选项。添加对常见协议(TCP、UDP、HTTP、DNS 等)的协议分析。包含带宽使用情况和连接数的流量统计。实现数据包解码并显示详细的头部信息。添加 PCAP 和 CSV 格式的导出功能。包含针对可疑流量模式的告警系统。实现带有状态信息的连接跟踪。添加 IP 地址的地理位置查询。包含所有选项的命令行参数,并提供合理的默认值。实现彩色输出以提升可读性。