Did you know there are two versions of IP addresses? There are Internet Protocol version 4 (IPv4) addresses and Internet Protocol version 6 (IPv6) addresses. In this post, I’ll discuss IPv4 addresses.
Every device connected to a network, such as the Internet or your home network, is given an IP address. An IP address is a numerical number assigned to a device that wishes to communicate via Internet Protocol (IP). Every device connected to a computer network requires an IP address; otherwise, communication is difficult. It would be impossible for computers to send information to other computers not on their local subnet. When it comes to sending information locally, we use MAC addresses. But, for sending information from router-to-router, we need IP addresses.
As another example, how would you expect your Amazon package order to be delivered to your home if your house didn’t have an address? It kind of works the same way on our networks. Computers need a destination address to send information to a device outside of its subnet.
Internet Protocol version 4 (IPv4) Addresses
IP addresses are managed and allocated by the Internet Assigned Numbers Authority (IANA). Companies must pay to have a pool or “block” of IP address allocated to them. ISPs subnet these IP addresses and pass them to their customers. As a customer to your ISP, you pay for your own IP address too! Most likely, you are paying for one IP address that you share with the devices in your home (using NAT technology, of course).
The IP version 4 addresses are the IP addresses you’re probably most familiar with. IPv4 addresses are 32-bit addresses expressed in a dotted-decimal format (e.g., XXX.XXX.XXX.XXX). Here’s an example of a real IPv4 address in dotted decimal notation: 192.168.128.169. This IPv4 address can also be represented in dotted-binary format by converting each octet into binary numbers (1s and 0s).
I can get into converting decimal-to-binary and binary-to-decimal in a later post, but now you can see that it really is nothing more than a 32-bit address! We just have the dotted-decimal format to assist us mere humans who have trouble reading such long addresses. If you count the number of binary bits in the dotted-binary representation in the bottom row, the total number of bits is equal to 32-bits. We call each section separated by the dots an “octet” since there are 8-bits per section.
IPv4 Packet Header
The full IPv4 packet header has 14 different fields, but only 13 are required. Some fields are merged into one.
- Version: identifies the IP version, in this case its version 4.
- Header Length: The total size of the IP portion of the Packet in words (32-bits) is displayed in the header length field.
- Type of Service (ToS): Specifies how the packet should be handled within the network.
- Differentiated Services Code Point (DSCP): (not shown) contains data used by bandwidth-sensitive applications like VoIP.
- Total Length: The size of the header and data in octets.
- Identification: uses when the packet is fragmented.
- Flags: used when the packet is fragmented.
- Fragment Offset: Used when the packet is fragmented.
- Time to Live (TTL): Protection against endless loops, decremented by 1 on every router the packet passes through. Routers sometimes create loops. TTL prevents an IP packet from indefinitely spinning through the Internet by using a counter that decrements by 1 every time the packet goes through a router. This number cannot start higher than 225; many applications start at 128.
- Protocol: identifies the Layer 4 protocol (TCP or UDP). It also identifies what’s encapsulated in the packet.
- Header Checksum: Used to verify its integrity.
- Source IP address: Source of logical IP address.
- Destination IP address: Destination of logical IP address.
- IP Options: Used for debugging.
- Padding: used for debugging.
- Data: The Transport Layer data.
IPv4 Address Exhaustion
Since IPv4 addresses are only 32-bits in length, there are only 4,294,967,296 IPv4 addresses available. Clearly, there are not enough IPv4 addresses to go around for all of our devices. For that reason, we created IPv6 addresses, private IP addresses, subnetting, and NAT.
IPv4 Address Classes
In the past, we relied on “classful” subnetting. Subnetting strays off into networking topics, but it’s useful to know this.
IPv4 addresses are categorized into 5 classes from A to E, but we only use Class A, B, and C on our networks.
The Class A addresses are within the range of 188.8.131.52 – 184.108.40.206.
The Class B addresses are between 220.127.116.11 – 18.104.22.168.
The Class C addresses are between 192.0.0.0 – 22.214.171.124.
The Class D addresses are used for multicast groups.
The Class E addresses are for experimental use.
Additionally, IPv4 addresses that start with 127 or 169.254 are not included. This is because the 127.0.0.0/8 network is reserved as a loopback address in IPv4 and is not associated with any particular class. On the other hand, 169.254.x.x addresses are used for APIPA. I understand this is very confusing, so I’ve provided a visual display below. Hopefully, this table will help you better understand IPv4 address classes.
These are all “public IP addresses” and they are used for external communication. Public IP addresses can be accessed by every other Internet-facing machine and they are unique on the Internet.
We’ve also created “private IP addresses” too. Private IP addresses are reserved and used only internally within a company or home network. They are not advertised on the Internet, allowing each of our companies and homes to use the same private IP address infrastructure and still have it be unique to our own networks. Private IP addresses are therefore a good option on internal networks such as LANs or home networks without paying the IS. Three specific ranges of IP address in each class are reserved for private use. ISP routers by default drop any packet having a private IP address as its destination (but it is possible to route the private IP address packets across the Internet using a VPN.) Private IP address ranges, as defined by RFC 1918, are as follows:
Network Addresses, Host Addresses, Broadcast Addresses, and Subnet Masks
To help conserve the number of IPv4 addresses and to more easily manage our networks in a secure way, we can subnet our networks. You don’t need to understand what subnetting is since it strays into networking concepts, but in layman’s terms, it basically means dividing the network into smaller pieces. Why subnet a network into these smaller pieces? Why can’t we just all connect to the network and everyone can communicate with everyone else? Because there are technical limitations with that. To know where everyone else is on the ENTIRE network, especially a world-wide network like the Internet, would require some extraordinary technical resources. Instead, we know where the next step is to communicate with routing and we let the routers handle the rest of the communication. There would also be cost limitations. You would have to build some amazing technologies to be able to understand where every single person is, or every single IP address, on the entire worldwide Internet. And of course, there’s security concerns with this. Maybe we want a network that is private to us? Even the largest networks in the world still subnet to smaller pieces for security and manageability.
As you probably noticed in the table above, each IPv4 address Class from A to C has a default “subnet mask.” It is also sometimes referred to as a “natural mask” or “network mask.” The subnet mask starts with a continuous string of bits with the value of 1 and ends with a string of 0s. The number of bits with the value of 1 represents the number of bits in the IP Address that must be considered in order to calculate the network address. A subnet mask bit of 0 indicates that the corresponding bit in the IPv4 address is a host bit.
Every subnet mask has a network portion (seen in blue) and a host portion (seen in orange) of the address. Class A networks have a 24-bit host address, which leaves them a maximum of 16,777,216 available hosts on the network! But, since we don’t count the network address or the broadcast address as “hosts,” it’s actually 16,777,214 hosts. How did I come up with that number? 2^24 = 16,777,216.
Class B networks have 16-bit host addresses, leaving them with a maximum of 2^16 = 65,536 -2 = 65,534 hosts.
And finally, Class C networks have an 8-bit host address, which leaves them with only a maximum of 2^8 = 256 -2 = 254 available hosts.
Let’s go back to our original example of an IPv4 address 192.168.128.169/24 and determine its Class, subnet mask, network address, host address, and broadcast address
Since this example IPv4 address starts with 192, we assume that it is a Class C address since it’s between 192.0.0.0 and 126.96.36.199. You can also tell by the CIDR notation “/24,” which indicates there are 24 “1s” in the subnet mask, leaving only 8-bits in the host portion. The subnet mask for this IPv4 address is therefore 255.255.255.0 or 11111111.11111111.1111111.00000000.
Every IPv4 address has a network address. The network address can be found by writing out the IPv4 address and its subnet mask and performing a function called a “Bitwise AND.” To do this, we look at the differences between the top and bottom bits. If they’re both 1s, then bring down a 1. If it’s anything else (e.g., 0 and 0, 1 and 0, or 0 and 1), bring down a 0.
Therefore, after performing the bitwise AND and converting it from binary to decimal format, the network address is 192.168.128.0!
To find the broadcast address, change the 0s at the end of the bitwise AND row to all 1s. The answer is 11000000.10101000.10000000.11111111 in dotted-binary, format which equals 192.168.128.255 in dotted-decimal format.
A summary of what we’ve found from just one IP address 192.168.128.169/24 is displayed below.
But, There’s More…
That’s all for now. This post particularly deals with IPv4 addresses. Later on, I’ll talk about Internet Protocol version 6 (IPv6) addresses, which have 3.4×10^38 or 340 undecillion IPv6 addresses!
Cisco. (August 2010). IP Addressing and Subnetting for New Users. Cisco Systems. Retrieved from https://www.cisco.com/c/en/us/support/docs/ip/routing-information-protocol-rip/13788-3.html
Meyers, M. (2015). All in One CompTIA Network+ Certification Exam N10-006. McGraw-Hill Education: New York, NY.