Internet Protocol#


Table of Contents#


Addresses#


IPv4#

An IPv4 address consists of four octets (where an octet is two bytes or eight bits) for a total of 32 bits each octet of which is separated by a period. The IPv4 address space makes room for almost 4.3 billion unique addresses.

\( \underbrace{11111111}_{255}.\underbrace{11111111}_{255}.\underbrace{11111111}_{255}.\underbrace{00000000}_{0} \\ \)

print(f'number of unique IP addresses: {2**32:,}')
number of unique IP addresses: 4,294,967,296

1981-1993: Classful IPv4#

The classful network addressing architecture was in use from 1981 to 1993 when it was superseded by the classless network addressing architecture. Prior to 1981, a handful of networks were designated by 8-bit network IDs none of which exceeded ID 64 (1000000 base 2). These networks formed the basis of Class A of the classful network addressing architecture.

Class A networks were designated by a 0 high bit and consisted of a 7-bit network ID (NID) and a 24-bit host ID (HID); Class B, 10 high bits, a 14-bit NID and a 16-bit HID; Class C, 110 high bits, a 21-bit NID and an 8-bit HID. Classes D and E by 1110 and 1111 high bits respectively but were never defined completely. An all-zero bit HID represented the network address and an all-one bit HID represented the broadcast address.

Many organizations that were delegated Class C networks needed more address space but Class B networks were much larger than what most required and were quickly depleted.

\( \begin{aligned} 0.0.0.0-127.255.255.255 && 0\underbrace{000\,0000}_{\text{NID}}.\underbrace{0000\,0000.0000\,0000.0000\,0000}_{\text{HID}}-0\underbrace{111\,1111}_{127}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255} && \text{128 Class A networks with 16,777,216-2 hosts per network} \\ 128.0.0.0-191.255.255.255 && 10\underbrace{00\,0000.0000\,0000}_{\text{NID}}.\underbrace{0000\,0000.0000\,0000}_{\text{HID}}-10\underbrace{11\,1111.1111\,1111}_{16,383}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255} && \text{16,384 Class B networks with 65,536-2 hosts per network} \\ 192.0.0.0-223.255.255.255 && 110\underbrace{0\,0000.0000\,0000.0000\,0000}_{\text{NID}}.\underbrace{0000\,0000}_{\text{HID}}-110\underbrace{1\,1111.1111\,1111.1111\,1111}_{2,097,151}.\underbrace{1111\,1111}_{255} && \text{2,097,152 Class C networks with 256-2 hosts per network} \\ 224.0.0.0-239.255.255.255 && 1110\,\underbrace{0000.0000\,0000.0000\,0000.0000\,0000}_{0}-1110\,\underbrace{1111.1111\,1111.1111\,1111.1111\,1111}_{268,435,455} && 2^{28} = 268,435,456 \text{ addresses: Class D network} \\ 240.0.0.0-255.255.255.255 && 1111\,\underbrace{0000.0000\,0000.0000\,0000.0000\,0000}_{0}-1111\,\underbrace{1111.1111\,1111.1111\,1111.1111\,1111}_{268,435,455} && 2^{28} = 268,435,456 \text{ addresses: Class E network} \\ \end {aligned} \)

Class A example

\( \begin{aligned} 0. 0. 0. 0 && \text{network address} \\ 0.255.255.255 && \text{broadcast address} \\ 255. 0. 0. 0 && \text{subnet mask} \\ \end {aligned} \)

Class B example

\( \begin{aligned} 128. 0. 0. 0 && \text{network address} \\ 128. 0.255.255 && \text{broadcast address} \\ 255.255. 0. 0 && \text{subnet mask} \\ \end {aligned} \)

Class C example

\( \begin{aligned} 192. 0. 0. 0 && \text{network address} \\ 192. 0. 0.255 && \text{broadcast address} \\ 255.255.255. 0 && \text{subnet mask} \\ \end {aligned} \)

Post 1993: Classless IPv4#

\( \begin{aligned} && \text{subnet mask} && 2^{\text{address length}-\text{prefix length}} &= \text{number of addresses} \\ /1 && \underbrace{1000\,0000}_{128}.\underbrace{0000\,0000}_{ 0}.\underbrace{0000\,0000}_{0 }.\underbrace{0000\,0000}_{0 } && 2^{32- 1} &= 2,147,483,648 \\ /2 && \underbrace{1100\,0000}_{192}.\underbrace{0000\,0000}_{ 0}.\underbrace{0000\,0000}_{0 }.\underbrace{0000\,0000}_{0 } && 2^{32- 2} &= 1,073,741,824 \\ /3 && \underbrace{1110\,0000}_{224}.\underbrace{0000\,0000}_{ 0}.\underbrace{0000\,0000}_{0 }.\underbrace{0000\,0000}_{0 } && 2^{32- 3} &= 536,870,912 \\ /4 && \underbrace{1111\,0000}_{240}.\underbrace{0000\,0000}_{ 0}.\underbrace{0000\,0000}_{0 }.\underbrace{0000\,0000}_{0 } && 2^{32- 4} &= 268,435,456 \\ /5 && \underbrace{1111\,1000}_{248}.\underbrace{0000\,0000}_{ 0}.\underbrace{0000\,0000}_{0 }.\underbrace{0000\,0000}_{0 } && 2^{32- 5} &= 134,217,728 \\ /6 && \underbrace{1111\,1100}_{252}.\underbrace{0000\,0000}_{ 0}.\underbrace{0000\,0000}_{0 }.\underbrace{0000\,0000}_{0 } && 2^{32- 6} &= 67,108,864 \\ /7 && \underbrace{1111\,1110}_{254}.\underbrace{0000\,0000}_{ 0}.\underbrace{0000\,0000}_{0 }.\underbrace{0000\,0000}_{0 } && 2^{32- 7} &= 33,554,432 \\ /8 && \underbrace{1111\,1111}_{255}.\underbrace{0000\,0000}_{ 0}.\underbrace{0000\,0000}_{0 }.\underbrace{0000\,0000}_{0 } && 2^{32- 8} &= 16,777,216 \\ /16 && \underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255}.\underbrace{0000\,0000}_{0 }.\underbrace{0000\,0000}_{0 } && 2^{32-16} &= 65,536 \\ /24 && \underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255}.\underbrace{0000\,0000}_{0 } && 2^{32-24} &= 256 \\ /32 && \underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255} && 2^{32-32} &= 1 \\ \end {aligned} \)

IPv4 Private Address#

\( \begin{aligned} 10.0.0.8/8 && \underbrace{0000\,1010}_{10}.\underbrace{0000\,0000}_{0}.\underbrace{0000\,0000}_{0}.\underbrace{0000\,0000}_{0}-\underbrace{0000\,1010}_{10}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255} && \text{1 class A network} \\ 172.16.0.0/12 && \underbrace{1010\,1100}_{172}.\underbrace{0001\,0000}_{16}.\underbrace{0000\,0000}_{0}.\underbrace{0000\,0000}_{0}-\underbrace{1010\,1100}_{172}.\underbrace{0001\,1111}_{31}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255} && \text{16 class B networks} \\ 192.168.0.0/16 && \underbrace{1100\,0000}_{192}.\underbrace{1010\,1000}_{168}.\underbrace{0000\,0000}_{0}.\underbrace{0000\,0000}_{0}-\underbrace{1100\,0000}_{192}.\underbrace{1010\,1000}_{168}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255} && \text{256 class C networks} \\ \end {aligned} \)

print(f'number of unique  10.  0.0.8/ 8 addresses:   {   256**3:>10,}')
print(f'number of unique 100. 64.0.0/10 addresses:   {64*256**2:>10,}')
print(f'number of unique 172. 16.0.0/12 addresses:   {16*256**2:>10,}')
print(f'number of unique 192.168.0.0/16 addresses:   {   256**2:>10,}')
number of unique  10.  0.0.8/ 8 addresses:   16,777,216
number of unique 100. 64.0.0/10 addresses:    4,194,304
number of unique 172. 16.0.0/12 addresses:    1,048,576
number of unique 192.168.0.0/16 addresses:       65,536

Carrier Grade NAT Address#

