Revisiting computer networking

Derek Wang22 min read

Layers and encapsulation, IP and routing, reliable TCP transport, DNS, and HTTP. Includes an HTTPS example and complete sequence diagram.

1. Basic concepts: layers and data flow

Layering and encapsulation

Five-layer teaching modelResponsibilityExamples
ApplicationDefine how applications exchange informationHTTP, DNS
TransportTransfer data between application endpointsTCP, UDP
NetworkForward packets across networks toward a destinationIP, routing
Data linkDeliver frames across an individual linkEthernet, Wi-Fi link functions
PhysicalTransmit signals representing bits through a mediumElectrical signals, light, radio waves
  • The seven-layer OSI model adds presentation and session layers between application and transport.
  • The four-layer TCP/IP model uses application, transport, internet, and link layers.

Presentation handles encoding and representation; session handles session management. TCP/IP includes these functions in other layers.

Encapsulation adds control information at each layer; decapsulation reverses the process. Unencrypted HTTP over TCP:

Text
Application:                            HTTP data
Transport:                 TCP header + HTTP data
Network:       IP header + TCP header + HTTP data
Link: frame header + IP header + TCP header + HTTP data + trailer
Physical: encode these bits as signals and transmit them

Same-layer peers communicate logically; actual data still travels through lower layers.

LANs, WANs, and access networks

  • A LAN, or local area network, connects a limited area such as a home or office.
  • A MAN, or metropolitan area network, covers a city-scale area.
  • A WAN, or wide area network, connects more distant regions.
  • An access network connects users to a provider's network.

Joining Wi-Fi provides access to a wireless LAN, not necessarily to the Internet.

Connection-oriented and connectionless service

ComparisonConnection-orientedConnectionless
Before communicationEstablish a connectionNo connection establishment required
StateEndpoints maintain connection stateMessages are handled independently
ExamplesTCPUDP, IP
Order and reliabilityDepend on the protocol; TCP provides a reliable, ordered byte streamUDP and IP do not themselves guarantee reliable, ordered delivery

A TCP connection is state maintained at both ends: sequence numbers, windows, and status. IP packets can arrive out of order; TCP delivers their bytes in order.

Five recurring protocol concerns

ConcernMeaning
AddressingIdentify where data comes from and where it is going
Error controlDetect corruption or loss, then correct or retransmit as the protocol specifies
Flow controlKeep a sender from overwhelming the receiver's buffers
Multiplexing and demultiplexingShare resources among communications and deliver received data to the correct endpoints
RoutingDetermine a path toward the destination

Scope differs: the link layer covers one link; TCP operates end to end.

2. Physical layer: turning bits into signals

Shannon capacity: the limit of a noisy channel

  • : theoretical channel capacity, in bit/s.
  • : channel bandwidth, in Hz.
  • : the ratio of signal power to noise power, expressed as a linear ratio.

Suppose:

Then:

If the signal-to-noise ratio is given in decibels, convert it first:

For example, corresponds to .

Capacity grows linearly with spectral bandwidth and logarithmically with signal-to-noise ratio. Coding and protocol overhead reduce usable throughput.

Units: spectral bandwidth uses Hz; data rate uses bit/s.

Wired and wireless transmission media

MediumCharacteristics and uses
Twisted pairCopper wires twisted together to reduce interference; common in Ethernet cabling
Coaxial cableA central conductor with shielding; used in systems such as cable television
Fiber opticsCarries light, offers high capacity and long reach, and is immune to electromagnetic interference
MicrowaveWireless transmission; directional links must account for line of sight and obstructions
InfraredCommon in short-range communication, such as remote controls
Communication satellitesBroad coverage; propagation delay depends on orbital altitude

Wavelength and frequency are related by:

is the speed of light in a vacuum; use propagation speed within a medium.

Carrier frequency (Hz) is different from data rate (bit/s).

Frequency, time, and wavelength division multiplexing

  • FDM, frequency division multiplexing: separate frequency bands.
  • TDM, time division multiplexing: separate time slots.
  • WDM, wavelength division multiplexing: different wavelengths in one fiber.

Framing: recognizing boundaries

Framing identifies individual frame boundaries within a bit stream.

MethodMechanismConsideration
Byte countRecord the frame lengthA corrupted length can disrupt boundary recognition
Flag bytes with byte stuffingMark boundaries with special bytes and escape matching bytes in the payloadThe receiver must undo the escaping
Flag bits with bit stuffingMark boundaries with a bit pattern and alter potentially conflicting payload patternsThe receiver removes the inserted bits
Physical-layer coding violationsUse special symbols that cannot occur as ordinary data in the encoding schemeDepends on the physical encoding

Bit stuffing: with 01111110 as a boundary, insert 0 after every five consecutive data bits set to 1. The receiver removes it, keeping data from matching the boundary.

Sliding windows: allowing multiple frames in flight

Stop-and-wait:

Text
Send 0 → wait for acknowledgment → send 1 → wait for acknowledgment → …

Waiting after every frame wastes transmission time. A sliding window permits multiple frames in flight; with a window of four:

Text
Currently allowed to send: 0, 1, 2, 3

After frame 0 is acknowledged:

The window advances to:    1, 2, 3, 4

Acknowledgments advance the window and allow new data to be sent.

At rate and round-trip time RTT, keeping a link busy requires approximately this much data in flight:

This is the bandwidth-delay product.

Go-Back-N and selective repeat

Suppose the sender transmits:

Text
0, 1, 2, 3, 4, 5

and frame 2 is corrupted:

BehaviorGo-Back-NSelective repeat
Receiver gets later frames 3, 4, and 5Usually discards themBuffers them
RetransmissionResends unacknowledged frames starting at the gapResends only missing or damaged frames
Receiver bufferingLowerHigher
Implementation complexityLowerHigher
Wasted bandwidth after lossHigherLower

Selective repeat accepts out-of-order frames but delivers them upward in order after filling the gap.

4. Network layer: addressing, routing, and forwarding

Distance vector: updating routes from neighbors' distances

Each router keeps its cost to each destination and exchanges that information with its neighbors.

For each neighbor , add the cost of reaching it to its reported cost to the destination, then take the minimum.

Candidate routes from J to C:

Via neighborCost from J to neighborNeighbor's reported cost to CTotal
A82533
I101828
H121931
K63642

J therefore records:

Text
Destination C: cost 28, next hop I

Cost can represent hops, delay, or another metric. Stale neighbor reports can cause loops or counting to infinity.

Discover neighbors and link costs → flood link-state information → run Dijkstra on the topology.

Seq. distinguishes newer information; Age helps expire old information.

Distance vectorLink state
Neighbors report their distances to destinationsRouters announce their direct connections and link costs
Update routes from neighbors' distancesCompute routes from the topology
Common mathematical basis: Bellman-FordCommon shortest-path algorithm: Dijkstra

Tunneling: adding an outer encapsulation

Encapsulating IPv6 across an IPv4 network:

Text
Before the tunnel:             IPv6 packet

Across the IPv4 network: IPv4 header + IPv6 packet

After the tunnel:              IPv6 packet

Intermediate routers use the outer IPv4 header; the exit removes it. Encryption depends on the tunneling protocol.

IPv4 header: information needed for forwarding

An IPv4 header is 20–60 bytes.

FieldPurpose
VersionIP version; 4 for IPv4
IHLHeader length in four-byte units; 5 means 20 bytes
Total LengthLength of the entire IPv4 packet, including header and data
Source / Destination AddressSource and destination IPv4 addresses, 32 bits each
TTLLimits continued forwarding to prevent indefinite circulation
ProtocolIdentifies the upper-layer protocol, such as 6 for TCP or 17 for UDP
Header ChecksumDetects corruption in the IPv4 header
Identification, Flags, Fragment OffsetSupport fragmentation and reassembly
Differentiated ServicesSupports functions such as differentiated service and congestion notification
  • Protocol is not a port number: it selects TCP, UDP, or another upper-layer protocol. A transport port then identifies an application endpoint.
  • The IPv4 header checksum does not cover the payload.

Fragmentation: DF forbids it, MF indicates more fragments, and offsets use eight-byte units.

IP addresses: from address classes to CIDR

Historical classes: A/B/C used default prefixes /8, /16, and /24; D is multicast and E is reserved.

CIDR uses the explicit /n to identify a network prefix. 127.0.0.0/8 is reserved for loopback. CIDR

For example:

Text
192.168.8.34/24

has a 24-bit network prefix and an eight-bit host portion.

Subnets and route aggregation

Consider a /24:

Text
Host address:      192.168.8.34/24
Subnet mask:       255.255.255.0
Network address:   192.168.8.0
Broadcast address: 192.168.8.255

An ordinary /24 broadcast subnet has 256 addresses, typically 254 available to hosts.

The network address is calculated by bitwise AND:

Route aggregation can combine these eight contiguous, aligned /24 prefixes:

Text
192.168.8.0/24
192.168.9.0/24
…
192.168.15.0/24

into a single prefix:

Text
192.168.8.0/21

Eight networks require three bits, giving the aggregate prefix length:

The third octet ranges from 8 through 15:

Text
8  = 00001000
15 = 00001111
     └───┘
     First 5 bits match

Shared prefix: 16 + 5 = 21 bits.

Covers 192.168.8.0–192.168.15.255. Route aggregation does not change the original LAN boundaries.

SNAT and DNAT

SNAT example:

Text
Source before translation: 10.0.0.1:5544
Source after translation:  198.60.42.12:3344

Both source address and source port change.

  • SNAT changes the source address, commonly for private hosts accessing an external network.
  • DNAT changes the destination address, commonly to map a public entry point to an internal server.

A DNAT example is:

Text
External destination: 203.0.113.5:8080
Internal destination: 10.0.0.10:80

The device records mappings and reverses them for return traffic. Address-and-port translation lets private connections share a public IP.

ARP, RARP, and DHCP

ARP resolves an IPv4 address to a MAC address on the local link.

For an external destination, resolve the next-hop gateway's MAC. The frame targets the gateway; the IP packet still targets the remote server.

RARP is a historical protocol for obtaining an IP address from a hardware address.

DHCP configures the IP address, subnet mask, gateway, and DNS server. Its initial DORA exchange:

Text
Discover → Offer → Request → ACK
Find a server → offer settings → request selected settings → confirm assignment

Addresses have leases that need renewal. DHCP

OSPF and BGP

An AS (autonomous system) is a group of networks with a unified routing policy, such as a provider network.

ProtocolMain roleMain approach
OSPFRouting within an autonomous systemLink state, shortest-path computation, areas
BGPExchanging routes between autonomous systemsPath attributes and routing policy

BGP selects routes using attributes such as AS paths and administrative policy, not necessarily shortest distance or lowest delay.

5. Transport layer: endpoints, reliability, and sending control

Ports and communication endpoints

IP provides network-layer addressing; ports distinguish application communication endpoints.

A TCP connection is commonly distinguished by a four-tuple:

Text
Source IP, source port, destination IP, destination port

For example:

Text
192.168.1.10:51000 → 203.0.113.20:443
192.168.1.10:51001 → 203.0.113.20:443

Different source ports distinguish these connections, letting one server port serve many connections.

UDP: transmission with message boundaries

A UDP header is always eight bytes, consisting of four 16-bit fields:

FieldPurpose
Source PortSource port
Destination PortDestination port
LengthTotal length of UDP header and data
ChecksumError detection

UDP preserves message boundaries. Upper layers handle loss recovery, ordering, and sending rate as needed.

Uses include DNS, real-time media, and QUIC. Low overhead does not guarantee a faster application.

Common service ports

PortService
21FTP control connection
20Common server data port for active-mode FTP
22SSH
25SMTP
80HTTP
110POP3
143IMAP
443HTTPS
554RTSP
631IPP printing protocol

These defaults can be reconfigured. IANA port registry

TCP header and byte sequence numbers

A TCP header is at least 20 bytes.

  • Sequence Number: the starting byte sequence number of this segment's data.
  • Acknowledgment Number: the sequence number the receiver expects next.
  • Window: the receive window advertised by the receiver.
  • Checksum: checks the TCP header and data, together with pseudo-header information.
  • Flags: including SYN, ACK, FIN, and RST.
  • Options: such as maximum segment size, window scaling, and timestamps.

TCP sequence numbers count bytes. Suppose a segment carries:

Text
SEQ = 1000
Data length = 500 bytes

The bytes occupy sequence numbers 1000–1499. Once received contiguously:

Text
ACK = 1500

ACK identifies the next expected byte, not the last received byte.

TCP has no message boundaries: two send() calls need not match two recv() calls. Applications delimit messages with lengths, separators, or similar mechanisms.

TCP's three-way handshake

TCP handshake with client initial sequence number 100 and server initial sequence number 500; both sides acknowledge the other's number.

The three-way handshake. Full-size figure · Mermaid source

  1. The client requests a connection and announces its initial sequence number.
  2. The server acknowledges the client's number and announces its own.
  3. The client acknowledges the server's number.

The third message confirms receipt of the server's initial sequence number and prevents old requests from directly creating incorrect connections.

SYN consumes one sequence number, which is why the acknowledgments add one.

TCP closing and half-close

Text
Client → server: FIN, I have no more data to send
Server → client: ACK, your sending direction is acknowledged as finished

The server can still send its remaining data…

Server → client: FIN, I also have no more data to send
Client → server: ACK, your sending direction is acknowledged as finished

Half-close: after sending FIN, an endpoint can still receive data.

ACK and FIN may be combined. FIN and SYN each consume one sequence number.

TCP state machine

Text
Active open:
CLOSED → SYN-SENT → ESTABLISHED

Passive open:
LISTEN → SYN-RECEIVED → ESTABLISHED

Typical active close:
ESTABLISHED → FIN-WAIT-1 → FIN-WAIT-2 → TIME-WAIT → CLOSED

Typical passive close:
ESTABLISHED → CLOSE-WAIT → LAST-ACK → CLOSED
  • CLOSE-WAIT: the peer sent FIN; the local application has yet to close its sending direction. Long-lived entries can indicate delayed application closure.
  • TIME-WAIT: retained state allows acknowledgment of retransmitted FINs and limits interference from old segments.

TIME-WAIT normally lasts 2MSL. MSL is maximum segment lifetime, not RTT. TCP closing

Flow control and congestion control

WindowProblem addressedWho determines it
Receive window rwndHow much data the receiver can acceptAdvertised by the receiver
Congestion window cwndHow much unacknowledged data the network should carryAdjusted by the sender from feedback

Outstanding data is mainly limited by:

Subtract outstanding data to find room for new data. TCP's Window field advertises rwnd; the sender maintains cwnd.

PhaseApproximate window behavior
Slow startStarts small and roughly doubles per RTT under ideal conditions
Congestion avoidanceSwitches to roughly linear growth after reaching a threshold
Retransmission timeoutReduces the window substantially and restarts slow start
Fast retransmit and fast recoveryUse duplicate acknowledgments to detect likely loss earlier and reduce sending intensity

Illustrative window growth:

Text
Slow start:           1 → 2 → 4 → 8
Congestion avoidance: 8 → 9 → 10 → 11

The initial value of one is illustrative.

Classic fast retransmit uses three duplicate ACKs to detect likely loss before timeout. Fast recovery reduces the window without returning to slow start every time. TCP congestion control

6. Application layer: DNS and HTTP

DNS namespace

Consider this domain name:

Text
robot.cs.washington.edu.

Read it from right to left:

Text
.               Root
edu             Top-level domain
washington      Next domain level
cs              Another domain level
robot           Specific name

The trailing dot denotes the root and is usually omitted. Different levels can be managed separately.

Name resolution uses the hostname within the URL:

Text
https://www.example.com/course?id=19
        └── domain ───┘└─ path and query ─┘

DNS resource records

TypePurpose
AIPv4 address for a name
AAAAIPv6 address for a name
CNAMEAlias pointing to another name
MXMail receiving server and preference
NSAuthoritative name server for a zone
SOAZone administration data, including serial number and refresh parameters
PTRName pointer used in reverse lookups
TXTText, often used for verification or mail policy
SRVService location, including target, port, and priority

SPF policies use TXT records. SPF

DNS queries and caching

With no cached answer, resolving robot.cs.washington.edu can proceed as follows:

  1. The computer asks its configured recursive resolver.
  2. The resolver asks a root server and receives information about .edu servers.
  3. It asks a .edu server and learns about servers for washington.edu.
  4. It follows any further delegation, such as to a server responsible for cs.washington.edu.
  5. It obtains the answer, returns it to the client, and caches it as allowed.
  • The client asks the recursive resolver to obtain a result on its behalf.
  • The resolver's successive queries to other servers are typically iterative queries.

Root servers normally refer the resolver to the next servers to ask.

DNS TTL is a cache lifetime; IP TTL limits forwarding. Cached answers avoid starting again at the root.

HTTP connection reuse

MethodSequenceMain effect
New connection each timeConnect → request → response, then connect againRepeats connection establishment costs
Persistent connection, sequential requestsKeep the connection and send the next request after the previous responseSaves setup costs but retains serial waiting
Persistent connection, pipelined requestsSend further requests without waiting for earlier responsesReduces request waiting, but response ordering remains constrained
  • HTTP/1.1 pipelining: send later requests early; responses remain ordered.
  • HTTP/2: interleave frames from multiple streams; missing TCP bytes can block those streams.
  • HTTP/3: use QUIC over UDP to reduce cross-stream transport head-of-line blocking. Version differences

HTTP methods and status codes

MethodMeaning
GETRetrieve a representation of a resource
HEADRequest metadata similar to GET without response content
POSTSubmit data for processing according to the target resource's semantics
PUTCreate or replace the target resource state with the supplied representation
DELETERequest removal of the association between the resource and its current functionality
OPTIONSQuery communication options
CONNECTEstablish a tunnel, commonly through a proxy
TRACERequest a diagnostic loopback

Idempotence: repeating a request has the same intended effect as performing it once, such as PUTting identical content. Status codes need not match. HTTP methods

RangeMeaningExamples
1xxInterim information100 Continue
2xxSuccess200 OK, 201 Created, 204 No Content
3xxRedirection or conditional-request outcomes301, 302, 304
4xxClient-related request problems400, 401, 403, 404
5xxServer-side processing failures500, 502, 503, 504
  • 401: valid authentication credentials are missing.
  • 403: the server understands the request but refuses to fulfill it.
  • 404: the requested resource was not found.
  • 304: a conditional request found no modification, so the stored representation can be reused; this is not an ordinary redirect.
  • 204: the request succeeded without response content.

HTTP headers and cache validation

PurposeTypical fields
Target and client informationHost, User-Agent, Referer
Content negotiationAccept, Accept-Encoding, Accept-Language
Authentication and stateAuthorization, Cookie, Set-Cookie
Content descriptionContent-Type, Content-Length, Content-Encoding
Caching and conditional requestsCache-Control, ETag, If-None-Match, Last-Modified, If-Modified-Since
Redirection and range requestsLocation, Range, Content-Range, Accept-Ranges
  • Accept states which types the client can receive; Content-Type identifies the type of the supplied content.
  • Accept-Encoding states supported content encodings; Content-Encoding identifies the encoding actually applied, such as gzip.
  • Set-Cookie asks the client to store a cookie; Cookie carries stored cookies on later requests according to the applicable rules.
  • ETag identifies a version of a representation; If-None-Match supplies a previously obtained tag for a conditional request.

Requests can also carry Content-Type and Content-Length.

HTTP/1.1 conditional request:

http
GET /index.html HTTP/1.1
Host: example.com
Accept: text/html
Accept-Encoding: gzip
If-None-Match: "v3"

The blank line ends the headers.

If the representation still matches "v3":

http
HTTP/1.1 304 Not Modified
ETag: "v3"
Cache-Control: max-age=60
  • Fresh cache: reuse directly, potentially without a request.
  • Validation required, resource unchanged: receive 304 and reuse the cache without retransferring the resource body.

Supporting example: connecting the layers through a product-page visit

Assumptions: Ethernet, IPv4, no usable cache or existing connection; DNS over UDP, website over HTTP/2 + TLS 1.3 + TCP. Addresses and port mappings are illustrative.

Product-page URL:

Text
https://shop.example.com/products/42?color=blue#reviews
RoleAddress
Computer192.168.1.10/24
Default gateway, the router's LAN interface192.168.1.1
Router's WAN interface198.51.100.23
Recursive DNS resolver192.0.2.53
Web server, discovered through DNS later203.0.113.80

Network configuration and URL parsing

DHCP first answers four configuration questions:

Text
What is my own IP address?
Which addresses are in my subnet?
Where should I send traffic for external destinations?
Which server should I ask for DNS answers?

Here the home router provides DHCP service. The client uses UDP port 68 and the server uses UDP port 67:

Text
Computer                         DHCP server
   |--- DHCP Discover -------------->|
   |<-- DHCP Offer ------------------|
   |--- DHCP Request --------------->|
   |<-- DHCP ACK --------------------|

DHCP settings; the exchange runs when obtaining or renewing a lease:

Text
IP address:      192.168.1.10
Subnet mask:     255.255.255.0
Default gateway: 192.168.1.1
DNS server:      192.0.2.53

The browser then parses the URL:

ComponentValuePurpose
SchemehttpsUse HTTPS
Hostshop.example.comHostname
PortDefault 443Service port
Path/products/42Resource path
Querycolor=blueQuery parameter
FragmentreviewsLocation within the page
Text
Use HTTPS,
connect to port 443 on shop.example.com,
and request /products/42?color=blue.

#reviews is handled by the browser and is not sent as part of the URL.

Routing and ARP before the DNS query can leave

The name-resolution question is:

Text
What is the IPv4 address of shop.example.com?

This query uses these endpoints:

Text
Source:      192.168.1.10:53000
Destination: 192.0.2.53:53
Transport:   UDP

The local subnet and selected route are:

Text
192.168.1.0/24
Text
Default route → next hop 192.168.1.1

The external DNS server is reached through the gateway. Without a cached gateway MAC, first broadcast:

Text
Who has IP address 192.168.1.1?
Tell 192.168.1.10 your MAC address.

The router replies, and the computer records the mapping:

Text
I have 192.168.1.1.
My MAC address is 02:00:00:00:00:01.
Text
192.168.1.1 → 02:00:00:00:00:01

The destination addresses at the two layers therefore differ:

Text
IP destination:    the DNS server's IP
Frame destination: the gateway's MAC

ARP has no TCP/UDP ports and resolves only the next-hop MAC. Here it precedes transmission of the DNS query.

Encapsulating the DNS query and resolving the name

The query gains headers at successive layers before being encoded as signals:

Text
Application layer
DNS query: what is the A record for shop.example.com?

       ↓ Add a UDP header

Transport layer
UDP: source port 53000, destination port 53

       ↓ Add an IPv4 header

Network layer
IPv4: source 192.168.1.10, destination 192.0.2.53

       ↓ Add an Ethernet header and trailer

Data link layer
Ethernet: computer's source MAC, gateway's destination MAC

       ↓ Encode and modulate signals

Physical layer
Send electrical signals through the cable

The router forwards the IP packet and creates a UDP NAT mapping. With no cached answer, the resolver queries the hierarchy:

Text
Computer
  |
  | What is the address of shop.example.com?
  v
Recursive resolver
  |
  +-- Ask a root server
  |    → Obtain a referral to .com name servers
  |
  +-- Ask a .com name server
  |    → Obtain a referral to example.com's authoritative servers
  |
  +-- Ask an authoritative server for example.com
       → shop.example.com's A record is 203.0.113.80

The resolved address and web service endpoint are:

Text
shop.example.com → 203.0.113.80
Text
Target service: 203.0.113.80:443

The resolver queries other servers using its own endpoints and caches results according to DNS TTL.

TCP through NAT and hop-by-hop forwarding

The computer selects temporary TCP port 51514:

Text
192.168.1.10:51514 → 203.0.113.80:443

The router maps it to a public endpoint, which becomes the source seen by the server:

Text
Internal TCP endpoint              Public endpoint
192.168.1.10:51514        ↔    198.51.100.23:62001
Text
198.51.100.23:62001

Packets travel through:

Text
Computer → home router → provider network → other networks → server's network → server

Routers consult forwarding tables, decrement TTL, and re-encapsulate for the outgoing link. Ordinary Layer 2 switches generally preserve source and destination MACs.

The product-page TCP handshake, with client initial sequence number 1000 and server initial sequence number 8000.

The example's handshake; every arrow travels through the lower network layers. Full-size figure · Mermaid source

TCP provides the reliable byte stream; TLS supplies authentication and encryption.

TLS handshake: authenticating and deriving keys

Full TLS 1.3 certificate handshake:

Text
Browser                                      Server
  |--- ClientHello ---------------------------->|
  |    Supported versions, algorithms, key share |
  |                                             |
  |<-- ServerHello -----------------------------|
  |<-- Encrypted extensions, certificate,        |
  |    signature proof, Finished                |
  |                                             |
  | Validate certificate and handshake messages |
  |--- Finished ------------------------------->|
  |                                             |
  |<--------- Encrypted application data ------>|
  • Verify the certificate hostname, trust chain, validity, and signature proof.
  • Derive communication keys through ephemeral key exchange; protect later data with symmetric encryption and integrity checks.

SNI identifies the requested server name. ALPN selects the application protocol, here h2 for HTTP/2. TLS 1.3 handshake

HTTP request, server processing, and response

After HTTP/2 initialization, the request fields are as follows; the wire format uses binary frames:

Text
:method: GET
:scheme: https
:authority: shop.example.com
:path: /products/42?color=blue
accept: text/html
accept-encoding: gzip, br

At the application level, this means:

Text
Return the blue version of product 42's page.
I want HTML and support the indicated content compression.

Request encapsulation and Ethernet frame structure:

Text
HTTP/2: encode the request into HEADERS and other frames
   ↓
TLS: encrypt and add integrity protection
   ↓
TCP: organize the byte stream into segments
   ↓
IP: add source and destination IP and other network fields
   ↓
Ethernet: encapsulate a frame for the gateway
   ↓
Physical: transmit as signals
Text
[Ethernet header][IPv4 header][TCP header][part of the TLS byte stream][FCS]

Layer boundaries need not align. HTTP/2 frames and streams The server reverses the process:

Text
Physical layer recovers bits from signals
   ↓
NIC and link layer recognize frames and check FCS
   ↓
IP layer processes packets addressed to this host
   ↓
TCP identifies the connection, orders and deduplicates data, and delivers contiguous bytes
   ↓
TLS verifies and decrypts
   ↓
HTTP/2 parses the request
   ↓
Web application handles /products/42?color=blue
Text
Find product 42
→ Select the blue variant
→ Read its name, price, and image address
→ Generate HTML

Application-generated HTML:

HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="/assets/site.css">
  <script defer src="/assets/product.js"></script>
</head>
<body>
  <h1>Blue mechanical keyboard</h1>
  <p class="price">¥299</p>
  <img src="/images/keyboard-blue.webp"
       width="600" height="400" alt="Blue mechanical keyboard">
  <section id="reviews">Customer reviews</section>
</body>
</html>

The response fields might be:

Text
:status: 200
content-type: text/html; charset=utf-8
content-encoding: br

Compressed content returns through TLS and TCP/IP. This example combines the HTTPS entry point and application; a deployment may also use a CDN or reverse proxy.

Return traffic, loss, and resource reuse

The response's public endpoints and its endpoints after reverse NAT are:

Text
203.0.113.80:443 → 198.51.100.23:62001
Text
203.0.113.80:443 → 192.168.1.10:51514

If the second segment is lost:

Text
Sent:     segment 1, segment 2, segment 3, segment 4
Received: segment 1,            segment 3, segment 4

TCP buffers later bytes, fills the gap through retransmission, then delivers in order. Two constraints limit sending:

Text
Does the receiver have room? → flow control and receive window
Can the network handle it?   → congestion control and congestion window

A TCP acknowledgment does not mean the page is visible. Decryption, decompression, and parsing reveal dependencies:

HTML
<link rel="stylesheet" href="/assets/site.css">
<script defer src="/assets/product.js"></script>
<img src="/images/keyboard-blue.webp">

Dependent resources can share the HTTP/2 connection:

Text
GET /assets/site.css
GET /assets/product.js
GET /images/keyboard-blue.webp
Text
Within one TCP/TLS connection:

CSS data → image data → JS data → image data → CSS data…

Frames from different streams can be interleaved, but a gap in the TCP byte stream can still hold up multiple streams.

Browser rendering and subsequent requests

HTML produces a DOM, and CSS contributes style information before layout and painting:

HTML, CSS, and JavaScript feed browser processing, followed by layout, painting, rasterization, and compositing.

The main rendering dependencies. Full-size figure · Mermaid source

DOM describes document structure. Layout computes positions and sizes; painting generates instructions; rasterization and compositing produce and combine pixels. Downloads and rendering can overlap. Browser rendering

defer downloads without blocking HTML parsing; image dimensions reserve space; #reviews applies once the target is available.

After displaying the page, the script may request stock information:

JavaScript
fetch("/api/stock?product=42")
  .then(response => response.json())
  .then(data => {
    // Update the page using the stock result
  });

That request passes through the layers again and can trigger a page update:

Text
HTTP request
→ TLS
→ TCP
→ IP
→ Data link layer
→ Physical layer
→ Server
→ Response returns
→ JavaScript updates the DOM
→ Necessary style, layout, and paint updates

First paint, DOMContentLoaded, load, and business-data readiness are separate milestones. Connections can remain reusable.

Complete sequence: tracking IP, MAC, and ports together

MAC labels are listed below; the Internet lifeline folds several router hops together. TLS and HTTP arrows still traverse that same route.

MAC labelInterface
CComputer's network interface
GL / GWHome router's LAN / WAN interfaces
IProvider's first-hop router interface
RD / RSLast-hop router interface on the DNS / web server's link
D / SDNS / web server network interface

Complete sequence showing ARP, DNS, TCP, TLS, HTTP, and rendering, with IP, MAC, and port changes along the path.

The complete sequence; open the full-size figure to read the address details. Full-size figure · Mermaid source

FieldComputer sendsAfter outbound NATOrdinary routingReturn to the home network
IPPrivate computer address is the sourceSource becomes the router's public IPAddresses usually stay the same; TTL decreasesDestination becomes the private computer IP
TCP portSource port 51514Source changes to 62001UnchangedDestination changes back to 51514
MACC → GLGW → IRe-encapsulated at each router hopFinal hop GL → C

UDP uses 53000 ↔ 63000; TCP uses 51514 ↔ 62001. These NAT mappings are independent.

Search the site

Notes
Blog
Projects
Resources
About me