linux – 如何接收错误的以太网帧并禁用CRC / FCS计算?
我在运行
Linux的两台PC之间产生流量(通过发送以太网帧),这样做的目的是捕获一些错误帧.问题是当Phy层检测到帧上的错误时(如果CRC或FCS无效)帧被丢弃并且我无法在我的程序中接收它.
是否有任何接收错误帧的方法(禁用Phy层中的丢弃并接收指示该帧错误的指示符)以及如何查询NIC卡的统计数据(丢弃的数量等等) ). 解决方法
您没有指定哪个操作系统,但我至少可以代表Linux:
它可能在您的内核,NIC和驱动程序以及ethtool版本上. 我们需要告诉驱动程序/硬件做两件通常不会做的事情: 有两种ethtool选项可以实现以下各项: ethtool -K eth0 rx-fcs on #1 above: give us the FCS field ethtool -K eth0 rx-all on #2 above: even receive bad packets 有了这些,我可以使用wireshark或tcpdump来查看FCS字段,即使它们不正确. (在我的情况下,我有一些网络设备,它使用准确的时间戳即时替换校验和 – 这会导致数据包显示为“坏”,并使用上述内容进行恢复) 并非所有卡都会实现这一点!他们可能将上述ethtool选项“修复”或不回应. 以1G的速度,我看到e1000卡运行良好.在10G我还没有找到一个可以做到这一点的网卡,而且必须依赖更复杂的数据采集卡. 同样,我不知道最低内核/ ethtool版本要求是什么,但我确实记得要升级CentOS服务器以使其工作. 我也知道r8169和e1000驱动程序/卡可以做到,但根本不能说任何其他组合. 另请注意,您将无法在发送它们的计算机上捕获传出的FCS值,因为它们在过程中很晚才添加(可能已卸载到卡本身),因此pcap无法看到. 在Linux 3.10.11内核上,使用ethtool 3.10: $ethtool -k eth0 Features for eth0: rx-checksumming: on tx-checksumming: on tx-checksum-ipv4: off [fixed] tx-checksum-ip-generic: on tx-checksum-ipv6: off [fixed] tx-checksum-fcoe-crc: off [fixed] tx-checksum-sctp: off [fixed] scatter-gather: on tx-scatter-gather: on tx-scatter-gather-fraglist: off [fixed] tcp-segmentation-offload: on tx-tcp-segmentation: on tx-tcp-ecn-segmentation: off [fixed] tx-tcp6-segmentation: on udp-fragmentation-offload: off [fixed] generic-segmentation-offload: on generic-receive-offload: on large-receive-offload: off [fixed] rx-vlan-offload: on tx-vlan-offload: on ntuple-filters: off [fixed] receive-hashing: on highdma: on [fixed] rx-vlan-filter: on [fixed] vlan-challenged: off [fixed] tx-lockless: off [fixed] netns-local: off [fixed] tx-gso-robust: off [fixed] tx-fcoe-segmentation: off [fixed] tx-gre-segmentation: off [fixed] tx-udp_tnl-segmentation: off [fixed] fcoe-mtu: off [fixed] tx-nocache-copy: on loopback: off [fixed] rx-fcs: off rx-all: off tx-vlan-stag-hw-insert: off [fixed] rx-vlan-stag-hw-parse: off [fixed] rx-vlan-stag-filter: off [fixed] 然后: $sudo ethtool -K eth0 rx-fcs on rx-all on 给我: $ethtool -k eth0 Features for eth0: rx-checksumming: on tx-checksumming: on tx-checksum-ipv4: off [fixed] tx-checksum-ip-generic: on tx-checksum-ipv6: off [fixed] tx-checksum-fcoe-crc: off [fixed] tx-checksum-sctp: off [fixed] scatter-gather: on tx-scatter-gather: on tx-scatter-gather-fraglist: off [fixed] tcp-segmentation-offload: on tx-tcp-segmentation: on tx-tcp-ecn-segmentation: off [fixed] tx-tcp6-segmentation: on udp-fragmentation-offload: off [fixed] generic-segmentation-offload: on generic-receive-offload: on large-receive-offload: off [fixed] rx-vlan-offload: on tx-vlan-offload: on ntuple-filters: off [fixed] receive-hashing: on highdma: on [fixed] rx-vlan-filter: on [fixed] vlan-challenged: off [fixed] tx-lockless: off [fixed] netns-local: off [fixed] tx-gso-robust: off [fixed] tx-fcoe-segmentation: off [fixed] tx-gre-segmentation: off [fixed] tx-udp_tnl-segmentation: off [fixed] fcoe-mtu: off [fixed] tx-nocache-copy: on loopback: off [fixed] rx-fcs: on rx-all: on tx-vlan-stag-hw-insert: off [fixed] rx-vlan-stag-hw-parse: off [fixed] rx-vlan-stag-filter: off [fixed] (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |