User:Dandorid/Sandbox/IPv4 address

=Talk:IPv4 address=

=IPv4 address=

An Internet Protocol Version 4 address (IPv4 address) is a numerical label that is used to identify a network interface of a computer or a network node participating in an IPv4 computer network.

An IP address serves the purpose of identifying an individual network interface of a host, locating it on the network, and thus permitting the routing of IP packets between hosts. For routing, IP addresses are present in fields of the packet header where they indicate source and destination of the packet.

IPv4 uses 32-bit addresses which defines the address space to have a total of 232 or $4,294,967,296$ addresses. Most of these are public addresses, allowing them to be used for routing accross the Internet. IPv4 reserves 3 special address blocks for private networks (~18 million addresses) and one special address block for multicast addresses (~270 million addresses).

Representation
IPv4 addresses may be represented in any notation expressing a 32-bit integer value. They are most often written in the dot-decimal notation, which consists of four octets of the address expressed individually in decimal numbers and separated by periods.

For example, an IP address with the 32-bit decimal value $3,221,226,219$, which in hexadecimal format is 0xC00002EB, is represented by the quad-dotted (0xC0 = 192, 0x00 = 0, 0x02 = 2, 0xEB = 235). This value may also be expressed in dotted hex format as 0xC0.0x00.0x02.0xEB, or with octal byte values as 0300.0000.0002.0353 , but this is seen less often.

CIDR notation
The Classless Inter-Domain Routing (CIDR) notation combines the address with its routing prefix in a compact format, in which the address is followed by a slash character (/) and the count of consecutive 1 bits in the routing prefix (subnet mask).

For example, instead of, the shorter is used, indicating that there are 24 consecutive 1 bits in the routing prefix.

Address space allocation
The hierarchical structure created by CIDR is managed by the Internet Assigned Numbers Authority (IANA) and the regional Internet registries (RIRs). Each RIR maintains a publicly searchable WHOIS database that provides information about IP address assignments.

Special addresses
The Internet Engineering Task Force (IETF) and the Internet Assigned Numbers Authority (IANA) have restricted from general use various reserved IP addresses for special purposes. Some are used for maintenance of routing tables, for multicast traffic, operation under failure modes, or to provide addressing space for public, unrestricted uses on private networks. 
 * {| class="wikitable"

!CIDR address block !First address !Last address !Number of addresses !Scope !Description
 * + Special address blocks
 * align="right"|
 * align="right"|
 * align="right"|232-8 = 224 = $16,777,216$
 * Software
 * Current network (only valid as source address).
 * align="right"|
 * align="right"|
 * align="right"|$16,777,216$
 * Private network
 * Used for local communications within a private network.
 * align="right"|$4,194,304$
 * Private network
 * Used for local communications within a private network.
 * Used for local communications within a private network.


 * align="right"|
 * align="right"|
 * align="right"|$16,777,216$
 * Private network
 * Shared address space for communications between a service provider and its subscribers when using a carrier-grade NAT.
 * align="right"|
 * align="right"|
 * align="right"|$65,536$
 * Host
 * Used for loopback addresses to the local host.
 * align="right"|$1,048,576$
 * Host
 * Used for loopback addresses to the local host.


 * align="right"|
 * align="right"|
 * align="right"|$256$
 * Subnet
 * Used for link-local addresses between two hosts on a single link when no IP address is otherwise specified, such as would have normally been retrieved from a DHCP server.
 * align="right"|
 * align="right"|
 * align="right"|$256$
 * Private network
 * Used for local communications within a private network.
 * align="right"|$256$
 * Private network
 * Used for local communications within a private network.


 * align="right"|
 * align="right"|
 * align="right"|$65,536$
 * Private network
 * IETF Protocol Assignments.
 * align="right"|
 * align="right"|
 * align="right"|$131,072$
 * Documentation
 * Assigned as TEST-NET-1, documentation and examples.
 * align="right"|
 * align="right"|
 * align="right"|$256$
 * Internet
 * Reserved. Formerly used for IPv6 to IPv4 relay (included IPv6 address block IPv6 Address).
 * align="right"|
 * align="right"|
 * align="right"|$256$
 * Private network
 * Used for local communications within a private network.
 * align="right"|
 * align="right"|
 * align="right"|$268,435,456$
 * Private network
 * Used for benchmark testing of inter-network communications between two separate subnets.
 * align="right"|
 * align="right"|
 * align="right"|$268,435,456$
 * Documentation
 * Assigned as TEST-NET-2, documentation and examples.
 * align="right"|
 * align="right"|
 * align="right"|$1$
 * Documentation
 * Assigned as TEST-NET-3, documentation and examples.
 * align="right"|
 * align="right"|
 * align="right"|$16,777,216$
 * Documentation
 * Assigned as TEST-NET-2, documentation and examples.
 * align="right"|
 * align="right"|
 * align="right"|$1,048,576$
 * Documentation
 * Assigned as TEST-NET-3, documentation and examples.
 * align="right"|$65,536$
 * Documentation
 * Assigned as TEST-NET-3, documentation and examples.
 * Assigned as TEST-NET-3, documentation and examples.


 * align="right"|
 * align="right"|
 * align="right"|⇭⇭⇭
 * Internet
 * In use for IP multicast. (Former Class D network).
 * align="right"|
 * align="right"|
 * align="right"|⇭⇭⇭
 * Internet
 * Reserved for future use. (Former Class E network).
 * align="right"|
 * align="right"|
 * align="right"|⇭⇭⇭
 * Subnet
 * Reserved for the "limited broadcast" destination address.
 * }
 * align="right"|⇭⇭⇭
 * Subnet
 * Reserved for the "limited broadcast" destination address.
 * }
 * }

