我有两台硬件(嵌入式设备),已将它们设置为以客户端/服务器方式通过以太网上的 TCP 进行通信。
网络拓扑结构如下:
-----
| S ||=|== Debug PC (w/ Wireshark) 192.168.10.41
| W ||=|== Hardware 1 TCP Client 192.168.10.42
| I ||=|== Hardware 2 TCP Server 192.168.10.40
| T |
| C |
| H |
-----
当硬件 1 尝试向服务器硬件 2 发送数据包时,它首先发送一个 ARP 数据包来获取硬件 2 的 MAC 地址:
No. Time Source Destination Protocol Length Info
157 11772.776136 Microchi_13:c3:6a Broadcast ARP 60 Who has 192.168.10.40? Tell 192.168.10.42
然而,它没有收到服务器的回复,几分钟后,服务器对客户端的 MAC 地址进行了 ARP 处理:
No. Time Source Destination Protocol Length Info
158 12183.800839 00:3f:2d:02:1a:35 Broadcast ARP 60 Who has 192.168.10.42? Tell 192.168.10.40
客户端也没有回复。我很困惑。
我知道服务器正在正确回复,因为我用 C# 编写了一个简单的 TCP 客户端,它可以从调试 PC 连接并向服务器发送数据包。
我不确定为什么我的硬件客户端无法通信。
提前感谢您的帮助。
如果需要,ARP 数据包的详细信息:
来自客户:
Ethernet II, Src: Microchi_13:c3:6a (00:04:a3:13:c3:6a), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Destination: Broadcast (ff:ff:ff:ff:ff:ff)
Source: Microchi_13:c3:6a (00:04:a3:13:c3:6a)
Type: ARP (0x0806)
Trailer: 000000000000000000000000000000000000
Address Resolution Protocol (request)
Hardware type: Ethernet (1)
Protocol type: IP (0x0800)
Hardware size: 6
Protocol size: 4
Opcode: request (1)
[Is gratuitous: False]
Sender MAC address: Microchi_13:c3:6a (00:04:a3:13:c3:6a)
Sender IP address: 192.168.10.42 (192.168.10.42)
Target MAC address: Broadcast (ff:ff:ff:ff:ff:ff)
Target IP address: 192.168.10.40 (192.168.10.40)
从服务器:
Frame 158: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)
Ethernet II, Src: 00:3f:2d:02:1a:35 (00:3f:2d:02:1a:35), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Destination: Broadcast (ff:ff:ff:ff:ff:ff)
Source: 00:3f:2d:02:1a:35 (00:3f:2d:02:1a:35)
Type: ARP (0x0806)
Trailer: 000000000000000000000000000000000000
Address Resolution Protocol (request)
Hardware type: Ethernet (1)
Protocol type: IP (0x0800)
Hardware size: 6
Protocol size: 4
Opcode: request (1)
[Is gratuitous: False]
Sender MAC address: 00:3f:2d:02:1a:35 (00:3f:2d:02:1a:35)
Sender IP address: 192.168.10.40 (192.168.10.40)
Target MAC address: 00:00:00_00:00:00 (00:00:00:00:00:00)
Target IP address: 192.168.10.42 (192.168.10.42)
答案1
你不会在“调试 PC”交换机端口上看到任何 ARP 回复,因为这些将单播到目标主机。您的交换机正在过滤单播数据包到外部目的地,以供“调试 PC”使用。如果您还需要监控单播流量,您可以使用集线器代替交换机,或者启用“监控”或“镜像端口”功能在您的交换机上(大多数托管交换机都有类似的东西)让所有流量(包括外部单播)涌入“调试 PC”端口。