TCP\IP协议簇-各层主要协议帧格式
本文只是对各协议的概要,详细请参考rfc文件.
官方下载地址:https://tools.ietf.org/rfc/index
rfc中文:http://man.chinaunix.net/develop/rfc/default.htm
一、IPV4
- Version: 4 bits
The Version field indicates the format of the internet header. This document describes version 4.
版本(Version)字段:占4比特。
用来表明IP协议实现的版本号,当前一般为IPv4,即0100。
- IHL: 4 bits
Internet Header Length is the length of the internet header in 32 bit words, and thus points to the beginning of the data. Note that the minimum value for a correct header is 5.
报头长度(Internet Header Length,IHL)字段:占4比特。
是头部占32比特的数字,包括可选项。普通IP数据报(没有任何选项),该字段的值是5,即160比特=20字节。此字段最大值为60字节。
- Type of Service: 8 bits
The Type of Service provides an indication of the abstract parameters of the quality of service desired. These parameters are to be used to guide the selection of the actual service parameters when transmitting a datagram through a particular network. Several networks offer ervice precedence, which somehow treats high precedence traffic as more important than other traffic (generally by accepting only traffic above a tain precedence at time of high load). The major choice is a three way tradeoff between low-delay, high-reliability, and high-throughput.
Bits 0-2: Precedence.
Bit 3: 0 = Normal Delay, 1 = Low Delay.
Bits 4: 0 = Normal Throughput, 1 = High Throughput.
Bits 5: 0 = Normal Relibility, 1 = High Relibility.
Bit 6-7: Reserved for Future Use.
Precedence
111 - Network Control
110 - Internetwork Control
101 - CRITIC/ECP
100 - Flash Override
011 - Flash
010 - Immediate
001 - Priority
000 - Routine
服务类型(Type of Service ,TOS)字段:占8比特。
其中前3比特为优先权子字段(Precedence,现已被忽略)。第8比特保留未用。第4至第7比特分别代表延迟、吞吐量、 可靠性和花费。当它们取值为1时分别代表要求最小时延、最大吞吐量、最高可靠性和最小费用。这4比特的服务类型中只能置其中1比特为1。可以全为0,若全 为0则表示一般服务。服务类型字段声明了数据报被网络系统传输时可以被怎样处理。例如:TELNET协议可能要求有最小的延迟,FTP协议(数据)可能要 求有最大吞吐量,SNMP协议可能要求有最高可靠性,NNTP(Network News Transfer Protocol,网络新闻传输协议)可能要求最小费用,而ICMP协议可能无特殊要求(4比特全为0)。实际上,大部分主机会忽略这个字段,但一些动态 路由协议如OSPF(Open Shortest Path First Protocol)、IS-IS(Intermediate System to Intermediate System Protocol)可以根据这些字段的值进行路由决策。
- Total Length: 16 bits
Total Length is the length of the datagram, measured in octets, including internet header and data. This field allows the length of
a datagram to be up to 65,535 octets. Such long datagrams are impractical for most hosts and networks. All hosts must be prepared to accept datagrams of up to 576 octets (whether they arrive whole or in fragments). It is recommended that hosts only send datagrams larger than 576 octets if they have assurance that the destination is prepared to accept the larger datagrams. The number 576 is selected to allow a reasonable sized data block to be transmitted in addition to the required header information. For example, this size allows a data block of 512 octets plus 64 header octets to fit in a datagram. The maximal internet header is 60 octets, and a typical internet header is 20 octets, allowing a margin for headers of higher level protocols.
总长度字段:占16比特。
指明整个数据报的长度(以字节为单位)。最大长度为65535字节,实际如此长的报文对大多数主机和网络来说是非常不切实际的. 所有的主机都必须接受最多576个字节
- Identification: 16 bits
An identifying value assigned by the sender to aid in assembling the fragments of a datagram.
标志字段:占16比特。
用来唯一地标识主机发送的每一份数据报。通常每发一份报文,它的值会加1。发送者分配.
- Various Control Flags.
Bit 0: reserved, must be zero
Bit 1: (DF) 0 = May Fragment, 1 = Don't Fragment.
Bit 2: (MF) 0 = Last Fragment, 1 = More Fragments.
标志位字段:占3比特。
标志一份数据报是否要求分段。
- Fragment Offset: 13 bits
This field indicates where in the datagram this fragment belongs. The fragment offset is measured in units of 8 octets (64 bits). The
first fragment has offset zero.
段偏移字段:占13比特。
如果一份数据报要求分段的话,此字段指明该段偏移距原始数据报开始的位置。
- Time to Live: 8 bits
This field indicates the maximum time the datagram is allowed to remain in the internet system. If this field contains the value zero, then the datagram must be destroyed. This field is modified in internet header processing. The time is measured in units of seconds, but since every module that processes a datagram must decrease the TTL by at least one even if it process the datagram in less than a second, the TTL must be thought of only as an upper bound on the time a datagram may exist. The intention is to cause undeliverable datagrams to be discarded, and to bound the maximum datagram lifetime.
生存期(TTL:Time to Live)字段:占8比特。
用来设置数据报最多可以经过的路由器数。由发送数据的源主机设置,通常为32、64、128等。每经过一个路由器,其值减1,直到0时该数据报被丢弃。
- Protocol: 8 bits
This field indicates the next level protocol used in the data portion of the internet datagram. The values for various protocols are specified in "Assigned Numbers" [9].
协议字段:占8比特。
指明IP层所封装的上层协议类型,如ICMP(1)、IGMP(2) 、TCP(6)、UDP(17)等。
- Header Checksum: 16 bits
A checksum on the header only. Since some header fields change (e.g., time to live), this is recomputed and verified at each point that the internet header is processed.
头部校验和字段:占16比特。
内容是根据IP头部计算得到的校验和码。计算方法是:对头部中每个16比特进行二进制反码求和。(和ICMP、IGMP、TCP、UDP不同,IP不对头部后的数据进 行校验)。
- Source Address: 32 bits
The source address.
- Destination Address: 32 bits
The destination address.
源IP地址、目标IP地址字段:各占32比特。
用来标明发送IP数据报文的源主机地址和接收IP报文的目标主机地址。
- 可选项字段:占32比特。
用来定义一些任选项:如记录路径、时间戳等。这些选项很少被使用,同时并不是所有主机和路由器都支持这些选项。可选项字段的长度必须是32比特的整数倍,如果不足,必须填充0以达到此长度要求。
TODO ICMP协议格式,具体返回内容
tips:
1:ip层支持自动分配, 但是没有超时重传机制(更高层(比如TCP)来负责超时和重传), 所以丢一帧也会导致整个报文的重传.
2:如报文长度比MTU大,设备将整个报文数据分成数片,每一片的长度都小于等于MTU减去IP首部长度。接下来每一片均被放到独立的IP报文中.
2: MTU(Maximum Transmission Unit,MTU),最大传输单元. 由链条层决定,不同的传输介质不一样.
MSS(Maxitum Segment Size)最大分段大小, 是TCP协议里面的参数
TCP\IP协议簇-各层主要协议帧格式的更多相关文章
- 《TCP/IP详解卷1:协议》第2章 链路层-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
- 《TCP/IP详解卷1:协议》第11章 UDP:用户数据报协议-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
- 《TCP/IP详解 卷1:协议》第4章 ARP:地址解析协议
4.1 引言 本章我们要讨论的问题是只对TCP/IP协议簇有意义的IP地址.数据链路如以太网或令牌环网都有自己的寻址机制(常常为48 bit地址),这是使用数据链路的任何网络层都必须遵从的.一个网络如 ...
- 《TCP/IP详解卷1:协议》第1章 概述-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
- 《TCP/IP详解卷1:协议》第3章 IP:网际协议(1)-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
- 《TCP/IP详解卷1:协议》第3章 IP:网际协议(2)-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
- 《TCP/IP详解卷1:协议》第4章 ARP:地址解析协议-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
- 《TCP/IP详解卷1:协议》第5章 RARP:逆地址解析协议-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
- 《TCP/IP详解卷1:协议》第6章 ICMP:Internet控制报文协议-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
随机推荐
- 连接数据库方法2-DBCP
DBCP(连接池): 解决对数据库建立以及关闭连接时消耗大量资源的解决方案. 程序创建和关闭对数据库连接时会消耗大量的资源,连接池技术帮我们 在程序运行的开始时就预先创建大量的连接,这些连接组成一个池 ...
- h5-transform二维变换-扑克牌小案例
html代码:6张扑克牌 <div class="pkBox"> <img src="../img/pk1.jpg" alt="&q ...
- 沙龙报名 | 京东云DevOps——自动化运维技术实践
随着互联网技术的发展,越来越多企业开始认识DevOps重要性,在企业内部推进实施DevOps,期望获得更好的软件质量,缩短软件开发生命周期,提高服务稳定性.但在DevOps 的实施与落地的过程中,或多 ...
- cisco3900板卡sm-es3g-24-p使用方法
不知道是不是叫板卡,还是叫线卡希望不予深究.本文摘自:https://zhidao.baidu.com/question/1669814353056144947.html 插上板卡后,在配置界面仅显示 ...
- c/c++基础 输入函数/流
....光看算法了没怎么注意输入函数输入流 无论get(char *) gets(char *)/gets_s(char * ,sizeof char*) cin.getline(char* ,siz ...
- Linux bootloader
1.bootloader:初始化相关的硬件 loader:将操作系统从硬盘当中拷贝到内存当中去,,然后让CPU跳转到内存中执行操作系统. 2.boot阶段:(1)关闭影响cpu正常执行的外设 比 ...
- 剑指offer【10】- 变态跳台阶
题目:一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 关于本题,前提是n个台阶会有一次n阶的跳法.分析如下: f(1) = 1 f(2) ...
- 5314跳跃游戏IV
题目:给你一个整数数组 arr ,你一开始在数组的第一个元素处(下标为 0).每一步,你可以从下标 i 跳到下标: i + 1 满足:i + 1 < arr.length i - 1 ...
- Python remove()和del语句 区别和辨析 列表删除操作
del语句可以删除列表中下标处的值,表中被删除值后后面的所有值将向前移动一个下标 spam = ['A','B','C','D','E'] del spam[2] spam 打印显示:['A', 'B ...
- 四十、LAMP与LNMP加速与缓存优化进阶实战上部
实例: 一. 所有服务器配置定时时间同步,必须通过web server上网. 有两种方式: 1.服务器A能进行上网,作为web server ,通过指定为ntp服务器,所有服务器访问这个服务器 2.服 ...