Private networks
Of the approximately four billion addresses defined in IPv4, three ranges are reserved for use in private networks, where they are commonly subnetted.


 * {| class="wikitable"

!Name!!CIDR address block!!First address!!Last address!!Number of addresses!!Classful description
 * 24-bit block||align="right"|||align="right"|||||align="right"|⇭⇭⇭||Single Class A.
 * 20-bit block||align="right"|||align="right"|||||align="right"|⇭⇭⇭||Contiguous range of 16 Class B blocks.
 * 16-bit block||align="right"|||align="right"|||||align="right"|⇭⇭⇭||Contiguous range of 256 Class C blocks.
 * }
 * 16-bit block||align="right"|||align="right"|||||align="right"|⇭⇭⇭||Contiguous range of 256 Class C blocks.
 * }
 * }

Packets with addresses in these ranges are not routable in the public Internet, because they are ignored by all public routers. Therefore, private hosts cannot directly communicate with public networks, but require network address translation (NAT) at a routing gateway for this purpose. This also means that two private networks, e.g., two branch offices, cannot directly interoperate via the public Internet. The two networks can be bridged across the Internet, however, via a virtual private network (VPN) or an IP tunnel, which encapsulate the packet in a protocol layer during transmission across the public network. Additionally, encapsulated packets may be encrypted for the transmission across public networks to secure the data.

Link-local addressing
The address block is reserved for link-local addressing. These addresses are only valid on links (such as a local network segment or point-to-point connection) connected to a host. 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 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 created an implementation called Automatic Private IP Addressing (APIPA), which was deployed on millions of machines and became a de facto standard. Many years later, in May 2005, the IETF defined a formal standard for it.

Loopback
The class A network (classless network ) is reserved for loopback. IP packets whose source addresses belong to this network should never appear outside a host. The modus operandi of this network expands upon that of a loopback interface:
 * IP packets whose source and destination addresses belong to the network (or subnetwork) of the same loopback interface are returned to that interface;
 * IP packets whose source and destination addresses belong to networks (or subnetworks) of different interfaces of the same host, one of them being a loopback interface, are forwarded regularly.

Shared address space
The block is meant to be used by Internet Service Providers (or ISPs) that implement carrier-grade NAT, to connect their customer-premises equipment (CPE) to their core routers.

Addresses for documentation
Networks (TEST-NET-1),  (TEST-NET-2), and  (TEST-NET-3) have been reserved for use in documentation. These addresses should not be assigned to hosts, as routing packets over the Internet with these networks as destination is actively discouraged.

Broadcast address
A broadcast address is a logical address at which all devices connected to a multiple-access communications network are enabled to receive datagrams. A message sent to a broadcast address may be received by all network-attached hosts.

Addresses ending in 0 or 255
Networks with subnet masks of at least 24 bits, i.e. Class C networks in classful networking, and networks with CIDR suffixes to  ( – ) may not have an address ending in  or.

Classful addressing prescribed only three possible subnet masks: Class A, or ; Class B,  or ; and Class C,  or. For example, in the subnet  the identifier  commonly is used to refer to the entire subnet. To avoid ambiguity in representation, the address ending in the octet 0 is reserved.

A broadcast address is an address that allows information to be sent to all interfaces in a given subnet, rather than a specific machine. Generally, the broadcast address is found by obtaining the bit complement of the subnet mask and performing a bitwise OR operation with the network identifier. In other words, the broadcast address is the last address in the address range of the subnet. For example, the broadcast address for the network is. For networks of size or larger (,, etc.), the broadcast address always ends in.

However, this does not mean that every address ending in or  cannot be used as a host address. For example, in the subnet, which is equivalent to the address range  – , the broadcast address is. One can use the following addresses for hosts, even though they end with :, , etc. Also, is the network identifier and must not be assigned to an interface. However, the addresses, , etc., may be assigned, despite ending with.

In the past, conflict between network addresses and broadcast addresses arose because some software used non-standard broadcast addresses with zeros instead of ones.

In networks smaller than, broadcast addresses do not necessarily end with. For example, a CIDR subnet has the broadcast address.

Default address selection
On hosts that have IPv4 addresses only, the source address for outgoing packets is determined by the routing table. On dual-stacked hosts, IPv6 addresses may be favored over IPv4 addresses, when an IPv6 route exists to the destination host.

Address resolution
Hosts on the Internet are usually known by names, e.g., www.example.com, not primarily by their IP address, which is used for routing and network interface identification. The use of domain names requires translating, called resolving, them to addresses and vice versa. This is analogous to looking up a phone number in a phone book using the recipient's name.

The translation between addresses and domain names is performed by the Domain Name System (DNS), a hierarchical, distributed naming system which allows for subdelegation of name spaces to other DNS servers.

History
In the original design of IPv4, an IP address was divided into two parts: the network identifier was the most significant (highest order) octet of the address, and the host identifier was the rest of the address. The latter was also called the rest field. This structure permitted a maximum of 256 network identifiers, which was quickly found to be inadequate.

To overcome this limit, the most-significant address octet was redefined in 1981 to create network classes, in a system which later became known as classful networking. The revised system defined five classes. Classes A, B, and C had different bit lengths for network identification. The rest of the address was used as previously to identify a host within a network, which meant that each network class had a different capacity for addressing hosts. Class D was defined for multicast addressing and Class E was reserved for future applications.

Starting around 1985, methods were devised to subdivide IP networks. One method that has proved flexible is the use of the variable-length subnet mask (VLSM). In 1993, this system of classes was officially replaced with Classless Inter-Domain Routing (CIDR), which expressed the number of bits (from the most significant) as, for instance,, and the class-based scheme was dubbed classful, by contrast. CIDR was designed to permit repartitioning of any address space so that smaller or larger blocks of addresses could be allocated to users.