let’s build the internet from scratch!
📶

let’s build the internet from scratch!

why?

the internet is one of the most epic breakthroughs ever. it’s why you can read this!

yet almost no one knows how it works. tragic! 🥲

the best way to learn something is to just build it!

so let’s build it!

image

how

every sunday i build for 3-7 hrs

i’ve never done this before so i’m learning most of it as I go

i’ll live-stream when I can, if i can’t i’ll write notes!

i’m ~60% done and it’s amazing how much I’ve learned by just showing up to try

i’ll clean up notes + publish code + DIY guide once done!!

progress

part 1: tf is the internet? (4hrs) / June 5, 2022

extra notes from stream
tf is the internet

computer receives data: 0s and 1s

encode data into some format: 😃 HI! catpic.png, sandstorm.wav

image

change data into TCP packet

image

TCP: breaks down packets into tiny IP

image

computer software sends packets to hardware on computer via drivers/controllers

hardware sends data through the sky (wifi) or wires (ethernet) or some other way

data is received by another computer after going through routers/modems/ISPS etc

that other computer builds up the data

what makes internet internet

routers / modems

image

internet service providers

datacenter: store data /does compute

domain registars: GODADDY

URL

top-level domain names. .COM, .net

DNS

scope of what i wanna build
  • going to purely send IP address, no DNS/ISP
  • assume we have technology available as of 1990s, but nothing more
    • c++, python
  • payload gets from A to B at least once
    • payload is broken down into packets
    • all the packets get to other machine
    • message is recreated
    • latency/throughput/don’t matter
    • don’t care about lost packets sometimes
  • wireless: bcz cool
  • send meaningful data: a cat pic or text
given HTTP payload, convert to TCP→IP → raspberry pi

design

Software world

make a client: listens for HTTP

send HTTP request to another local process using sockets

Hardware world

  • hack raspberry pi to take in morriscode IP packets
    • implement morriscode pattern
    • other PI has mic that listens to morriscode, encodes packets into IP format
    • decodes to IP packets
    • encodes into HTTP format
    • prints cat text / pic
tangents

in physics: most things seem to be waves

  • wifi: radio waves
  • sonar: sound waves
  • LiFI: light waves
  • ethernet: cables. NOPE. magnetic waves

when was internet defined

when tcp/ip was made

the darkweb is just TCP/IP with proxies/encryption to hide from ISPs

part 2: Implementing the TCP/IP Handshake (4.5hrs) / June 12, 2022

part 3: Bit Hacking & Building a WIFI Driver (7 hrs) / June 26, 2022

part 4: How Radio Works + Designing Wifi Hardware (4hrs, July 17, 2022)

note: caught flu so no live stream, here are rough notes I took from the morning!

How does a Wifi device work?

wifi device 1 ——> radio waves(bits) ——> wifi device 2

wtf is going on

What are radio waves?

  • like a bunch of slinkies that travel through the sky, or water, or some other medium
  • the slinkies are “energy”

tangent: is physics “true”?
i suspect physics models are much stronger than say a soft-science like psychology, or an API in golang. because physics + math models have more proof that they work. i.e., a golang library is built on some assumptions on the libraries beneath it, which may fail, but physics doesn’t fail because we’ve built our whole society on top of it. if it failed we’d know lol.
secondly, many math/physics models can reach the same conclusion about some phenomena. We can have a number of different branches of math physics find similar patterns (find examples)

so tl;dr in physics we assume some equation is true based on observations + modelling, and from it we create planes, trains, etc and so via a crazy amount of eng progress that validate the principle is true.

this doesn’t mean it is true tho, perhaps we’ll extend out of our earth environment and models break. So laws of physics imo are only as valuable as the degree to which they let us built useful things on top of them

i suppose with physics we come up with principles that describe the world and haven’t been shown otherwise empirically… then we assume these things as “truths” and deduce more things from this. it’s like assuming an interface “works” and then building a library on top of it. if the interface fails you’re fucked. So its just functions input + outputs and we assume we know the function

a belief I have is that an idea or law or principle is only as valuable as the things you can do with it. so i care about chemistry/physics/math only insofar as you can build valuable things with them

a corollary from this, is that a great way to find which areas of physics/chemistry/math to learn, is to reverse engineer useful things and see what laws they depend on, and study those

aircraft, vaccines, anesthetics, antibiotic, engines (for cars etc), electricity, internet

what’s preventing teleportation? renewable energy? anti-death? AGI?

how are bits encoded in radio waves?

thing called modulation

waves have frequency (how fast they are) and amplitude (how high they go)

