TCP/IP协议原理吴凡通信与信息工程学院网络工程系E-mail:wufan@uestc.edu.cnPhone:61830521(O)2020/1/10TCP/IPProtocolSuite2Chapter6ARPandRARPARPARPpackage(ARP软件包)RARP2020/1/10TCP/IPProtocolSuite3两级地址IP分组交付到主机或路由器需要两级地址互连网级:逻辑地址标识主机/路由器全网统一编址,具有全局唯一性——全局地址所有与互联网打交道的软件都要使用逻辑地址在Internet中,逻辑地址就是IP地址(32bit)物理网级:物理地址标识主机/路由器本地范围内具有唯一性,但在整个互联网内不一定具有全局唯一性——本地地址分组需要通过物理网络才能到达路由器或主机以太网中,物理地址就是MAC地址(48bit)NetworkAddressMaskNext-hopAddressInterface路由表项(至少4项)MACAMACEMACBMACCMACR2020/1/10TCP/IPProtocolSuite4MappingLogicaladdress(IP)PhysicaladdressNetworkDataLinkPhysicalMappingTo:电子科技大学成都市建设北路2段4号单位名称(逻辑)单位地址(物理)2020/1/10TCP/IPProtocolSuite5IssuesA送往E的分组需封装在Ethernet帧中传送IP地址:全局性物理地址:本地性AA仅知道:IPA,MACA,IPEEthernetFrame:IPPacket?EBCD目的MAC类型FCS源MACMACA2020/1/10TCP/IPProtocolSuite6AddressMapping(地址映射)LogicaladdressPhysicaladdressStaticmapping映射表固定设置DynamicmappingStaticTableLogicaladdressPhysicaladdress……………………Consider:NICchangedMobilecomputerCacheLogicaladdressPhysicaladdress……………………Lookforthetargetondemanding,usingdynamicAddressResolutionProtocol2020/1/10TCP/IPProtocolSuite7ARPandRARPARPLogicaladdressPhysicaladdressRARPLogicaladdressPhysicaladdress2020/1/10TCP/IPProtocolSuite8ARPAddressResolutionProtocol,RFC826地址解析协议:IPaddressMACaddressIPLANsMANsWANsICMPIGMPARPRARPNetworkLayerNetworkAccessLayerTransportLayerApplicationLayer2020/1/10TCP/IPProtocolSuite9ARPOperationA:1.2.3.1E:1.2.3.5I’mlookingforthephysicaladdressofanodewhoseIPaddressis:1.2.3.5Iamthenodeyouarelookingfor,andmyphysicaladdressis:0005.5D06.1418RequestRequestRequestReplyRequestBroadcastUnicastB:1.2.3.2C:1.2.3.3D:1.2.3.4IPaddressMACaddressA’sARPCache:1.2.3.50005.5D06.1418bind2020/1/10TCP/IPProtocolSuite10ARPCacheARPcacheTomaintaintherecentmappingsfromlogicaladdresses(IP)tohardwareaddresses(MAC)典型存活时间:2minutesEssentialtotheefficientoperationofARP举例:主机ARPCacheC:arp–aInterface:172.18.64.38---0x50002InternetAddressPhysicalAddressType172.18.64.6200-03-31-b5-50-00Dynamic2020/1/10TCP/IPProtocolSuite11用户输入命令“ftp主机名”时的操作FTPTCPIPARP以太网驱动程序主机名解析器以太网驱动程序以太网驱动程序主机名IP地址(1)(2)(3)(4)(6)ARPARPFTPTCPIP(5)(7)目的源2020/1/10TCP/IPProtocolSuite12ARPPacketHardwareTypeProtocolTypeHardwareaddresslenProtocoladdresslenOperationRequest1,Reply2Senderhardwareaddress(Forexample,6bytesforEthernet)Senderprotocoladdress(Forexample,4bytesforIP)Targethardwareaddress(Forexample,6bytesforEthernet)Targetprotocoladdress(Forexample,4bytesforIP)Itisnotfilledinarequest2020/1/10TCP/IPProtocolSuite13EncapsulationofARPpacketThebyteorderofARPpacketExample:EthernetframeHTypePTypeHLPLOPsMACsIPtMACtIP222116644byteARPPacket目的MAC类型FCS源MACPacket66246~15004pad28bytes460x0806byte2020/1/10TCP/IPProtocolSuite14Example:ARPRequestPacket2020/1/10TCP/IPProtocolSuite15Example:ARPReplyPacket2020/1/10TCP/IPProtocolSuite16IPPacketandARPPacketIPIPIPIPARPrequestARPreplyIPpacketBindingIPpacketIPpacketIPpacketNobinding2020/1/10TCP/IPProtocolSuite17ARPProcessCase1:ABInsameIPnetworkCase2:ADIndifferentIPnetworkACBDR1R2IPA,MACAIPB,MACBIPC,MACCIPD,MACDIP1MAC1IP2MAC2IP3MAC3IP4MAC42020/1/10TCP/IPProtocolSuite18Case1:ABACBDR1R2IPA,MACAIPB,MACBIPC,MACCIPD,MACDIP1MAC1IP2MAC2IP3MAC3IP4MAC4IPAddressMACAddressA’sARPCache:IPBMACBB’sARPCache:IPAMACAR1’sARPCache:IPAMACAsIP=IPA,dIP=IPBARPrequestARPrequestARPrequestARPrequestARPreplyIPIPsMAC=MACA,dMAC=MACBsIP=IPA,dIP=IPBdMAC=广播,Target_IP=IPBSenderhardwareaddress:MACASenderprotocoladdress:IPATargethardwareaddress:0x00000000Targetprotocoladdress:IPBSenderhardwareaddress:MACBSenderprotocoladdress:IPBTargethardwareaddress:MACATargetprotocoladdress:IPA2020/1/10TCP/IPProtocolSuite19Case2:ADACBDR1R2IPA,MACAIPB,MACBIPC,MACCIPD,MACDIP1MAC1IP2MAC2IP3MAC3IP4MAC4IPAddressMACAddressA’sARPCache:IP1MAC1B’sARPCache:IPAMACAR1’sARPCache:IPAMACAsIP=IPA,dIP=IPDARPrequestARPrequestARPrequestARPrequestARPreplyIPIPsMAC=MACA,dMAC=MAC1sIP=IPA,dIP=IPDdMAC=广播,Target_IP=IP1IPD不在本网内,分组由R1转发sMAC=MAC2,dMAC=MAC3sIP=IPA,dIP=IPDsMAC=MAC4,dMAC=MACDsIP=IPA,dIP=IPDIP1是A的缺省网关(DefaultGateway)2020/1/10TCP/IPProtocolSuite20关键问题:ARP解析谁的IP地址?交付类型2020/1/10TCP/IPProtocolSuite21ExampleAhostwithIPaddress130.23.43.20andphysicaladdress0xB23455102210hasapackettosendtoanotherhostwithIPaddress130.23.43.25andphysicaladdress0xA46EF45983AB.ThetwohostsareonthesameEthernetnetwork.ShowtheARPrequestandreplypacketsencapsulatedinEthernetframes.2020/1/10TCP/IPProtocolSuite22Example:ARPRequest2020/1/10TCP/IPProtocolSuite23Example:ARPReply12020/1/10TCP/IPProtocolSuite24ProxyARP(代理ARP)ProxyARP:——产生子网效应代表另一个物理网络中一组主机回答ARPRequest,在ARPReply中通告自己的MAC地址(即将解析的IP与代理ARP的MAC绑定)TofoolthesenderoftheARPrequestintothinkingthattherouteristhedestinationhost,wheninfactthedestinationhostisontheothersideoftherouter“Honest”HidedQ:InthesameIPnetworkornot?子网效应:属于相同IP子网的节点间通信仍然需要经过路由器转发2020/1/10TCP/IPProtocolSuite25AnswerRFC925:Multi-LANAddressResolutionExplicitsubnetsTransparentsubnets(ExtendedARP)RFC1027:UsingARPtoImplementTransparentSubnetGatewaysRouters:ExplicitsubnetsHosts:Transparentsubnets“Fromthehostpointofview,therearenosubnets,andtheirphysicalnetworksaresim