網絡協議之ARP協議


ARP(Address Resolution Protocol)地址解析協議用來建立和維護IP地址和MAC地址之間的映射關系,稱為"ARP表"。ARP表中有動態表項和靜態表項,動態表項可以老化。

ARP表

查看arp表

C:\Users\Justin>arp -a

接口: 192.168.1.3 --- 0xd
  Internet 地址         物理地址              類型
  192.168.1.1           78-c3-13-4b-1f-a1     動態
  192.168.1.2           f4-83-cd-b1-69-b7     動態
  192.168.1.255         ff-ff-ff-ff-ff-ff     靜態
  224.0.0.22            01-00-5e-00-00-16     靜態
  224.0.0.251           01-00-5e-00-00-fb     靜態
  224.0.0.252           01-00-5e-00-00-fc     靜態
  239.11.20.1           01-00-5e-0b-14-01     靜態
  239.255.255.250       01-00-5e-7f-ff-fa     靜態
  255.255.255.255       ff-ff-ff-ff-ff-ff     靜態

添加ARP表項

C:\Users\Justin>arp -s 10.10.10.10 34-bf-9c-00-01-76

C:\Users\Justin>arp -a

接口: 192.168.1.3 --- 0xd
  Internet 地址         物理地址              類型
  10.10.10.10           34-bf-9c-00-01-76     靜態
  192.168.1.1           78-c3-13-4b-1f-a1     動態
  192.168.1.2           f4-83-cd-b1-69-b7     動態
  192.168.1.255         ff-ff-ff-ff-ff-ff     靜態
  224.0.0.22            01-00-5e-00-00-16     靜態
  224.0.0.251           01-00-5e-00-00-fb     靜態
  224.0.0.252           01-00-5e-00-00-fc     靜態
  239.11.20.1           01-00-5e-0b-14-01     靜態
  239.255.255.250       01-00-5e-7f-ff-fa     靜態
  255.255.255.255       ff-ff-ff-ff-ff-ff     靜態

 ARP 報文分析

本機只知道對方的IP地址,不知道對方的MAC地址時,會在當前子網內廣播ARP請求,讓子網內所有設備接收到這個廣播ARP請求報文;對方主機收到這個ARP請求報文之后,會發送一個單播ARP應答報文,告知自己的MAC地址。

ARP請求報文

廣播包,EtherType 0x0806, IpProtocol 0x0800,OpCode 1

ARP應答報文

單播包,EtherType 0x0806, IpProtocol 0x0800,OpCode 2

ARP表刷新

RFC1122定義了四種ARP緩存條目刷新的機制:

1)Timeout 超時老化

Periodically time out cache entries, even if they are in use. Note that this timeout should be restarted when the cache entry is "refreshed" (by observing the source fields, regardless of target address, of an ARP broadcast from the system in question). For proxy ARP situations, the timeout needs to be on the order of a minute.
 

2)Unicast Poll 單播輪詢

Actively poll the remote host by periodically sending a point-to-point ARP Request to it, and delete the entry if no ARP Reply is received from N successive polls. Again, the timeout should be on the order of a minute, and typically N is 2。

定時向ARP表中的主機發送單播ARP請求報文,超過N次沒有收到ARP應答報文,則從ARP表中刪除該條目。

 

3)Link-Layer Advice 鏈路層故障清空ARP表
If the link-layer driver detects a delivery problem, flush the corresponding ARP cache entry.


4)Higher-layer Advice 應用層故障清空ARP表
Provide a call from the Internet layer to the link layer to indicate a delivery problem. The effect of this call would be to invalidate the corresponding cache entry.
This call would be analogous to the "ADVISE_DELIVPROB()" call from the transport layer to the Internet layer (see Section 3.4), and in fact the ADVISE_DELIVPROB routine might in turn call the link-layer advice routine to invalidate the ARP cache entry.

代理ARP

代理ARP是ARP協議的一個變種。 對於沒有配置缺省網關的計算機要和其他網絡中的計算機實現通信,網關收到源計算機的 ARP請求會使用自己的 MAC地址與目標計算機的 IP地址對源計算機進行應答。代理ARP就是將一個主機“作為”另一個主機對收到的ARP請求進行應答。它能使得在不影響路由表的情況下添加一個新的Router,使得子網對該主機來說變得更透明化。同時也會帶來巨大的風險,除了ARP欺騙,和某個網段內的ARP增加,最重要的就是無法對網絡拓撲進行網絡概括。代理ARP的使用一般是使用在沒有配置默認網關和路由策略的網絡上的。 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM