Internet Protocol version 4 (IPv4) is the fourth iteration of the Internet Protocol (IP) and it is the first version of the protocol to be widely deployed. The Internet Protocol ( IP) is a protocol used for communicating data across a Packet-switched Internetwork using the Internet Protocol IPv4 is the dominant network layer protocol on the Internet and apart from IPv6 it is the only standard internetwork-layer protocol used on the Internet. The Network Layer is Layer 3 (of seven in the OSI model of networking The Internet is a global system of interconnected Computer networks Internet Protocol version 6 ( IPv6) is an Internet Layer protocol for packet -switched internetworks. The Internet is a global system of interconnected Computer networks
It is described in IETF RFC 791 (September 1981) which made obsolete RFC 760 (January 1980). The United States Department of Defense also standardized it as MIL-STD-1777. The United States Department of Defense ( DOD or DoD) is the federal department charged with coordinating and supervising all agencies and functions of the government
IPv4 is a data-oriented protocol to be used on a packet switched internetwork (e. Packet switching is a network communications method that splits data traffic (digital representations of text sound or video data into chunks called packets, that are then Internetworking involves connecting two or more distinct Computer networks or network segments via a common routing technology g. , Ethernet). Ethernet is a family of frame -based Computer networking technologies for Local area networks (LANs It is a best effort protocol in that it does not guarantee delivery. Best effort delivery describes a network service in which the network does not provide any guarantees that data is delivered or that a user is given a guaranteed Quality It does not make any guarantees on the correctness of the data; this may result in duplicated packets or packets delivered out of order. These aspects are addressed by an upper layer protocol (e. In Computer networking, the term upper layer protocol ( ULP) refers to a more abstract protocol when performing encapsulation. g. TCP, and partly by UDP). The Transmission Control Protocol (TCP is one of the core protocols of the Internet Protocol Suite. User Datagram Protocol ( UDP) is one of the core protocols of the Internet Protocol Suite.
Contents |
IPv4 uses 32-bit (four-byte) addresses, which limits the address space to 4,294,967,296 (232) possible unique addresses. A bit is a binary digit, taking a value of either 0 or 1 Binary digits are a basic unit of Information storage and communication A byte (pronounced "bite" baɪt is the basic unit of measurement of information storage in Computer science. In Computing, an address space defines a range of discrete addresses each of which may correspond to a physical or virtual Memory register, a network host However, some are reserved for special purposes such as private networks (~18 million addresses) or multicast addresses (~16 million addresses). In Internet terminology a private network is typically a network that uses private IP address space following the agreed standard of RFC 1918 Multicast is a network addressing method for the delivery of Information to a group of destinations simultaneously using the most efficient strategy This reduces the number of addresses that can be allocated as public Internet addresses. As the number of addresses available are consumed, an IPv4 address shortage appears to be inevitable, however Network Address Translation (NAT) has significantly delayed this inevitability. In Computer networking network address translation (NAT is the process of modifying Network address information in datagram packet headers while in transit across
This limitation has helped stimulate the push towards IPv6, which is currently in the early stages of deployment and is currently the only contender to replace IPv4. Internet Protocol version 6 ( IPv6) is an Internet Layer protocol for packet -switched internetworks.
When writing IPv4 addresses in human-readable form, the most common notation is the dot-decimal notation. In Computer networking, dot-decimal notation (also known as quad-dotted notation and dotted quad notation for IPv4 addresses is a method of There are other notations based on the values of 200. 100 in the dot-decimal notation which comprises four octets in decimal separated by periods. The decimal ( base ten or occasionally denary) Numeral system has ten as its base. This is the base format used in the conversion in the following table:
| Notation | Value | Conversion from dot-decimal |
|---|---|---|
| Dot-decimal notation | 192. In Computer networking, dot-decimal notation (also known as quad-dotted notation and dotted quad notation for IPv4 addresses is a method of 0. 2. 235 | N/A |
| Dotted Hexadecimal | 0xC0. 0x00. 0x02. 0xEB | Each octet is individually converted to hex |
| Dotted Octal | 0300. 0000. 0002. 0353 | Each octet is individually converted into octal |
| Hexadecimal | 0xC00002EB | Concatenation of the octets from the dotted hexadecimal |
| Decimal | 3221226219 | The hexadecimal form converted to decimal |
| Octal | 030000001353 | The hexadecimal form converted to octal |
Most of these formats should work in all browsers. In Mathematics and Computer science, hexadecimal (also base -, hexa, or hex) is a Numeral system with a The decimal ( base ten or occasionally denary) Numeral system has ten as its base. The octal Numeral system, or oct for short is the base -8 number system and uses the digits 0 to 7 Additionally, in dotted format, each octet can be of any of the different bases. For example, 192. 0x00. 0002. 235 is a valid (though unconventional) equivalent to the above addresses.
A final form is not really a notation since it is rarely written in an ASCII string notation. That form is a binary form of the hexadecimal notation in binary. This difference is merely the representational difference between the string "0xCF8E83EB" and the 32-bit integer value 0xCF8E83EB. This form is used for assigning the source and destination fields in a software program.
Originally, an IP address was divided into two parts:
This created an upper limit of 256 networks. As the networks began to be allocated, this was soon seen to be inadequate.
To overcome this limit, different classes of network were defined, in a system which later became known as classful networking. Classful network is a term that is used to describe the network architecture of the Internet until around 1993. Five classes were created (A, B, C, D, and E), three of which (A, B, and C) had different lengths for the network field. The rest of an address was used to identify a host within a network, which meant that each network class had a different maximum number of hosts. Thus there were a few networks with each having many host addresses and numerous networks with each only having a few host addresses. Class D was for multicast addresses and Class E was reserved. Multicast is a network addressing method for the delivery of Information to a group of destinations simultaneously using the most efficient strategy
Around 1993, these classes were replaced with a Classless Inter-Domain Routing (CIDR) scheme, and the previous scheme was dubbed "classful", by contrast. Year 1993 ( MCMXCIII) was a Common year starting on Friday (link will display full 1993 Gregorian calendar) Classless Inter-Domain Routing ( CIDR, pronounced "cider" is a method of categorizing Internet Protocol (IP addresses for the purpose of allocating CIDR's primary advantage is to allow re-division of Class-A, -B and -C networks so that smaller (or larger) blocks of addresses may be allocated to various entities (such as Internet service providers, or their customers) or local area networks. An Internet service provider ( ISP, also called Internet access provider or IAP) is a company which primarily offers their customers access to the Internet
The actual assignment of an address is not arbitrary. The fundamental principle of routing is that the address of a device encodes information about the device's location within a network. Routing is the process of selecting paths in a network along which to send network traffic This implies that an address assigned to one part of a network will not function in another part of the network. A hierarchical structure, created by CIDR and overseen by the Internet Assigned Numbers Authority (IANA) and its Regional Internet Registries (RIRs), manages the assignment of Internet addresses worldwide. The Internet Assigned Numbers Authority (IANA is the entity that oversees global IP address allocation, DNS root zone management, media types A Regional Internet Registry ( RIR) is an organization overseeing the allocation and registration of Internet number resources within a particular region of the world Each RIR maintains a publicly-searchable WHOIS database that provides information about IP address assignments; information from these databases plays a central role in numerous tools that attempt to locate IP addresses geographically. WHOIS (pronounced " who is " not an acronym is a query/response protocol which is widely used for querying an official Database in order to determine
| CIDR address block | Description | Reference |
|---|---|---|
| 0. Classless Inter-Domain Routing ( CIDR, pronounced "cider" is a method of categorizing Internet Protocol (IP addresses for the purpose of allocating 0. 0. 0/8 | Current network (only valid as source address) | RFC 1700 |
| 10. 0. 0. 0/8 | Private network | RFC 1918 |
| 14. In Internet terminology a private network is typically a network that uses private IP address space following the agreed standard of RFC 1918 0. 0. 0/8 | Public data networks (per 2008-02-10, available for use[1]) | RFC 1700 |
| 127. 0. 0. 0/8 | Loopback | RFC 3330 |
| 128. In Computer networking of Unix-like operating systems localhost (meaning "this computer" is the standard Hostname given to the address of the 0. 0. 0/16 | Reserved (IANA) | RFC 3330 |
| 169. 254. 0. 0/16 | Link-Local | RFC 3927 |
| 172. Zeroconf, or Zero Configuration Networking, is a set of techniques that automatically create a usable IP network without configuration or special servers 16. 0. 0/12 | Private network | RFC 1918 |
| 191. In Internet terminology a private network is typically a network that uses private IP address space following the agreed standard of RFC 1918 255. 0. 0/16 | Reserved (IANA) | RFC 3330 |
| 192. 0. 0. 0/24 | Reserved (IANA) | RFC 3330 |
| 192. 0. 2. 0/24 | Documentation and example code | RFC 3330 |
| 192. 88. 99. 0/24 | IPv6 to IPv4 relay | RFC 3068 |
| 192. Internet Protocol version 6 ( IPv6) is an Internet Layer protocol for packet -switched internetworks. 168. 0. 0/16 | Private network | RFC 1918 |
| 198. In Internet terminology a private network is typically a network that uses private IP address space following the agreed standard of RFC 1918 18. 0. 0/15 | Network benchmark tests | RFC 2544 |
| 223. 255. 255. 0/24 | Reserved (IANA) | RFC 3330 |
| 224. 0. 0. 0/4 | Multicasts (former Class D network) | RFC 3171 |
| 240. Multicast is a network addressing method for the delivery of Information to a group of destinations simultaneously using the most efficient strategy 0. 0. 0/4 | Reserved (former Class E network) | RFC 1700 |
| 255. 255. 255. 255 | Broadcast |
Of the four billion addresses allowed in IPv4, four ranges of address are reserved for private networking use only. In Internet terminology a private network is typically a network that uses private IP address space following the agreed standard of RFC 1918 In Internet terminology a private network is typically a network that uses private IP address space following the agreed standard of RFC 1918 These ranges are not routable outside of private networks, and private machines cannot directly communicate with public networks. They can, however, do so through network address translation. In Computer networking network address translation (NAT is the process of modifying Network address information in datagram packet headers while in transit across
The following are the four ranges reserved for private networks:
| Name | Address range | Number of addresses | Classful description | Largest CIDR block |
|---|---|---|---|---|
| 24-bit block | 10. Classful network is a term that is used to describe the network architecture of the Internet until around 1993. Classless Inter-Domain Routing ( CIDR, pronounced "cider" is a method of categorizing Internet Protocol (IP addresses for the purpose of allocating 0. 0. 0–10. 255. 255. 255 | 16,777,216 | Single Class A | 10. 0. 0. 0/8 |
| 20-bit block | 172. 16. 0. 0–172. 31. 255. 255 | 1,048,576 | 16 contiguous Class Bs | 172. 16. 0. 0/12 |
| 16-bit block | 169. 254. 0. 0–169. 254. 255. 255 | 65,536 | 256 contiguous Class Cs | 169. 254. 0. 0/16 |
| 16-bit block | 192. 168. 0. 0–192. 168. 255. 255 | 65,536 | 256 contiguous Class Cs | 192. 168. 0. 0/16 |
The ranges 10. 0. 0. 0/8, 172. 16. 0. 0/12, and 192. 168. 0. 0/16 are reserved for private networking by RFC 1918, while the 169. 254. 0. 0/16 range is reserved for Link-Local addressing as defined in RFC 3927. Zeroconf, or Zero Configuration Networking, is a set of techniques that automatically create a usable IP network without configuration or special servers
In addition to private networking, the address range 127. In Computer networking of Unix-like operating systems localhost (meaning "this computer" is the standard Hostname given to the address of the 0. 0. 0–127. 255. 255. 255 (or 127. 0. 0. 0/8 in CIDR notation) is reserved for localhost communication. Classless Inter-Domain Routing ( CIDR, pronounced "cider" is a method of categorizing Internet Protocol (IP addresses for the purpose of allocating In Computer networking of Unix-like operating systems localhost (meaning "this computer" is the standard Hostname given to the address of the Any address within this range should never appear on an actual network and any packet sent to this address does not leave the source computer, and will appear as an incoming packet on that computer (known as loopback). The term loopback (sometimes spelled 'loop-back' is generally used to describe methods or procedures of routing electronic signals digital data streams or other flows of items from
It is a common misconception that addresses ending in 255 or 0 can never be assigned to hosts, but this is only true of networks with subnet masks of at least 24 bits — Class C networks in the old classful addressing scheme, or in CIDR, networks with masks of /24 to /32 (or 255. Certain IPv4 address space regions are specially allocated and reserved for special uses such as Loopback interfaces Private networks (RFC 1918 and 255. 255. 0–255. 255. 255. 255).
In classful addressing (now obsolete with the advent of CIDR), there are only three possible subnet masks: Class A, 255. Classless Inter-Domain Routing ( CIDR, pronounced "cider" is a method of categorizing Internet Protocol (IP addresses for the purpose of allocating 0. 0. 0 or /8; Class B, 255. 255. 0. 0 or /16; and Class C, 255. 255. 255. 0 or /24. For example, in the subnet 192. 168. 5. 0/255. 255. 255. 0 (or 192. 168. 5. 0/24) the identifier 192. 168. 5. 0 refers to the entire subnet, so it cannot also refer to an individual device in that subnet.
A broadcast address is an address that allows information to be sent to all machines on a given subnet rather than a specific machine. In Computer networking, a broadcast address is an IP address that allows information to be sent to all machines on a given subnet rather than a specific Generally, the broadcast address is found by taking the bit complement of the subnet mask and then OR-ing it bitwise with the network identifier. More simply, the broadcast address is the last address in the range belonging to the subnet. In our example, the broadcast address would be 192. 168. 5. 255, so to avoid confusion this address also cannot be assigned to a host. On a Class-A, -B, or -C subnet, the broadcast address would always end in 255.
However, this does not mean that every addresses ending in 255 cannot be used as a host address. For example, in the case of a Class B subnet 192. 168. 0. 0/255. 255. 0. 0 (or 192. 168. 0. 0/16), equivalent to the address range 192. 168. 0. 0–192. 168. 255. 255, the broadcast address is 192. 168. 255. 255. However, one can assign 192. 168. 1. 255, 192. 168. 2. 255, etc. (though this can cause confusion). Also, 192. 168. 0. 0 is the network identifier and so cannot be assigned, but 192. 168. 1. 0, 192. 168. 2. 0, etc. can be assigned (though this can also cause confusion).
With the advent of CIDR, broadcast addresses do not necessarily end with 255.
In general, the first and last addresses in a subnet are used as the network identifier and broadcast address, respectively. All other addresses in the subnet can be assigned to hosts on that subnet.
Hosts on the Internet are usually known not by IP addresses but by names (e. The Domain Name System (DNS is a hierarchical naming system for computers services or any resource participating in the Internet. The Internet is a global system of interconnected Computer networks g. , www. wikipedia. org, www. whitehouse. gov, www. freebsd. org, www. berkeley. edu). The routing of IP packets across the Internet is not connected to such names. This requires translating (or resolving) names to addresses.
The Domain Name System (DNS) provides such a system to convert names to addresses and addresses to names. The Domain Name System (DNS is a hierarchical naming system for computers services or any resource participating in the Internet. Much like CIDR addressing, the DNS naming is also hierarchical and allows for subdelegation of name spaces to other DNS servers. Classless Inter-Domain Routing ( CIDR, pronounced "cider" is a method of categorizing Internet Protocol (IP addresses for the purpose of allocating
Think of this in a similar way to how you find a phone number. You want to call The Acme Bakers but don't know the number. You ring directory enquiries and they tell you the number you need to dial or can even connect you. Next you might want to call Acme Builder. Again, you only need to know the phone number of directory enquiries, they will almost always have the number you want and connect you. Only if you ask directory enquiries for the number of a company which doesn't exist will they say they can't connect you - similar to a DNS error in your web browser.
Since the 1980s, there has been concern that the number of available IP(v4) addresses is being exhausted. IP address exhaustion refers to the decreasing supply of unallocated IPv4 addresses This depletion has been a concern since the 1980s when the Internet started to This was the driving factor in classful networks and then later in the creation of CIDR addressing. Classful network is a term that is used to describe the network architecture of the Internet until around 1993. Classless Inter-Domain Routing ( CIDR, pronounced "cider" is a method of categorizing Internet Protocol (IP addresses for the purpose of allocating
Today, there are several driving forces to the next address allocation solution:
The most visible solution is to migrate to IPv6 since the address size jumps dramatically from 32 bits to 128 bits, which would allow each of about 18 quintillion people their own set of 18 quintillion addresses (3. A laptop computer, also known as a notebook computer, is a small Personal computer designed for mobile use. Asymmetric Digital Subscriber Line ( ADSL) is a form of DSL, a data communications technology that enables faster data transmission over Copper Telephone A cable modem is a type of Modem that provides access to a data signal sent over the Cable television infrastructure Internet Protocol version 6 ( IPv6) is an Internet Layer protocol for packet -switched internetworks. Names of numbers larger than a quadrillion are almost never used for reasons discussed further below 4e38 total addresses). However, migration has proved to be a challenge in itself, and total Internet adoption of IPv6 is unlikely to occur for many years.
Some things that can be done to mitigate the IPv4 address exhaustion are (not mutually exclusive):
As of April 2008, predictions of exhaustion date of the unallocated IANA pool seem to converge to between February 2010. In Computer networking network address translation (NAT is the process of modifying Network address information in datagram packet headers while in transit across In Internet terminology a private network is typically a network that uses private IP address space following the agreed standard of RFC 1918 "vhost" redirects here for vhosts in relation to Internet Relay Chat see Vhost (IRC Virtual hosting is a method that servers A Regional Internet Registry ( RIR) is an organization overseeing the allocation and registration of Internet number resources within a particular region of the world [2] and May 2011[3]
One method to increase both address utilization and security is to use network address translation (NAT). In Computer networking network address translation (NAT is the process of modifying Network address information in datagram packet headers while in transit across In Computer networking network address translation (NAT is the process of modifying Network address information in datagram packet headers while in transit across With NAT, assigning one address to a public machine as an internet gateway and using a private network for an organization's computers allows for considerable address savings. Internetworking involves connecting two or more distinct Computer networks or network segments via a common routing technology In Telecommunications, the term gateway has the following meaning In a Communications network, a network node equipped for interfacing with In Internet terminology a private network is typically a network that uses private IP address space following the agreed standard of RFC 1918 This also increases security by making the computers on a private network not directly accessible from the public network.
Since private address ranges are deliberately ignored by all public routers, it is not normally possible to connect two private networks (e. g. , two branch offices) via the public Internet. Virtual private networks (VPNs) solve this problem.
VPNs work by inserting an IP packet (encapsulated packet) directly into the data field of another IP packet (encapsulating packet) and using a publicly routable address in the encapsulating packet. Once the VPN packet is routed across the public network and reaches the endpoint, the encapsulated packet is extracted and then transmitted on the private network just as if the two private networks were directly connected.
Optionally, the encapsulated packet can be encrypted to secure the data while over the public network (see VPN article for more details).
IP is a protocol associated with the network layer and deals heavily with logical addressing schemes (i. In Computer networking the Address Resolution Protocol ( ARP) is the method for finding a host's hardware address when only its Network Layer address is The Network Layer is Layer 3 (of seven in the OSI model of networking e. , IP addresses). If node A on network 1 sends a packet (which includes the source and destination IP) of information across a segmented network to node B on network 2, the interconnecting network device(s) — such as a switch, which has addressing tables that are dynamically populated — must be able to resolve a node's physical MAC address to its logical IP address in order for it to forward that packet to the destination IP address. A In Computer networking a Media Access Control address ( MAC address) or Ethernet Hardware Address ( EHA) hardware address This discovery and mapping of IP addresses to hardware (MAC) addresses is accomplished through Address Resolution Protocol (ARP) messages, which are always executed as a network layer broadcast. In Computer networking the Address Resolution Protocol ( ARP) is the method for finding a host's hardware address when only its Network Layer address is Once the mapping has been made, it is stored in the switch's addressing/routing table for a specified amount of time, otherwise known as TTL, for future use. Time to live (sometimes abbreviated TTL) is a limit on the period of time or number of iterations or transmissions in Computer and Computer network technology
Unlike the situation outlined for ARP, the case arises when a computer knows its data link layer address but not its IP address. Reverse Address Resolution Protocol ( RARP) is a Link layer networking protocol used by a host computer to obtain its IPv4 address given only its link-layer In Computing, Bootstrap Protocol, or BOOTP, is a UDP network protocol used by a network client to obtain its IP address automatically The Data Link Layer is Layer 2 of the seven-layer OSI model. It responds to service requests from the Network Layer and issues service requests to the This is a common scenario in private networks and Digital Subscriber Line (DSL) connections when the IP addresses of the machines are irrelevant. In Internet terminology a private network is typically a network that uses private IP address space following the agreed standard of RFC 1918 This is usually the case for work stations but not servers. A workstation, such as a Unix workstation, RISC workstation or Engineering workstation, is a high-end Microcomputer A server is a Computer dedicated to providing one or more services over a computer network typically through a request-response routine
RARP is an obsoleted method for answering this question: “This is my hardware address; what is my IP address?” RARP was replaced by BOOTP which, in turn, was replaced by Dynamic Host Configuration Protocol (DHCP). In Computing, Bootstrap Protocol, or BOOTP, is a UDP network protocol used by a network client to obtain its IP address automatically
In addition to assigning an IP address, DHCP can also assign an NTP server, DNS servers, and more. The Network Time Protocol ( NTP) is a protocol for distributing the Coordinated Universal Time (UTC by means of synchronizing the clocks of computer systems The Domain Name System (DNS is a hierarchical naming system for computers services or any resource participating in the Internet.
An IP packet consists of a header section and a data section.
The header consists of 13 fields, of which only 12 are required. The 13th field is optional (red background in table) and aptly named: options. The fields in the header are packed with the most significant byte first (big endian), and for the diagram and discussion, the most significant bits are considered to come first. The most significant bit is numbered 0, so the version field is actually found in the four most significant bits of the first byte, for example.
| + | Bits 0–3 | 4–7 | 8–15 | 16–18 | 19–31 | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Version | Header length | Type of Service (now DiffServ and ECN) |
Total Length | ||||||||||||||||||||||||||||
| 32 | Identification | Flags | Fragment Offset | |||||||||||||||||||||||||||||
| 64 | Time to Live | Protocol | Header Checksum | |||||||||||||||||||||||||||||
| 96 | Source Address | |||||||||||||||||||||||||||||||
| 128 | Destination Address | |||||||||||||||||||||||||||||||
| 160 | Options | |||||||||||||||||||||||||||||||
| 160 or 192+ |
Data |
|||||||||||||||||||||||||||||||
) which would exceed the maximum IP packet length of 65,535 with the header length included. | Field | Size (bits) | Description |
|---|---|---|
| Copied | 1 | Set to 1 if the options need to be copied into all fragments of a fragmented packet. |
| Option Class | 2 | A general options category. 0 is for "control" options, and 2 is for "debugging and measurement". 1, and 3 are reserved. |
| Option Number | 5 | Specifies an option. |
| Option Length | 8 | Indicates the size of the entire option (including this field). This field may not exist for simple options. |
| Option Data | Variable | Option-specific data. This field may not exist for simple options. |
The last field is not a part of the header and, consequently, not included in the checksum field. The contents of the data field are specified in the protocol header field and can be any one of the transport layer protocols. In Computer networking, the Transport Layer is a group of methods and protocols within a layered architecture of network components within which it is responsible for encapsulating
Some of the most commonly used protocols are listed below including their value used in the protocol field:
See List of IPv4 protocol numbers for a complete list. The Internet Control Message Protocol ( ICMP) is one of the core protocols of the Internet Protocol Suite. The Internet Group Management Protocol ( IGMP) is a Communications protocol used to manage the membership of Internet Protocol Multicast groups The Transmission Control Protocol (TCP is one of the core protocols of the Internet Protocol Suite. User Datagram Protocol ( UDP) is one of the core protocols of the Internet Protocol Suite. Open Shortest Path First ( OSPF) is a dynamic Routing protocol for use in Internet Protocol (IP networks In Computer networking, the Stream Control Transmission Protocol (SCTP is a Transport Layer protocol, serving in a similar role as the popular protocols
To make IPv4 more tolerant of different networks the concept of fragmentation was added so that, if necessary, a device could break up the data into smaller pieces. The Internet Protocol allows IP fragmentation so that Datagrams can be fragmented into pieces small enough to pass over a link with a smaller MTU than the In Computer storage, fragmentation is a phenomenon in which storage space is used inefficiently reducing storage capacity This is necessary when the maximum transmission unit (MTU) is smaller than the packet size. In Computer networking, the term Maximum Transmission Unit ( MTU) refers to the size (in Bytes of the largest packet or frame
For example, the maximum size of an IP packet is 65,535 bytes while the typical MTU for Ethernet is 1,500 bytes. Ethernet is a family of frame -based Computer networking technologies for Local area networks (LANs Since the IP header consumes 20 bytes (without options) of the 1,500 bytes leaving 1,480 bytes of IP data per Ethernet frame (this leads to an MTU for IP of 1,480 bytes). Therefore, a 65,535-byte data payload would require 45 packets (65535/1480 = 44. 28).
The reason fragmentation was chosen to occur at the IP layer is that IP is the first layer that connects hosts instead of machines. If fragmentation were performed on higher layers (TCP, UDP, etc. ) then this would make fragmentation/reassembly redundantly implemented (once per protocol); if fragmentation were performed on a lower layer (Ethernet, ATM, etc. ) then this would require fragmentation/reassembly to be performed on each hop (could be quite costly) and redundantly implemented (once per link layer protocol). Therefore, the IP layer is the most efficient one for fragmentation.
When a device receives an IP packet it examines the destination address and determines the outgoing interface to use. This interface has an associated MTU that dictates the maximum data size for its payload. If the MTU is smaller than the data size then the device must fragment the data.
The device then segments the data into segments where each segment is less-than-or-equal-to the MTU less the IP header size (20 bytes minimum; 60 bytes maximum). Each segment is then put into its own IP packet with the following changes:
For example, for an IP header of length 20 bytes and an Ethernet MTU of 1,500 bytes the fragment offsets would be: 0, (1480/8) = 185, (2960/8) = 370, (4440/8) = 555, (5920/8) = 740, etc.
By some chance if a packet changes link layer protocols or the MTU reduces then these fragments would be fragmented again.
For example, if a 4,500-byte data payload is inserted into an IP packet with no options (thus total length is 4,520 bytes) and is transmitted over a link with an MTU of 2,500 bytes then it will be broken up into two fragments:
| # | Total length | More fragments (MF) flag set? |
Fragment offset | |
|---|---|---|---|---|
| Header | Data | |||
| 1 | 2500 | Yes | 0 | |
| 20 | 2480 | |||
| 2 | 2040 | No | 310 | |
| 20 | 2020 | |||
Now, let's say the MTU drops to 1,500 bytes. Each fragment will individually be split up into two more fragments each:
| # | Total length | More fragments (MF) flag set? |
Fragment offset | |
|---|---|---|---|---|
| Header | Data | |||
| 1 | 1500 | Yes | 0 | |
| 20 | 1480 | |||
| 2 | 1020 | Yes | 185 | |
| 20 | 1000 | |||
| 3 | 1500 | Yes | 310 | |
| 20 | 1480 | |||
| 4 | 560 | No | 495 | |
| 20 | 540 | |||
Indeed, the amount of data has been preserved — 1480 + 1000 + 1480 + 540 = 4500 — and the last fragment offset plus data — 3960 + 540 = 4500 — is also the total length.
Note that fragments 3 & 4 were derived from the original fragment 2. When a device must fragment the last fragment then it must set the flag for all but the last fragment it creates (fragment 4 in this case). Last fragment would be set to 0 value.
When a receiver detects an IP packet where either of the following is true:
then the receiver knows the packet is a fragment. The receiver then stores the data with the identification field, fragment offset, and the more fragments flag. When the receiver receives a fragment with the more fragments flag set to 0 then it knows the length of the original data payload since the fragment offset plus the data length is equivalent to the original data payload size.
Using the example above, when the receiver receives fragment 4 the fragment offset (495 or 3960 bytes) and the data length (540 bytes) added together yield 4500 — the original data length.
Once it has all the fragments then it can reassemble the data in proper order (by using the fragment offsets) and pass it up the stack for further processing.
Address exhaustion