TCP/IP协议原理吴凡通信与信息工程学院网络工程系E-mail:wufan@uestc.edu.cnPhone:61830521(O)2020/1/10TCP/IPProtocolSuite2Chapter8ICMPOverviewTypesofmessagesMessageformatErrorreportingQueryChecksumICMPpackage2020/1/10TCP/IPProtocolSuite3OverviewIPlackoferrorcontrolIPhasnoerror-reportingmechanismassistancemechanismAmechanismforhostandmanagementrequiresICMP(InternetControlMessageProtocol)AcompaniontotheIP,tocompensatefortheabovetwodeficienciesProvideerrorreporting(而不是error-correcting!)forIPProvideassistancemechanismforotherlayers(TCP/UDPandapplication)主机可以通过使用ICMP与Internet中路由器或者主机实现控制报文的通信1.aroutercannotfindaroutetothefinaldestination2.Time-to-livefieldhasa0value3.destinationdiscardsallfragmentsofadatagram2020/1/10TCP/IPProtocolSuite4ErrorReportingVSErrorCorrectionIP传输过程中出现差错是不可避免的IP分组传输出现差错时,会产生相应的ICMP报文通过ICMP报文提供差错报告ICMP差错报告只能送给IP分组的源站,协议只提供差错处理建议原因:IP数据报中只记录了IP源和目的地址,而没有记录完整路由检查到错误的路由器无法了解分组经过了哪些中间路由器差错纠正由上层协议负责源站可能无法确定差错源,需要与网络管理员一起协作处理2020/1/10TCP/IPProtocolSuite5InternetControlMessageProtocolRFC792:InternetControlMessageProtocol,1981RFC1256:ICMPRouterDiscoveryMessages,1991IPLANsMANsWANsICMPIGMPARPRARPNetworkLayerNetworkAccessLayerTransportLayerApplicationLayer2020/1/10TCP/IPProtocolSuite6MessagedeliveryandEncapsulationICMP在IP之上实现,逻辑上与IP同在网络层Connectionlesscommunication直接送达目的站点,沿途的转发路由器不能获知ICMP报文内容EncapsulationICMPmessageIPheaderIPdataFramedataTrailer(ifany)FrameheaderICMPmessageIPheaderIPdataProtocol=12020/1/10TCP/IPProtocolSuite7Chapter8ICMPOverviewTypesofmessagesMessageformatErrorreportingQueryChecksumICMPpackage2020/1/10TCP/IPProtocolSuite8TypesofMessagesICMPmessagesError-reporting差错报告Query测试查询ToreportproblemsthatarouteroradestinationhostmayencounterwhenitprocessesanIPpacketTohelpahostoranetworkmanagergetspecificinformationfromarouteroranotherhost2020/1/10TCP/IPProtocolSuite9TypesCategoryTypeMessageReasonError-reportingmessages3DestinationunreachableUnreachable4SourcequenchCongestion11TimeexceededToolongroute12ParameterproblemFormaterror5RedirectionRoutechangedQuerymessages8or0EchorequestorreplyReachability13or14TimestamprequestorreplySynchronization17or18AddressmaskrequestorreplyMaskmaintenance10or9RoutersolicitationoradvertisementCoincidencebetweenrouters过时:15Informationrequest16Informationresponse2020/1/10TCP/IPProtocolSuite10Chapter8ICMPOverviewTypesofmessagesMessageformatErrorreportingQueryChecksumICMPpackage2020/1/10TCP/IPProtocolSuite11MessageFormatCodeChecksumContentdependsontypeandcodeType8bits8bits16bits差错报文:引起差错的原始数据报的一部分(首部+数据部分的前8个字节)查询报文:基于查询类型的额外信息Specifythereasonfortheparticularmessagetype2020/1/10TCP/IPProtocolSuite12Chapter8ICMPOverviewTypesofmessagesMessageformatErrorreportingQueryChecksumICMPpackage2020/1/10TCP/IPProtocolSuite13ErrorReportingICMPjustsimplyreporterrorsnotcorrectICMPalwaysreportserrormessagestotheoriginalsourceICMPerrormessagewillNOTbegeneratedfor:AdatagramcarryinganICMPerrormessageAfragmenteddatagramthatisNOTthefirstfragmentAdatagramhavingamulticastaddressAdatagramhavingaspecialaddresssuchas127.0.0.0or0.0.0.0ErrorreportingDestinationunreachableSourcequenchTimeexceededParameterproblemsRedirection2020/1/10TCP/IPProtocolSuite14ContentsofDataFieldforErrorMessagesIPheader8bytesIPdataIPheader8bytesICMPpacketICMPheaderIPheader8bytesSentIPdatagramICMPheaderIPheaderReceiveddatagramProvideinformationaboutTCPandUDP2020/1/10TCP/IPProtocolSuite15DestinationUnreachableWhenaroutercannotrouteadatagramorahostcannotdeliveradatagramThedatagramisdiscardedTherouterorthehostsendsadestinationunreachablemessagebacktothesourceCode=0~12ChecksumType=3IPheader+8bytesIPdata0x00000000不可达的原因供源站分析错误Aroutercannotdetectallproblemsthatpreventthedeliveryofapacket2020/1/10TCP/IPProtocolSuite16DestinationUnreachableCodesCodeDescriptionCodeDescription0网络不可达7目的主机未知1主机不可达8源主机被隔离2协议不可达9与目的网络的通信被禁止3端口不可达10与目的主机的通信被禁止4需要分片,但DF=111对指定TOS,网络不可达5源路由失败12对指定TOS,主机不可达6目的网络未知哪些目的不可达报文只能由目的主机产生?哪些目的不可达报文只能由路由器产生?2020/1/10TCP/IPProtocolSuite17SourceQuench(源点抑止)ThelackofflowcontrolinIPcongestion拥塞:路由器中队列溢出源站点,中继节点(Router),目的站点间没有关于流量信息的通信主机产生的数据量可能比网络快不适当的路由使流量过分集中,超过信道容量路由器的转发性能低路由器或主机因拥塞丢弃IP分组时,向源站发送ICMP源抑制报文,通知源站ThedatagramhasbeendiscardedThereisacongestionsomewhereinthepathandthesourceshouldslowdownthesendingprocess——quench2020/1/10TCP/IPProtocolSuite18SourceQuench(源点抑止)Congestedrouterordestinationsendsonesource-quenchICMPforeachdiscardeddatagramtothesourceThereisnomechanismtotellthesourcethatthecongestionhasbeenrelieveCode=0ChecksumType=4IPheader+8bytesIPdata0x000000002020/1/10TCP/IPProtocolSuite19TheSolutionoftheCongestion发送队列缓冲:缓解短暂的突发数据丢弃报文,产生源抑制ICMP报文给源站丢弃算法——QoS源站减缓发送速率源站没有收到源抑制报文后逐步提高发送速率源抑制报文的拥塞控制能力只能解决因某个特定主机问题造成的拥塞对因路由或路由器问题造成的拥塞不起作用2020/1/10TCP/IPProtocolSuite20TimeExceeded若数据报的TTL=0,路由器丢弃分组,并向源站发送ICMP超时报文路由器对每一个被处理数据报的TTL值自动减1目的主机为需要重组的数据报启动定时器,如果重组无法在定时内完成,丢弃分组,并向源站发送ICMP超时报文Code=0,1ChecksumType=11IPheader+8bytesIPdata0x00000000Code=0——路由器检测到分组的TTL值为0Code=1——目的站在规定时间内没有收到所有分片2020/1/10TCP/IPProtocolSuite21ParameterProblem路由器或主机因首部字段格式或取值错误而