Computer Networks
University Computer Science Topic 9 7:25 English narration · English and 中文 subtitles you can switch
Chapters
Transcript
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 routing.
前三个单元介绍帧的传输:分层、链路层与 IP,以及路由。
The next two make delivery reliable and useful, with transport and application protocols.
接下来的两个单元介绍如何通过传输层和应用层协议,使交付可靠且有用。
The last two secure and scale it.
最后两个单元介绍如何保障网络安全并扩展网络规模。
Every header in this course is decoded byte by byte, so you can check it.
本课程中的每个首部都会逐字节解码,方便你核对。
Five layers each offer a service upward and use one below: physical, link, network, transport and application.
五个层次各自向上一层提供服务,并使用下一层的服务:物理层、链路层、网络层、传输层和应用层。
Going down, each adds a header: a 100-byte payload leaves with 54 bytes of headers, 14 for Ethernet, 20 for IP and 20 for TCP.
向下传递时,每层都添加一个首部:100 字节 的载荷发送时带有共 54 字节 的首部,其中 以太网 占 14,IP 占 20,TCP 占 20。
IP is the narrow waist: applications and links have changed many times, but IP has not.
IP 是中间狭窄的一层:应用和链路已经改变了许多次,但 IP 没有改变。
Read the stack as five promises, one on top of another.
把这个协议栈看作上下叠放的五个约定。
Going down, each layer wraps the data in its own header.
向下传递时,每层都用自己的首部封装数据。
Coming up at the receiver, each layer strips its header and hands the rest upward.
在接收端向上传递时,每层都去掉自己的首部,再把剩余部分交给上层。
A layer can be replaced completely, as long as it keeps its promise to the layers above and below.
只要一个层次遵守对上下层的约定,就可以被完全替换。
The TCP/IP model has four layers: application, transport, internet and link.
TCP/IP 模型有四层:应用层、传输层、网际层和链路层。
Going down the stack, the data gains a TCP header, then an IP header, then a frame header.
数据沿协议栈向下传递时,先加上 TCP 首部,再加上 IP 首部,然后加上帧首部。
At the receiver, each layer removes its own header.
在接收端,每层都去掉自己的首部。
Because each layer only talks to its neighbours, one can change without the others.
由于每层只与相邻层通信,一层发生变化时,其他层可以不变。
A MAC address names a neighbour on the same link, and it changes at every hop; an IP address names the distant stranger and stays the same.
MAC 地址标识同一链路上的邻居,每经过一跳就会改变;IP 地址标识远端的目标,保持不变。
In this IPv4 header, the first byte says the header is 5 words, 20 bytes, and the total length is 60.
在这个 IPv4 首部中,第一个字节表示首部长度为 5 个字,即 20 字节,总长度为 60。
TTL is 64, and protocol 6 means TCP.
TTL 是 64,协议号 6 表示 TCP。
The IP checksum covers only the header.
IP 校验和只覆盖首部。
Read these bytes the way the receiver does, field by field.
像接收端一样,逐个字段读取这些字节。
Version 4 and header length 5.
版本为 4,首部长度为 5。
Total length 60 bytes: 20 of header and 40 of payload.
总长度为 60 字节:其中首部占 20,载荷占 40。
Time to live 64, decremented at every router.
生存时间为 64,每经过一个路由器就减一。
Protocol 6, so TCP comes next.
协议号为 6,所以下一部分是 TCP。
Routers rewrite the TTL, so they recompute the header checksum but never touch the data.
路由器会改写 TTL,因此会重新计算首部校验和,但不会改动数据。
An Ethernet frame starts with a preamble and a start-of-frame marker.
Ethernet 帧以前导码和帧起始标记开头。
The data part holds the destination and source MAC addresses, a type or length field, the payload and a frame check sequence.
数据部分包含目的和源 MAC 地址、类型或长度字段、载荷以及帧校验序列。
The receiver recalculates the check and drops the frame if it does not match.
接收端重新计算校验值,如果不匹配就丢弃该帧。
Routers forward by longest prefix match.
路由器按照最长前缀匹配进行转发。
With routes for slash 8, slash 16 and slash 24, the address 10.1.2.200 goes by the most specific, slash 24, while 10.9.9.9 falls back to slash 8.
当路由表中有 /8、/16 和 /24 的路由时,地址 10.1.2.200 使用最具体的 /24,而 10.9.9.9 则使用 /8。
Dijkstra's algorithm builds shortest paths by always settling the nearest unsettled node.
Dijkstra 算法通过不断确定距离最近的未确定节点来构建最短路径。
Aggregation keeps routing tables small: one slash 12 covers a million addresses.
路由聚合使路由表保持精简:一个 /12 就能覆盖一百万个地址。
Trace Dijkstra's tree from A on this weighted graph.
在这个带权图上,从 A 开始追踪 Dijkstra 算法构建的树。
C settles first at distance 2, then B at 3, D at 8 and E at 10.
首先确定 C,距离为 2,接着是 B,距离为 3;D 为 8,E 为 10。
F settles at 13, by the path A, C, B, D, E, F, which beats the direct link from D at 14.
F 的最终距离为 13,路径是 A、C、B、D、E、F,比从 D 直接到达 F 的距离 14 更短。
Once a node is settled, its distance is final.
一个节点一旦被确定,它的距离就是最终值。
TCP keeps a ledger.
TCP 会记录传输情况。
After the handshake, 100 bytes go with sequence number 1 and are acknowledged with 101, meaning next byte expected.
握手之后,100 字节 的数据以序列号 1 发送,收到的确认号为 101,表示下一个期望接收的字节。
If a 30-byte segment at 151 is lost, the acknowledgement stays at 151 until it is resent, then jumps to 181.
如果从 151 开始的一个 30 字节 报文段丢失,确认号就会一直保持在 151,直到该报文段被重传,然后跳到 181。
UDP has only an 8-byte header and keeps no ledger, which suits DNS and live video.
UDP 的首部只有 8 字节,也不记录传输情况,适合 DNS 和实时视频。
Follow the acknowledgement numbers through this diagram.
沿着图中的确认号看一遍。
The three-way handshake sets up the connection.
三次握手建立连接。
Two segments arrive and each acknowledgement names the next byte expected.
两个报文段到达,每个确认号都表示下一个期望接收的字节。
Then a segment is lost: the receiver keeps acknowledging 151 until the sender's timer fires and it retransmits.
接着一个报文段丢失:接收端持续确认 151,直到发送端的计时器超时并重传。
TCP guarantees order and delivery, but never speed.
TCP 保证按序交付,但不保证速度。
DNS delegates downward: the root refers you to the top-level domain server, which refers you to the authoritative server, and caching skips this walk until the answer expires.
DNS 逐级向下委派:根服务器将你引向顶级域名服务器,后者再将你引向权威服务器;缓存可以省去这个查询过程,直到答案过期。
HTTP is a request and response grammar: a GET with a Host header, then 200 OK with a content length of 128 and exactly 128 bytes of body.
HTTP 是一种请求和响应的规则:先发送带有 Host 首部的 GET 请求,然后返回 200 OK,内容长度为 128,消息体恰好有 128 字节。
Status codes are promises.
状态码代表服务器作出的承诺。
One page load, two protocols.
加载一个页面,涉及两种协议。
First the DNS walk: root, then top-level domain, then the authoritative server returns the address.
首先是 DNS 查询:先查根服务器,再查顶级域名服务器,最后由权威服务器返回地址。
Then the HTTP exchange: the request goes out, and the response comes back with a status code.
然后是 HTTP 交换:发出请求,再收到带有状态码的响应。
200 means here it is, 301 means moved, 404 means you asked wrong, and 500 means the server broke.
200 表示找到了,301 表示已转移,404 表示请求的内容不存在,500 表示服务器出了问题。
Security has three properties: confidentiality from encryption, integrity from a message authentication code, and authentication from certificates.
安全有三个性质:加密提供机密性,消息认证码提供完整性,证书提供身份认证。
In a TLS handshake, both sides send fresh random numbers, the server presents a certificate, and they agree a session key.
在 TLS 握手中,双方各自发送新的随机数,服务器出示证书,然后双方协商出会话密钥。
Then fast symmetric encryption protects the data.
接着,快速的对称加密保护数据。
HTTPS makes the channel private, but the content itself can still lie.
HTTPS 使通道具有私密性,但内容本身仍可能是虚假的。
Follow the TLS flow.
来看 TLS 的流程。
ClientHello and ServerHello exchange fresh randoms, and the server sends its certificate.
ClientHello 和 ServerHello 交换新的随机数,服务器发送证书。
Key exchange uses one expensive public-key operation to agree a shared secret.
密钥交换使用一次开销较大的公钥运算来协商共享秘密。
Both sides send Finished messages to verify the handshake was not altered.
双方发送 Finished 消息,验证握手过程没有被篡改。
After that, data flows at full speed under symmetric encryption.
之后,数据在对称加密保护下全速传输。
In a distributed system, failures are partial, and a timeout means unknown, not failed.
在分布式系统中,故障可能只发生在一部分节点,而超时意味着状态未知,不代表已经失败。
Lamport clocks order events without real time: on receiving a message, take the larger of your counter and the message's, then add one.
Lamport 时钟不依赖真实时间就能为事件排序:收到消息时,取本地计数器和消息中计数器的较大值,再加一。
If a happened before b, a's clock is smaller, but not the other way round.
如果 a 发生在 b 之前,a 的时钟值就比 b 小,但反过来不一定成立。
Make retries idempotent with a request key.
使用请求键,使重试操作具有幂等性。
Count along the arrows.
沿着箭头数一数。
Process 0 sends a message at counter 1.
进程 0 在计数器为 1 时发送一条消息。
Process 1 receives it and sets its counter to the larger value plus one: 2.
进程 1 收到消息,将计数器设为两者中的较大值加一,也就是 2。
It sends a reply at 3.
它在计数器为 3 时发送回复。
Process 0 receives that and jumps to 4.
进程 0 收到回复后,计数器跳到 4。
Causality is preserved even though neither process ever looked at a real clock.
虽然两个进程都没有查看真实时钟,因果关系仍然得到了保留。
Now test yourself from memory.
现在凭记忆自测。
How many bytes of Ethernet, IP and TCP headers wrap a 100-byte payload?
100 字节 的载荷外面包裹了多少字节 的 以太网、IP 和 TCP 首部?
What header size does IHL 5 mean?
IHL 5 表示首部大小是多少?
At what distance does F settle on the course graph?
在课程的图中,F 的最终距离是多少?
Process 1 sends at counter 3 to process 0 at counter 1: what does process 0 become?
进程 1 在计数器为 3 时向计数器为 1 的进程 0 发送消息:进程 0 的计数器会变成多少?
Pause, answer, then check.
暂停,回答,然后核对。
Comments
No comments yet. Be the first to ask or share something.