Protocol Fundamentals Series

📜 Understanding What a Protocol Actually Is From a "Top 1%" Perspective — The Design Philosophy Behind Communication Agreements

Introduction

This article is part of the Top 1% Series’ full article guide, and the first article in a new series on protocol fundamentals. It assumes you understand protocol layering (encapsulation) from Understanding the Network Stack from a “Top 1%” Perspective.

Prerequisites

Getting the Big Picture

The Three Elements a Protocol Is Made Of

A protocol’s “agreement” can, in practice, be broken down into three elements.

graph TB
    Protocol["Protocol (an agreement)"]
    Protocol --> Syntax["Syntax<br/>What byte sequence/format represents the data"]
    Protocol --> Semantics["Semantics<br/>What each field/message actually means"]
    Protocol --> Timing["Timing / state<br/>In what order messages may be exchanged"]

Communication only succeeds once all three of these elements exactly match between the two communicating parties. Conversely, as long as these three elements match between them, it functions as “a protocol,” no matter what the data looks like, or who defined it. This is the most essential answer to the question, covered later, of “can you design your own custom protocol?”

Fundamentals, Explained Thoroughly

Syntax: How Data Gets Laid Out

Syntax is the rule defining exactly what byte sequence represents the data being communicated. Protocol syntax design broadly splits into two directions.

KindCharacteristicsRepresentative examples
Text-basedRepresents data as a string, directly readable by a human eyeHTTP (request lines and headers as newline-delimited strings), SMTP, the FTP control channel
BinaryA byte sequence with each field’s position and length fixed in advance, optimized for machine processingSMB (CIFS), TLS’s record layer, the IP/TCP/UDP headers themselves

A text-based protocol is easy to visually inspect and debug even without a tool like Wireshark, and easy to extend later — such as adding a new header field. A binary protocol, on the other hand, has the advantage of representing the same information in fewer bytes, and parsing it much faster. Which of “ease of use for humans” and “efficiency for machines” to prioritize when designing a protocol is a clear design decision, determined by that protocol’s intended use.

Even within syntax, there are further variations in how variable-length data gets represented

For data that can’t be represented with fixed-length fields alone (such as an HTTP URL, whose length varies each time), a protocol’s syntax mainly has two approaches. The delimiter approach treats everything up to a specific character (for HTTP, the newline CRLF) as one piece of data. The length-prefix approach places a numeric field indicating the data’s length before the data itself (adopted by many binary protocols). The delimiter approach pairs well with text-based protocols, and the length-prefix approach pairs well with binary protocols.

Semantics: What a Field Actually Means

Semantics is the rule defining what an individual field or message, carved out by the syntax, concretely means. For example, HTTP’s status code 200 has no inherent meaning of its own as a number. Only once both communicating parties share the convention (the semantics) that “the number 200 means success” ahead of time does this number function as a message.

Timing / State: In What Order Things Are Exchanged

Timing (state) is the rule defining which messages may be exchanged at which point, and in what order. This ties into viewing a protocol as a finite state machine.

Why Do Protocols Have “Layers”?

The layered structure (encapsulation) covered in Understanding the Network Stack from a “Top 1%” Perspective isn’t an absolute necessity, like a physical law — it’s a design choice for divide-and-conquer of complexity. Each layer’s protocol only interprets its own header portion, and passes along the content that follows (the payload) as-is, on the premise that “I don’t need to understand this, but the next layer will handle it correctly.” This division of responsibility keeps each individual protocol’s design and implementation simple.

Not every protocol sits neatly on top of the transport layer

As covered in Understanding the Relationship Between TCP/UDP “Sessions” and Port Numbers from a “Top 1%” Perspective, protocols like ICMP, ESP, AH, and GRE don’t sit on top of a port-based transport-layer protocol like TCP/UDP — they’re positioned directly under IP, roughly on par with IP itself. Not every piece of communication fits neatly into the “application layer → transport layer → network layer” hierarchy — an important premise for understanding protocols as a whole. The next article digs into ICMP, the most common representative example of this.

The View From the Top 1% Perspective

Why You Can Design Your Own Custom Protocol

Coming back to the understanding above — “a protocol is an agreement that holds as long as three elements (syntax, semantics, timing) match between both parties” — the answer becomes clear. Approval by a standards body like the IETF isn’t a required condition for something to function as a protocol. A protocol published and standardized as an RFC is simply “a shared, publicly agreed-upon convention that lets anyone in the world interoperate with anyone else” — nothing more. A private, unpublished set of syntax, semantics, and timing rules independently agreed upon by two communicating parties (say, a client and server within some company’s internal system) also functions as a technically legitimate “protocol,” as long as it matches between those two parties. In fact, many companies’ internal systems use protocols that communicate in an unpublished, proprietary binary format.

How an Unencrypted Custom Protocol Gets Analyzed

Even for a custom protocol, if it isn’t encrypted, anyone can observe its raw byte sequence with a packet capture tool like Wireshark. Even if the syntax and semantics aren’t published, reverse engineering (analysis) is attempted through approaches such as:

A custom protocol has “secrecy” in the sense of not being publicly documented, but that doesn’t guarantee its content can’t be read or analyzed, unless it’s encrypted. If you want to prevent a third party from reading the content of communication, you need to separately incorporate encryption (such as TLS), independent of whether the protocol itself is custom.

Common Misconceptions and Pitfalls

The Troubleshooting Perspective

Investigation stalling due to a shallow understanding of protocols can be prevented by always being conscious of “which layer’s, which protocol’s header am I looking at right now.”

  1. You look at a packet capture but can’t judge what’s happening: Using the display filters covered in How to Use Wireshark, narrow down to just the protocol at the layer you want to focus on first (IP, TCP, a specific application-layer protocol, and so on), and confirm that layer’s syntax and semantics one at a time.
  2. You need to investigate communication using an unknown custom protocol: Capture traffic before and after a known operation, and try to infer syntax and semantics by comparing the differences.

Preventive Measures and Permanent Fixes

Summary

What to Keep in Mind From Today

  1. When you encounter a new protocol, build the habit of breaking it down into syntax, semantics, and timing to understand it.
  2. Rethink the word “protocol” as a broader agreement, not limited only to things that sit on top of TCP/UDP.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).