第三天 基于TCP/IP的 互连网络和ip地址子网划分

Slides:



Advertisements
Similar presentations
Copyright©2013 Huawei Technologies Co., Ltd. All Rights Reserved. The information in this document may contain predictive statements including, without.
Advertisements

朝阳区统计系统 网络基础知识培训 计算机中心
第五章 網際網路 5-1 網際網路的歷史沿革 5-2 網際網路基本運作原理 5-3 連線媒介與連線上網 5-4 網際網路上的熱門應用
第 8 章 IP 基礎與定址.
计算机网络课程总结 一、计算机网络基础 计算机网络定义和功能、基本组成 OSI/RM参考模型(各层的功能,相关概念, 模型中数据传输 等)
第 12 章 UDP 與 TCP.
第 4 章 网络层.
计算机网络教程(第 2 版) 第 7 章 网络互连 课件制作人:谢希仁.
因特网 TCP/IP协议 IP路由技术 Internet接入技术 Internet服务.
网络协议及架构安全 培训机构名称 讲师名字.
第6章 Internet与TCP/IP体系结构
Chapter 12 UDP 與 TCP.
第2章 计算机网络的协议与体系结构 2.1 计算机网络体系结构的形成 2.2 协议与划分层次 2.3 计算机网络的原理体系结构
网络基础 上海广电通讯网络有限公司 金宁亚
数据转发过程.
Foundations of Computer Science Chapter 6 電腦網路
NetGuru 創新 網路通訊實驗教學解決方案 PART I TCP/IP通訊協定深入剖析/以NetGuru實作
第3章 局域网互连 3.1 网络互连的层次 3.2 网络互连的设备 3.3 实例教学 3.4 VLAN路由配置 3.5 VPN互连远程局域网.
“通信工程基础” 主讲教师:姚玉坤 副教授 承担单位:重庆邮电大学通信与信息工程学院 —通信网络教研中心 办公地点:逸夫科技楼三楼
網路基本概念與設定方法 林文宗 資管系助理教授
PPP协议 点到点协议 深圳职业技术学院电信学院网络技术专业.
PPP协议 点到点协议 深圳职业技术学院计算机系网络专业.
网络安全威胁与防御策略. TCP/IP Protocols  Contains Five Layers  Top three layers contains many protocols  Actual transmission at the physical layer.
Lab312.
實驗8 ICMP協定分析 實驗目的 明瞭ICMP(Internet Control Message Protocol;網際網路控制訊息協定)的工作原理 解析ICMP協定下封包資料傳送的格式。
传输层是整个协议层次的核心,其任务是在源机器和目标机器之间提供可靠的、性价比合理的数据传输功能,并与当前所使用的物理网络完全独立
第 12 章 UDP 與 TCP.
通訊協定 OSI分層模式 與 TCP/IP協定
第3讲 网络安全协议基础 此为封面页,需列出课程编码、课程名称和课程开发室名称。
(C) Active Network CO., Ltd
计算机网络原理 计算机与信息工程分院 周文峰.
網路技術管理進階班---網路連結 講師 : 陳鴻彬 國立東華大學 電子計算機中心.
第 16 章 Internet架構.
第六章 差错与控制报文 (ICMP).
第五章 網際網路 5-1 網際網路的歷史沿革 5-2 網際網路基本運作原理 5-3 連線媒介與連線上網 5-4 網際網路上的熱門應用
TCP和UDP基本原理.
Internet Protocol (IP)
32 bit destination IP address
附錄 通訊協定堆疊.
TCP/IP Protocol Suite TCP/IP協定 第二組 投影片製作by簡嘉宏 綦凱宏 林睿敏 滕孟哲.
系統與網路管理工具.
ARP, RARP & ICMP.
第 2 章 TCP / IP 簡介.
第四章 IP地址 子网划分 VLSM CIDR Purpose: This chapter reviews the physical layer and describes how to cable various network devices. Timing: This chapter takes.
在一定程度上 人类的思维产生于 简单个体之间的相互作用 ——Marvin Minsky.
第十讲 TCP协议 协议概述 报文段格式 差错控制 流控和拥塞控制 TCP连接管理 TCP性能问题 TCP软件设计 2018/12/7
預官考試輔導 計算機概論提要 91年12月4日.
第4章 OSI傳輸層.
第4讲 传输层之二 本讲目的: 本讲概述: Internet传输层的实现和实例 面向连接的传输: TCP TCP拥塞控制 拥塞控制原则
實驗目的 明瞭可靠傳輸層的基礎觀念 TCP協定下區段資料傳送的格式
第七讲 网际协议IP.
校園網路架構介紹與資源利用 主講人:趙志宏 圖書資訊館網路通訊組.
第5讲 网络层 本讲目的: 概述: 理解网络层服务原理: 因特网的实现实例 网络层的服务 路由选择原理 分层的路由选择 IP协议
第 12 章 UDP 與 TCP 著作權所有 © 旗標出版股份有限公司.
第十三章 TCP/IP 與 Internet 網路連結技術
第2讲 网络安全协议基础 此为封面页,需列出课程编码、课程名称和课程开发室名称。
TANet PROTOCOL ANALYSIS - WIRESHARK - 350.
第7章 传输层协议——TCP与UDP 任课教师 卢豫开.
Westmont College 网络互连 Part 4 (传输协议, UDP and TCP, 协议端口)
3.1 通訊協定 3.2 開放系統參考模式(OSI) 3.3 公眾數據網路 3.4 TCP/IP通訊協定
實驗5 IP協定分析 明瞭IP(Internet Protocol;Internet協定)的基礎觀念
Source: Journal of Network and Computer Applications, Vol. 125, No
Speaker : Chang Kai-Jia Date : 2010/04/26
Distance Vector vs Link State
Chapter 10 Mobile IP TCP/IP Protocol Suite
数据报分片.
IP Layer Basics, Firewall, VPN, and NAT
Distance Vector vs Link State Routing Protocols
Internet课程设计 教师:陈 妍 朱海萍 西安交通大学计算机系
第7章 传输层协议——TCP与UDP 任课教师 卢豫开.
Presentation transcript:

第三天 基于TCP/IP的 互连网络和ip地址子网划分 Purpose: This chapter reviews the physical layer and describes how to cable various network devices. Timing: This chapter takes approximately 1 hour to present. Note: This section has a cabling laboratory exercise at the end. Contents: Objectives—This section explains what the student will be able to do at the end of this chapter. TCP/IP Overview—This section describes the TCP/IP protocol stack. TCP/IP Application Layer Overview—This section describes the application protocols. TCP/IP Transport Layer Overview—This section describes TCP and UDP. TCP/IP Internet Layer Overview—This section describes IP and other Internet layer protocols. TCP/IP Address Overview—This section describes IP addressing. Configuring IP Addresses—This section describes how to address an IOS device with IP Interconnecting Networks—This section describes how to interconnect separate VLANs and WANs With TCP/IP. Written Exercise—This section has students work with IP addresses in binary format.

本章目标 通过本章的学习,您应该掌握以下内容: 了解TCP/IP协议栈,各个分层的主要功能、IP协议的应用 Purpose: This figure states the chapter objectives. Emphasize: Read or state each objective so each student has a clear understanding of the chapter objectives.

TCP/IP介绍 早期的协议族 全球范围 Internet TCP/IP 主机 主机 Purpose: This figure explains the history of TCP/IP. Emphasize: In the mid-1970s, DARPA established a packet-switched network to provide electronic communication between research institutions in the United States. DARPA and other government organizations understood the potential of packet-switched technology and were just beginning to face the problem virtually all companies with networks now have—how to establish communication between dissimilar computer systems. 早期的协议族 全球范围

协议模型和参考模型 7 6 5 4 3 Purpose: This figure shows the protocol layers and compares them with the layers of the OSI reference model. Emphasize: This figure shows the TCP/IP conceptual layer titles. The protocol stack is used several times in this chapter, and the lower two layers may be sometimes called the network interface layer. The terms “packet” and “datagram” are nearly interchangeable. However, a datagram is a unit of data, while a packet is a physical entity that appears on a network. In most cases, a packet contains a datagram. In some protocols, though, a datagram is divided into a number of packets to accommodate a requirement for smaller transmittable pieces. Note: Creation and documentation of the Internet protocols closely resembles an academic research project. The protocols are specified in documents called RFCs. RFCs are published, reviewed, and analyzed by the Internet community. 2 1

TCP/IP 协议族 TCP/UDP IP 接口和线缆 HTTP、Telnet、FTP、 TFTP、Ping、etc 提供应用程序网络接口 ARP/RARP IP IGMP ICMP Ethernet、802.3、PPP、 HDLC、FR、etc 接口和线缆 提供应用程序网络接口 应用层 传输层 建立端到端连接 寻址和路由选择 网络层 物理介质访问 网络接入层 二进制数据流传输

应用层概述 文件传输 - TFTP * - FTP * - NFS E-Mail - SMTP 远程登陆 - Telnet * - rlogin * 网络管理 - SNMP * 名称管理 - DNS* 应用层 Purpose: This figure discusses application-layer protocols. Emphasize: The common network applications today include file transfer, remote login, network management, and e-mail. We focus on TCP/IP in this course for several reasons: TCP/IP is a universally available protocol and you will use it at work. TCP/IP is a useful reference for understanding other protocols, because it includes elements that are representative of other protocols. TCP/IP is important because the router uses it as a configuration tool. The router uses Telnet for remote configuration, TFTP to transfer configuration files and operating system images, and SNMP for network management. Transition: The next section moves down the model to discuss the transport layer. 传输层 Internet层 网路接入层 * 路由器使用

传输层概述 Transmission Control Protocol (TCP) 面向连接 非面向连接 User Datagram Protocol (UDP) 面向连接 非面向连接 应用层 传输层 Internet层 Purpose: This figure introduces the protocols used at the transport layer. Emphasize: TCP is one protocol within the protocol suite of TCP/IP. TCP is an acknowledged transport-layer protocol. However, TCP has a large header so there is much overhead. UDP is unacknowledged. By eliminating all of the acknowledgement mechanisms, UDP is fast and efficient. UDP does not divide application data into pieces. Reliability is assumed to be handled by the upper-layer protocols, by a reliable lower-layer protocol, or by an error-tolerant application. UDP does have a smaller header and less overhead. 网络接入层

Acknowledgement number (32) TCP 数据格式 Bit 0 Bit 15 Bit 16 Bit 31 Source port (16) Destination port (16) Sequence number (32) Acknowledgement number (32) 20 Bytes Header length (4) Purpose: This figure explains what is contained in a TCP segment. Emphasize: Source Port and Destination Port are the connections to the upper-layer protocol. Sequence and Acknowledgment numbers are the position in the user’s byte stream of this segment. Sequence numbers are used for establishing reliability. HLEN is the header length. It tells us where the data begins. Six bits are reserved for future use. Code Bits distinguish session management messages from data. Window is a term we will come back to in a few slides. For now, consider it the size of the receivers buffers. Checksum is a cyclic redundancy check (CRC). It verifies that the datagram arrived intact. Urgent Pointer is used to signify out-of-band data. Options are used by vendors to enhance their protocol offering. The data portion of the frame contains the upper-layer protocol data. Reserved (6) Code bits (6) Window (16) Checksum (16) Urgent (16) Options (0 or 32 if any) Data (varies)

TCP 数据格式 序号:指出段中数据在发送端数据流中的位置。 确认号:指出本机希望下一个接收的字节的序号。 头长:指出以32比特为单位的段头长度。它是针对变长的“选项”域设计的。 码位:有些报文段是用于传输数据的,但有些报文段仅仅携带了确认信息,另一些报文段携带的是建立和关闭连接的请求。它使用“码位”来指出段的目的与内容。这6个比特各位的意义如图: 0 URG,紧急指针字段可用 1 ACK,确认字段可用 2 PSH,本报文段请求急迫(PUSH)操作 3 RST,连接复位 4 SYN,序号同步,用于建立连接中的同步 5 FIN,发送方字节流结束

TCP 数据格式 当所有的紧急数据消失之后,TCP软件会告诉应用程序恢复正常的操作状态。PUSH位提供了数据强迫传输机制,以强迫传输当前流中的数据,而不必等待缓冲区满。远程登录中,终端的击键信号就是用PUSH操作来提供的。 窗口(滑动窗口):用于通知接收端接收缓冲区的大小。 理解TCP的面向连接特性: 一条TCP连接是一条虚电路,它通过主机IP地址和端口号来标识一条连接。如(192.168.2.37,21;192.168.2.30,21)就标识了一条TCP连接。所以两个程序可以共享主机上的同一端口,因为连接不同。 连接的建立和拆除需要得到对方的认可,而UDP中,一方发送数据是不需要得到对方的认可的。 连接能保持状态并实现可靠性,而无连接不能保持状态。一般来说,控制信息是通过TCP来传递的。 它是在无连接的协议,IP协议之上来实现面向连接的。

端口号 F T P T E L N E T S M T P D N S T F T P S N M P R I P 应用层 21 23 25 Purpose: This figure explains how TCP uses port numbers to connect applications. Emphasize: These port numbers were standardized in RFC 1340. This RFC has been obsoleted by RFC 1700. However, many of the port numbers outlined in RFC 1340 are still being used as standards. It is possible to filter on TCP port numbers. The TCP port number, combined with other information, is what UNIX C language developers call a socket. However, work sockets have different meanings in XNS and Novell, where they are service access point abstractions or programming interfaces rather than service access point identifiers. 21 23 25 53 69 161 520 端口号 传输层 TCP UDP

TCP 端口号 Telnet Z 源端口 目标端口 … Host Z Host A SP DP 目标端口 = 23. 1028 23 … Purpose: This figure continues to explain how TCP uses port numbers. Emphasize: In most cases the TCP port number on one side of a conversation is the same on the other side. For example, when a file transfer takes place, the software on one host is communicating with a peer application on another host. In this example we see a Telnet (TCP port 23) session. It is possible to have multiple Telnet sessions running simultaneously on a host or router. Telnet selects an unused port number above 1023 to represent the source port for each independent session. Notice that the destination port is still 23. Port numbering is important to understand in order to configure IP extended access lists. The lack of symmetry in port number use is a critical factor in establishing effective security. SP DP 目标端口 = 23. 1028 23 …

TCP 三次握手 1 发送 SYN (seq=100 ctl=SYN) 接收 SYN Host A Host B Layer 1 of 3: Host A begins by sending a SYN segment indicating that host A will use sequence numbers starting with sequence number 100. Emphasize: TCP is a simple protocol in terms of connection establishment. Some protocols have dozens of negotiation messages that are transmitted prior to session initialization. TCP implements a strategy that is both necessary and sufficient.

TCP 三次握手 1 2 发送 SYN (seq=100 ctl=SYN) 接收 SYN 发送 SYN, ACK Host A Host B 1 发送 SYN (seq=100 ctl=SYN) 接收 SYN 2 发送 SYN, ACK (seq=300 ack=101 ctl=syn,ack) Layer 2 of 3: Host B sends an ACK and acknowledges the SYN it received from host A. Host B also sends a SYN. Note that the acknowledgment field indicates host B is now expecting to hear sequence 101, acknowledging the SYN that occupied sequence 100. 接收 SYN

TCP 三次握手 1 2 3 发送 SYN (seq=100 ctl=SYN) 接收 SYN 发送 SYN, ACK Host A Host B 1 发送 SYN (seq=100 ctl=SYN) 接收 SYN 2 发送 SYN, ACK (seq=300 ack=101 ctl=syn,ack) Layer 3 of 3: In the next segment, host A sends some data. Note that the sequence number of the segment in step 3 is the same as as the ACK in step 2. Emphasize: This sequence is like two people talking. The first person wants to talk to the second, so she says, “I would like to talk with you.” (SYN.) The second person responds, “Good. I want to talk with you.” (SYN, ACK.) The first person then says, “Fine—let us talk. Here is what I have to say.” (SYN, ACK, DATA.) At this point either side can begin communicating and either side can break the connection. TCP is a peer-to-peer (balanced) communication method (no primary/secondary). Note: This figure explains TCP connection establishment. For more information regarding the three-way handshake in establishing a TCP connection, refer to RFC 793. 接收 SYN 建立会话 (seq=101 ack=301 ctl=ack) 3

TCP 简单确认 滑动窗口 = 1 发送方 接收方 Layer 1 of 7: The window size is the number of messages transmitted before the sender must wait for an acknowledgment. Window size was presented earlier in the course, so this slide is a review. The initial state, no messages being sent. 滑动窗口 = 1

TCP 简单确认 滑动窗口 = 1 发送方 接收方 发送 1 接收 1 Layer 2 of 7: Data message 1 sent. (Send 1, Receive 1) 滑动窗口 = 1

TCP 简单确认 滑动窗口 = 1 发送方 接收方 发送 1 接收 1 发送 ACK 2 接收 ACK 2 Layer 3 of 7: Acknowledgment message 2 sent. (Send ACK 2, Receive ACK 2) 滑动窗口 = 1

TCP 简单确认 滑动窗口 = 1 发送方 接收方 发送 1 接收 1 发送 ACK 2 接收 ACK 2 发送 2 接收 2 Layer 4 of 7: Data message 2 sent. (Send 2, Receive 2) 滑动窗口 = 1

TCP 简单确认 滑动窗口 = 1 发送方 接收方 发送 1 接收 1 发送 ACK 2 接收 ACK 2 发送 2 接收 2 Layer 5 of 7: ACK for message 2. (Send ACK 3, Receive ACK 3) 发送 ACK 3 接收 ACK 3 滑动窗口 = 1

TCP 简单确认 滑动窗口 = 1 发送方 接收方 发送 1 接收 1 发送 ACK 2 接收 ACK 2 发送 2 接收 2 Layer 6 of 7: Send 3, Receive 3. 发送 ACK 3 接收 ACK 3 发送 3 接收 3 滑动窗口 = 1

TCP 简单确认 滑动窗口 = 1 发送方 接收方 发送 1 接收 1 发送 ACK 2 接收 ACK 2 发送 2 接收 2 Layer 1 of 7: ACK for message 3. (Send ACK 4, Receive ACK 4) This sequence helps to convey the delay associated with a window size of one. Note: TCP acknowledgments are expectational and are sometimes called forward referenced, which means that they refer to the segment they are expecting to receive, not the one just sent. Acknowledgment field sizes can become an issue when transmitting data at FDDI and ATM speeds. 发送 ACK 3 接收 ACK 3 发送 3 接收 3 发送 ACK 4 接收 ACK 4 滑动窗口 = 1

TCP 顺序号和确认号 我发送 #10. 源端口 目标端口 顺序号 # 确认号 # … Source Dest. Seq. Ack. Layer 1 of 4: Layer 1 shows the Sequence number is 10. Source Dest. Seq. Ack. 1028 23 10 1

TCP 顺序号和确认号 我发送 #10. 我已收到 #10, 现在我需要 #11. 源端口 目标端口 顺序号 # 确认号 # … Layer 2 of 4: Layer 2 shows the acknowledgment number is 11. Source Dest. Seq. Ack. 1028 23 10 1 Source Dest. Seq. Ack. 23 1028 1 11

TCP 顺序号和确认号 我发送 #10. 我已收到 #10, 现在我需要 #11. 源端口 目标端口 顺序号 # 确认号 # … Layer 3 of 4: Layer 3 shows the next sequence number is 11. Source Dest. Seq. Ack. 1028 23 10 1 Source Dest. Seq. Ack. 23 1028 1 11 Source Dest. Seq. Ack. 1028 23 11 2

TCP 顺序号和确认号 我发送 #11 我已收到 #11, 现在我需要 #12. 源端口 目标端口 顺序号 # 确认号 # … Source Layer 4 of 4: Layer 4 shows the acknowledgment number is 12. Emphasize: The Sequence and Acknowledgment numbers are directional. The slide highlights the communication going in one direction. The sequence and acknowledgments take place with the sender on the right. TCP provides full-duplex communication. Source Dest. Seq. Ack. 1028 23 10 1 Source Dest. Seq. Ack. 23 1028 1 11 Source Dest. Seq. Ack. 1028 23 11 2 Source Dest. Seq. Ack. 23 1028 2 12

TCP 窗 口 发送方 接收方 Layer 1 of 5: This figure points out the benefit of a larger window size. Layer 1 is in the initial state, no messages being sent.

TCP 窗 口 发送方 接收方 Window size = 3 Send 1 Window size = 3 Send 2 Layer 2 of 5: Layer 2 illustrates how the sending device defines its window buffer as 3 and sends three bytes.

TCP 窗 口 发送方 接收方 数据 3 被丢弃 Window size = 3 Send 1 Window size = 3 Send 2 Layer 3 of 5: In layer 3, the receiving device acknowledges the two first bytes, drops 3, and advertises its window size as 2. ACK 3 Window size = 2 数据 3 被丢弃

TCP 窗 口 发送方 接收方 数据 3 被丢弃 Window size = 3 Send 1 Window size = 3 Send 2 Layer 4 of 5: In layer 3 the sending device transmits 2 bytes but maintains a window size of 2. ACK 3 Window size = 2 数据 3 被丢弃 Window size = 3 Send 3 Window size = 3 Send 4

TCP 窗 口 发送方 接收方 数据 3 被丢弃 Window size = 3 Send 1 Window size = 3 Send 2 Layer 5 of 5: In layer 5, the receiving device acknowledges the 2 bytes and still advertises its window size as 2. 数据 3 被丢弃 ACK 3 Window size = 2 Window size = 3 Send 3 Window size = 3 Send 4 ACK 5 Window size = 2

UDP 数据格式 没有顺序号和确认号 Bit 0 1 Bit 15 Bit 16 Bit 31 Source port (16) Destination port (16) 8 Bytes Length (16) Checksum (16) Purpose: This graphic explains the format of UDP. Emphasize: UDP is simple and efficient but not reliable. The UDP segment format includes a source port, a destination port, a length field, and an optional checksum field. It has no sequencing, acknowledgments, or windowing. Example: TFTP uses a checksum. At the end of the transfer if the checksum does not match then the file did not make it. The user is notified and must type in the command again. As a result, the user has become the reliability mechanism. Transition: The next section discusses the network layer of the OSI model and how it corresponds to the TCP/IP internet layer. Data (if any) 没有顺序号和确认号

UDP 数据格式 UDP信宿端口:一个UDP端口是一个可读写的软件结构,内部有一个接收报文缓冲区。接收数据时,UDP软件要判断此信宿端口是否与当前使用的端口匹配,如是,则将数据报放入相应的接收队列,否则,抛弃该数据并向信源端口发送“端口不可达”的差错消息报文。 长度:以字节计的整个报文长度,最小为8,只有报头。 校验和:它是一个可选项,以提高效率。 在利用IP传送语音和视频的时候,要利用UDP协议。

TCP/UDP端口 UDP TCP TCP、UDP 服务/端口(保留):一共有216=65536个端口 42 NAMESERVER 端口号 关键字 描述 42 NAMESERVER 主机名字服务 53 DOMAIN 域名服务 UDP 67 BOOTPS 启动协议服务 69 TFTP 简单文件传输 111 SUNRPC 微系统公司RPC(远程过程调用) 20 FTP-DATA 文件传输服务(数据连接) 21 FTP 文件传输服务(控制连接) 23 TELNET 远程登录服务 TCP 25 SMTP 简单邮件服务 42 NAMESERVER 主机名字服务 53 DOMAIN 域名服务

Internet 层概述 OSI 网络层对应的是TCP/IP的internet层 Internet Protocol (IP) Internet Control Message Protocol (ICMP) Address Resolution Protocol (ARP) Reverse Address Resolution Protocol (RARP) 应用层 传输层 Purpose: This figure presents a list of the protocols operating at the Internet layer. Emphasize: Review the protocols briefly. They are covered in detail on the coming pages. Routing protocols are usually considered layer-management protocols that support the network layer. Internet层 数据链路层 物理层 OSI 网络层对应的是TCP/IP的internet层

IP协议 IP协议: 传输机制 IP数据报传输是一种简洁而有效的分组交换方式,为了达到最高的传输速率,它放弃了可靠性保证(如检错、重传等,数据的可靠性要靠更高层协议,如TCP等来保证),以便尽快将数据报传往目的地。它不保证传输质量,只是尽最大努力来传输要传的数据。IP数据报传输的关键问题是分片和重组。分片是为了适应物理网的最大传输单元(MTU),重组是为了将已分片的数据根据分片规则重新组合起来。数据报传输的一大特点是随机路由,因而从信源到信宿的时延也是随机的。另外,在路由时数据报还可能进入一条循环路由,IP中采用“生存期”来解决。

Priority & Type of Service (8) Destination IP Address (32) Bit 0 1 Bit 15 Bit 16 Bit 31 Version (4) Header Length (4) Priority & Type of Service (8) Total Length (16) Flags (3) Identification (16) Fragment offset (13) 20 Bytes Time to live (8) Protocol (8) Header checksum (16) Purpose: This figure explains what is contained in an IP datagram. Emphasize: Discuss the format of the IP datagram. The current generation of IP is version 4. We need the Header Length (HLEN) and the Total Length in this example because the IP Options field allows a variable length. Time-To-Live (TTL) is a countdown field. Every station must decrement this number by one or by the number of seconds it holds onto the packet. When the counter reaches zero, the time to live expires and the packet is dropped. TTL keeps packets from endlessly wandering the internet in search of nonexistent destinations. The next generation of IP (called IPng) is IP version 6. It is covered in RFC 1752. Good references for this topic are Douglas Comer’s books on TCP/IP. Source IP Address (32) Destination IP Address (32) Options (0 or 32 if any) Data (varies if any)

IP 数据报 版本(Version) :V4 报头长度(Header Length) :它是以32比特为单位的。最常见的是5(不含IP选项,20B),也有为6的(含IP选项,24B)。 业务类型(TOS):IP协议是一个不保证质量的协议。它通过 TOS来弥补一下其QOS的不足。其8个比特的含义如下 3 5 7 优先级 D T R 保留 三个比特的优先级指明本数据报的优先级,允许发送方表示数据报的重要程度。优先级从0到7,其中“0”表示普通用户优先级,“7”表示网络控制优先级。 D、T、R表示本数据报希望的传输类型。D=1表示低时延,T=1表示高吞吐量,R=1表示高可靠性。注意,优先级对网络没有强制性,目前大多数网络对此一般不作处理,但为技术的进一步的提供了手段。

IP 数据报 总长度(Total Length) :指明IP数据报的长度,以字节为单位。数据报最长为216=64k字节 标识符(Identification) :指明了它原来属于哪一个数据报 标志(Flags) :它一共有3个比特,第一个比特指明是否要对数据报分片,为‘1’表明这是一个分片数据报;第二个比特指明该分片是否是这个数据报的最后一个分片,‘1’表示不是最后一个分片,也就是说分片未完;第三个比特未用。 分片偏移量(Fragment offset) :指明该分片的数据在原来数据只能中从数据头开始的字节偏移量,第一个分片的偏移量为0,这样可以确定数据片在原数据中的位置,以便到终端进行重组。

IP 数据报 我们知道,任何IP帧最终都要封装在链路层帧中才能发送和被目标所接收。而链路层帧在每一种物理网络中都有一个最大长度限制,这个最大长度称为最大传输单元(Maximum Transfer Unit,MTU)。所以虽然IP数据报的最大长度可以达到64k,但在链路上传输的数据帧最大只能达到MTU。所以当IP数据报从IP层传到数据链路层和从一个MTU较大的的物理网络通过路由器达到另外一个MTU较小的网络的时候,主机和路由器先要将IP数据报划分成较小的数据单元,这个过程叫做数据报分片。较小的数据报在达到目的地之前不会进行重组,他们可以自由路由,到达目的地后他们会重新组合成原来的数据报,若在这个过程中,某一个数据报片丢失,整个数据报将无法重组。在实际情况下,接收机在收到初始片后将启动一个重组定时器,如果在收到所有分片之前定时器超时,则接收机丢弃已收到的分片,不对数据报进行进行处理。IP规范要求:路由器必须接收所连网络中MTU大小的数据报;同时必须随时能够处理至少576B的数据报,对主机的要求也是如此。

IP 数据报 分片和重组的具体过程: 在将数据报分片时,先将原数据报的报头复制到每个数据报片中,然后填入“标志”域,它一共有3个比特,第一个比特指明是否要对数据报分片,为‘0’表明这是一个分片数据报;第二个比特指明该分片是否是这个数据报的最后一个分片,‘1’表示不是最后一个分片,也就是说分片未完;第三个比特未用。其中的标识符指明了它原来属于哪一个数据报。然后填入“偏移量”域,它指明该分片的数据在原来数据只能中从数据头开始的字节偏移量,第一个分片的偏移量为0,这样可以确定数据片在原数据中的位置,以便到终端进行重组。它还要填入“总长度”域,它指明分片的长度。 当各分片通过各种路径到达接收机的时候,通过“标志”域的第一位可以知道这是一个分片,并且由“标识符”知道它属于哪一个数据报;由第二位知道是否收到了最后一个分片,如果收到了最后一个分片,由该分片中的“偏移量”和所有属于该数据报的数据总长度就可以知道是否收到了所有的分片,从而可以进行重组。重组好数据报后就可以交给IP层去处理。

IP 数据报 TTL(Time To Live,生存期):它用来处理时延。它以秒为单位,指明了数据报在网络中的最长有效时间。路由器处理报头时,从TTL中减1;若数据报在路由器中排队而被延迟;则要从TTL中减去等待时间;若TTL=0则将它从网络中删除。 协议:它指明数据区中的数据格式,说明在IP的上一层(传输层)所采用的协议,如(TCP、UDP)。当IP数据报到达对端以后,将按照“协议”来将数据报交给传输层进行相应处理。 头部校验和:对报头的CRC。 IP选项:包括时间戳、源站路由、路由器路由,IP数据报中可以没有这些选项。

协议域 决定上层协议 Transport Layer TCP UDP Protocol Numbers 6 17 Internet Layer Purpose: This figure explains the use of the protocol field. Emphasize: Protocol numbers connect, or multiplex, IP to the transport layer. These numbers are standardized in RFC 1700. Cisco uses these numbers in filtering with extended access lists. IP 决定上层协议

