简体中文 / [English]


Implementing a TCP/IP Stack - Dnet Ep.0 Preface & Background

 

This article is currently an experimental machine translation and may contain errors. If anything is unclear, please refer to the original Chinese version. I am continuously working to improve the translation.

The goal of this blog series is to clearly and intuitively explain computer networking concepts by implementing a TCP/IP protocol stack from scratch. For more details, see Episode 0 of this series. The corresponding code is open-sourced at https://github.com/lyc8503/DNet-core.

Preface

Here I go again, digging a new rabbit hole on my blog. The motivation behind this series is that I’m currently taking a computer networking course in my undergraduate studies, but the textbook content always feels lengthy and dull. I thought, why not try to learn by doing? After all, “Reading about it gives only shallow understanding; true mastery comes from practice.”

So I decided to write my own TCP/IP stack, dig deeper into how it actually works under the hood, and share the journey here on my blog.


Previously, my blog posts were mostly about “recording” — documenting fragments of new or interesting technologies I’ve encountered. While jotting down isolated knowledge bits is easy, presenting a complex system in a structured and coherent way is much harder.

This time, I want to start from scratch and walk through the entire system in a smooth, connected narrative. Not just random fragments. It’s also a way to push myself to learn computer networking more systematically.

Of course, due to limitations in my time and expertise, this series won’t become a comprehensive computer networking tutorial (and there are already plenty of those out there). It will only cover the parts I need to implement my TCP/IP stack — primarily how end systems process network packets. I don’t aim to be exhaustive, but rather to offer a high-level “sightseeing tour” of modern network stack implementations.

If, by the end of this series, I (or you) gain a deeper understanding of today’s computer networks, appreciate some of the clever designs, or even spot certain flaws and form our own opinions, then all this typing will have been worth it.

And of course, if I make any mistakes due to my limited knowledge, please forgive my imperfection — and feel free to leave a comment or send me an email to correct me.

Enough talking. Let’s start.

Background

Ever since its birth, computer networking has aimed to solve a very simple problem: How can multiple computers exchange information?

Long ago, people might have used an RS-232 serial port to directly connect two computers and transfer data point-to-point. We could also manually transfer data using floppy disks, CDs, USB drives, or other physical media.

But as computers became more widespread, connecting every computer directly via serial cables or other data lines quickly became impractical.

Moreover, as computer networks continued to grow in scale, many real-world challenges emerged:

  • Interconnection of billions of computers

    Computers around the world need to communicate with each other. How do we find a path from one machine to another? How can we route traffic efficiently and avoid congestion?

  • Data reliability

    Electrical signals on transmission lines are inevitably subject to interference, leading to errors. Network devices may become congested, unstable, or even fail, causing data loss. How can we ensure that data sent from one computer arrives correctly and in order at the destination?

  • Data security

    Network links aren’t always trustworthy — for example, when we connect to the internet via public Wi-Fi. How can we protect our data from eavesdropping or tampering?

  • Scalability

    The entire computing industry is still evolving rapidly, with new requirements constantly emerging. Internet protocols should have some degree of extensibility to meet future needs for years to come.

  • ……

Today’s networking protocols adopt a layered architecture (which is why it’s called a network stack). In the upcoming posts, I’ll implement each layer from the bottom up, eventually building a working TCP/IP stack.

This article is licensed under the CC BY-NC-SA 4.0 license.

Author: lyc8503, Article link: https://blog.lyc8503.net/en/post/tcpip-0-background/
If this article was helpful or interesting to you, consider buy me a coffee¬_¬
Feel free to comment in English below o/