⭐ PART 1 — Bits, Nibbles, Bytes (The Foundations)
Bit
-
A 0 or 1
-
Smallest unit of data.
Example:
1 or 0
Nibble
-
4 bits
-
Can represent values 0–15 decimal
-
Hex digit maps perfectly to a nibble, which is why hex exists in networking.
Example:
Byte
-
8 bits = 2 nibbles
-
Can represent 0–255 decimal
Example:
⭐ PART 2 — Why Networking Loves Hex
Hex is just a human-friendly way to write binary.
-
1 hex digit = 4 bits
-
2 hex digits = 1 byte (8 bits)
This makes it ideal for:
-
MAC addresses (48 bits)
-
IPv6 addresses (128 bits)
-
TCP/IP headers (lots of 16-bit and 32-bit fields)
⭐ PART 3 — MAC Addresses (48 bits, always hex)
A MAC address is 48 bits = 6 bytes = 12 hex digits.
Example MAC:
Let’s decode the first byte:
First byte: AA
| Hex | Binary |
|---|---|
| A | 1010 |
| A | 1010 |
So AA in binary:
The entire MAC in binary:
Important MAC-level bits:
The first byte contains two special bits:
| Bit | Meaning |
|---|---|
| LSB of first byte | Unicast (0) / Multicast (1) |
| 2nd LSB | Globally unique (0) / Locally administered (1) |
Example:
AA = 10101010
-
LSB =
0→ Unicast -
Next bit =
1→ Locally administered MAC
⭐ PART 4 — IPv4 Addresses
(32 bits = 4 bytes = 8 hex digits)
Example IPv4 address:
Break into bytes:
-
192→11000000→C0 -
168→10101000→A8 -
1→00000001→01 -
10→00001010→0A
IPv4 in hex:
IPv4 in binary (all 32 bits):
Why useful?
This is exactly how routers see IPs in memory and packet headers.
⭐ PART 5 — IPv6 Addresses
(128 bits = 16 bytes = 32 hex digits)
Example IPv6:
Each group is 16 bits (2 bytes):
-
2001in binary =
0010 0000 0000 0001
IPv6 in full binary representation is a 128-bit monster, but hex makes it readable.
⭐ PART 6 — Example: IP Header Fields in Binary/Hex
Let’s decode the first 4 bytes of an IPv4 header:
Hex dump:
Breakdown:
Byte 1 — Version + IHL
45 hex = 0100 0101 binary
-
Version =
0100= 4 -
IHL =
0101= 5 × 4 bytes = 20-byte header
Byte 2 — DSCP/ECN
00 hex = 0000 0000
-
DSCP = 000000
-
ECN = 00
Bytes 3–4 — Total Length
00 54 hex → 0x0054 → 84 bytes
⭐ PART 7 — ARP Packet Example (MAC + IP in binary/hex)
Example ARP request (simplified):
Sender MAC: AA-BB-CC-11-22-33
Sender IP: 192.168.1.10
Sender IP in hex:
ARP field dump (simplified):
Binary:
⭐ PART 8 — TCP Header Example (16-bit and 32-bit fields)
TCP Source Port: 443
-
Decimal:
443 -
Hex:
01BB -
Binary:
0000 0001 1011 1011
Sequence number (32 bits):
Example: 0xABCD1234 → 128-bit hex notation becomes useful.
⭐ PART 9 — Hex is Everywhere in Protocols
-
VLAN tags: 0x8100
-
EtherType fields:
-
IPv4 = 0x0800
-
IPv6 = 0x86DD
-
ARP = 0x0806
-
-
TCP flags are individual bits inside a byte
-
STP BPDUs have fields like:
-
Root Priority:
0x8000 -
Bridge ID uses MAC + priority (combination of hex + binary)
-
⭐ PART 10 — Quick Conversion Table (for your brain)
Hex → Binary
| Hex | Binary |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
| A | 1010 |
| B | 1011 |
| C | 1100 |
| D | 1101 |
| E | 1110 |
| F | 1111 |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.