IPv4 datagram format and semantics

A, IP datagram format shown in FIG.

version

Header length

Service type

Datagram length

16-bit identification

Mark

13-bit Fragment Offset

life

Upper layer protocol

Header checksum

32-bit source IP address

32-bit destination IP address

Options (if any)

data

IPv4 datagram format

Second, the semantic part

1) version (number): 4bit, it specifies the IP protocol version data packet; by viewing the version number, the router can determine how to interpret the remaining portion of the IP datagram

2) the header length: because IPV4 datagram can contain a variable number of options, so it is necessary to use this 4bit to determine the length of the header, to determine the data portion of an IP datagram is actually where to start. Most IP datagrams do not contain options, it is generally IP datagram header has 20 bytes

3) Service Type: 8bit, service type included in the header section to make different types of IP data packets can be distinguished from each other, for example, real-time data packets (e.g., an IP phone application) and non-real-time traffic (e.g., FTP) to distinguish off may be useful to provide a particular level of service is determined by the router administrator policy issues

4) the datagram length : This is the total length of the IP datagram (header portion plus data), in bytes, because the field length is 16bit, so the maximum theoretical length of the IP datagram is 65,535 bytes, but the data are reported little larger than 1500 bytes (because IP data transport but also on the data link layer, and the maximum amount of data link layer is called a frame that can carry the maximum transport unit (maximum Transmission unit, MTU))

5) identification, flags, fragment offset:

  To understand these three elements, we must first understand some other knowledge

  (1) slice : the data in the IP datagram is divided into two or more smaller IP datagram encapsulating the link layer frame to the individual smaller IP datagrams, each of these smaller data newspaper called slices

  (2) Why slice : Since each IP datagram encapsulated in link layer frames transmitted from a router to the next router, the maximum amount of the data link layer frame is able to carry (the maximum transport unit (Maximum Transmission Unit, MTU) is constant, it is strictly limited to the link layer frame length of the IP datagram; and each segment of the link on the route with the destination and the sender may use different link layer protocols, and each protocol may have different the MTU, it is more likely to be fragmented, and that the data packets so as to be capable of smoothly transferring data packets

  (3) Assembly: The purpose host receives a series of datagrams from the same source, you need to determine which data packets are fragmented, if it is fragmented, then, should receive further guidance when the last fragment, how received fragment stitching together to form an initial data packet, it will IPV4 designer logos, marks and the sheet offset field in the IP datagram header, when generating a datagram, the datagram sending host is provided for source and destination addresses at the same time, and then fill in the identification number

Identification: 16bit, when each packet source host transmits an IP datagram, each datagram is normally transmitted its identification number is incremented by 1, so when a router needs a datagram to a sheet, is formed ( source address slice) has an initial data packet destination address, and identification number, so that the destination host can be determined which slice belongs to an initial datagram

Mark: 3bit, because the IP is an unreliable service, one or more pieces may never reach the destination, so in order to make the absolute destination host believes it has received the last piece of the original datagram, the last piece of the flag bit is set to 0, while all other tag bits are set to 1 piece

Offset sheet: 13bit, marking the data offset value from the initial data packet, and a predetermined offset value to be 8-byte blocks. So in addition to the number of all the initial data payload last sheet should be a multiple of 8 bytes

6) : life time 8bit, lifetime (Time-To_Live, TTL) field is used to ensure that data is not always reported (e.g., due to the long route selection loop) circulating in the network, each time the data packet is processed by a router , minus a value of this field. When the TTL field is reduced to 0, then the data packet must be discarded.

7) Protocol: . 8 'bit, this field will only be useful if the final destination of an IP datagram arrives, the change field indicates the data portion of an IP datagram which particular transport layer protocol to be, such as: the value should be 6 handed over TCP, while a value of 17 represents the data portion to be handed over UDP, other possible values View    https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml

8) header checksum: 16bit, bit error header checksum and is used to help detect router received an IP datagram. Header checksum is calculated by: the first portion of each of two bytes as a number, with the inverse number of the summing operation code; specific to a sender or receiver is calculated as follows:

  When transmitting data, in order to calculate the checksum of the IP packet. It should be as follows:
  (1) the checksum field is set to the IP packet 0;
  (2) to the header 16 as numbers of units, sequentially summing the binary one;
  (3) to give the the result is stored in the checksum field.
     When data is received, the packet checksum calculation is relatively simple, as follows:
  (1) in the header portion 16 as numbers of units, sequentially summing the binary one, comprising a checksum field;
  ( 2) check the calculated result of the checksum is equal to zero (trans code 16 should be 0);
  (3) equal to zero if, description is divisible, the checksum is correct. Otherwise, the checksum is wrong, protocol stacks to discard the packet.

Router to calculate for each received IP datagram which header checksum and, if the datagram checksum inconsistent header carried checksum and calculated, it is checked that a mistake, routers usually will discard the detected erroneous data packets

9) source and destination IP address : 32bit, when the IP address of a source generating a datagram, the sending host is inserted in the two fields of the IP address and the destination, the source host typically DNS lookup to determine the destination address

10) Options: 32bit, IP header field allows the option to be extended. Header option means rarely used, it was decided for each data packet header information does not include the option field, this can save costs, but because some of the data reported to have options, some of the data reported no options, it led to a deal with an IP router time required for data reported vary widely.

11) data (payload): 32bit, which is the primary reason for the existence of a datagram! In most cases, the data field contains the IP datagram to be delivered to the destination transport layer segment (UDP or TCP)

NOTE: Noting IP datagram has a total length of 20 byte header (assuming no options) If a datagram carries a TCP packet, each (non-fragmented) datagram carrying a total of 40 bytes of total length header (20-byte IP datagram 20-byte TCP header) and Practical packets

Third, examples of identification, flags, fragment offset of

  Suppose a data packet is 4000 bytes (3980 bytes plus 20 bytes of IP data payload) to the router, and must be forwarded to a link MTU of 1500 bytes, how fragmentation?

  A: initial data packet will be divided into three pieces, wherein each piece is an IP datagram, the datagram is assumed that the transmission of the identification number is given to the host 777, three sheets of the following features:

sheet

byte

ID

Offset

Mark

The first piece

1480

 

ID=777

Offset=0

Flag=1

The second piece

1480

 

ID=777

Offset=185

Flag=1

The third piece

1020(3980-1480*2)

ID=777

Offset=370

Flag=0


NOTE: At this point it is necessary to transport the initial 4040 bytes of data packets, the fragmentation overhead is required

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/alphabetical/p/11079902.html