IP Technology Basics · Topic 1 of 5
IPv4 Header, Addresses and Subnetting
Learn the IPv4 header fields, address classes, private and special addresses, masks and subnetting math for the Huawei HCIA-Datacom H12-811 exam.
- 6 min
- The IPv4 header is 20 bytes minimum, 60 maximum, and the Protocol field values are 1 ICMP, 6 TCP, 17 UDP and 89 OSPF.
- TTL stops loops, and the header checksum covers only the header.
- Class A is 1 to 126, B 128 to 191, C 192 to 223, D (multicast) 224 to 239.
What it is
The network layer moves packets from one network to another. Its main protocol is IPv4, helped by ICMP for error and test messages and by ARP, which finds the MAC address for a next hop IP address on Ethernet.
An IPv4 address is 32 bits, written as four decimal octets such as 192.168.1.10. A mask splits it into a network part and a host part. Subnetting borrows host bits to cut one network into several smaller ones.
How it works
The IPv4 header
The header is 20 bytes without options and up to 60 bytes with them.
| Field | Size | Purpose |
|---|---|---|
| Version | 4 bits | 4 for IPv4 |
| Header Length | 4 bits | Header size in 4 byte units, 5 means 20 bytes |
| Type of Service (DS field) | 8 bits | Priority marking (DSCP) for QoS |
| Total Length | 16 bits | Header plus data, up to 65,535 bytes |
| Identification | 16 bits | Same value on every fragment of one packet |
| Flags | 3 bits | DF (do not fragment) and MF (more fragments) |
| Fragment Offset | 13 bits | Position of the fragment, in 8 byte units |
| TTL | 8 bits | Decreased by 1 at each router, discarded at 0 |
| Protocol | 8 bits | Upper layer protocol: 1 ICMP, 6 TCP, 17 UDP, 89 OSPF |
| Header Checksum | 16 bits | Checks the header only |
| Source and Destination Address | 32 bits each | Sender and receiver |
When a packet is larger than the outgoing link MTU (1500 bytes on Ethernet by default), it is fragmented unless DF is set. The receiving host reassembles the fragments using Identification, MF and Fragment Offset.
Address classes
| Class | First octet | Default mask | Use |
|---|---|---|---|
| A | 1 to 126 | 255.0.0.0 (/8) | Unicast |
| B | 128 to 191 | 255.255.0.0 (/16) | Unicast |
| C | 192 to 223 | 255.255.255.0 (/24) | Unicast |
| D | 224 to 239 | None | Multicast |
| E | 240 to 255 | None | Reserved |
In binary, class A starts with 0, B with 10, C with 110, D with 1110 and E with 1111. Today classless addressing (CIDR) is used, and the prefix length decides the network part.
Private and special addresses
| Range | Meaning |
|---|---|
| 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | Private, not routed on the internet, need NAT |
| 127.0.0.0/8 | Loopback, tests the local stack |
| 169.254.0.0/16 | Link local, used when DHCP fails |
| 0.0.0.0 | This host, or the default route as 0.0.0.0/0 |
| 255.255.255.255 | Limited broadcast, never forwarded by routers |
In each network, the address with all host bits 0 is the network address and all host bits 1 is the broadcast address. Neither can be given to a host.
Subnetting math
With n host bits, a subnet has 2^n addresses and 2^n minus 2 usable host addresses. Borrowing m bits gives 2^m subnets.
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
The block size is 256 minus the interesting mask octet. With /26 the block size is 64, so subnets start at .0, .64, .128 and .192. VLSM uses different prefix lengths inside one network, such as /30 for router links and /24 for user LANs.
Setting an address on VRP
<Huawei> system-view
[Huawei] interface GigabitEthernet0/0/0
[Huawei-GigabitEthernet0/0/0] ip address 192.168.1.1 255.255.255.0
The mask can also be given as a length, as in ip address 192.168.1.1 24. Check it with display ip interface brief.
A worked example
A host has 172.16.45.200/27. The block size is 256 minus 224, which is 32. The multiples of 32 are 160 and 192, so the host is in subnet 172.16.45.192.
The broadcast is 172.16.45.223, and the usable hosts are 172.16.45.193 to 172.16.45.222. That gives 30 usable addresses.
How the exam asks about this
- "Which field in the IPv4 header prevents packets from looping forever?" → TTL, decreased by 1 at each hop.
- "How many usable host addresses does a /28 subnet provide?" → 14.
- "Which address can be configured on a host interface: 10.1.1.63/26, 10.1.1.64/26 or 10.1.1.65/26?" → 10.1.1.65/26, because .63 is a broadcast and .64 is a network address.
What to remember for the exam
- The IPv4 header is 20 bytes minimum, 60 maximum, and the Protocol field values are 1 ICMP, 6 TCP, 17 UDP and 89 OSPF.
- TTL stops loops, and the header checksum covers only the header.
- Class A is 1 to 126, B 128 to 191, C 192 to 223, D (multicast) 224 to 239.
- Private ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.
- Usable hosts are 2^n minus 2, and a /30 gives 2 hosts for a router link.
127.x.x.x is not class A unicast and cannot be assigned to an interface, even though its first octet looks like class A.
Common mistakes
Forgetting the two reserved addresses. A /27 has 32 addresses but only 30 hosts. The network and broadcast addresses are not usable.
Reading 172.16.0.0/12 as 172.16 only. The private class B block runs from 172.16.0.0 to 172.31.255.255. An address like 172.20.1.1 is private too.
Counting Fragment Offset in bytes. It is counted in 8 byte units. An offset of 185 means byte 1480 of the original data.
Check yourself
What is the broadcast address of 192.168.10.70/26?
192.168.10.127, because the /26 block size is 64 and the host sits in the 192.168.10.64 subnet.
Which IPv4 header field tells the receiver that more fragments follow?
The MF (more fragments) flag, set on every fragment except the last one.
Is 169.254.10.5 a valid address to use on the internet?
No. It is a link local address that a host gives itself when it cannot get one from DHCP.
Topic 1 of 5 in IP Technology Basics
Test yourself on IP Technology Basics
The full Huawei HCIA-Datacom H12-811 question bank has 600 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Huawei. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.