Back to Course
Chapter 05 • 06

The Grand Master Gauntlet: 15 Production Engine Builds

12 Lessons • Hands-on practice

01

Type-Length-Value (TLV) Binary Stream Parser

Binary protocols prefer Type-Length-Value (TLV) encoding over JSON for speed and compact size. Each frame specifies a 1-byte tag, a 2-byte big-endian length, and raw payload bytes. Parsing streams requires strict boundary checking to prevent buffer over-reads.

Start
02

Bit-Packed Status Bitmask (64 flags in 8 bytes)

Storing 64 individual booleans in Python dictionaries consumes over 1,500 bytes of heap memory. A bitmask packs 64 boolean flags into an 8-byte unsigned integer (uint64) using bitwise shifts and masks, delivering microsecond operations with zero memory waste.

Start
03

WebSocket Frame Encoder (RFC 6455)

WebSocket frames encapsulate payload data with bitfields for FIN, opcode, mask flag, and variable-length payload lengths (7-bit, 16-bit, or 64-bit). Client-to-server frames must be XOR-masked with a 4-byte key to prevent malicious intermediary cache poisoning.

Start
04

DNS A-Record Packet Unpacker

DNS operates primarily over UDP using compact binary structures defined in RFC 1035. Unpacking DNS responses requires navigating a 12-byte header, skipping length-prefixed domain labels in question sections, and extracting 4-byte IPv4 addresses from Type 1 (A) resource records.

Start
05

Fixed-Header Packet Chunk Reassembler

TCP streams deliver arbitrary byte chunks rather than discrete application messages. A single read may contain a partial packet or multiple concatenated packets. Reassembling packets requires buffering incoming bytes and decoding fixed headers containing magic numbers and declared lengths.

Start
06

Network Endianness Converter: Big vs Little Endian

Network protocols standardize on big-endian byte order (most significant byte first), whereas modern x86 and ARM client CPUs run in little-endian. Converting multibyte numbers across byte boundaries requires bit manipulation or struct format specifiers (> for network, < for little-endian).

Start
07

Tarball Header Block Parser (POSIX ustar)

The Unix tar archive format organizes files into contiguous 512-byte blocks without central directory records. Each file begins with a 512-byte POSIX ustar header containing null-terminated file names and base-8 octal ASCII strings for sizes, modes, and timestamps.

Start
08

PNG Chunk Reader & CRC Checksum Validator

Portable Network Graphics (PNG) files stream chunks containing a 4-byte length, 4-byte type code, variable data payload, and a 4-byte CRC-32 checksum. Validating PNGs requires verifying the 8-byte file signature and calculating CRC-32 over chunk types and data.

Start
09

IP Address & CIDR Subnet Calculator

IPv4 addresses are 32-bit unsigned integers disguised in dot-decimal notation. Classless Inter-Domain Routing (CIDR) applies a bitmask of prefix length to partition networks. Calculating netmasks, network roots, and host membership requires pure bitwise AND, OR, and NOT operations.

Start
10

Variable-Length Quantity (VLQ / LEB128) Codec

Storing small integers in fixed 64-bit slots wastes 87% of payload space. Variable-Length Quantity (LEB128/Varint) encodes integers using 7 payload bits per byte. The most significant bit (0x80) serves as a continuation flag, compressing small numbers into a single byte.

Start
11

ZigZag Integer Encoding / Decoding

Standard Varints represent negative integers using two's complement, bloating small numbers like -1 into 10-byte sequences. ZigZag encoding maps signed integers to positive values by interleaving positive and negative numbers, allowing small negatives to compress into 1 byte.

Start
12

Raw ICMP Echo Request Packet Crafter

The Internet Control Message Protocol (ICMP) underpins network diagnostic utilities like ping. An Echo Request packet consists of an 8-byte header (type 8, code 0, identifier, sequence number, and a 16-bit one's complement Internet Checksum) followed by arbitrary payload data.

Start