©1999,CiscoSystems,Inc.8-1第三章TCP/IP协议栈©1999,CiscoSystems,Inc.—8-2本章目标通过本章的学习,您应该掌握以下内容:•掌握TCP/IP分层模型•掌握三次握手过程•理解OSI和TCP/IP模型的区别和联系©1999,CiscoSystems,Inc.—8-3早期的协议族全球范围TCP/IP介绍主机InternetTCP/IP主机©1999,CiscoSystems,Inc.—8-4TCP/IP协议族7654325432应用层表示层会话层传输层网络层数据链路层物理层1应用层主机到主机层Internet层1网络接入层©1999,CiscoSystems,Inc.—8-5应用层概述*路由器使用应用层主机到主机层Internet层文件传输-TFTP*-FTP*-NFSE-Mail-SMTP远程登陆-Telnet*-rlogin*网络管理-SNMP*名称管理-DNS*网络接入层©1999,CiscoSystems,Inc.—8-6主机到主机层概述TransmissionControlProtocol(TCP)UserDatagramProtocol(UDP)应用层主机到主机层Internet层网络接入层面向连接非面向连接©1999,CiscoSystems,Inc.—8-7TCP数据格式Sourceport(16)Destinationport(16)Sequencenumber(32)Headerlength(4)Acknowledgementnumber(32)Reserved(6)Codebits(6)Window(16)Checksum(16)Urgent(16)Options(0or32ifany)Data(varies)20BytesBit0Bit15Bit16Bit31©1999,CiscoSystems,Inc.—8-8端口号TCP端口号FTP传输层TELNETDNSSNMPTFTPSMTPUDP应用层2123255369161RIP520©1999,CiscoSystems,Inc.—8-9TCP端口号源端口目标端口…HostA102823…SPDPHostZTelnetZ目标端口=23.©1999,CiscoSystems,Inc.—8-10发送SYN(seq=100ctl=SYN)接收SYNHostAHostBTCP三次握手1©1999,CiscoSystems,Inc.—8-11发送SYN(seq=100ctl=SYN)接收SYN发送SYN,ACK(seq=300ack=101ctl=syn,ack)HostAHostB接收SYN12TCP三次握手©1999,CiscoSystems,Inc.—8-12发送SYN(seq=100ctl=SYN)接收SYN发送SYN,ACK(seq=300ack=101ctl=syn,ack)建立会话(seq=101ack=301ctl=ack)HostAHostB123接收SYNTCP三次握手TCP连接建立©1999,CiscoSystems,Inc.—8-13TCP简单确认滑动窗口=1发送方接收方©1999,CiscoSystems,Inc.—8-14TCP简单确认滑动窗口=1发送方接收方发送1接收1©1999,CiscoSystems,Inc.—8-15TCP简单确认滑动窗口=1发送方接收方发送1接收1接收ACK2发送ACK2©1999,CiscoSystems,Inc.—8-16TCP简单确认滑动窗口=1发送方接收方发送1接收1接收ACK2发送ACK2发送2接收2©1999,CiscoSystems,Inc.—8-17TCP简单确认滑动窗口=1发送方接收方发送1接收1接收ACK2发送ACK2发送2接收2接收ACK3发送ACK3©1999,CiscoSystems,Inc.—8-18TCP简单确认滑动窗口=1发送方接收方发送1接收1接收ACK2发送ACK2发送2接收2接收ACK3发送ACK3发送3接收3©1999,CiscoSystems,Inc.—8-19滑动窗口=1发送方接收方发送1接收1接收ACK2发送ACK2发送2接收2接收ACK3发送ACK3发送3接收3接收ACK4发送ACK4TCP简单确认©1999,CiscoSystems,Inc.—8-20TCP顺序号和确认号源端口目标端口…顺序号#确认号#SourceDest.Seq.Ack.102823101我发送#10.©1999,CiscoSystems,Inc.—8-21TCP顺序号和确认号我已收到#10,现在我需要#11.源端口目标端口…顺序号#确认号#102823SourceDest.10Seq.1Ack.102823SourceDest.11Seq.1Ack.我发送#10.©1999,CiscoSystems,Inc.—8-22TCP顺序号和确认号源端口目标端口…顺序号#确认号#102823SourceDest.11Seq.2Ack.102823SourceDest.10Seq.1Ack.102823SourceDest.11Seq.1Ack.我已收到#10,现在我需要#11.我发送#10.©1999,CiscoSystems,Inc.—8-23TCP顺序号和确认号源端口目标端口…顺序号#确认号#102823SourceDest.11Seq.2Ack.102823SourceDest.10Seq.1Ack.102823SourceDest.11Seq.1Ack.102823SourceDest.12Seq.2Ack.我已收到#11,现在我需要#12.我发送#11©1999,CiscoSystems,Inc.—8-24TCP窗口发送方接收方©1999,CiscoSystems,Inc.—8-25TCP窗口Windowsize=3Send2发送方接收方Windowsize=3Send1Windowsize=3Send3©1999,CiscoSystems,Inc.—8-26Windowsize=3Send2TCP窗口发送方Windowsize=3Send1Windowsize=3Send3ACK3Windowsize=2数据3被丢弃接收方©1999,CiscoSystems,Inc.—8-27Windowsize=3Send2TCP窗口发送方Windowsize=3Send1Windowsize=3Send3ACK3Windowsize=2数据3被丢弃Windowsize=3Send4Windowsize=3Send3接收方©1999,CiscoSystems,Inc.—8-28Windowsize=3Send2TCP窗口发送方Windowsize=3Send1Windowsize=3Send3ACK3Windowsize=2数据3被丢弃Windowsize=3Send4Windowsize=3Send3ACK5Windowsize=2接收方©1999,CiscoSystems,Inc.—8-29没有顺序号和确认号UDP数据格式Sourceport(16)Destinationport(16)Length(16)Data(ifany)1Bit0Bit15Bit16Bit31Checksum(16)8Bytes©1999,CiscoSystems,Inc.—8-30Internet层概述OSI网络层对应的是TCP/IP的internet层InternetProtocol(IP)InternetControlMessageProtocol(ICMP)AddressResolutionProtocol(ARP)ReverseAddressResolutionProtocol(RARP)应用层主机到主机层Internet层网络接入层©1999,CiscoSystems,Inc.—8-31IP数据Version(4)DestinationIPAddress(32)Options(0or32ifany)Data(variesifany)1Bit0Bit15Bit16Bit31HeaderLength(4)Priority&TypeofService(8)TotalLength(16)Identification(16)Flags(3)Fragmentoffset(13)Timetolive(8)Protocol(8)Headerchecksum(16)SourceIPAddress(32)20Bytes©1999,CiscoSystems,Inc.—8-32决定上层协议协议域TransportLayerInternetLayerTCPUDPProtocolNumbersIP176©1999,CiscoSystems,Inc.—8-33ICMP协议ApplicationTransportInternetNetworkAccessDestinationUnreachableEcho(Ping)OtherICMP1©1999,CiscoSystems,Inc.—8-34ARP协议172.16.3.1172.16.3.2IP:172.16.3.2=???我需要知道176.16.3.2的物理地址.©1999,CiscoSystems,Inc.—8-35ARP协议172.16.3.1172.16.3.2IP:172.16.3.2=???我知道你的请求,这是我的物理地址我需要知道176.16.3.2的物理地址.©1999,CiscoSystems,Inc.—8-36ARP协议172.16.3.1IP:172.16.3.2Ethernet:0800.0020.1111172.16.3.2IP:172.16.3.2=???我知道你的请求,这是我的物理地址我需要知道176.16.3.2的物理地址.©1999,CiscoSystems,Inc.—8-37ARP协议映射IPEthernetLocalARP172.16.3.1IP:172.16.3.2Ethernet:0800.0020.1111172.16.3.2IP:172.16.3.2=???我知道你的请求,这是我的物理地址我需要知道176.16.3.2的物理地址.©1999,CiscoSystems,Inc.—8-38RARP协议Ethernet:0800.0020.1111IP=???我的地址是多少?©1999,CiscoSystems,Inc.—8-