Packets and packet switching
A network carries data for many users at once, so a large file is not sent in one piece. It is broken down into small, numbered packets, and each one makes its own way to the receiver.
Packet structure
A packet travels alone, so it has to carry its own address and its place in the file.
1 · Header
Destination address · packet number · originator’s address
2 · Payload
The actual data being sent
3 · Trailer
Error-checking data · end-of-packet marker
Packet switching: each packet finds its own route
Follow one colour from Sender to Receiver: each line is one packet’s route through the routers K to Q.
Example
Arrive: 2 · 1 · 3
Reordered: 1 · 2 · 3
Packet 1 is delayed at a busy router, so packet 2 arrives first.
1 A file is sent as 5 packets numbered 1 to 5. They arrive in the order 3, 1, 2, 5, 4. What does the receiver do?
2 Name two items in a packet header.
3 What does a router read to decide where to forward a packet?
- 1It sorts the packets by packet number into 1, 2, 3, 4, 5. If one is missing, it asks for that packet again.
- 2Any two of: destination address, packet number, originator’s (source) address.
- 3The destination address.
Serial, parallel and USB
Bits cross a cable in one of two ways. Serial sends one bit at a time down one wire. Parallel sends several bits at once down several wires.
A USB cable is thin, yet old printer cables were wide, flat ribbons with a wire for every bit. Serial sends one bit at a time down one wire; parallel sends several bits at once down several wires.
Serial or parallel: how many bits at once?
Describe each one, and choose the right one for a long or a short link.
Serial
- One bit at a time down a single wire.
- Cheaper: fewer wires. Less interference (crosstalk).
- Bits arrive in order, so it is reliable over long distances.
- At the same bit rate per wire, transfers fewer bits per second than parallel.
Parallel
- Multiple bits at once: each bit of a byte has its own wire.
- At the same bit rate per wire, faster: several bits travel at the same time.
- More wires: more expensive; crosstalk between wires.
- Bits can arrive out of step (skew), so only for short distances.
USB: a serial interface
USB is the serial link most people plug in every day. Give a benefit and a drawback of it, linked to the device.
USB: universal serial bus
- A standard interface: it sets the rules for sending data along the cable.
- Data goes by serial transmission: one bit after another on a single wire, so bits arrive in order.
- The cable can also carry power.
Benefits
- Universal: one standard port and cable for many kinds of device
- Plug and play: the device is recognised and its driver installed automatically
- Backward compatible; versions offer different data transmission speeds
- Supplies power, so it can run or charge a keyboard or webcam
Drawbacks
- Cable length is limited (about 5 m), and a cable restricts how far a handheld device can move
- At the same bit rate per wire, serial data transfer is slower than parallel
1 A byte is sent in parallel. How many wires carry the data?
2 A sensor is joined to a computer by a 40 m cable. Should the link be serial or parallel? Give one reason.
3 Give two benefits of USB.
- 18 wires: one for each bit.
- 2Serial: over a long distance, bits stay in order. Parallel bits can arrive out of step (skew).
- 3Any two of: one standard port for many devices; plug and play; backward compatible; supplies power.
Direction of transmission
A sensor only ever reports, but a phone call needs both people talking. So as well as how many bits travel at once (serial or parallel), every link has a direction: which way data can travel.
Simplex, half-duplex or full-duplex: which direction?
Name the direction from a description, and give an example use of each.
| Direction | Example use | Advantage | Disadvantage | |
|---|---|---|---|---|
| Simplex one way only | sensor → computer; computer → monitor | simple and cheap | no reply or acknowledgement possible | |
| Half-duplex both ways, one at a time | walkie-talkie; a card reader and a till taking turns | two-way on a single channel | cannot send and receive at the same time | |
| Full-duplex both ways at once | phone or video call | no delay between sending and receiving | needs a link that carries both directions at once |
Simplex
Data travels one way only: a sensor sends readings without receiving a reply.
Half-duplex
Both devices can transmit, but take turns. Each must wait while the other sends.
Full-duplex
Both devices can transmit at the same time: each can send while receiving.
Choose and justify a method
To justify, name the method and give a reason for each part that fits the scenario.
| Scenario | Method | Why serial or parallel | Why this direction |
|---|---|---|---|
| A river-level sensor sends readings to a flood office 3 km away | Serial simplex | A long link: serial keeps the bits in order. Small readings need no extra speed. | The office never replies, so one direction is enough. |
| Inside a camera, an image sensor passes photos to a processor a few centimetres away | Parallel simplex | A short path: little skew. A photo has many bits, so sending several at once is faster. | Data flows one way. |
| A café till sends an amount; a card reader returns a payment result | Serial half-duplex | Short messages: serial is fast enough. | Both devices send, but they take turns. |
| Offices in different cities hold a video meeting | Serial full-duplex | A long link: serial keeps the bits in order. | Both sides send and receive at the same time. |
Serial simplex
A river-level sensor sends readings to a flood office 3 km away
- Serial: A long link: serial keeps the bits in order. Small readings need no extra speed.
- Simplex: The office never replies, so one direction is enough.
Parallel simplex
Inside a camera, an image sensor passes photos to a processor a few centimetres away
- Parallel: A short path: little skew. A photo has many bits, so sending several at once is faster.
- Simplex: Data flows one way.
Serial half-duplex
A café till sends an amount; a card reader returns a payment result
- Serial: Short messages: serial is fast enough.
- Half-duplex: Both devices send, but they take turns.
Serial full-duplex
Offices in different cities hold a video meeting
- Serial: A long link: serial keeps the bits in order.
- Full-duplex: Both sides send and receive at the same time.
1 A baby monitor sends sound to a parent unit and never receives anything. Which direction is this?
2 Two engineers use walkie-talkies and take turns to speak. Which direction is this?
3 A weather station on a mountain, 20 km from its base, sends temperature readings and never receives. Name the method and justify it.
- 1Simplex: one way only.
- 2Half-duplex: both ways, but one at a time.
- 3Serial simplex. The link is long, so serial keeps the bits in order. Readings are small, so parallel speed is not needed. The base never replies, so one direction is enough.
Error detection: parity checks
Interference (for example electrical noise) can corrupt data during transmission: bits can be lost, gained or changed. The receiver must check what arrives.
Crackle on a phone line is noise you can hear. On a data cable the same interference can flip a bit, and nothing looks wrong: bits can be lost, gained or changed. So how does the receiver know what arrived is right?
Parity bit: make the number of 1s even or odd
- 1Before sending, both devices agree to use even or odd parity.
- 2The sender sets the parity bit (the first, left-most bit here) so that the byte has an even or odd number of 1s, as agreed.
- 3The receiver counts the 1s in every byte. A count that breaks the agreed parity means an error is detected.
Parity block: check each byte and each column
One parity bit can tell you a byte is wrong, but not which bit. Checking the columns as well finds it.
| P | 1 | 2 | 3 | 4 | 5 | 6 | 7 | check | |
|---|---|---|---|---|---|---|---|---|---|
| Byte 1 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | ✓ even |
| Byte 2 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | ✓ even |
| Byte 3 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | ✗ odd |
| Byte 4 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | ✓ even |
| Parity byte | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | ✓ even |
| check | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✓ | ✓ |
At the receiver: two bytes, even parity agreed
The faulty byte has to be sent again: ARQ arranges this with acknowledgements and a timeout.
Limitation
- Two bits in the same byte change, or two bits swap places (transposition).
- The number of 1s still matches the agreed parity, so the error is not detected.
- A parity check shows that a byte is wrong, but not which bit, unless a parity block is used.
1 Even parity is agreed. What parity bit is added to 1101001?
2 Even parity is agreed. The receiver gets 01101011. Is an error detected?
3 Two bits in a byte change in transit. Why can parity not detect this?
- 1
1101001has 4 ones, which is even, so the parity bit is 0. - 2
01101011has 5 ones, which is odd, so yes, an error is detected. - 3The number of 1s is still even (or odd) as agreed, so the byte looks correct.
Checksum, echo check and check digit
Counting 1s is not the only way to catch an error. Each of these checks compares two things that should match; if they differ, the data is sent again or the number is typed again.
Each check compares two things. If they differ, the data is sent again or the number is typed again.
Checksum: compare a value calculated from the data
Follow the three values from Sender to Receiver. One changed on the way, so the two totals disagree.
- 1The sender runs an agreed algorithm on the data (the figure adds the values) to get a checksum value.
- 2The checksum is sent along with the data.
- 3The receiver runs the same algorithm on what arrived.
- 4Two different values mean the data changed on the way: an error is detected and the data is sent again.
Before sending, the sender runs an agreed algorithm on the data (the figure adds the values) to get a checksum value and sends it along with the data. The receiver runs the same algorithm on what arrived. Two different values mean the data changed on the way: an error is detected and the data is sent again.
Echo check: compare the data itself
Here the receiver does no checking at all: it sends the data straight back, and the sender compares the two copies.
- Limitation: if the copies differ, the sender cannot tell whether the error happened on the way there or on the way back.
- Every echo returns a full copy of the data, so traffic doubles.
Limitation: if the copies differ, the sender cannot tell whether the error happened on the way there or on the way back. Every echo returns a full copy of the data, so traffic doubles.
Check digit: detect errors in data entry
1 The sender adds the values 12, 7 and 20 to make a checksum. The receiver gets 12, 9 and 20 and adds them. What happens?
2 In an echo check, who compares the data?
3 Which check finds a typing mistake in a barcode number?
- 1Checksum 39. The receiver’s total is 41. They differ, so an error is detected and the data is sent again.
- 2The sender, by comparing the echo with the original.
- 3A check digit.
Resending data (ARQ) and encryption
A check can find an error, but the damaged data still has to be sent again. Data can also be intercepted on the way and read by the wrong person. ARQ deals with the first problem, and encryption with the second.
Automatic repeat query (ARQ): confirm data arrived without error
- The receiver checks each packet (e.g. with a parity check or checksum) and reports with an acknowledgement.
- The sender starts a timeout with each packet. What it does when the time runs out depends on the method.
The receiver checks each packet (e.g. with a parity check or checksum) and reports with an acknowledgement. The sender starts a timeout with each packet; what it does when the time runs out depends on the method.
Time runs down each diagram. Follow the arrows between Sender and Receiver, and watch what happens to packet 2.
ARQ with positive acknowledgement
ARQ with negative acknowledgement
Encryption: intercepted data cannot be understood
- Encryption uses an algorithm and a key (a string of characters or numbers) to turn plaintext into ciphertext.
- It does not stop data being intercepted; it stops anyone without the right key from understanding it.
Encryption uses an algorithm and a key (a string of characters or numbers) to turn plaintext into ciphertext. It does not stop data being intercepted; it stops anyone without the right key from understanding it.
Follow each one from Plaintext to Plaintext and see which key is used at each step: one shared key, or two different ones.
Symmetric or asymmetric
Say which key encrypts, which decrypts, and how the key is shared.
Symmetric: the same key encrypts and decrypts, so it must be shared securely: anyone who intercepts both the key and the ciphertext can decrypt the data. Asymmetric: the public key can be given to anyone and encrypts; only the matching private key, kept secret by its owner, can decrypt.
Symmetric
- The same key encrypts and decrypts, so it must be shared securely.
- Anyone who intercepts both the key and the ciphertext can decrypt the data.
Asymmetric
- The public key can be given to anyone and encrypts.
- Only the matching private key, kept secret by its owner, can decrypt.
1 A sender uses positive acknowledgement. No ACK arrives before the timeout. What does the sender do?
2 What is the difference between plaintext and ciphertext?
3 In asymmetric encryption, which key encrypts and which decrypts?
- 1It resends the packet.
- 2Plaintext can be read by anyone; ciphertext cannot be understood without the key.
- 3The public key encrypts; the matching private key decrypts.