Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

hdp

> 编程语言
Open source

What would happen if we didn't use TCP or UDP?

357 stars0 likes0 views
WebsiteGitHub

About

What would happen if we didn't use TCP or UDP?

What would happen if we didn't use TCP or UDP?

Switches, bridges, routers, load balancers, firewalls—these network boxes keep the internet running. Routing, blocking, mirroring, duplicating and deduplicating traffic in ways most people never think about. Without them, this document wouldn’t have reached you

But the network is just one layer. The OS has its own way of handling packets—classifying, queuing, enforcing firewall rules, translating addresses, deciding what gets through and what gets dropped without a trace. Every part plays by its own rules, shaping what’s “allowed” and what's not

At some point, I wondered—what if I sent a packet using a transport protocol that didn’t exist? Not TCP, not UDP, not even ICMP—something completely made up. Would the OS let it through? Would it get stopped before it even left my machine? Would routers ignore it, or would some middlebox kill it on sight? Could it actually move faster by slipping past common firewall rules?

No idea.

So I had to try.

First, I sent the packets to myself, just to see how my own machine handled the poison I made up. Then, I sent them across continents to a remote Linux machine to see if they’d actually make it

Some background first

[!NOTE] Feel free to skip this section if you already know how the internet works. Otherwise, continue reading on

But wait—what exactly is a transport layer protocol?

The internet isn’t magic. It just looks that way. Underneath, it’s a stack of protocols, each one shoving data to the next until it reaches its destination. At the application level, you send a request—loading a website, streaming a video, or whatever you do. That request gets wrapped by the OS in multiple layers of metadata, addresses, and headers, until it’s nothing but raw bits flying through the network

It kinda works like this:

The diagram is 100% correct and should be included in all networking textbooks.

At the top, apps—browsers, games, whatever—generate requests (Load this page, Send this message, Connect to this game server). Then the requests start their descent through the network stack, getting wrapped, encoded, and addressed at each layer, until all that’s left is a stream of bits flying into the void

Each layer plays a role. IP assigns addresses and makes sure packets know where they’re going. The link layer handles the actual transmission—Wi-Fi, Ethernet, fiber optics, whatever. There’s more to it, but we’re not going down that rabbit hole right now. What matters is the layer that makes network communication actually usable

The transport layer is where networking personally starts to get interesting. It’s the first truly complex protocol layer. It doesn’t just move packets—it manages connections, makes sure multiple applications can share the same machine, and decides how data should flow.

This is where TCP, UDP, and their weird cousins live. The IP Protocol defines a field called Protocol. Setting this field to 6 means the encapsulated packet is TCP, 17 is UDP, and there are others defined but some numbers are deliberately left out for future use

But what if we used those unused numbers?

Experiment #1: Sending traffic.. to me!

There are simply too many variables to this experiment. My OS, my router, the receiver's OS, and god knows how many middle boxes are littered on the open internet. It's hard to extrapolate conclusions from experimentation with all these moving parts—so I thought of the following: To begin, I'll send the packets to my own machine, this guarantees that any results are solely due to my OS's behaviour

First, I designed a simple protocol: HDP. The specifics don’t matter—what matters is that it doesn’t resemble any known protocol. It’s an outsider, something the OS and network stack weren’t expecting

Next, I built a server, or a listener, whatever you call it. The machine running this code will be patiently waiting for any packets. Then I wrote a client, the machine running this code will send HDP packets to the server

Finally, here are the steps I'll attempt

  1. Startup an HDP server
    • Which will ask the OS to forward any packets with the protocol 255 to a socket it controls
  2. Run the HDP client, sending packets to my local machine
    • The client will ask the OS to nicely deliver the packets to 127.0.0.1
      • The OS is configured to hand packets with that target address to the loopback network interface
        • The loopback interface should realize: "uhhh.. this packet should go right back in?", and send it back to my own machine
  3. The OS delivers them to the HDP server unmodified..??

Let's do it

I opened two shells—one was the server:

haskell
$ sudo cargo run --bin server

And in another shell I opened the client

haskell
$ fortune | cowsay | sudo cargo run --bin client 127.0.0.1

Alright, let's send the packet via the client. 3, 2, 1, and..

The server got the message!

…

Success! The OS accepted my protocol, looped it back, and delivered it to the server with no shenanigans happening, unexpected!. But before calling it a day, I had another question:

What would happen if we repeated this experiment, whilst changing the protocol number defined in the IP packet?

My initial choice of 255 was arbitrary—it was an unused protocol number. But what if I tried something more… unconventional? I decided to test different protocol numbers, including:

  • 6, the number assigned to TCP packets
  • Or 2, which is the protocol number used for ICMP (i.e., the thing powering ping)
  • Or even 256, an index beyond the defined boundaries of the IP Protocol Would they make it? Would the OS freak out?

Let's see:

haskell
fortune | cowsay | sudo cargo run --bin client 127.0.0.1 # This time looping over protocol numbers

Results

Protocol Number Source IP (Server) Byte Sum (Server) Received (Server) Succeeded (Client) Byte sum (Client) Failure reason (Client) Time difference (μs)
0 127.0.0.1 373 373 - 70
1 nan nan 373 - nan
2 nan nan 373 - nan
3 127.0.0.1 373 373 - 61
4 127.0.0.1 373 373 - 52
5 127.0.0.1 373 373 - 54
6 nan nan 373 - nan
7 127.0.0.1 373 373 - 77
8 127.0.0.1 373 373 - 63
9 127.0.0.1 373 373 - 66
10 127.0.0.1 373 373 - 52
11 127.0.0.1 373 373 - 52
12 127.0.0.1 373 373 - 63
13 127.0.0.1 373 373 - 63
14 127.0.0.1 373 373 - 50
15 127.0.0.1 373 373 - 80
16 127.0.0.1 373 373 - 64
17 nan nan 373 - nan
18 127.0.0.1 373 373 - 42
19 127.0.0.1 373 373 - 82
20 127.0.0.1 373 373 - 71
21 127.0.0.1 373 373 - 59
22 127.0.0.1 373 373 - 50
23 127.0.0.1 373 373 - 51
24 127.0.0.1 373 373 - 54
25 127.0.0.1 373 373 - 46
26 127.0.0.1 373 373 - 48
27 127.0.0.1 373 373 - 43
28 127.0.0.1 373 373

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言