Application protocols
導入済み
7:25
コンピュータネットワーク
A network carries your bytes across a planet of machines that owe each other nothing. The first three units move a frame: layering, the link layer with IP, and…
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| DNS/ˌdiː en ˈes/ | ドメイン名システム |
| delegation/ˌdelɪˈɡeɪʃn/ | handing responsibility for part of the DNS name space to another server |
| HTTP/ˌeɪtʃ tiː tiː ˈpiː/ | 超文本転送プロトコル |
| headers | |
| status code/ˈsteɪtəs kəʊd/ | |
| multiplexing/ˌmʌltɪˈpleksɪŋ/ | carrying several streams over one connection or link |
| stateless/ˈsteɪtləs/ | keeping no memory of earlier requests between one request and the next |
Resolve the name
- DNS 域名系统 turns a name into an address by passing the question down a hierarchy (delegation 委派). Each answer points one level down:
| Ask | It knows | So it answers |
|---|---|---|
| A root server | the top-level domain (TLD) servers | "ask the .com servers" |
A .com server |
each domain's authoritative servers | "ask example.com's server" |
| The authoritative server | the hosts in its domain | the address |
- Caching skips the walk until the answer's TTL (time to live) runs out.
- HTTP 超文本传输协议 is a request and response format: a request line, headers, a blank line and a body. The class of the status code 状态码 is a promise: 2xx success, 3xx redirect, 4xx client error, 5xx server error.

DNS delegation means the root answers with —
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Each level refers downward; the authoritative server holds the host record.
Put an uncached DNS lookup of www.example.com in order.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Every answer except the last is a referral one level down. The cache is why most lookups skip the whole walk.
One page, byte by byte
GET /index.html HTTP/1.1with a Host header. The server answers200 OK, then headers 首部 (Content-Type,Content-Length: 128), a blank line, and exactly 128 body bytes.- The blank line matters: the parser waits for exactly that empty line. Content-Length counts only the body bytes; the end of the headers is marked by the blank line.
The header block ends at —
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Two newlines end the headers - the parser waits for exactly those.
Codes as promises
- 200 (here is the body), 301 (it moved;
Locationsays where), 404 (you asked for something that is not there), 500 (the server failed). A search crawler treats 301 as a pointer, 404 as a dead end and 500 as "try again later". - One global table of names would mean one global outage. Delegation 委派 splits the risk of failure as well as the data.
A 301 response tells the client —
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Redirect: the resource lives elsewhere now.
Caching and HTTP versions
Cache-Control: max-age=3600lets a browser reuse a response for an hour without any request. After that it checks again with theETag: if nothing changed, the server sends304 Not Modifiedwith no body.- HTTP/1.1 keeps connections open; HTTP/2 sends many requests at once over one TCP connection (multiplexing 多路复用); HTTP/3 runs over QUIC on UDP, so one lost packet no longer holds up every stream.
- A DNS lookup with nothing cached asks the root, the TLD and the authoritative server: $3$ queries.
A server answers a revalidation with 304 Not Modified. The browser —
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
304 means the cached copy is still valid, so no body is sent.
A resolver has the .com TLD server cached but not the domain. How many queries does it send to resolve www.example.com?
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
It skips the root: one query to the .com server, one to the authoritative server.
A stateless protocol that remembers you
- HTTP keeps no memory between requests (it is stateless 无状态). After a login the server sends
Set-Cookie: session=7f3a…, and the browser returns that cookie with every later request to the site. - The server looks up the session and knows who is asking. Mark session cookies
SecureandHttpOnly, so they travel only over HTTPS and page scripts cannot read them.
By default an HTTP server remembers each client between requests.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
HTTP is stateless; cookies carry the state.
Worked example: ten images at 50 ms
- A page has its HTML and 10 small images, and the round trip is 50 ms. HTTP 超文本传输协议/1.1 on one connection: 1 RTT to connect, 1 for the HTML, then 10 requests one after another: $12 \times 50 = \mathbf{600}$ ms.
- HTTP/2 sends all 10 requests together on that connection: $1 + 1 + 1 = 3$ RTTs, 150 ms. Browsers once opened six connections side by side to get part of this gain.
HTTP/1.1, one connection, RTT 50 ms: connect, HTML, then 10 images one at a time. Total (ms)?
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
$(1 + 1 + 10) \times 50 = 600$ ms.
Same page over HTTP/2 with the 10 requests multiplexed: total (ms)?
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
$3 \times 50 = 150$ ms.
Marks that slip away
- Forgetting the blank line. Headers 首部 end at an empty line; without it the server keeps waiting.
- Counting headers in
Content-Length. It counts body bytes only. - A 404 for a moved page. Answer
301with aLocationheader; a 404 tells crawlers the page is gone.
Recap
- DNS delegates: root, TLD, authoritative; caching skips the walk for the TTL.
- HTTP 超文本传输协议: request line, headers, a blank line, then exactly Content-Length body bytes.
- 2xx success, 3xx redirect, 4xx client error, 5xx server error.
何が問題でしたか?この内容はサイトの運営チームだけが確認します。