假设我们在同一个共享介质中有 3 个设备:A、B 和 C。
A 想向 B 发送消息,所以之前,它以广播消息的形式发送 ARP 请求。当 B 收到它时,它将用 A 的 MAC 地址更新其 ARP 表并发送单播响应。C 也看到了 A 的广播消息,所以它也可以添加 A 的 MAC 地址。
因此,我认为 A 最终会在其 ARP 表中包含 B 的地址,反之亦然,但我不确定 C 会发生什么。
任何帮助,将不胜感激。提前致谢!
假设我们在同一个共享介质中有 3 个设备:A、B 和 C。
A 想向 B 发送消息,所以之前,它以广播消息的形式发送 ARP 请求。当 B 收到它时,它将用 A 的 MAC 地址更新其 ARP 表并发送单播响应。C 也看到了 A 的广播消息,所以它也可以添加 A 的 MAC 地址。
因此,我认为 A 最终会在其 ARP 表中包含 B 的地址,反之亦然,但我不确定 C 会发生什么。
任何帮助,将不胜感激。提前致谢!
C 也看到了 A 的广播消息,所以它也可以添加 A 的 MAC 地址。
这取决于操作系统。根据 RFC,如果 A 的条目已经存在于其 ARP 表中,C 只会更新其 ARP 表。
RFC 826,以太网地址解析协议——或——将网络协议地址转换为 48 位以太网地址以在以太网上传输硬件具有假定 tp 发生的伪代码,但不同的操作系统(此处偏离主题)可能会有所不同:
数据包接收:
当接收到地址解析数据包时,接收以太网模块将数据包交给地址解析模块,地址解析模块通过类似于以下的算法。否定条件表示处理结束并丢弃数据包。
?Do I have the hardware type in ar$hrd? Yes: (almost definitely) [optionally check the hardware length ar$hln] ?Do I speak the protocol in ar$pro? Yes: [optionally check the protocol length ar$pln] Merge_flag := false If the pair <protocol type, sender protocol address> is already in my translation table, update the sender hardware address field of the entry with the new information in the packet and set Merge_flag to true. ?Am I the target protocol address? Yes: If Merge_flag is false, add the triplet <protocol type, sender protocol address, sender hardware address> to the translation table. ?Is the opcode ares_op$REQUEST? (NOW look at the opcode!!) Yes: Swap hardware and protocol fields, putting the local hardware and protocol addresses in the sender fields. Set the ar$op field to ares_op$REPLY Send the packet to the (new) target hardware address on the same hardware on which the request was received.
每个 ARP 表条目都是自行创建或清除的。当主机需要向 ARP 表中没有对应的第 2 层地址的第 3 层地址发送某些内容时,将创建 ARP 表条目。ARP 表中的条目将在一段时间不使用后超时并被清除。下次主机想要向第 3 层地址发送内容时,它将重新创建它。