Saturday, November 29, 2025

Bits, Bytes, and Hex

 

⭐ 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:

Binary: 1010 Decimal: 10 Hex: A

Byte

  • 8 bits = 2 nibbles

  • Can represent 0–255 decimal

Example:

Binary: 11001100 Nibbles: 1100 1100 Hex: CC Decimal: 204

⭐ 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:

AA-BB-CC-11-22-33

Let’s decode the first byte:

First byte: AA

HexBinary
A1010
A1010

So AA in binary:

1010 1010

The entire MAC in binary:

AA BB CC 11 22 33 1010 1010 1011 1011 1100 1100 0001 0001 0010 0010 0011 0011

Important MAC-level bits:

The first byte contains two special bits:

BitMeaning
LSB of first byteUnicast (0) / Multicast (1)
2nd LSBGlobally unique (0) / Locally administered (1)

Example:
AA = 10101010

  • LSB = 0Unicast

  • Next bit = 1Locally administered MAC


⭐ PART 4 — IPv4 Addresses

(32 bits = 4 bytes = 8 hex digits)

Example IPv4 address:

192.168.1.10

Break into bytes:

  • 19211000000C0

  • 16810101000A8

  • 10000000101

  • 10000010100A

IPv4 in hex:

C0 A8 01 0A

IPv4 in binary (all 32 bits):

11000000 10101000 00000001 00001010

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:

2001:0db8:85a3:0000:0000:8a2e:0370:7334

Each group is 16 bits (2 bytes):

  • 2001 in 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:

45 00 00 54

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:

C0 A8 01 0A

ARP field dump (simplified):

AA BB CC 11 22 33 C0 A8 01 0A

Binary:

[48 bits MAC] [32 bits IP] 10101010 10111011... 11000000 10101000 00000001 00001010

⭐ 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

HexBinary
00000
10001
20010
30011
40100
50101
60110
70111
81000
91001
A1010
B1011
C1100
D1101
E1110
F1111

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

LWAPP (Lightweight Access Point Protocol)

  LWAPP was Cisco’s original tunneling + control protocol used between lightweight APs and a Wireless LAN Controller (WLC) before CAPWAP bec...