BPF 表达式只捕获 arp-reply 个数据包

BPF expression to capture only arp-reply packets

是否有一个 BPF 表达式只能捕获 arp-reply 个数据包?目前,我正在使用 Pcap4J 和以下 BPF 表达式:

arp and dst host host and ether dst mac

其中 host 是我设备的 IP 地址,mac 是我的 MAC 地址主要网络接口。不幸的是,当数据包被捕获时,这个过滤器允许 ARP 广播请求也被捕获,所以我必须采取额外的步骤来检查 ARP header 的操作字段是否为 2 而不是 1.

试试这个:

(arp[6:2] = 2) and dst host host and ether dst mac