Internet Protocol
Overview
The most ubiquituous protocol used at the internetwork layer is IP (Internet Protocol). IP addresses are typically expressed in one of #IPv4 and/or #IPv6.
Allocation
IP address space is allocated, usually in large chunks, by a collection of hierarchically organized authorities.
At the top of this hierarchy is the Internet Assigned Numbers Authority (IANA). For unicast IPv4 and IPv6 address space, the IANA delegates much of its allocation authority to a few regional Internet registries (RIRs). The authorities then allocate address space to various owners - ISPs, smaller authorities, etc.
Address ranges owned and managed by ISPs are called provider-aggregatable (PA) since they consist of one or more prefixes that can be aggregated with other prefixes the ISP owns. This is in contrast to provider-independent (PI) address space consisting of addresses allocated to a user directly and that can be used with any ISP.
Addressing Methods
Unicast
A unicast delivers a message to a specific host in a network using a one-to-one association between a sender and receiver.

Broadcast
A broadcast delivers a message to all hosts in a network using a one-to-all association. A single message from one sender is routed to all possible endpoints associated with a broadcast address.

In every IPv4 subnet is a specially designated subnet broadcast address, formed by setting the network/subnetwork portion of the address to an appropriate value and the bits in the host portion to 1. Address 255.255.255.255 is reserved as the local net broadcast address and is never forwarded by routers.
Multicast
A multicast delivers a message to a group of hosts in a network using a one-to-many-of-many or many-to-many-of-many association. Messages are routed simultaneously in a single transmission to many recipients.

The portion of the network that a group covers is known as the group's scope. Common scopes include:
- The node-local scope (the same computer).
- The link-local scope (the same subnet).
- The site-local scope (the same site).
- The global scope (the entire Internet).
- The administrative scope (some manually configured portion of the network).
Anycast
An anycast delivers a message to any one out of a group of hosts using a one-to-one-of-many association. Typically the recipient is the one closest to the source of the message.

Address Ranges
In the beginning, a classful addressing scheme was used to partition the IPv4 address space. As network infrastructure began struggling against the number of IP addresses, a classless addressing scheme was adopted instead.
Classful
Each unicast address was divided into a network portion and a host portion. The contiguous bits that made up each portion were called the net number and host number respectively. This partitioning was organized into five classes, with each class representing a different trade-off in the number of bits of an IPv4 address were devoted to the net number vs. host number.
| Class | Prefix | Network Bits | Host Bits |
|---|---|---|---|
A | 0 | 8 | 24 |
B | 10 | 16 | 16 |
C | 110 | 24 | 8 |
D | 1110 | - | - |
E | 1111 | - | - |
Classes A, B, and C were used for unicast addresses. Class D addresses were for multicast use. Class E addresses were reserved.
Subnets
Subnet addressing refers to the partitioning of the original host portion of a network address into a subnetwork number and a host number. The length of the subnetwork number is usually configurable, specific to each local network.
The subnet mask is an assignment of bits used by a host or router to determine how the network and subnetwork information is partitioned from the host information. They are arranged as some number of 1 bits followed by some number of 0 bits, with total number of bits matching the number used in IPv4 and IPv6 respectively. The number of 1 bits is called the prefix length and a mask is often denoted as /k where k is the prefix length in question.
VLSM
Variable-length subnet masks (VLSM) is a generalization of subnetting in which different portions of a site/network can have different-length subnet masks.
CIDR
To help scale, the classful addressing scheme was generalized using a scheme similar to VLSM called Classless Inter-Domain Routing (CIDR). A CIDR mask, which mirrors subnet masks, is used to partition network portions and host portions of addresses. The contiguous bits of 1s at the start of a CIDR mask is called the prefix.
Address Families
IPv4
An IPv4 address is a 32-bit nonnegative integer. It is usually represented using dotted-quad or dotted-decimal notation, e.g. 65.195.130.107. Each decimal number in the dotted-quad notation is a nonnegative integer in the range
Packet Format
The following is a diagram of the IPv4 packet format.

- Version. A value of
is used to indicate IPv4. - Internet Header Length (IHL). The number of 32-bit words in the header, including any options.
- Total Length. The total length of the IPv4 datagram in bytes. Since this is a 16-bit field, the maximum size of a datagram (including header) is
bytes. - That said, a link layer like Ethernet must fragment an IP datagram according to its MTU. Also, hosts are not required to receive IPv4 datagrams larger than 576 bytes.
- Identification. An ID used to distinguish fragments of one datagram. Usually corresponds to a serially increasing integer.
- Time-to-Live (TTL). Specifies an upper limit on the number of routers through which a datagram can pass. Better called hop limit.
- Protocol. The type of data found in the payload. Most commonly 17 (for UDP) and 6 (for TCP).
- Header Checksum. A checksum calculated over just the header. That is, the payload is not checked for correctness.
Special Addresses
There exist a number of IPv4 addresses designated for special purposes. The following describes a subset of them:
| Prefix | Special Use |
|---|---|
0.0.0.0/32 | The unspecified address. May be used as a source IP address. |
10.0.0.0/8 | Address for private networks. Such addresses never appear on the public Internet. |
127.0.0.0/8 | Internet host loopback addresses. |
172.16.0.0/12 | Address for private networks. Such addresses never appear on the public Internet. |
192.168.0.0/16 | Address for private networks. Such addresses never appear on the public Internet. |
224.0.0.0/4 | Multicast addresses. Used only as destination addresses. |
255.255.255.255/32 | The local network (limited) broadcast address. |
IPv6
An IPv6 address is a 128-bit nonnegative integer. An address is typically represented as eight blocks (also called fields) of four hexadecimal numbers each. In addition:
- Leading zeros of a block can be omitted.
- Blocks of all zeros can be omitted and replaced with notation
::.- The
::notation can only be used once within an IPv6 address.
- The
IPv4 addresses can be embedded into the IPv6 format as an IPv4-mapped IPv6 address. This is a hybrid notation in which the block preceding the IPv4 portion of the address has value ffff and the remaining part of the address is formatted using dotted-quad. For example, ::ffff:10.0.0.1.
Packet Format
The following is a diagram of the IPv6 packet format.

- Version. A value of
is used to indicate IPv6. - Payload Length. The length of the IPv6 datagram excluding the length of the header. Since this is a 16-bit field, the maximum size of the payload is
bytes. - Next Header. This header generalizes the Protocol field in IPv4. It indicates the type of the header following the IPv6 header.
- Hop Limit. Specifies an upper limit on the number of routers through which a datagram can pass.
Special Addresses
There exist a number of IPv6 addresses designated for special purposes. The following describes a subset of them:
| Prefix | Special Use |
|---|---|
::/128 | The unspecified address. May be used as a source IP address. |
::1/128 | The Internet host loopback address. |
::ffff:0:0/96 | IPv4-mapped addresses. Such addresses never appear in pcaket headers. For internal host use only. |
ff00::/8 | Multicast addresses. Used only as destination addresses. |
Host Models
A system operating with respect to the strong host model accepts a datagram only if the IP address specified in the destination field matches an address configured on the receiving interface.
A system operating with respect to the weak host model accepts a datagram if the IP address specified in the destination field matches an address configured on any interface, receiving or otherwise.
Analogous behavior is followed on sending.