1、TCP/IP Protocol Suite,1,Chapter 7,Upon completion you will be able to:,ARP and RARP,Understand the need for ARPUnderstand the cases in which ARP is usedUnderstand the components and interactions in an ARP packageUnderstand the need for RARP,Objectives,TCP/IP Protocol Suite,2,Figure 7.1 ARP and RARP,
2、TCP/IP Protocol Suite,3,Figure 7.2 Position of ARP and RARP in TCP/IP protocol suite,TCP/IP Protocol Suite,4,7.1 ARP,ARP associates an IP address with its physical address. On a typical physical network, such as a LAN, each device on a link is identified by a physical or station address that is usua
3、lly imprinted on the NIC.,The topics discussed in this section include:,Packet Format Encapsulation Operation Proxy ARP,TCP/IP Protocol Suite,5,Figure 7.3 ARP operation,TCP/IP Protocol Suite,6,Figure 7.4 ARP packet, 硬件类型表示硬件地址的类型,以太网为1。 协议类型字段表示要映射的协议地址类型,IP协议对应的值为0x0800。 硬件地址长度:以太网为6。 协议地址长度:以太网为4,
4、即IP地址长度, IPv4。ipv6添16,这里单位是字节 操作字段:ARP请求1,ARP应答2,RARP请求3,RARP应答4。 当系统收到一份目的端为本机的ARP请求报文时,它就把硬件地址填进去,然后用两个目的端地址分别替换两个发送端地址(源和目的地址交换),并把操作字段置为2,最后把它发送出去。,TCP/IP Protocol Suite,7,TCP/IP Protocol Suite,8,Figure 7.5 Encapsulation of ARP packet,目的地址,源地址,类型,CRC,数 据,461500字节,6,6,2,4,0800 IP数据报,461500字节,2,08
5、06 ARP请求/应答 PAD,0835 RARP请求/应答 PAD,2,28,18,类型,TCP/IP Protocol Suite,9,TCP/IP Protocol Suite,10,含有ARP消息的以太网帧,TCP/IP Protocol Suite,11,含有ARP消息的以太网帧,129.84.25.02,TCP/IP Protocol Suite,12,Figure 7.6 Four cases using ARP,TCP/IP Protocol Suite,13,An ARP request is broadcast; an ARP reply is unicast.,Note:
6、,TCP/IP Protocol Suite,14,A host with IP address 130.23.43.20 and physical address B2:34:55:10:22:10 has a packet to send to another host with IP address 130.23.43.25 and physical address A4:6E:F4:59:83:AB (which is unknown to the first host). The two hosts are on the same Ethernet network. Show the
7、 ARP request and reply packets encapsulated in Ethernet frames.,Example 1,See Next Slide,TCP/IP Protocol Suite,15,Solution Figure 7.7 shows the ARP request and reply packets. Note that the ARP data field in this case is 28 bytes, and that the individual addresses do not fit in the 4-byte boundary. T
8、hat is why we do not show the regular 4-byte boundaries for these addresses. Also note that the IP addresses are shown in hexadecimal. For information on binary or hexadecimal notation see Appendix B.,Example 1 (Continued),See Next Slide,TCP/IP Protocol Suite,16,Figure 7.7 Example 1,TCP/IP Protocol
9、Suite,17,Figure 7.8 Proxy ARP,TCP/IP Protocol Suite,18,7.2 ARP PACKAGE,In this section, we give an example of a simplified ARP software package to show the components and the relationships between the components. This ARP package involves five modules: a cache table, queues, an output module, an inp
10、ut module, and a cache-control module.,The topics discussed in this section include:,Cache Table Queues Output Module Input Module Cache-Control Module,TCP/IP Protocol Suite,19,Figure 7.9 ARP components,TCP/IP Protocol Suite,20,Table 7.1 Original cache table used for examples,TCP/IP Protocol Suite,2
11、1,输出模块(算法),睡眠,直到从IP软件收到IP分组。 检查高速缓存表,查找对应该IP分组的目的端的项目。 若找到 若状态是RESOLVED 从项目中提取硬件地址值。 将分组连同硬件地址一起发送到数据链路层。 返回。 若状态是PENDING pending 把分组放入相应的队列。 返回。 若未找到 创建一个高速缓存项目,状态置为P且尝试置1。 创建一个队列 将分组放入队列。 发送ARP请求。 返回。,TCP/IP Protocol Suite,22,输入模块(算法),睡眠,直到ARP分组(请求或回答)到达。 检查高速缓存表,查询对应该ARP分组的项目。 若找到 更新这个项目。 若状态是PEN
12、DING 当队列非空 把一个分组从队列中取出。 将分组连同硬件地址一起发送给数据链路层。 若找不到 创建一个项目。 在高速缓存表中添加该项目。 若分组是请求 发送ARP回答。 返回,TCP/IP Protocol Suite,23,高速缓存控制模块(算法),睡眠,直到周期性计时器到时间。 对高速缓存表中的每一个项目 若状态为FREE 继续。 若状态为PENDING 把尝试值加1。 若尝试值大于最大数 把状态改为FREE。 撤销相应的队列。 否则 发送ARP请求。 继续 若状态为RESOLVED 把超时字段的值减去已经过的时间。 若超时字段的值小于或等于零 把状态改为FREE。 撤销相应的队列。
13、 返回。,TCP/IP Protocol Suite,24,The ARP output module receives an IP datagram (from the IP layer) with the destination address 114.5.7.89. It checks the cache table and finds that an entry exists for this destination with the RESOLVED state (R in the table). It extracts the hardware address, which is
14、457342ACAE32, and sends the packet and the address to the data link layer for transmission. The cache table remains the same.,Example 2,TCP/IP Protocol Suite,25,Twenty seconds later, the ARP output module receives an IP datagram (from the IP layer) with the destination address 116.1.7.22. It checks
15、the cache table and does not find this destination in the table. The module adds an entry to the table with the state PENDING and the Attempt value 1. It creates a new queue for this destination and enqueues the packet. It then sends an ARP request to the data link layer for this destination. The ne
16、w cache table is shown in Table 7.2.,Example 3,See Next Slide,TCP/IP Protocol Suite,26,Table 7.2 Updated cache table for Example 3,TCP/IP Protocol Suite,27,Fifteen seconds later, the ARP input module receives an ARP packet with target protocol (IP) address 188.11.8.71. The module checks the table an
17、d finds this address. It changes the state of the entry to RESOLVED and sets the time-out value to 900. The module then adds the target hardware address (E34573242ACA) to the entry. Now it accesses queue 18 and sends all the packets in this queue, one by one, to the data link layer. The new cache ta
18、ble is shown in Table 7.3.,Example 4,See Next Slide,TCP/IP Protocol Suite,28,Table 7.3 Updated cache table for Example 4,TCP/IP Protocol Suite,29,Twenty-five seconds later, the cache-control module updates every entry. The time-out values for the first three resolved entries are decremented by 60. T
19、he time-out value for the last resolved entry is decremented by 25. The state of the next-to-the last entry is changed to FREE because the time-out is zero. For each of the three pending entries, the value of the attempts,Example 5,See Next Slide,TCP/IP Protocol Suite,30,Table 7.4 Updated cache tabl
20、e for Example 5,TCP/IP Protocol Suite,31,7.3 RARP,RARP finds the logical address for a machine that only knows its physical address.,The topics discussed in this section include:,Packet Format Encapsulation RARP Server Alternative Solutions to RARP,TCP/IP Protocol Suite,32,The RARP request packets a
21、re broadcast; the RARP reply packets are unicast.,Note:,TCP/IP Protocol Suite,33,Figure 7.10 RARP operation,TCP/IP Protocol Suite,34,Figure 7.11 RARP packet,TCP/IP Protocol Suite,35,Figure 7.12 Encapsulation of RARP packet,TCP/IP Protocol Suite,36,Alternative Solutions to RARP When a diskless comput
22、er is booted, it needs more information in addition to its IP address. It needs to know its subnet mask, the IP address of a router, and the IP address of a name server. RARP cannot provide this extra information. New protocols have been developed to provide this information. In Chapter 17 we discuss two protocols, BOOTP and DHCP, that can be used instead of RARP.,TCP/IP Protocol Suite,37,Homework,Chapter7.6.1 8,16 实验1练习使用Ethereal抓包工具,对照ARP报文格式逐项分析每一个字段的含义。(该道题结合实验110月21日完成,无需提交纸质作业),