中间节点是否学习 ARP 中的 MAC 地址?

网络工程 协议理论 arp 播送 射频卡
2021-07-10 14:16:56

我的疑问是关于 ARP 协议。我知道这个过程:如果主机想知道另一个主机的 MAC 地址,则发送一个广播帧,目标用它的 MAC 应答。但是,如果所考虑的 LAN 中的中间节点接收到广播帧,它是否也学习了源 MAC 地址,或者只是因为 IP 不是它而丢弃该帧?

我希望有一个人可以帮助我。谢谢您的反馈!

1个回答

中间节点是数据包必须通过的节点才能到达目的地。根据您的评论,听起来您的意思是同一广播域上的对等主机。

当发送 ARP 请求时,它是广播的。这意味着广播域上的每个主机都会看到 ARP 请求,并且每个看到 ARP 请求的主机都应该使用请求者信息更新其 ARP 表中的现有条目。

这在RFC 826,以太网地址解析协议中进行了解释

数据包接收:

当收到地址解析数据包时,接收以太网模块将数据包交给地址解析模块,该模块通过类似于以下的算法。否定条件表示处理结束并丢弃数据包。

?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.

请注意,在查看操作码之前,<protocol type, sender protocol address, sender hardware address> 三元组已合并到表中。这是基于通信是双向的假设;如果 A 有一些理由与 B 交谈,那么 B 可能有一些理由与 A 交谈。 另请注意,如果 <protocol type, sender protocol address> 对已经存在一个条目,那么新的硬件地址将取代旧的一。相关问题为此提供了一些动力。

概括: ar$hrd 和 ar$hln 字段允许将此协议和数据包格式用于非 10Mbit 以太网。对于 10Mbit 以太网,<ar$hrd, ar$hln> 的值为 <1, 6>。对于其他硬件网络,ar$pro 字段可能不再对应于以太网类型字段,但它应该与正在寻求地址解析的协议相关联。

当一个特定的主机看到一个不适合它的 ARP 请求时,它实际上会做什么取决于主机操作系统,这在这里是题外话。例如,主机不仅可以更新现有的 ARP 表条目,还可以在不存在的情况下创建 ARP 表条目。

当主机用 ARP 回复响应 ARP 请求时,回复是作为单播而不是广播发送的,因此回复将直接发送到请求主机。这意味着广播域上的其他主机甚至不会看到 ARP 回复。