Skip to content

Data Transmission

IGCSE Computer Science Topic 2 10:56 English narration · English + 中文 subtitles burned in

space play · ←/→ 5s · j/l 10s · f fullscreen · ,/. speed

Chapters

Transcript
You send a photo to a friend on the other side of the world. 你把一张照片发给地球另一端的朋友。
It does not travel as one lump. 它并不是整整一大块地传过去的。
It is chopped into hundreds of small packets, each one labelled and sent off separately — often by different routes, through different countries. 它被切成了几百个小小的数据包,每一个都贴好标签、分别送出——常常走不同的路线, 穿过不同的国家。
They arrive out of order and must be reordered, some may arrive damaged, and on the way complete strangers can watch them go past. 它们到达时顺序是乱的,有些可能已经损坏, 而且一路上完全陌生的人都能看着它们经过。
And yet the photo appears, perfect, in the right order, and unreadable to everyone except your friend. 然而那张照片还是出现了,完好无损、顺序正确, 而且除了你的朋友之外谁也读不懂。
This lesson is how all three of those tricks work. 这节课讲的就是这三个戏法是怎么变的。
Data transmission — moving data safely from one place to another. 数据传输——把数据安全地从一个地方送到另一个地方。
Today: packets and packet switching, serial and parallel, simplex and duplex, USB, finding errors with parity, checksums and acknowledgements, and encryption. 今天我们讲:数据包与数据包交换、 串行与并行、单工与双工、USB、用奇偶校验和校验和以及确认来发现错误,还有加密。
Let's begin. 让我们开始吧。
Data often travels along a cable. 数据常常沿着一条线缆走。
An Ethernet cable uses a plastic plug with gold pins, called an RJ45, and carries electrical signals on a wired network. 以太网线用的是带金针的塑料插头,叫 RJ45, 在有线网络上传送电信号。
A fibre-optic cable carries data as pulses of light along thin glass fibres. 光纤电缆则把数据变成光脉冲,沿着细玻璃丝传送。
Light does not pick up electrical interference the way copper does, so fibre is used for long, fast links. 光不像铜那样容易受到电干扰,所以长距离、高速度的链路用光纤。
Both still carry packets. 两种线缆运的都还是数据包。
The exam may show you a photograph of either one. 考试可能给你看其中任意一种的照片。
Data transmission simply means moving data from one place to another — your computer to a website, your phone to a printer. 数据传输,说白了就是把数据从一个地方送到另一个地方——从你的电脑送到某个网站, 从你的手机送到打印机。
Before it is sent, the data is broken into small, equal-sized pieces called packets. 在发送之前,数据会被切成一小块一小块、大小相等的片段,叫数据包。
Each packet travels on its own, and they are put back together at the far end. 每个数据包各走各的,到了另一端再重新拼起来。
Why bother chopping it up? 为什么要这么费事地切开呢?
Three reasons. 有三个理由。
If one packet is lost or damaged, only that packet has to be sent again, not the whole file. 如果某一个包丢了或者坏了,只需要重发那一个包,而不是整个文件。
Packets can take different routes, so a busy or broken route can be avoided. 数据包可以走不同的路线,这样就能绕开拥堵或者断掉的线路。
And many users can share the same connection at the same time. 而且很多用户可以在同一时间共用同一条连接。
The structure of a packet: three parts. 每一个数据包都有三个部分。
The header carries the control information: the sender's address, the receiver's address, and the packet number — which says where this piece belongs in the order. 包头装的是控制信息:发送方的地址、接收方的地址, 以及数据包编号——它说明这一块在整个顺序里排在哪儿。
The payload is the actual data being carried. 有效载荷才是真正要运送的数据。
And the trailer marks where the packet ends, and holds an error check. 而尾部标出这个包在哪里结束,并且带有一个错误校验。
Header, payload, trailer. 包头、有效载荷、尾部。
Remember that both addresses and the packet number live in the header — that is the detail the exam asks for. 记住:两个地址和数据包编号都在包头里——这正是考试要问的细节。
Look again at the header. 再看一遍包头。
The sender's IP address says where the packet came from. 发送方的 IP 地址说明这个包从哪里来。
The receiver's IP address says where it is going. 接收方的 IP 地址说明它要去哪里。
The packet number says where this piece belongs when the file is rebuilt. 数据包编号说明这一块在文件拼回去时排在哪儿。
Without those three, a router cannot choose a route, and the receiver cannot put the photo back together. 没有这三项,路由器就选不了路线, 接收方也拼不出那张照片。
The payload is just the slice of the file. 有效载荷只是文件的一小片。
The trailer still holds the error check. 尾部仍然装着错误校验。
Packet switching is how those packets actually cross a network. 数据包交换,讲的就是这些包到底怎么穿过网络。
Devices called routers read each packet's header and choose the best route for it at that moment. 叫作路由器的设备会读取每个包的包头, 并为它挑选当下最合适的路线。
So each packet may take its own path. 所以每个包都可能走自己的那条路。
Because those paths differ in length and in how busy they are, the packets can arrive out of order — and that is completely normal. 因为这些路线的长短和拥堵程度都不一样,包到达时顺序可能是乱的——而这完全正常。
Once the last one has arrived, the receiver puts them back into order using their packet numbers. 等最后一个包到齐之后,接收方就用它们的数据包编号,把顺序重新排好。
Now, how the bits actually travel down the wire. 现在来看,比特到底是怎么在导线里走的。
Serial transmission sends one bit after another along a single wire. 串行传输是一个比特接着一个比特,沿着一条导线发送。
Parallel transmission sends several bits at the same time, along several wires. 并行传输则是好几个比特同时发送,沿着好几条导线一起走。
Parallel is faster — but only over short distances, because down a long wire the bits start arriving at slightly different times and the data gets scrambled. 并行更快——但只在短距离上更快, 因为在长导线上,各个比特开始在略微不同的时刻到达,数据就乱了。
Serial keeps the bits in order, works over long distances, and needs fewer wires so it costs less. 串行能保持比特的顺序,能走长距离,而且用的导线更少,所以成本也更低。
That is why long-distance links are serial, and parallel is kept for short connections inside a machine. 这就是为什么长距离的连接都用串行,而并行只留给机器内部的短连接。
Next, direction. 接下来是方向。
Simplex means data travels one way only — a computer sending to a printer. 单工的意思是数据只能朝一个方向走——比如电脑发送给打印机。
Half-duplex means it can go both ways, but only one way at a time — a walkie-talkie, where you have to stop talking before you can listen. 半双工的意思是两个方向都可以,但同一时间只能走一个方向——比如对讲机, 你得先停止讲话,才能听对方说。
Full-duplex means both directions at the same time — a phone call, where both people can speak at once. 全双工则是两个方向同时进行——比如打电话,两个人可以同时说话。
Which one you choose depends on the distance, the speed you need, the cost, and whether data has to flow both ways at once. 具体选哪一种,取决于距离、需要的速度、成本,以及数据是不是必须同时双向流动。
The choice of serial or parallel, and of simplex or duplex, depends on four things. 选串行还是并行、选单工还是双工,取决于四件事。
Distance: serial wins over a long cable. 距离:长电缆上串行更合适。
Speed: parallel is faster, but only over a short run. 速度:并行更快,但只在短距离上更快。
Cost: serial needs fewer wires. 成本:串行用的导线更少。
And whether data must travel both ways at once: that is when you pick full-duplex. 还有数据是不是必须同时双向流动:那才选全双工。
Write those four words — distance, speed, cost, both ways — and the method mark is yours. 考试里写出这四个词——距离、速度、成本、双向——方法分就到手了。
A quick word on USB — the universal serial bus, the standard interface for plugging a device into a computer. 简单说一下 USB——通用串行总线,是把设备插到电脑上的标准接口。
Its benefits: one connector shape works for many different devices; the computer detects the device and loads the right driver automatically; the cable carries power, so it can charge or even run the device; and the plug only fits one way round, so it is hard to get wrong. 它的好处是: 同一种接口形状可以用于很多不同的设备;电脑会自动检测到设备,并加载正确的驱动程序; 线缆本身能供电,所以可以给设备充电,甚至直接带动设备运行; 而且插头只能按一个方向插进去,所以很难插错。
Its drawbacks: the cable can only be a few metres long, older versions are slow, and some other connection types transfer data faster. 它的缺点是:线缆只能有几米长、 较老的版本速度慢,而且有些别的连接方式传输得更快。
Now the important part: things go wrong. 现在到了重要的部分:事情会出错。
While data is travelling, interference can damage it, in three ways. 数据在传输途中,干扰可能会破坏它,方式有三种。
Data loss — some bits never arrive at all. 数据丢失——有些比特压根就没到。
Data gain — extra bits appear that were never sent. 数据增多——冒出了一些从来没被发送过的额外比特。
And data change — bits get flipped, a one becoming a zero or a zero becoming a one. 还有数据改变——比特被翻转了,一变成了零,或者零变成了一。
So the receiver has to check whether what arrived is really what was sent. 所以接收方必须检查:收到的,到底是不是当初发出去的那个。
There are several ways to do that. 检查的办法有好几种。
The simplest is a parity check. 最简单的是奇偶校验。
One extra bit, called the parity bit, is added to each byte. 给每个字节加上一个额外的位,叫奇偶校验位。
With even parity, the total number of ones — counting the parity bit — must come out even. 如果用偶校验, 那么一的总个数——把校验位也算进去——必须是偶数。
With odd parity, it must come out odd. 如果用奇校验,就必须是奇数。
The two sides agree beforehand which one they are using. 双方事先约定好用哪一种。
Take the data one-zero-one-one-zero-zero-one. 以数据一零一一零零一为例。
It already holds four ones, which is even, so with even parity the parity bit is zero. 它本来就有四个一,是偶数, 所以在偶校验下,校验位就是零。
The receiver simply counts the ones. 接收方只要数一数一的个数就行。
If even parity was agreed and a byte arrives with an odd number of ones, something went wrong on the way. 如果约定的是偶校验,而收到的字节里一的个数却是奇数,那就说明路上出了问题。
But be careful: if two bits flip, the count can still look correct, so a parity check cannot catch every error. 但要小心:如果有两个位同时翻转,个数看上去可能仍然是对的, 所以奇偶校验并不能抓出所有的错误。
A single parity bit tells you that an error happened, but not where it happened. 单独一个奇偶校验位,只能告诉你出错了,却说不出错在哪里。
A parity block tells you exactly where. 奇偶校验块能精确地告诉你在哪里。
Several bytes are sent together, each with its own row parity bit, and then one extra parity byte at the bottom holds a parity bit for each column. 把好几个字节一起发送,每个字节都带上自己的行校验位,然后在最下面再加一个校验字节, 里面为每一列各存一个校验位。
Look at this block. 来看这个方块。
Even parity was used throughout, and one bit was flipped on the way. 全程用的是偶校验,而途中有一个位被翻转了。
Row three has an odd number of ones, so the error is somewhere in that row. 第三行里一的个数是奇数,所以错误就在那一行的某处。
Column b3 has an odd number of ones, so the error is somewhere in that column. b3 这一列里一的个数是奇数, 所以错误就在那一列的某处。
The faulty bit is where they cross: byte three, bit b3. 出问题的那个位,就在它们交叉的地方:第三个字节,第 b3 位。
Flip it back, and the data is repaired. 把它翻回去,数据就修好了。
That is the difference — one parity bit detects, but a parity block locates and even repairs. 这就是区别——一个校验位只能发现错误, 而一个校验块能定位错误,甚至还能修好它。
Three more methods. 还有三种方法。
A checksum is a value worked out from all the data before sending; the receiver works it out again from what actually arrived, and if the two values do not match, the data is sent again. 校验和是在发送之前,根据全部数据算出来的一个值; 接收方再根据实际收到的数据重新算一遍,如果两个值对不上,数据就重发。
An echo check sends the data back to the sender, who compares it with the original — reliable, but everything has to travel twice, so it is slow. 回送校验是把数据原样送回给发送方,由发送方和原件比对——很可靠, 但所有东西都要跑两趟,所以很慢。
And automatic repeat request uses acknowledgements: the receiver sends a positive acknowledgement if a packet arrived correctly, or a negative one if it did not, and the sender runs a timeout timer — if no positive acknowledgement comes back in time, it just sends the packet again. 而自动重传请求用的是确认消息: 如果包正确到达,接收方就发一个肯定确认,没到就发一个否定确认, 同时发送方会跑一个超时计时器——要是在规定时间内没等到肯定确认,它就把这个包再发一次。
One more, for a different job: a check digit is an extra digit on the end of a number, worked out from the other digits. 还有一个,用途不太一样:校验码是加在一串数字末尾的一个额外数字,由其他数字算出来。
It catches the four typing mistakes the syllabus names: an incorrect digit typed in, a transposition error where two digits are swapped, a digit left out or an extra digit added, and a phonetic error — a digit that sounds similar, like thirteen and thirty. 它能抓住输入时的错误——写错了一个数字、两个数字调换了位置,或者漏掉了一个数字。
Barcodes and book numbers use them. 条形码和书号用的就是它。
Automatic Repeat reQuest, or ARQ, is how a lost packet is asked for again. 自动重传请求,也就是 ARQ,讲的是丢掉的包怎么再要一次。
The receiver sends a positive acknowledgement if a packet arrived correctly, or a negative acknowledgement if it did not. 如果包正确到达, 接收方就发一个肯定确认;如果没有,就发一个否定确认。
The sender starts a timeout timer. 发送方会启动一个超时计时器。
If no positive acknowledgement comes back in time, the sender just sends the packet again. 要是在规定时间内没等到肯定确认,它就把这个包再发一次。
That is how a chopped-up photo still arrives complete even when one packet vanished on the way. 一张被切碎的照片即使路上丢了一个包,也还能完整到达,靠的就是这一步。
Those are the error detection methods. 最后是加密。
Last, encryption. Even if the data arrives perfectly, someone may have watched it go past. 就算数据完好无损地到达了,路上也可能有人看着它经过。
Encryption scrambles the data, so that if it is intercepted it cannot be understood. 加密会把数据打乱,这样即使被拦截,别人也读不懂。
The readable version is called plaintext; the scrambled version is ciphertext. 可读的那份叫明文;打乱之后的那份叫密文。
And note this carefully: encryption does not stop data being intercepted. It only stops it being understood. 而且这一点要特别注意:加密并不能阻止数据被拦截,它只能阻止数据被读懂。
Symmetric encryption uses one single key for both scrambling and unscrambling, so both sides have to share that same secret key — and the key itself could be stolen while it is being shared. 对称加密用同一把密钥来打乱和还原,所以双方必须共享同一把秘密密钥—— 而这把密钥本身,在传递的过程中就可能被偷走。
Asymmetric encryption uses two keys instead: a public key that anyone may have, used to encrypt, and a private key that stays secret, used to decrypt. 非对称加密改用两把密钥: 一把谁都可以拿到的公钥,用来加密;还有一把始终保密的私钥,用来解密。
Because the private key is never sent anywhere, it is safer. 因为私钥从来不需要传送到任何地方,所以它更安全。
Four marks to lock in. 四个要拿稳的分。
First, a packet is a header holding both addresses and the packet number, then a payload, then a trailer. 第一,一个数据包由包头、有效载荷和尾部组成, 包头里装着两个地址和数据包编号。
Second, serial is one bit at a time and good over long distances; parallel is several bits at once and short range only. 第二,串行是一次一个比特、适合长距离; 并行是一次好几个比特、只适合短距离。
Third, a single parity bit shows that an error happened, while a parity block shows exactly where. 第三,单个奇偶校验位只能表明出错了, 而奇偶校验块能指出错在哪里。
Fourth, symmetric uses one shared key, and asymmetric uses a public key to encrypt and a private key to decrypt. 第四,对称加密用一把共享密钥, 非对称加密用公钥加密、用私钥解密。
Nail these, and this topic is yours. 掌握这些,这个专题就是你的了。

Log in or create account

IGCSE, A-Level & AP