Layering, Switching and the Data Link Layer
Three Ways to Move a Message
| Aspect | Circuit | Packet (datagram) | Virtual circuit |
|---|---|---|---|
| Setup before data | Yes — a path is reserved | None | Yes — once, then labels |
| Do all units follow one path? | Yes | No — each is routed alone | Yes |
| Can they arrive out of order? | No | Yes | No |
| Address in each unit | None needed after setup | Full destination address | A short circuit id |
| Idle capacity | Wasted — reserved regardless | Shared with everyone | Shared (bandwidth is not reserved) |
Framing and Error Detection, Both Run
A receiver has to find where a frame begins and ends. The flag-byte approach delimits with a fixed pattern — HDLC uses 01111110 — and then has to guarantee that pattern never appears inside the payload. Bit stuffing does it: the sender inserts a 0 after every run of five 1s, so six consecutive 1s can only be the flag. Run it on 0111111111111110 and you get 011111011111011110, two bits longer, with no 01111110 anywhere inside. The receiver strips a 0 whenever it follows five 1s, recovering the original exactly. Note the cost is data-dependent — a payload of all 1s grows by one bit in six, which is why the worst-case frame expansion is a real quantity and not a rounding error.
(x + 1) divides the generator. And it detects every burst shorter than or equal to r bits. CRC is a detection code only — it cannot correct, and any option claiming otherwise is wrong.| Scheme | What it computes | Guarantee |
|---|---|---|
| Single parity bit | One bit making the count of 1s even (or odd) | Detects odd numbers of bit errors only; two errors are invisible |
| Internet checksum | 16-bit ones-complement sum with end-around carry | Cheap in software; misses some reordering and compensating errors |
| CRC | Remainder of polynomial division, r bits | Detects every burst of length ≤ r; still cannot correct |
| Hamming code | r parity bits with 2r ≥ m + r + 1 | Corrects one bit error — the only scheme here that corrects |
Medium Access, and the Frame That Must Not Be Short
CSMA/CD listens before transmitting and keeps listening while it transmits, so it can abort on a collision instead of wasting the whole frame. That only works if the station is still transmitting when the collision signal gets back to it — otherwise it finishes, believes it succeeded, and the collision is silently lost. So the transmission time must be at least the round-trip propagation time, which gives a lower bound on frame length: L ≥ 2 × Tp × B.
| Window W | Tt | Tp | a | Efficiency |
|---|---|---|---|---|
| 1 (stop-and-wait) | 1 ms | 20 ms | 20 | 2.44% |
| 1 | 100 µs | 200 µs | 2 | 20% |
| 5 | 100 µs | 200 µs | 2 | 100% |
| 7 | 100 µs | 200 µs | 2 | 100% (capped) |
Key takeaways
- Routing is the network layer, medium access the data link layer; a switch is not a router.
- OSI adds only session and presentation over TCP/IP; both fold into the application layer.
- A switch separates collision domains but not broadcast domains; a router separates both.
- Only datagram switching can deliver out of order; both circuit and virtual circuit cannot.
- Bit stuffing inserts a 0 after five 1s: 0111111111111110 becomes 011111011111011110.
- CRC: append r zeros, divide by the generator, and the receiver accepts on a zero remainder.
- CRC detects every burst of length ≤ r and corrects nothing; only Hamming corrects.
- Hamming parity bits solve 2r ≥ m + r + 1 — m = 8 needs r = 4.
- Minimum CSMA/CD frame is 2·Tp·B — 250 bits at 10 Mbps over 2500 m, below Ethernet’s 512.
- Efficiency is W/(1 + 2a), capped at 1; sequence numbers cap W at 2m−1 (GBN) or 2m−1 (SR).
Practice questions (8)
Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.
A CSMA/CD network runs at 10 Mbps over a maximum span of 2500 m, with signals propagating at 2 × 10⁸ m/s. The minimum frame size in bits is ______
Numerical answer — type the value.
Show answer
Answer: 250
250 bits. A station must still be transmitting when a collision signal returns to it, so the transmission time has to be at least the round-trip propagation time. One-way propagation is 2500 / (2 × 10⁸) = 12.5 µs, so the round trip is 25 µs, and the frame must occupy the link that long: L = 25 × 10⁻⁶ × 10 × 10⁶ = 250 bits. Two errors are worth naming. Using one-way delay instead of the round trip halves it to 125 — but a collision has to travel to the far end and the jam signal back, which is why the 2 is there. And answering 512 applies Ethernet’s mandated 64-byte minimum instead of computing the bound: 512 bits is what the standard chose, and it is deliberately larger than 250 because the 51.2 µs slot time budgets repeater latency and a safety margin as well as propagation. When a question hands you distance and bandwidth, it wants the bound.A message of 10 data bits 1101011011 is protected by a CRC with generator 10011. The 4-bit CRC appended to the message is ______ (write the bits, e.g. 0101)
Numerical answer — type the value.
Show answer
Answer: 1110
1110. The generator 10011 has degree 4, so append four zeros to get 11010110110000 and divide by 10011 using XOR in place of subtraction. The 4-bit remainder is 1110, so the transmitted frame is 11010110111110. Check it the way the receiver does: divide the whole transmitted frame by 10011 and the remainder is 0000, which is the acceptance test — the sender picks a remainder that makes the total divisible, so the receiver never recomputes and compares, it just checks divisibility. Two habits prevent most errors here. Append exactly degree zeros, not one fewer, and keep the CRC width equal to the degree: a degree-4 generator always yields 4 bits, so an answer of a different length is wrong before it is checked. And use XOR throughout — there are no borrows in this arithmetic.A sliding-window protocol has a = Tp/Tt = 2. What is the smallest window size that achieves 100% link utilisation?
Show answer
Answer: B — 5
5. Efficiency is W/(1 + 2a), capped at 1, so utilisation reaches 100% exactly when W ≥ 1 + 2a = 1 + 4 = 5. The reading behind the formula: a station sends W frames back to back, then must wait for the first acknowledgement, which arrives one round trip (2a frame-times) after the first frame left plus the frame time itself — so 1 + 2a frame-times of work keeps the link busy continuously. Option A gives 3/5 = 60% and option C gives 4/5 = 80%, both short. Option D works but is not the smallest — W = 7 gives 7/5, capped to 100%, so the extra two frames of window buy nothing and the question asked for the minimum. Worth pairing with the second, independent cap: with 3-bit sequence numbers Go-Back-N could not exceed 7 anyway, and Selective Repeat could not exceed 4 — so on this link SR with 3-bit sequence numbers would be stuck at 80% no matter how it was tuned.Which of the following are true?
Show answer
Answer: A — A bridge separates collision domains; C — A hub forwards a collision along with the data; D — A router separates both collision and broadcast domains
A, C and D. A is true because each bridge port is its own segment with its own contention: a collision on one port never reaches another. C is true and is what a hub is — a physical-layer repeater copies bits with no notion of an address, so a collision is just more bits to copy, which is why a hub keeps one collision domain across all its ports. D is true because a router terminates both: it is a separate segment per interface, and it does not forward broadcasts. B is false, and it is the one worth remembering: a bridge floods a frame whose destination is unknown or is the broadcast address out of every other port, by the third rule of the learning algorithm — so a broadcast crosses a bridge unchanged and the broadcast domain is unchanged with it. Separating broadcast domains needs a router, or a VLAN configured on the switch, which is a way of making one switch behave as several.A Hamming code must correct any single-bit error in an 8-bit data word. The minimum number of parity bits required is ______
Numerical answer — type the value.
Show answer
Answer: 4
4. The r parity bits must identify which of the m + r codeword positions is corrupted, plus the case that nothing is corrupted — that is m + r + 1 outcomes, and r bits can name at most 2r of them, giving 2r ≥ m + r + 1. With m = 8: r = 3 gives 8 ≥ 12, false; r = 4 gives 16 ≥ 13, true. So 4 parity bits and a 12-bit codeword. Solve the inequality rather than recalling a table, because the same one answers every variant: m = 4 needs r = 3 (8 ≥ 8, exactly tight — the famous (7,4) code, which wastes nothing), m = 7 needs 4, and m = 32 needs 6. The commonest wrong answer is 3, from checking 2³ ≥ m + 1 and forgetting that the parity bits themselves occupy positions that can also be corrupted. And note what this code does not do: single-error correction needs minimum distance 3, which detects two errors but corrects only one — a double error is silently mis-corrected.With bit stuffing and the flag 01111110, the data 0111111111111110 is transmitted as:
Show answer
Answer: B — 011111011111011110
011111011111011110. Walk the data inserting a 0 after every fifth consecutive 1, counting from the start of each run. The input is a 0 then thirteen 1s then a 0. After the first five 1s insert a 0 (giving0111110), which resets the count; the next five 1s trigger another insertion (111110); the remaining three 1s and the trailing 0 pass through. That yields0 11111 0 11111 0 111 0= 011111011111011110, two bits longer than the 16-bit input. Option A misses the point of the rule: stuffing does not look for the whole flag in the data, it pre-empts it by making six consecutive 1s impossible in the payload, so the only place the flag can appear is as a real delimiter. Options C and D miscount the runs — the reliable method is to reset the counter to zero the moment a 0 is emitted, whether that 0 was original data or stuffed. The receiver reverses it mechanically: delete any 0 that directly follows five 1s.Which statement about circuit switching and datagram packet switching is correct?
Show answer
Answer: B — Circuit switching reserves capacity that is wasted when idle; datagram switching shares it but promises nothing
That is the trade in one sentence, and everything else follows from it. Reserving a path guarantees the rate and the ordering and cannot be shared while idle; sharing the links gives statistical multiplexing and therefore no guarantee about delay, jitter or ordering. Option A is half right at most: only datagram switching can reorder, because each packet is routed independently and may take a different path — a circuit is one fixed path, so units arrive in the order sent, and the same is true of a virtual circuit. Option C inverts the defining property: the absence of setup is what makes a datagram network a datagram network; it is the virtual circuit that sets up once and then labels. Option D describes datagram switching — after a circuit is established the units need no destination address at all, which is exactly the overhead the setup buys back, and a virtual circuit carries only a short circuit identifier.A protocol uses 4-bit sequence numbers. The maximum window sizes for Go-Back-N and Selective Repeat respectively are:
Show answer
Answer: B — 15 and 8
15 and 8. With m = 4 the sequence space holds 2⁴ = 16 numbers. Go-Back-N keeps a receive window of exactly one — it accepts only the next expected frame — so it needs the send window to be one short of the space to keep a retransmission distinguishable from a new frame: 2m − 1 = 15. Selective Repeat accepts out-of-order frames into a receive window of its own, so the send and receive windows together must not exceed the space, giving each at most 2m−1 = 8. Option C reverses them, which is the commonest error and is worth a check: SR is the more capable protocol but has the smaller maximum window, because capability at the receiver is what costs sequence space. Option A forgets that using the whole space makes an old retransmission indistinguishable from a fresh frame. Option D applies Go-Back-N’s rule to both. Worth pairing with the efficiency cap: a window is useless beyond 1 + 2a, so on a link with a = 2 both protocols saturate at W = 5 and neither limit bites.