you can modulate along these 2 things

here’s Amplitude Modulation (AM)

[figure]

here’s how u put 0/s and 1/s in Frequency Modulation (RM)

[figure]

tangent: Why does wifi only travel up to ~100ish meters? why not 10000?

limited power/amplitude, you could make it go further!

tangent: Do waves interfere? Like what if a bunch of wifi devices are running won’t they cause a bunch of noise and interrupt each-other like slinkies slamming into eachother

yep if you have multiple wifi signals on the same channel they will intefere

wifi channel is range of frequencies

so if you live near people and they have wifi running on the same frequency you’ll prob interfere

2.4 GHz and 5 GHz are the main frequencies

2.4GHZ has 14 channels but only 3 are non-overlapping

but only 3 don’t overlap

so if you have >3 people using 2.4GHZ you’ll have interference unless you physically block it with strong walls separating your houses

5GHZ has 24 non-overlapping channels so much less likely of major interference

tangent: so if wifi interference is a thing can i just blast a signal that knocks out wifi in a region?

EMPs? otherwise wifi signals don’t travel very far so not as big a problem

the amplitude of radio wave is based on how much energy is put into it

can use an amplifier + higher power source to make wave bigger

then in theory you could send a normal 2.4GHz wifi signal further out, and increase risk of conflict with other wifi devices

if you blast packets you can confuse networks a bunch to make them deauthenticate by sending them shutdown requests

ok so design looks like this

image

Each compute has a tranceiver + antenna

tranceiver sends/receives radio signals and converts to from digital 0/1s

tranceiver has 2 components: transmitter, receiver 😮 🧠

transmitter has a modulator to turn 0/1s into waves, and amplifier to make the waves thicc

image

receiver design: demodulator to go from waves to 0/1s, and amplifies to make smol

image

Do we need a raspberry or adruino even?

probably easier to program/interface /w the hardware using

but in theory prob could just plug this into my laptop port

don’t wanna break my shit so i’m gonna get a pi lol

how do i build a transceiver?

that seems lame

it has tcp/ip built in

that’s not building from scratch

let’s zoom in 🔍

image

so tranceiver has an amplifier + modulator + demodulator

one caveat to think about since i’m only sending to/from one device i don’t gotta do scanning for networks do need 802.11 packet frame tho so receiving device can partition an incoming signal into a packet and then store that packet on compute to be processed

anyway…

how to build an amplifier

lmfao this almost looked like satire but its legit i love tech

how to build a modulator

ok so at this point I roughly get how radio works at a high level, and know there’s a few hw components needed

computer 1 writes packet to arduino/pi etc wifi controller

wifi controller converts the packet file into wifi frames (0-1s)

wifi frame is sent through transceiver on board

transceiver first modulates signal into FM radio, then antenna amplifies it

another transceiver on other side has antenna & de-modulator to receive signal

signal is read onto wifi controller:

this is a state machine that reads 0/1s and outputs wifi IP packets

IP packets stored in buffer and written to filesystem over USB connection to other laptop

if this flow works then my tcp/ip handshake will handle the rest, so long as this HW reads/writes successfully

next up… finish designing WIFI hardware, buy parts!

part 5: Buying HW

notes

falling back from building radio from scratch. not necessary bcz radio was a primitive that existed >50 years before the internet

What I have

raspberry pi 3 A+ + power cable + microSD card (for OS) + breadboard

jumper cables: help spread out bread board layout

2x raspberry pi

found this tutorial: https://pimylifeup.com/raspberry-pi-on-screen-keyboard/

going to try sending fm radio through gpio4 pin on raspberry pi 3 A+

flashed microSD card with RasbianOS, setup on the PI 3 A+, downloading updates… wild that this lil board has internet + g
flashed microSD card with RasbianOS, setup on the PI 3 A+, downloading updates… wild that this lil board has internet + g

tangent: the PI 3 A+ has 1gb GpU ram + 32gb storage on my ssd

if i find a way to load one layer of torch inference server 1 at a time i can technically do a full gptj inference on raspberry pi

tangent: this raspberri pi is more than 100 thousand times stronger compute than the control system that helped us get to the moon in the Apollo 11 mission

to setup the radio device followed this guide: https://www.section.io/engineering-education/broadcasting-a-pirate-fm-radio-station-using-a-raspberry-pi/

iphone seems blocked on this bcz it doesn’t have internal fm radio receiver so just uses apps that listen to stations and shares to iphone over wifi, not true radio

android has fm tuner but need wired headphones to act as receiver antenna