\( \begin{aligned} 100.64.0.0/10 && \underbrace{0110\,0100}_{100}.\underbrace{0100\,0000}_{64}.\underbrace{0000\,0000}_{0}.\underbrace{0000\,0000}_{0}-\underbrace{0110\,0100}_{100}.\underbrace{0111\,1111}_{127}.\underbrace{1111\,1111}_{255}.\underbrace{1111\,1111}_{255} && \text{64 class B networks for Carrier-Grade NAT} \\ \end {aligned} \)

Loopback Address#

\(127.0.0.0/8\)

\(127.0.0.1\)


IPv6#

An IPv6 address consists of eight groups of up to four hexadecimal digits for a total of 32 hexadecimal digits (or 128 bits) each group of which is separated by a colon. The IPv6 address space makes room for over three hundred forty trillion trillion trillion addresses.

\(\underbrace{\text{FFFF}}_{65,536}:\text{FFFF}:\text{FFFF}:\text{FFFF}:\text{FFFF}:\text{FFFF}:\text{FFFF}:\text{FFFF}\)

print(f'number of IP addresses: {16**32:,}')
number of IP addresses: 340,282,366,920,938,463,463,374,607,431,768,211,456

\( \begin{aligned} && \text{subnet mask} && 2^{\text{address length}-\text{prefix length}} &= \text{number of addresses} \\ /1 && \text{8000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64- 1} &= 9,223,372,036,854,775,808 \\ /2 && \text{C000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64- 2} &= 4,611,686,018,427,387,904 \\ /3 && \text{E000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64- 3} &= 2,305,843,009,213,693,952 \\ /4 && \text{F000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64- 4} &= 1,152,921,504,606,846,976 \\ /5 && \text{F800}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64- 5} &= 576,460,752,303,423,488 \\ /6 && \text{FC00}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64- 6} &= 288,230,376,151,711,744 \\ /7 && \text{FE00}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64- 7} &= 144,115,188,075,855,872 \\ /8 && \text{FF00}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64- 8} &= 72,057,594,037,927,936 \\ /16 && \text{FFFF}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64-16} &= 281,474,976,710,656 \\ /24 && \text{FFFF}:\text{FF00}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64-24} &= 1,099,511,627,776 \\ /32 && \text{FFFF}:\text{FFFF}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64-32} &= 4,294,967,296 \\ /40 && \text{FFFF}:\text{FFFF}:\text{FF00}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64-40} &= 16,777,216 \\ /48 && \text{FFFF}:\text{FFFF}:\text{FFFF}:\text{0000}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64-48} &= 65,536 \\ /56 && \text{FFFF}:\text{FFFF}:\text{FFFF}:\text{FF00}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64-56} &= 256 \\ /64 && \text{FFFF}:\text{FFFF}:\text{FFFF}:\text{FFFF}:\text{0000}:\text{0000}:\text{0000}:\text{0000} && 2^{64-64} &= 1 \\ \end {aligned} \)

Link-Local Address

\(\underbrace{\text{FE80}}_{65,152}::/10\)

Unique Local Address

\(\underbrace{\text{FC00}}_{64,512}::/7\)

Loopback Address#

\(::1/128\)


Resources#


Figures#

  • [ w ] 1956----- Karn, Phil


Terms#

  • [ w ] Address Space

  • [ w ] Broadcast Address

  • [ w ] Carrier-Grade NAT

  • [ w ] Classful Network

  • [ w ] Classless Inter-Domain Routing (CIDR) [ RFC1518 ] [ RFC1519 ] [ RFC4632 ]

  • [ w ] Dotted Decimal Notation

  • [ w ] Internet Assigned Numbers Authority (IANA)

  • [ w ] IP Address

  • [ w ] IPv4

  • [ w ] IPv4 Address Exhaustion

  • [ w ] IPv4 Shared Address Space

  • [ w ] IPv6

  • [ w ] IPv6 Address

  • [ w ] Internet Protocol (IP)

  • [ w ] Link-Local Address

  • [ w ] Loopback Address

  • [ w ] Multicast Address [ pcmag ]

  • [ w ] Network Address

  • [ w ] Private Address [ RFC1918 ]

  • [ w ] [ RFC751 ]

  • [ w ] Stateless Address Auto Configuration (SLAAC) [ RFC4862 ]

  • [ w ] Subnet [ RFC950 ]

  • [ w ] Unique Local Address (ULA)