|
DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
|
This follows on from The OSI model. If you have not read that yet, read it first - this page builds on the layer idea.
The OSI model has seven layers and is the great teaching map. But the real internet was built on a more practical model with four layers, called TCP/IP (after its two most famous protocols, TCP and IP). It describes the same journey - it just groups some of OSI's layers together.
So TCP/IP's Application layer rolls OSI's top three into one, and its Link layer rolls OSI's bottom two. Same reality, fewer boxes. (Encryption, TLS, does not get its own number in either model - it tucks in just under the application data. This library keeps it in its own tls/ folder.)
IP (Internet Protocol) is the Internet/Network layer. Its one job: take a chunk of data, wrap it in a header that says where it is going and where it came from, and let the network's routers forward it hop by hop toward the destination.
192.168.1.85 (IPv4: four numbers 0-255). It is the "street address" of a device.TCP (Transmission Control Protocol) sits on top of IP (the Transport layer) and provides what most programs actually want: a reliable, ordered stream of bytes. You put bytes in one end; the exact same bytes come out the other end, in order, with nothing missing - even though the IP packets underneath were unreliable.
TCP pulls this off with a few tricks:
UDP (User Datagram Protocol) is TCP's minimalist sibling, also at the Transport layer. It just sends a packet (a datagram) and forgets about it - no handshake, no ACKs, no ordering. It can be lost without anyone noticing.
Why would you ever want that? Speed and simplicity. For things like a sensor shouting a reading every second, or DNS lookups, losing one is no big deal and the overhead of TCP is not worth it. This library uses UDP for exactly those cases (DNS, telemetry casts, the captive-portal responder).
| TCP | UDP | |
|---|---|---|
| Reliable delivery | yes (re-sends lost data) | no |
| Keeps order | yes | no |
| Connection setup | yes (handshake) | no |
| Speed / overhead | more overhead | very light |
| Good for | web pages, files, anything that must arrive | live telemetry, DNS, discovery |
One machine (one IP address) runs many network programs at once: a web server, maybe an SSH login, a sensor feed. A port number (0-65535) says which program a message is for. The IP address finds the machine; the port finds the program on it.
Some ports are conventional: 80 = HTTP (web), 443 = HTTPS (encrypted web), 22 = SSH, 53 = DNS. When this server starts with server.begin(80), it is saying "deliver anything arriving on port 80 to me".
The combination IP address + port (e.g. 192.168.1.85:80) uniquely identifies one endpoint of a conversation. A TCP connection is really four numbers: your IP+port and their IP+port.
Say your ESP32 runs this library at 192.168.1.85 and you open http://192.168.1.85/ in a browser:
192.168.1.85:80 (the three-way handshake). Now there is a reliable byte-pipe between the two.GET / HTTP/1.1 plus some headers (Application layer). TCP carries them reliably; IP routes the packets; Wi-Fi moves the bits./.Every numbered step maps to a folder in src/network_drivers/. That is the whole point: the theory you just read is the shape of the code.