ICMP协议 1 Destination Unreachable Echo (Ping) Other Application Transport 1 ICMP Purpose: This figure explains which messages are ICMP messages. Emphasize: Describe ICMP messages and ping. Internet Data Link Physical

ICMP数据报 IP数据报的传送不保证不丢失。但互连网层对数据报的传送还有一定的质量保证功能,这就是使用Internet控制报文协议ICMP(Internet Control Message Protocol)。ICMP允许主机或路由器报告差错情况和提供有关异常情况的报告。但ICMP不是高层协议,它仍是互连网层中的协议。ICMP报文作为互连网层数据报的数据,加上数据报的首部,组成IP数据报发送出去。ICMP报文的格式如图4-1所示。 ICMP报文与IP数据报的关系

ICMP数据报 ICMP报文的格式 ICMP报文的前四个字节是统一的格式,共有三个字段。

ICMP数据报 类型字段的值与ICMP报文的类型关系如下: 类型字段的值 ICMP报文的类型 0 Ech0(回送)回答 3 目的站不可达 3 目的站不可达 4 源站抑制(Source Quench) 5 改变路由(Redirect) 8 Echo请求 11 数据报的时间超过 12 数据报的参数有问题 13 时间戳(Timestamp)请求 14 时间戳回答 17 地址掩码(Address Mask)请求 18 地址掩码回答

ICMP数据报 ICMP报文的代码字段也占有一个字节。为的是进一步区分某种类型中的几种不同的情况。后面的检验和占两个字节,它检验整个ICMP报文。数据报首部的检验和不检验数据报的内容,因此不能保证ICMP报文是正确的。

ICMP报文分类 ICMP报文的类型很多,但可分为两种类型,即ICMP差错报文和ICMP询问报文。 常用的ICMP差错报文。 1、ICMP Echo请求报文是由主机或路由器向一个特定的目的主机发出的询问。收到此报文的机器必须给主机发送ICMP Echo回答报文。 2、ICMP时间戳请求报文是请某个主机或路由器回答当前的日期和时间。在ICMP时间戳回答报文中有一个32bit的字段,其中写入的整数代表从1900年1月1日起到当前时刻一共有多少秒。 3、ICMP地址掩码请求与回答可使主机向子网掩码服务器得到某个接口的地址掩码。 常用的ICMP差错报文。 1、改变路由报文 2、源站抑制报文

ICMP报文分类 ICMP改变路由报文的使用举例

ICMP报文分类 ICMP改变路由报文的格式 源站抑制报文: 当某个速率较高的源主机向另一个速率较慢的目的主机(或路由器)发送一连串的数据报时,就有可能使速率较慢的目的主机产生拥塞,因而不得不丢弃一些数据报。在这种情况下,目的主机就要向源主机发送ICMP源站抑制报文,使源站暂停发送数据报,过一段时间再逐渐恢复正常。

PING程序 ICMP Echo Request Echo Reply

PING程序 ICMP回显请求和回显应答报文 代码(0) 检验和 类型(0或8) 标识符 序号 选项数据 0 7 8 15 16 31 0 7 8 15 16 31 8字节

Traceroute程序 Traceroute 程序工作过程 IP报头TTL字段 ICMP

Traceroute程序 Traceroute 程序工作过程 1)发送一份TTL字段为1的IP数据报给目的主机 2)处理这份数据报的第一个路由器将TTL值减1,丢弃该数据报,并发回一份超时ICMP报文 3)这样就得到了该路径中的第一个路由器的地址。 4)Traceroute程序发送一份TTL值为2的数据报,按上面的办法就可以得到第二个路由器的地址 5)继续这个过程直至该数据报到达目的主机,但是目的主机哪怕接收到TTL值为1的IP数据报,也不会丢弃该数据报并产生一份超时ICMP报文,这是因为数据报已经到达其最终目的地。 6)Traceroute程序发送一份UDP数据报给目的主机,但它选择一个不可能的值作为UDP端口号(大于30000),使目的主机的任何一个应用程序都不可能使用该端口。因为,当该数据报到达时,将使目的主机的UDP模块产生一份“端口不可达”错误的ICMP报文。这样,Traceroute程序所要做的就是区分接收到的ICMP报文是超时还是端口不可达,以判断什么时候结束。

ARP协议报文格式 帧头 ARP数据报文 CRC 31 8 16 硬件类型 协议类型 操作 发送者硬件地址(0~3B) 当信源网卡想通过信宿IP地址知道其MAC地址的时候,它向同一线路上的所有机器广播一个ARP报文(如下图),该报文封装在以太帧中。它填充以太帧的“数据”字段。 帧头 ARP数据报文 CRC 31 8 16 硬件类型 协议类型 硬件地址长度 协议地址长度 操作 发送者硬件地址(0~3B) 发送者硬件地址(4~5B) 发送者IP(0~1B) 发送者IP(2~3B) 目的硬件地址(0~1B) 目的硬件地址(2~5B) 目的IP(0~3B)

