
How IPv4 Works – A Handbook for Developers
How IPv4 Works – A Handbook for Developers 관련
The Internet Protocol version 4 (IPv4) is one of the core protocols of standards-based internetworking methods in the Internet and other packet-switched networks. IPv4 is still the most widely deployed Internet protocol. Google’s IPv6 Statistics show 44.29% of traffic to Google services on April 24, 2025 is over IPv6, implying 55.71% goes over IPv4. This handbook will take you through every aspect of IPv4, from understanding IP addresses to examining packet headers and fragmentation. You'll learn:
- How IP addresses work and their different formats
- Network addressing schemes from fixed-length to CIDR
- Special IPv4 addresses and their uses
- The structure and purpose of every field in the IPv4 header
- How IPv4 handles packet fragmentation across different networks
Whether you're a network engineer, software developer, or IT professional, understanding IPv4 is crucial for working with modern computer networks.
- Classful Addressing
- CIDR: Classless Interdomain Routing
- Subnet Masks
- Interim Summary – IPv4 Addresses
- Test Yourself
- Special IPv4 Addresses
- IPv4 Header
- IPv4 Fragmentation
Quick notes before we start
- You can find more content about computer networks on my YouTube channel: Computer Networks Playlist
- I am working on a book about Computer Networks! Are you interested in reading the initial versions and providing feedback? Send me an email:
gitting.things@gmail.com
Background
IP stands for "Internet Protocol", so IPv4 is Internet Protocol version 4. It was described in RFC 791 by IETF, published in September 1981, and first deployed for production in 1982 on SATNET (the Atlantic Packet Satellite Network), which was an early satellite network that formed an initial segment of the Internet.
IPv4 is connectionless and operates in a best-effort delivery model. This means it doesn't guarantee delivery, correct ordering of packets, or the validity of the data. It's designed to be fast and flexible.
Understanding IP Addresses
IP addresses are hierarchical, logical addresses that power most internet connections today. Each consists of 4
bytes, or 32
bits. They're usually written in dotted decimal notation, for example:

(Source:
BriefVid
)Test yourself – Does the following address represent a valid IP address?

(Source:
BriefVid
)No. Since the dots separate different bytes, each value must be between 0
and 255
. Since the number 392
is bigger than 255
, it cannot be represented in a single byte.

(Source:
BriefVid
)Network ID and Host ID
IP addresses have two parts: a network identifier (or network ID) that belongs to all hosts in the network and a host identifier (or host ID) that identifies the specific host in this network.
The network identifier will be the same for all hosts in the network, and is also called a "prefix". For example, consider a network identifier of 201.22.3
. Given that this is the network prefix, the following addresses:
201.22.3.15
201.22.3.91
Are part of the same network, as they share the same prefix. The first address belongs to host number 15
in this network, and the second belongs to host number 91
.
This address has a different prefix, or a different network identifier, and thus belongs to a different network:
201.22.14.50
In the examples above, there's a network identifier consisting of 3 bytes, or 24 bits, and a host identifier consisting of 1 byte, or 8 bits.

(Source:
BriefVid
)How to Determine Network vs. Host Portions
A question arises: how do you know which bits are part of the network ID, and which are part of the host ID? Several approaches have evolved over time to address this challenge.
Fixed-Length Approach
Let's consider this solution: For every IP address, the first, most-significant byte would represent the network ID, and the remaining three, least-significant bytes would represent the host ID. This way it's really easy to read IP addresses. For example for this address:
20.12.1.92
You know that it describes network 20
, and the host 12.1.92
inside that network. Any IP address that doesn't start with 20
, such as 22.1.2.3
, would reside in a different network, and any IP address that starts with 20
, like 20.1.2.3
, would be within the same network.

(Source:
BriefVid
)What are the disadvantages here? 🤔
With only one byte (8 bits) to represent the network ID, you only have 2^8, or 256
, different networks. Of course, there are far more networks than that in the real world. Even in the early days of the internet, universities and large companies each needed their own network identifiers.
In general, using a fixed length for the network ID and a fixed length for the host ID is not flexible enough. If you decide that the two most-significant bytes will represent the network ID and the two least-significant bytes will represent the host ID, you can represent up to 2^16, or 65,536
networks, which is also not enough. Furthermore, some networks, such as those of large companies, might require more than 65,536
host IDs.
Summary – IPv4
In this comprehensive guide to IPv4, you've learned about the fundamental building blocks of Internet communications. Let's recap the key concepts we covered:
Addressing and Network Structure
- IPv4 addresses are 32-bit numbers typically written in dotted decimal notation
- Networks can be identified using various methods:
- Fixed-length approach (historically)
- Classful addressing (A, B, C, D, E classes)
- CIDR (modern approach allowing flexible network sizes)
- Special addresses serve specific purposes:
0.0.0.0
for "this host"127.0.0.0/8
for loopback255.255.255.255
for broadcast
IPv4 Header Structure
- The header contains crucial fields for packet routing and processing:
- Version and IHL for header interpretation
- Type of Service for traffic prioritization
- Total Length for packet size
- Various fields for fragmentation control
- TTL to prevent infinite routing loops
- Protocol to identify the encapsulated protocol
- Checksum for error detection
- Source and destination addresses
Fragmentation
- Allows IPv4 packets to traverse networks with different MTUs
- Uses three key fields:
- Identification to group fragments
- Flags to control fragmentation
- Fragment Offset to reassemble packets
Final Words
While IPv4 has limitations, particularly its address space constraints, its elegant design and robust features have allowed it to remain the backbone of the Internet for over four decades. Understanding IPv4 provides essential context for working with modern networks and helps in transitioning to newer protocols like IPv6. ---
About the Author
Omer Rosenbaum is Swimm’s Chief Technology Officer. He's the author of the Brief YouTube Channel (BriefVid
). He's also a cyber training expert and founder of Checkpoint Security Academy. He's the author of Gitting Things Done (in English) and Computer Networks (in Hebrew). You can find him on X (Omer_Ros
).
Additional References