AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1169696
Accepted
Deepanjan Das
Deepanjan Das
Asked: 2025-01-02 06:15:03 +0800 CST2025-01-02 06:15:03 +0800 CST 2025-01-02 06:15:03 +0800 CST

主机实际上是如何处理向它广播的 ARP 请求的,该请求的 IP 地址与其自己的 IP 地址相匹配?

  • 772

当我ping在 LAN 上找到主机 IP 地址时,我的主机会广播请求ARP。在收到ARP目标主机的回复后,它会启动一个ICMP echo包含回复的消息会话。

当目标主机从我的源主机接收时ARP request,目标主机是否会ARP使用请求中嵌入的信息更新缓存(因为源MAC address存在于中ARP request)?

如果是这样,为什么目标主机有时会ARP request为我的源主机 IP 地址发送另一个请求,并丢弃所有ICMP echo请求直到得到回复ARP reply?

请注意,这种行为是偶然发生的,有时ICMP echo会在ARP request目标主机发出响应之前做出响应,但这种响应ARP request总是出现在 ping 会话中间的某个地方。

我不知道这是否是由于早期 ping 会话中主机的 ARP 表更新所致,或者第二个只是一种协议,并且目标主机已经具有来自第一个的ARP request源主机的信息。MAC addressARP request

或者,目标主机根本不需要源主机MAC address,因为它总是封装在每个ICMP echo请求中,并且对每个此类请求的回复都使用收到的有关的信息MAC addresses并在响应帧中切换它们?

编辑 1:经过一番研究,我发现目标主机实际上并没有ARP cache从被动ARP requests(即来自其他主机的请求)中填充其内容。它ARP cache仅从ARP其自身请求收到的回复中填充其内容。

编辑2:继之后,在任何回复之前来自目标主机的Edit 1第二个回复表明源不在其内或已成为,从而在回复请求之前触发另一个回复。(有时首先通过探测检查地址,如果映射无效或探测超时,则发生新的回复。ARP requestICMP echoMAC addressARP cacheSTALEARP requestICMP echoSTALEARP request

ARP request因此,会话中间发生的第二个请求ping表明,由于某些原因(在我的主机中配置为 60 秒),源MAC address已进入STALE我的目标主机,从而触发了第二个请求。此外,这些第二个请求澄清了虽然目标主机不需要源填充到其请求中并使用有关源的信息来回复它,但它确实需要知道源才能回复请求。ARP cacheARP timeout valueARP requestARPMAC addressARP cacheARP requestMAC addressMAC addressTCMP echo

尽管如此,我们仍然非常感谢任何能够详细说明或纠正上述调查结果中的错误的答案。

networking
  • 1 1 个回答
  • 48 Views

1 个回答

  • Voted
  1. Best Answer
    Ron Maupin
    2025-01-02T06:55:25+08:002025-01-02T06:55:25+08:00

    当目标主机从我的源主机接收 ARP 请求时,它是否会使用请求中嵌入的信息更新其 ARP 缓存(因为源 MAC 地址存在于 ARP 请求中)。如果是这样,为什么目标主机有时会发送另一个 ARP 请求以获取我的源主机的 IP 地址,并丢弃所有 ICMP 回应请求,直到它收到 ARP 回复?

    如果目标主机的 ARP 表中已有条目,则当它看到 ARP 请求时,它应该更新其 ARP 表。如果该条目不在其 ARP 表中,则它可能不会在其 ARP 表中创建条目。

    经过一番研究,我发现目标主机实际上不会从被动 ARP 请求(即来自其他主机的请求)填充其 ARP 缓存。它只从其自身请求收到的 ARP 回复填充其 ARP 缓存。

    如果主机是 ARP 请求的目标,它应该更新其 ARP 表,但实际上并不总是这样。如果主机看到不是针对它的广播 ARP 请求,它应该只在其 ARP 表中已有源的情况下更新其 ARP 表。

    特定的操作系统实现决定了这是如何发生的,但是RFC 892(以太网地址解析协议)有伪代码来解释数据包接收过程。

    Packet Reception:
    -----------------
    
    When an address resolution packet is received, the receiving
    Ethernet module gives the packet to the Address Resolution module
    which goes through an algorithm similar to the following.
    Negative conditionals indicate an end of processing and a
    discarding of the packet.
    
    ?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.
    
    Notice that the <protocol type, sender protocol address, sender
    hardware address> triplet is merged into the table before the
    opcode is looked at.  This is on the assumption that communcation
    is bidirectional; if A has some reason to talk to B, then B will
    probably have some reason to talk to A.  Notice also that if an
    entry already exists for the <protocol type, sender protocol
    address> pair, then the new hardware address supersedes the old
    one.  Related Issues gives some motivation for this.
    

    从编辑 1 开始,在任何 ICMP 回显答复之前来自目标主机的第二个 ARP 请求表明源 MAC 地址不在其 ARP 缓存中或已变为 STALE,从而在答复 ICMP 回显请求之前触发另一个 ARP 请求。

    RFC 末尾有一节讨论了这个问题。RFC 中没有任何内容要求 ARP 表条目超时,但这是操作系统供应商的常见做法。RFC 讨论是这样开始的:

    Related issue:
    ---------------
    
    It may be desirable to have table aging and/or timeouts.  The
    implementation of these is outside the scope of this protocol.
    
    • 1

相关问题

  • 谁能指出我的 802.11n 范围扩展器?

  • 我怎样才能得到一个网站的IP地址?

  • 在一个 LAN 中使用两台 DHCP 服务器

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve