$ ss -tulnp && openssl s_client -tls1_3 -connect host:443

Networking, Transport & Data Formats

// from struct in memory to packets on the wire

End-to-end wire path

End-to-end path: serialization, TLS 1.3, transport, network devices, and server stackFive stages from left to right: 1 Data Serialization (JSON, CBOR, Protobuf, FlatBuffers), 2 Application and TLS 1.3 (HTTP/2-3, gRPC, Public-Key ECDHE + X.509 + AEAD), 3 Transport (TCP, UDP, QUIC), 4 Network Components (L2 Switch, OpenWrt/NAT/Firewall, BGP Router, L4/L7 Proxy), and 5 Server Stack (Bare-metal, VM, Container, Serverless running Web, App, DB, Cache, Queue).1. SERIALIZATION2. APP + TLS 1.33. TRANSPORT4. NETWORK (L2–L7)5. SERVER STACKWire FormatJSON / CBORProtobuf / AvroFlatBuffers (0-copy)bytes ↔ structHTTP + TLS 1.3HTTP/2 · HTTP/3 · gRPCX25519 ECDHE + X.509AEAD (AES-GCM)forward secrecyTCP / UDP / QUICTCP: ordered streamUDP: raw datagramQUIC: 1-RTT, no HoLConn ID migrationNet ComponentsL2 Switch · VLANOpenWrt / NAT / FWBGP L3 RouterL4 LB · L7 ProxyServersBare / VM / MicroVMContainer / IsolateWeb · App · DBCache · Queue1234PACKET ENCAPSULATION ON THE WIRE (OUTERMOST → INNERMOST)L2 Ethernetsrc/dst MAC · VLANL3 IPv4 / IPv6src/dst IP · TTLL4 TCP / UDPsrc/dst Port · seq/CIDTLS 1.3 / QUICAEAD ciphertext + tagL7 PayloadHTTP frame + Protobuf/JSONL1–L2 / HardwareL3 IP / RoutingL4 TransportTLS / CryptoL7 App / Wire FormatCompute / App DataLoss / Fault

// tcp vs udp vs quic (http/1.1 → http/3)

Transport Protocols

TCP + TLS 1.3 (2 RTT, HoL blocking) vs QUIC / HTTP/3 (1 RTT, independent streams)Left panel: TCP + TLS 1.3 requires 1 RTT for SYN/SYN-ACK and 1 RTT for TLS ClientHello/ServerHello before sending HTTP/2 data; a single lost TCP packet stalls every multiplexed stream. Right panel: QUIC merges transport and TLS 1.3 into 1 RTT over UDP (0-RTT on resume), and packet loss only stalls its own stream.TCP + TLS 1.3 (HTTP/2) — 2 RTT coldCLIENTSERVERSYNSYN-ACK (1 RTT done)ACK + TLS ClientHello (key_share)ServerHello + Cert + Finished (2 RTT)HTTP/2 App Data (all streams share 1 TCP seq)1 lost TCP segment → kernel stalls ALL HTTP/2 streams (HoL blocking)QUIC over UDP (HTTP/3) — 1 RTT cold / 0-RTT resumeCLIENTSERVERQUIC Initial + TLS ClientHello (+ 0-RTT if PSK)ServerHello + Cert + Finished (1 RTT done)Stream 1 (independent delivery)Stream 3 (loss here does NOT stall Stream 1)Connection ID survives Wi-Fi → 5G IP change; headers encrypted
Sources: RFC 9000 (QUIC), RFC 9114 (HTTP/3), RFC 9293 (TCP).
PropertyTCPUDPQUIC (UDP + TLS 1.3)
Handshake RTT1 RTT (SYN / SYN-ACK / ACK); +1 RTT for TLS 1.3 = 2 RTT0 RTT (connectionless)1 RTT cold (transport + TLS 1.3 merged); 0-RTT resumed (replayable!)
Ordering & HoL BlockingStrict byte-stream order; 1 lost packet stalls ALL multiplexed HTTP/2 streamsUnordered datagrams; app handles loss/orderIndependent streams inside 1 connection; loss stalls only the affected stream
Encryption & OssificationHeaders plaintext → middleboxes inspect/drop new TCP optionsPlaintext unless wrapped (DTLS / WireGuard)Transport headers + ACKs encrypted; middleboxes see only UDP + short header
Connection MigrationTied to 4-tuple (srcIP, srcPort, dstIP, dstPort) → Wi-Fi→5G drops connectionStatelessIdentified by Connection ID → survives IP/NAT rebinding without reconnect
HTTP MappingHTTP/1.1 (1 req/conn or pipelining) & HTTP/2 (binary frames, HPACK, TCP HoL)DNS, VoIP, gaming, WireGuardHTTP/3 (QPACK header compression, no transport HoL)

// asymmetric key agreement → symmetric aead

Public Key Encryption & TLS 1.3

TLS 1.3 1-RTT Handshake workflowClient generates an ephemeral X25519 key pair and sends ClientHello with key_share and SNI. Server generates its ephemeral key pair, computes shared secret via ECDHE, derives handshake keys with HKDF, and replies with ServerHello plus encrypted Certificate, CertificateVerify signature over the handshake transcript, and Finished MAC. Client verifies the X.509 chain and transcript signature, derives application AEAD keys, sends Finished, and exchanges encrypted data.Clientephemeral (c_priv, c_pub)holds Root CA storeServerephemeral (s_priv, s_pub)holds X.509 cert + privkeyClientHello: cipher suites + SNI + key_share (c_pub: X25519 / X25519MLKEM768)1ServerHello (s_pub) → both compute ECDHE(c_priv, s_pub) → HKDF handshake keys2{EncryptedExtensions, Certificate (X.509), CertificateVerify (signed transcript), Finished}3Verify CA chain + SAN + sig → {Finished} + AEAD App Data (AES-256-GCM / ChaCha20)4{...} = encrypted under handshake keys. Ephemeral keys are zeroed → Forward Secrecy.
Sources: Cloudflare TLS, Cloudflare Public Key Encryption, RFC 8446 (TLS 1.3).
MechanismHow it worksSecurity Consequence
Hybrid EncryptionAsymmetric crypto (X25519 / RSA / ECDSA) is ~1000× slower than symmetricTLS uses asymmetric crypto ONLY for key agreement + server AuthN, then switches to AEAD (AES-256-GCM or ChaCha20-Poly1305) via HKDF
Forward Secrecy (ECDHE)Ephemeral Diffie-Hellman keys per session, discarded after handshakeTLS 1.3 removed static RSA key exchange: stealing the server's private key later cannot decrypt previously recorded traffic
0-RTT Early DataClient sends app data in first flight using PSK from a prior sessionNOT replay-safe across servers: only allow idempotent GET requests, never state-changing operations
PKI & RevocationServer presents X.509 cert chain signed by a trusted Root CAValidate hostname (SAN) + chain + expiry; Certificate Transparency (CT) detects rogue CAs; OCSP stapling avoids client-side revocation lookup leaks
mTLS (Mutual TLS)Server ALSO requests and verifies the client's X.509 certificateCore building block of Zero Trust service meshes (SPIFFE/SPIRE): authenticates both endpoints at L4/L5 before L7 runs

// l2 switches, openwrt routers, bgp & l4/l7 proxies

Network Components

Packet path across L2, L3 (OpenWrt/BGP), L4, and L7 network componentsSix components left to right: L2 Switch (MAC/VLAN), Edge Router / OpenWrt (L3 IP, NAT, nftables, SQM), Internet BGP (AS-path routing), L4 Load Balancer (DSR/TCP passthrough), L7 Reverse Proxy or API/LLM Router (TLS termination, Envoy/OpenRouter), and Backend service.L2 SwitchMAC table802.1Q VLANsame subnetOpenWrt / FWL3 IP + NATnftables · SQMWireGuardBGP RouterAS-pathL3 prefixesFRR / VyOSL4 Load Bal5-tuple hashDSR / passthruno TLS termL7 Proxy / RtrTLS term · WAFEnvoy / NginxAPI/LLM routerBackendApp / DBprivate VPCL2 framesL3 LAN ↔ WANL3 packetsL4 TCP/UDPL7 HTTP/gRPC
Sources: OpenWrt Docs, FRRouting, WireGuard, OpenRouter.
ComponentLayerWhat it inspects / rewritesHard Detail
L2 SwitchL2 (Frames)Forwards by MAC address table + 802.1Q VLAN isolationDoes not route across IP subnets; broadcast domain boundary is L3
Router / OpenWrtL3 (Packets)Routes IP prefixes (OSPF/BGP), runs NAT/masquerade, stateful nftables firewall, DHCP/DNSOpenWrt brings Linux netifd, VLANs, WireGuard & SQM/CAKE (anti-bufferbloat) to embedded routers; VyOS/FRR/OPNsense cover DC/edge routing
NAT / Stateful FirewallL3–L4Rewrites src/dst IP:port via conntrack table; drops unsolicited inbound packetsNAT is address sharing, NOT a security architecture; symmetric NAT breaks P2P/UDP hole punching
L4 Load BalancerL4 (TCP/UDP)Distributes connections by 5-tuple hash; supports DSR (Direct Server Return) & TLS passthroughVery high throughput, low latency, but blind to HTTP paths/headers/cookies
L7 Reverse Proxy / WAFL7 (HTTP/gRPC)Terminates TLS, routes by host/path, enforces rate limits, AuthN/AuthZ, header hygiene (Envoy, Nginx)Sees plaintext payload; must preserve X-Forwarded-For safely (strip untrusted client headers!)
API / LLM RouterL7 (App)Routes model/API calls across providers with fallback, quota, token accounting (e.g. OpenRouter, Envoy AI Gateway)Adds unified auth/billing and failover, but introduces an extra trust hop for sensitive prompts
VPN (WireGuard / IPsec)L3 TunnelEncapsulates IP packets in authenticated encrypted UDP (Noise_IK in WireGuard)WireGuard is stateless-looking (silent drop on bad MAC, ~4k LoC, kernel-space); still needs Zero Trust L7 AuthZ inside

// deployment models × functional roles

Types of Servers

Server deployment models: isolation vs density spectrumFive deployment models from strongest hardware isolation on the left to highest density and fastest cold start on the right: Bare Metal, Type-1 VM (KVM), MicroVM (Firecracker), Container (shared Linux kernel with namespaces and cgroups), and Serverless / V8 Isolates.← STRONGER ISOLATION / DEDICATED HARDWAREHIGHER DENSITY / FASTER COLD START →Bare Metal1 OS per physical boxzero hypervisor taxfull PCIe / HSM / GPUboot: minutesVM (KVM / ESXi)Type-1 hypervisorown guest kernelVT-x / SEV isolationboot: 10–60sMicroVMFirecracker / Kataminimal guest kernelvirtio-only devicesboot: ~125msContainershared host kernel!namespaces + cgroupsseccomp / AppArmorboot: ~50msFaaS / IsolatesLambda / V8 Isolatesruntime sandboxscale-to-zero billingboot: <5ms (isolate)Color = isolation boundary: Slate (hardware) · Blue (guest kernel / hypervisor) · Teal (shared host kernel) · Amber (L7 runtime isolate).
Functional TypeStateRolePrimary Bottleneck / Failure Mode
Web / Edge / CDNStatelessTLS termination, static assets, HTTP/3 edge cachingNetwork bandwidth / TLS handshakes
Application / APIStateless (ideally)Business logic, AuthZ, orchestration; scales horizontally behind LBCPU, GC pauses, downstream DB/RPC latency
Database (OLTP / OLAP)StatefulACID transactions & durability (Postgres) or columnar analytics (ClickHouse)Disk IOPS, write locks, replication lag
Cache (Redis / Memcached)Ephemeral stateSub-ms RAM key-value reads, rate-limit counters, session storesMemory eviction, cache stampede (thundering herd)
Message Broker (Kafka / NATS)Durable log / queueDecouples producers/consumers, absorbs traffic spikes, replayable event streamsConsumer lag, partition skew, poison-pill messages

// json vs cbor vs protobuf vs flatbuffers

Data-Serialization Formats

Wire layout of { id: 42, ok: true } across JSON, CBOR, Protobuf, and FlatBuffersFour boxes comparing how the same record id=42, ok=true is encoded on the wire: JSON uses 21 ASCII bytes with repeated key names; CBOR uses 12 binary bytes with major-type tags; Protobuf uses 4 bytes with field numbers and varints; FlatBuffers adds a vtable and aligned offsets for zero-copy random access without parsing.SAME RECORD: { id: 42, ok: true } — WIRE REPRESENTATIONJSON (21 B){"id":42,"ok":true}ASCII text · no schemarepeats field namesmust parse full docCBOR (12 B)a2 62 69 64 18 2a62 6f 6b f5binary self-describingdeterministic mode (CDE)Protobuf (4 B)08 2a 10 01(tag#1=42, tag#2=1)needs .proto schemanon-canonical order!FlatBuffers (0-copy)[root offset][vtable][aligned fields in-place]read buf[off] directly0 parse, 0 heap allocColor = primary strength: Slate (human text) · Purple (canonical crypto signing) · Blue (compact RPC) · Green (zero-copy memory access).
Sources: RFC 8949 (CBOR), Protobuf Encoding, FlatBuffers, Comparison of data-serialization formats.
FormatWireSchema0-CopyStrengthHard Gotcha
JSONTextNoNoUniversal, human-readable, self-describingNo binary type (Base64 +33%), IEEE-754 loses precision > 2^53, repeats keys on every object
CBOR (RFC 8949)BinaryNoNoCompact JSON superset + native bytes/tags; deterministic CBOR (CDE) supports canonical crypto signing (COSE, WebAuthn)Smaller ecosystem than JSON; still carries field keys unless integer keys are used
MessagePackBinaryNoNoDrop-in binary JSON, very compact for small payloadsNo standard canonical form; less typed than CBOR tags
ProtobufBinaryYes (.proto)NoNumeric field tags + varint encoding; strong forward/backward evolution; default for gRPCNot canonical (field order & unknown fields vary → never sign raw Protobuf bytes directly)
Apache AvroBinaryYes (JSON schema)NoNo per-field tags on wire (smallest for bulk records); schema registry handles reader/writer evolutionReader MUST have exact writer schema to decode; poor fit for ad-hoc RPC
FlatBuffers / Cap'n ProtoBinaryYes (IDL)YesZero-copy random access directly from mmap/packet buffer via vtable offsets (no parse/alloc step)Larger wire size than Protobuf (alignment padding + offsets); stricter schema evolution