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 ...
随机推荐
- tensorflow函数参数查看
参考博客: https://www.cnblogs.com/wendj/archive/2018/09/21/9685012.html 第三步:鼠标放到函数名,按住ctrl即可查看
- 使用idea断点调试时出现no executable code found at line问题
问题描述 今天突然碰到了这样的一个问题: 使用断点调试时,断点的地方出现了一个叉号,而不是对勾,这就让我非常无奈了. 调了一天,终于把这个问题解决了,还是要记录一下的. 问题情况如下: 除了这里,de ...
- 代码review还是需要再仔细点-一次crash异常分析的总结
版本发布之后,外网新增了一些crash, 从mini dump看,的确是有异常的,619行crash了. 代码如下: 奔溃的地方如下 可以看到是Zip add的时候指针空了, 为什么呢? 结合代码,可 ...
- 关于Java的String字符串常量的长度问题
虽然这种问题应该很难遇到,但是遇到了也会感到莫名其妙.不知道大家有没有遇到那种在java代码里用字符串写sql语句的情况,但是如果sql语句字符串的长度太长的话就会报错. 代码如下: 代码A Stri ...
- 自己简单配置webpack
第一步 // 1.在新建文件夹中,npm init -y,生成package.json文件 // package.json 文件内容 { "name": "02webpa ...
- SPOJ 423 Assignments 状态DP
这个题目搁置了这么久,终于搞完了. 给n个人分配n个课程,已经告诉了你n个人对哪几门感兴趣,问最多有多少种分配方式 我刚开始都没找到这怎么还可以状态dp,哪来的状态转移,想用暴力DFS,果断TLE的妥 ...
- 翻译——3_Gaussian Process Regression
使用不同的机器学习方法进行预测 续上篇2_Linear Regression and Support Vector Regression 高斯过程回归 %matplotlib inline impor ...
- elasticsearch + springboot 整合
https://blog.csdn.net/chengyuqiang/article/details/102938266 https://blog.csdn.net/chengyuqiang/arti ...
- vue安装openlayers,jquery,bootstrap,阿里iconfont,
安装 安装openlayers安装指定包安装openlayersVUE中的地图import ol from "openlayers";import "openlayers ...
- Python 三十个实践、建议和技巧
[导读]2020年,你又立了什么新的 Flag?新一年,我们先为大家准备 30 个非常优秀的 Python 实践技巧.希望这些诀窍能在实际工作中帮助大家,并且学到一些有用的知识. 1.使用 pytho ...