ARP协议报文格式(续) ARP报文解释: ARP报文处理 硬件类型:发送者本机硬件接口类型(以太网卡:1) 协议类型:发送者提供的高级协议类型(IP协议:0X0800) 操作:说明报文类型 1:ARP请求 2:ARP响应 3:RARP请求 4:RARP应答 目的硬件地址:ARP请求时,空出该域。 有些硬件技术不支持上层软件访问帧头,所以在帧头中和ARP数据报文中都有发送者硬件地址域。 ARP报文处理 进行ARP请求时,发送者在“发送者硬件地址”域和“发送者协议地址”域分别填入本机的硬件地 址和IP地址;并在“目标协议地址”域填入要解析的目标机的IP地址,在“操作”域填入“1”。 目标机处理请求时,在所缺域中填入相应数据,交换发送者域和目标域的位置,将“操作”域更改 为“2”。

ARP协议 我需要知道176.16.3.2的物理地址. 172.16.3.1 172.16.3.2 Layer 1 of 4: Purpose: This figure shows how ARP is used to determine an IP address. In layer 1, host 172.16.3.1 needs the MAC address of host 172.16.3.2. It sends an ARP request message. IP: 172.16.3.2 = ???

ARP协议 我需要知道176.16.3.2的物理地址. 我知道你的请求,这是我的物理地址 172.16.3.1 172.16.3.2 Layer 2 of 4: In layer 2, host 172.16.3.2 is on the same wire and receives the ARP request message. IP: 172.16.3.2 = ???

ARP协议 我需要知道176.16.3.2的物理地址. 我知道你的请求,这是我的物理地址 172.16.3.1 172.16.3.2 Layer 3 of 4: In layer 3, host 172.16.3.2 sends an ARP reply with its MAC address to host 172.16.3.1. IP: 172.16.3.2 = ??? IP: 172.16.3.2 Ethernet: 0800.0020.1111

ARP协议 映射 IP Ethernet Local ARP 我需要知道176.16.3.2的物理地址. 我知道你的请求,这是我的物理地址 172.16.3.1 172.16.3.2 Layer 4 of 4: In layer 4, the bulleted items at the bottom of the slide appear. Emphasize: ARP provides translation between network and data link layers. Discuss why it is necessary to have a mechanism like ARP. Describe ARP operation. Not all protocols use ARP. Some use other methods for address translation. Note: For the message to be transmitted uniquely to a single interface on the multiaccess link, it is necessary to build a frame with the unique MAC address of the interface IP: 172.16.3.2 = ??? IP: 172.16.3.2 Ethernet: 0800.0020.1111 映射 IP Ethernet Local ARP

ARP协议 当A(IPa)为得到B(IPb)的MAC地址而广播ARP请求时,它在以太帧头的目的物理地址中填入“FFFFFF”。问在同一线路上的所有机器,“请IP地址是IPb的机器告诉它的MAC地址”。这时候只有B会响应,并回答出自己的MAC地址。 为了提高效率,ARP使用了高速缓存技术。机器尽 可能地将它所能知道的IP和MAC地址对存入高速缓 存(高速缓存中每一项的生存时间一般为20分钟,起始时间从被创建时开始算起),对在高速缓存中有的IP地址,它将不进行ARP请求。另外,在新机入网时,它主动广播其MAC地址。

ARP协议 ARP(源主机与目的主机在同一子网) HOST Y HOST Z Query MAC Host Y Network Ethernet HOST Y HOST Z Query MAC Host Y Network Address Response Host Z Broadcast

PROXY ARP(源主机与目的主机不在同一子网) Ethernet HOST Y HOST Z Query MAC Host Y Network Address Response Router A Broadcast

免费ARP 我们可以看到的另一个A R P 特性称作免费ARP (gratuitous ARP)。它 是指主机发送A R P 查找自己的I P 地址。通常,它发生在系统引导期间 进行接口配置的时候。 免费ARP 可以有两个方面的作用: 1) 一个主机可以通过它来确定另一个主机是否设置了相同的IP地址。 2) 如果发送免费A R P 的主机正好改变了硬件地址(很可能是主机关机了,并换了一块接口卡,然后重新启动),那么这个分组就可以使其他主机高速缓存中旧的硬件地址进行相应的更新。

RARP协议 我的地址是多少? Ethernet: 0800.0020.1111 IP = ??? Layer 1 of 4: Purpose: This figure explains how RARP works. In layer 1, the host on the left needs its IP address. It sends a RARP request with its MAC address. Ethernet: 0800.0020.1111 IP = ???

RARP协议 我听到了广播你的地址是 172.16.3.25. 我的地址是多少? Layer 2 of 4: In layer 2, the host on the right, functioning as a RARP server, maps the MAC address to an IP address. Ethernet: 0800.0020.1111 IP = ???

RARP协议 我听到了广播你的地址是 172.16.3.25. 我的地址是多少? Layer 3 of 4: In layer 3, the host on the right sends the IP address to the requester in a RARP reply message. Ethernet: 0800.0020.1111 IP = ??? Ethernet: 0800.0020.1111 IP: 172.16.3.25

RARP协议 映射 Ethernet IP 我听到了广播你的地址是 172.16.3.25. 我的地址是多少? Layer 4 of 4: In layer 4, the bulleted items appear at the bottom of the slide. Emphasize: RARP is used to boot diskless workstations over a network. Ethernet: 0800.0020.1111 IP = ??? Ethernet: 0800.0020.1111 IP: 172.16.3.25 映射 Ethernet IP