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协议里面的参数

 待续..

 


sharing

https://img-blog.csdnimg.cn/2022010704091770263.jpeg

转载于:https://www.cnblogs.com/soso-z/p/5479667.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值