La cabecera del datagrama IPv4 | | UPV
Overview of the IP Version 4 Datagram Header
Introduction to IP Datagram Header
- The objective is to explain the significance of each field in an IPv4 datagram header.
Structure of the Datagram Header
- The IPv4 header consists of a total of 32 bits, divided into five mandatory fields (20 bytes) and an optional part that can extend up to 40 bytes.
Key Fields in the Header
Version and Length Fields
- The version field is 4 bits long, indicating the IP version being used (IPv4). The length field specifies the header length in 32-bit words, allowing for a maximum length of fifteen words (60 bytes).
Service Field
- This field indicates the quality of service required for transmission, consisting of eight bits: three for priority (values from 0 to 7) and five for specific service requirements. A value of zero indicates normal priority while seven indicates maximum priority.
Total Length Field
- A 16-bit field that includes both the header and data lengths, with a maximum size limit set at 65,535 bytes.
Time to Live (TTL)
- TTL initializes at a set value upon sending; it decrements as it passes through routers or if delayed due to congestion. When TTL reaches zero, the datagram is discarded by routers.
Protocol and Checksum Fields
- The protocol field specifies which protocol is encapsulated within the IP datagram. The checksum verifies errors only in the header; it must be recalculated at each hop as TTL decreases.
Addressing Fields
- Contains both source and destination addresses, each being 32 bits long as per IPv4 standards.
Options Field
- This optional field can store various options such as recording all nodes traversed by the datagram; its maximum size is limited to 40 bytes allowing for tracking up to ten nodes.
Fragmentation Fields
Identifier and Offset
- The identifier helps track fragmented packets by assigning them a sequence number; offset indicates data position relative to original datagram structure measured in units of eight bytes.
Flags
- Two out of three flags are utilized: one indicates whether fragmentation is allowed (F bit), while another signals if it's the last fragment (MF bit). If F is set to one, fragmentation isn't permitted during transit; MF remains zero on final fragments only.
Understanding Datagram Fragmentation
Example of Datagram Fragmentation
- A practical example illustrates a datagram arriving at a router with a total length of 1420 bytes, consisting of a 20-byte header and 1400 bytes of data. The network's maximum PDU size is 620 bytes, necessitating fragmentation.
- The original datagram must be fragmented into smaller pieces due to the PDU limit. It can be split into two fragments of 600 bytes each and one final fragment of 200 bytes.
- All three fragments retain the same identifier (327). The "More Fragments" (MF) bit is set to one for the first two fragments and zero for the last, indicating it’s the final piece.
Calculating Offsets for Fragments
- When receiving fragments, if not all are received within a certain timeframe, any received fragments are discarded, prompting a resend of all datagrams.
- The total length of the original datagram can only be determined upon receiving the last fragment since they may arrive out of order.
- For instance, if the first fragment arrives with an offset calculated as 1200 bytes (150 in units of 8), its header indicates a total length that helps reconstruct the original datagram's data size.