#readwise
# IPv4 - Wikipedia

## Metadata
- Author: [[wikipedia.org]]
- Full Title: IPv4 - Wikipedia
- URL: https://en.wikipedia.org/wiki/IPv4
## Summary
IPv4 is a communication protocol used for sending data over the internet. It has many associated documents known as RFCs, which provide updates and guidelines. Some RFCs have been updated or replaced by newer versions to improve functionality. Overall, these documents ensure that IPv4 remains effective and relevant.
## Highlights
The Internet Protocol is the protocol that defines and enables [internetworking](https://en.wikipedia.org/wiki/Internetwork) at the [[Internet Layer - Wikipedia|internet layer]] of the Internet Protocol Suite. In essence it forms the Internet. It uses a logical addressing system and performs *routing*, which is the forwarding of packets from a source host to the next router that is one hop closer to the intended destination host on another network. ^69i76k
IPv4 is a [connectionless](https://en.wikipedia.org/wiki/Connectionless) protocol, and operates on a [best-effort delivery](https://en.wikipedia.org/wiki/Best-effort_delivery) model, in that it does not guarantee delivery, nor does it assure proper sequencing or avoidance of duplicate delivery. These aspects, including data integrity, are addressed by an [upper layer](https://en.wikipedia.org/wiki/Upper_layer_protocol) transport protocol, such as the [Transmission Control Protocol](https://en.wikipedia.org/wiki/Transmission_Control_Protocol) (TCP). ([View Highlight](https://read.readwise.io/read/01jj4grejjgwh49xc65fz4njps)) ^nj5dzg
---
IPv4 uses 32-bit addresses which limits the [address space](https://en.wikipedia.org/wiki/Address_space) to 4,294,967,296 $\left(2^{32}\right)$ addresses. ([View Highlight](https://read.readwise.io/read/01jj4gtg851spdzjg6brtf2xq7))
---
### Special-use addresses
The [Internet Engineering Task Force](https://en.wikipedia.org/wiki/Internet_Engineering_Task_Force) (IETF) and IANA have restricted from general use various [reserved IP addresses](https://en.wikipedia.org/wiki/Reserved_IP_addresses) for special purposes. Notably these addresses are used for [multicast](https://en.wikipedia.org/wiki/Multicast) traffic and to provide addressing space for unrestricted uses on private networks.
#### Special address blocks
| Address block | Address range | Number of addresses | Scope | Description |
| ------------------ | --------------------------- | ------------------: | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 0.0.0.0/8 | 0.0.0.0–0.255.255.255 | 16,777,216 | Software | Current (local, "this") network |
| 10.0.0.0/8 | 10.0.0.0–10.255.255.255 | 16,777,216 | Private network | Used for local communications within a private network |
| 100.64.0.0/10 | 100.64.0.0–100.127.255.255 | 4,194,304 | Private network | [Shared address space](https://en.wikipedia.org/wiki/IPv4_shared_address_space) for communications between a service provider and its subscribers when using a [carrier-grade NAT](https://en.wikipedia.org/wiki/Carrier-grade_NAT) |
| 127.0.0.0/8 | 127.0.0.0–127.255.255.255 | 16,777,216 | Host | Used for [loopback addresses](https://en.wikipedia.org/wiki/Loopback_address) to the local host |
| 169.254.0.0/16 | 169.254.0.0–169.254.255.255 | 65,536 | Subnet | Used for link-local addresses[^1] between two hosts on a single link when no IP address is otherwise specified, such as would have normally been retrieved from a [DHCP](https://en.wikipedia.org/wiki/DHCP) server |
| 172.16.0.0/12 | 172.16.0.0–172.31.255.255 | 1,048,576 | Private network | Used for local communications within a private network |
| 192.0.0.0/24 | 192.0.0.0–192.0.0.255 | 256 | Private network | IETF Protocol Assignments, [DS-Lite](https://en.wikipedia.org/wiki/DS-Lite) (/29) |
| 192.0.2.0/24 | 192.0.2.0–192.0.2.255 | 256 | Documentation | Assigned as TEST-NET-1, documentation and examples |
| 192.88.99.0/24 | 192.88.99.0–192.88.99.255 | 256 | Internet | Reserved. Formerly used for [IPv6 to IPv4](https://en.wikipedia.org/wiki/6to4) relay (included [[IPv6 - Wikipedia |
| 192.168.0.0/16 | 192.168.0.0–192.168.255.255 | 65,536 | Private network | Used for local communications within a private network |
| 198.18.0.0/15 | 198.18.0.0–198.19.255.255 | 131,072 | Private network | Used for benchmark testing of inter-network communications between two separate subnets |
| 198.51.100.0/24 | 198.51.100.0–198.51.100.255 | 256 | Documentation | Assigned as TEST-NET-2, documentation and examples |
| 203.0.113.0/24 | 203.0.113.0–203.0.113.255 | 256 | Documentation | Assigned as TEST-NET-3, documentation and examples |
| 224.0.0.0/4 | 224.0.0.0–239.255.255.255 | 268,435,456 | Internet | In use for [multicast](https://en.wikipedia.org/wiki/IP_multicast) (former Class D network) |
| 233.252.0.0/24 | 233.252.0.0–233.252.0.255 | 256 | Documentation | Assigned as MCAST-TEST-NET, documentation and examples (This is part of the above multicast space.) |
| 240.0.0.0/4 | 240.0.0.0–255.255.255.254 | 268,435,455 | Internet | Reserved for future use (former Class E network) |
| 255.255.255.255/32 | 255.255.255.255 | 1 | Subnet | Reserved for the "limited [broadcast](https://en.wikipedia.org/wiki/Broadcast_address)" destination address |
([View Highlight](https://read.readwise.io/read/01jj4gvpc5qrg2mtf37088kzax))
---
#### Private Networks
Of the approximately four billion addresses defined in IPv4, about 18 million addresses in three ranges are reserved for use in private networks. Packets addresses in these ranges are not routable in the public Internet; they are ignored by all public routers. Therefore, private hosts cannot directly communicate with public networks, but require [[Network address translation - Wikipedia|network address translation]] at a routing gateway for this purpose. ^x7xy22
Reserved private IPv4 network ranges
| Name | [CIDR](https://en.wikipedia.org/wiki/CIDR) block | Address range | Number of addresses | *[Classful](https://en.wikipedia.org/wiki/Classful)* description |
| ------------ | ------------------------------------------------ | ----------------------------- | -------------------: | ---------------------------------------------------------------- |
| 24-bit block | 10.0.0.0/8 | 10.0.0.0 – 10.255.255.255 | 16,777,216 | Single Class A |
| 20-bit block | 172.16.0.0/12 | 172.16.0.0 – 172.31.255.255 | 1,048,576 | Contiguous range of 16 Class B blocks |
| 16-bit block | 192.168.0.0/16 | 192.168.0.0 – 192.168.255.255 | 65,536 | Contiguous range of 256 Class C blocks |
Since two private networks, e.g., two branch offices, cannot directly interoperate via the public Internet, the two networks must be bridged across the Internet via a [virtual private network](https://en.wikipedia.org/wiki/Virtual_private_network) (VPN) or an [IP tunnel](https://en.wikipedia.org/wiki/IP_tunnel), which [encapsulates](https://en.wikipedia.org/wiki/Encapsulation_(networking)) packets, including their headers containing the private addresses, in a protocol layer during transmission across the public network. Additionally, encapsulated packets may be encrypted for transmission across public networks to secure the data. ([View Highlight](https://read.readwise.io/read/01jj4gwtza4kbynfj5pv6cf3rs))
---
#### Link-Local Addresses
RFC 3927 defines the special address block 169.254.0.0/16 for link-local addressing. These addresses are only valid on the link (such as a local network segment or point-to-point connection) directly connected to a host that uses them. These addresses are not routable. Like private addresses, these addresses cannot be the source or destination of packets traversing the internet. These addresses are primarily used for address autoconfiguration ([Zeroconf](https://en.wikipedia.org/wiki/Zeroconf)) when a host cannot obtain an IP address from a DHCP server or other internal configuration methods.
When the address block was reserved, no standards existed for address autoconfiguration. [Microsoft](https://en.wikipedia.org/wiki/Microsoft) created an implementation called [Automatic Private IP Addressing](https://en.wikipedia.org/wiki/Automatic_Private_IP_Addressing) (APIPA), which was deployed on millions of machines and became a [de facto standard](https://en.wikipedia.org/wiki/De_facto_standard). Many years later, in May 2005, the [IETF](https://en.wikipedia.org/wiki/IETF) defined a formal standard in RFC 3927, entitled *Dynamic Configuration of IPv4 Link-Local Addresses*. ([View Highlight](https://read.readwise.io/read/01jj4gyejhchap5r460eqt72rn)) ^fa8ury
For more see [[Link-Local Address - Wikipedia]].
---
#### Loopback Addresses
The class A network *127.0.0.0* (classless network *127.0.0.0/8*) is reserved for [loopback](https://en.wikipedia.org/wiki/Loopback). IP packets whose source addresses belong to this network should never appear outside a host. Packets received on a non-loopback interface with a loopback source or destination address must be dropped. ([View Highlight](https://read.readwise.io/read/01jj4gz6207p5dxz0krzqb4yjc))
---
### Subnets
The first address in a subnet is used to identify the subnet itself. In this address all host bits are *0*. To avoid ambiguity in representation, this address is reserved. The last address has all host bits set to *1*. It is used as a local [broadcast address](https://en.wikipedia.org/wiki/Broadcast_address) for sending messages to all devices on the subnet simultaneously. For networks of size */24* or larger, the broadcast address always ends in 255.
For example, in the subnet *192.168.5.0/24* (subnet mask *255.255.255.0*) the identifier *192.168.5.0* is used to refer to the entire subnet. The broadcast address of the network is *192.168.5.255*. ^8ew862
| Type | Binary form | Dot-decimal notation |
| ----------------- | ------------------------------------- | -------------------- |
| Network space | `11000000.10101000.00000101.00000000` | 192.168.5.0 |
| Broadcast address | `11000000.10101000.00000101.11111111` | 192.168.5.255 |
In red, is shown the host part of the IP address; the other part is the network prefix. The host gets inverted (logical NOT), but the network prefix remains intact.
However, this does not mean that every address ending in 0 or 255 cannot be used as a host address. For example, in the */16* subnet *192.168.0.0/255.255.0.0*, which is equivalent to the address range *192.168.0.0*–*192.168.255.255*, the broadcast address is *192.168.255.255*. One can use the following addresses for hosts, even though they end with 255: *192.168.1.255*, *192.168.2.255*, etc. Also, *192.168.0.0* is the network identifier and must not be assigned to an interface. The addresses *192.168.1.0*, *192.168.2.0*, etc., may be assigned, despite ending with 0. ([View Highlight](https://read.readwise.io/read/01jj4h2cvj156nmcen2dys1r5r)) ^ektegt
---
In networks smaller than */24*, broadcast addresses do not necessarily end with 255. For example, a CIDR subnet *203.0.113.16/28* has the broadcast address *203.0.113.31*. ([View Highlight](https://read.readwise.io/read/01jj4h3cw5kybet1wdwcfgydez)) ^x08p6n
---
As a special case, a */31* network has capacity for just two hosts. These networks are typically used for point-to-point connections. There is no network identifier or broadcast address for these networks. ([View Highlight](https://read.readwise.io/read/01jj4h3mn72v8y0r77897njeks)) ^gva06v
---
### Maximum Transmission Unit (MTU)
When a router receives a packet, it examines the destination address and determines the outgoing interface to use and that interface's MTU. If the packet size is bigger than the MTU, and the Do not Fragment (DF) bit in the packet's header is set to 0, then the router may fragment the packet.
The router divides the packet into fragments. The maximum size of each fragment is the outgoing MTU minus the IP header size (20 bytes minimum; 60 bytes maximum). ([View Highlight](https://read.readwise.io/read/01jj4hdhn0vm2e46ka9twxvwn2)) ^uu1cox
For more see [[Maximum Transmission Unit - Wikipedia]].
---
[^1]: For more info see [[Link-Local Address - Wikipedia]]