IPv4 is one of the two main versions of the Internet Protocol (IP). The other is IPv6.
Addressing
Each IP address in IPv4 is 32-bits. It takes a format:
xxx.xxx.xx.xx:portIt’s not possible to find the specific application a packet is going to, only the port number.
IPv4 addresses are written in dotted-decimal notation.
223 . 1 . 1 . 1
11011111 | 00000001 | 00000001 | 00000001Each decimal number corresponds to an 8-bit segment of the address.
IPv4 uses two types of addressing schemes:
- Classful addressing — an old and no longer used scheme. It divided addresses into 5 classes.
- Classless interdomain routing (CIDR) — which is the current scheme. It allows the subnet portion of the address to be of arbitrary length.
Private addresses are reserved addresses for private networks that roughly fall into the class A/B/C ranges. Routers in the public Internet discard packets with these addresses. Network Address Translation is used to convert between private and global IP addresses.
- 10.0.0.0 to 10.255.255.255 (10.0.0.0/8) - Class A range
- 172.16.0.0 to 172.31.255.255 (172.16.0.0/12) - Class B range
- 192.168.0.0 to 192.168.255.255 (192.168.0.0/16) - Class C range
Larger networks can be separated into subnets. IP addresses have a structure:
- Subnet part: devices in the same subnet have common higher-order bits.
- Host part: the remaining lower-order bits.
Specification

- Type of service — the router sets this.
- diffserv classifies what type of network traffic is being propagated.
- ECN (explicit congestion notification) is set when there’s congestion.
- TTL — decremented by 1 at each router. If the TTL is 0, then the packet must be dropped. This ensures that routers don’t loop around in the network forever.
- Upper layer protocol — for TCP, is set to 6. For UDP, is set to 17.
- Header checksum — is computed over the IP header. Since the header fields change each time (TTL), the checksum must be re-computed for each router. This is only in IPv4 and not in IPv6.