Network layer datagram format -IP

IP datagram format

  • Description: a data packet by the IP header and the data of two parts
  • The first portion is divided into two parts, the first part 固定长度(20 bytes), all IP datagrams must have some of the second portion 可选字段, which is variable length, but a maximum of 40 bytes.
    Thus a maximum IP datagram header is 60 bytes
    ****Here Insert Picture Description

A, P datagram detailed format of the fixed portion:

Here Insert Picture Description
Variable portion : - length of the IP datagram must be a multiple of 4 bytes, because the IP packet is a format of 32-bit aligned. Not enough to no meaningful data填充

Fixed part:

Field: separate out a portion of the byte independent significance.

  • 版本: Accounting for four, refers to the version of the IP protocol, the current IP protocol version number is 4 (ie IPV4). If it is 6, then the version number is IPV6.
  • 首部长度:Four bits representing the IP datagram header may represent the maximum value, the maximum value can be represented is 15 units as a unit of 4 bytes. Because the variable portion of the length of the header can vary, so the header length will change (the variable portion of the filling portion not go in)
  • Differentiated Services: service type, no access to basic
  • 总长度: Accounting for 16. It refers to the IP datagram length, i.e. the length of the header section + data section. Although the maximum data may represent a maximum of (2 ^ 16-1, which is 65535), but in the header length maximum limit, and have the data portion of 最大传送单元(MTU)(1500字节)limitations, so the total length of the IP datagram is also limited
  • 标识、标志、片偏移: P packets called datagrams, one packet of data from a long packet inside out out, after the need for the assembly, the assembly process will ultimately sign this written information.
    • Identifier : identifies several different groups of the same, then the packets are split from the same data have come to packets, i.e. they are from the same place.
    • Mark : accounting for three, only the first two meaningful
      • Flag field 最低位: Yes MF(More Fragment), MF = 1 which indicates there are "slice", MF = 0 indicates that it is the last fragment
      • Flag field 中间位: It is DF(Don‘t Fragment)only when DF = 0 if fragmentation is allowed, otherwise prohibit fragmentation
    • Fragment Offset: accounting for 13, the relative position of the long packet fragment after a packet of the original sheet, the sheet 8-byte offset unit offsets
      • Such as: a packet offset sheet 100, then its position in the original datagram is the first 800 bytes.
  • 生存时间(TTL):Represents a datagram packet forwarding can be many times (how many times jump), jump every time the survival time minus one. You can prevent broadcast storms (packet forwarding repeated back and forth).
  • 协议: IP datagram support multiple protocols, IP datagrams encapsulated PDU multiple protocols in the IP datagrams 数据部分(such as the network layer: ICMP error reporting message, the IGMP group management packet, and the like OSPF packets, before two later talked about focus, as well as IPV6 protocol (but not all stations support IPV6 protocol, but it must be supported by IPV4, so the need for a package IPV6 protocol.) the field also encapsulates the transport layer of the TCP and UDP, they serve two different communication needs of the application, these two different types of data packets are encapsulated in IP data sent to the message, the receiver receives the UDP and TCP will split out, how to distinguish the two a protocol field to see.)Here Insert Picture Description
  • 首部校验和: 16 accounted for only datagram header inspection without inspection data section. We are not used here CRC校验码. It uses a relatively simple calculation method ------ 16二进制反码求和算法
  • 原地址与目的地址: 4 bytes are because they are stored IP address (32-bit IP address, MAC address 48). Also very important point is that, IP datagrams over the course of the router packet forwarding (ie, hop) original and destination addresses are the same. Intermediate router forwarding all queries to the same destination address and routing table according forwarded to decide who (intermediate destination address of each hop determined by the routing table). Also in this knowledge add the MAC address, MAC frame forwarding process is not through the router, but through hardware circuit card to operate (does not require cpu), so the MAC frame forwarding process forward in every the MAC address table will be the source address and destination address (6 bytes, 48).
The variable part:
  • To support troubleshooting, measuring and safety measures, the content is very rich, but the basic need.
  • Option field of variable length, ranging from 40 bytes, depending on the selected item from one byte to.
  • To ensure that the IP header (fixed + variable portion) is 4 byte alignment.
  • In fact, each additional feature also increases the overhead of the router.

Examples IP datagram fragments:

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

Published 22 original articles · won praise 0 · Views 144

Guess you like

Origin blog.csdn.net/weixin_42649617/article/details/104900987