~ecs/ecs.d2evs.net

71e6199067fcc5af507722009af9761b9f7fa41d — Eyal Sawady 5 months ago 6db2481
Add _bits

Random bits that should turn into articles eventually
1 files changed, 68 insertions(+), 0 deletions(-)

A _bits/networking.md.w
A _bits/networking.md.w => _bits/networking.md.w +68 -0
@@ 0,0 1,68 @@
% # Copy-pasted without editing from an earlier draft of the
% # self-hosting article

Let's start at the highest level of abstraction. What most people call
the internet is actually the World Wide Web. The Web is a set of
documents, encoded in a programming language[^3] called HTML
(ironically, the name is an acronym for "HyperText Markup Language", it
was never meant to be a full programming language). These documents are
accessed via a protocol called HTTP[^4], the HyperText Transfer
Protocol.

[^3]: HTML+CSS is Turing-complete, and HTML+CSS+JS isn't even a Turing
  tarpit. While I'd argue that there's no place for downloading and
  executing arbitrary code from untrusted servers, thus is life. I hope
  for [Gopher](https://tools.ietf.org/html/rfc1436) and
  [Gemini](https://gemini.circumlunar.space/) to become more popular in
  the future.

[^4]: HTTP can also be used to access non-HTML documents. Most downloads
  use HTTP. In addition, most of the time, a similar protocol called
  HTTPS (HTTP Secure) is used. It's the same protocol, but encrypted.

HTTP is transported between computers as a series of bytes, which are
sent in a specific order and are guaranteed to all arrive exactly once,
as they were sent, and in order. However, no existing method of linking
computers can guarantee these properties. As such, there is a protocol,
TCP[^5], for guaranteeing those properties on top of an unreliable
network.

[^5]: The Transmission Control Protocol. There also exists an
  alternative protocol, UDP (the User Datagram Protocol), which has a
  much lower overhead but doesn't provide these guarantees.

TCP works on top of IP (the Internet Protocol), which gives each
computer[^6] an address, and allows there to be multiple "hops" between
computers. IP works on top of a variety of single-hop protocols,
including Ethernet, WiFi, DOCSIS (used by cable modems), DSL, PPP (used
for dial-up), and probably others.

[^6]: In practice, not all computers have a global IP address, but
  that's a topic for another day.

You'll note that nowhere here is there any distinction between a
"normal" computer and a server. That's because, fundamentally, they're
the same![^7]

[^7]: While many of the more computer-savvy readers will be unsurprised
  by this, the false dichotomy between clients and servers is
  surprisingly common.

There's one more protocol that I haven't mentioned yet: DNS (the Domain
Name System). This provides a mapping between human-readable names like
d2evs.net and IP addresses like 96.126.111.98.[^8] Since most ISPs don't
provide static IP addresses, it's not usually possible to host a server
from home.

[^8]: It also provides many more "records", for various other purposes.
  Yet another topic for a different day.

So how do you run a server? In practice, there are two ways: a VPS and
colocation. With a VPS, you pay some company some amount of money for a
virtual machine with (at least) one static global IP address. Colocation
is when you pay for a small space with an Ethernet port, a power outlet,
and cooling. Colocation is more appealing (more control is always
better!) and cheaper at a larger scale, but the cheapest VPS is a *lot*
cheaper than the cheapest option for colocation ($5/mo, and an extra
$10/yr for a domain name).