Link-Layer Services, Frames, and Physical Transmission Fundamentals
The Link Layer
The data link layer carries data between nodes on a network segment across the physical layer; typical examples are Ethernet and wireless LANs. It provides the functions for transferring data between two network entities, and it provides error detection to correct errors that occur in the physical layer.
In this chapter, hosts, routers, switches, and access points that run a link-layer protocol are all called nodes, and the communication channels that connect adjacent nodes are called links. A datagram traveling from the source host to the destination host crosses every link on its path in turn, and different links may use completely different link-layer protocols: for example, Ethernet first, then a point-to-point link over fiber, and finally a wireless LAN.
Link-layer addresses go by many names, such as LAN address, physical address, or MAC address. Because MAC address is the most popular term, link-layer addresses are generally called MAC addresses (Media Access Control addresses).
Before any network-layer datagram is transmitted, almost every link-layer protocol encapsulates it in a frame. If a frame is too large, the data link layer splits it into smaller frames, which make transmission control and error detection more efficient.
A frame consists of a header, a data field, and a trailer. The data field carries the network-layer datagram; the header usually contains link-layer addresses and a type field; and the trailer is usually an error-detection code. Services the link layer can provide include:
| Service | Description |
|---|---|
| Framing | Encapsulate datagrams in frames and let the receiver find frame boundaries |
| Link access | A medium access control (MAC) protocol decides when a node may send a frame onto the link |
| Reliable delivery | Acknowledgments and retransmissions move each frame across this one link without errors |
| Error detection and correction | Detect, and even correct, bit errors introduced by physical transmission |
Most link-layer functions are implemented in hardware on the network adapter (also called a network interface card); the rest are implemented in software in the host operating system.
One datagram, three different frames
Unlock the complete interactive lab, deeper explanations, and curated reference answers.
KNOWLEDGE QUIZ
Physical Transmission Fundamentals
The link layer hands frames to the physical layer, which turns bits into signals that propagate over copper, fiber, or air. The most direct encoding is non-return-to-zero (NRZ): 1 is a high level and 0 is a low level. When many identical bits occur in a row, however, the signal stays constant for a long time, and the receiver struggles to tell where each bit begins and ends.
Manchester encoding places a level transition in the middle of every bit: by the IEEE 802.3 convention, low-to-high means 1 and high-to-low means 0. The receiver can recover the sender's clock from these transitions, at the cost of a signal that changes twice as fast as the data rate. Early 10 Mbps Ethernet used Manchester encoding.
By whether data can travel in both directions at once, links are simplex (one direction only), half duplex (both directions, but not simultaneously), or full duplex (both directions simultaneously). The shared-medium networks of Section 5.4 are half duplex; modern Ethernet links through switches in Section 5.5 are full duplex.
Reliable Delivery
Reliable delivery at the network layer refers mainly to delivery from end system to end system, while reliable delivery at the data link layer refers mainly to node-to-node delivery across a single link. When a link-layer protocol provides reliable delivery, it guarantees to move each network-layer datagram across the link without error. Like TCP, link-layer reliable delivery uses acknowledgments and retransmissions.
Link-layer reliable delivery is typically used on links with high error rates, such as wireless links. Its goal is to correct a frame's errors locally rather than force end-to-end retransmission by a transport- or application-layer protocol. For low-error links such as fiber, coaxial cable, and twisted pair, link-layer delivery overhead is unnecessary, so these links usually do not provide reliable delivery.
Fix errors locally or end to end?
Unlock the complete interactive lab, deeper explanations, and curated reference answers.
KNOWLEDGE QUIZ
Price local versus end-to-end recovery
A packet crosses three links. The first two never lose packets; the last (wireless) link loses each attempt independently with probability p. With link-layer reliable delivery, only the last link retransmits; without it, the sender retransmits across all three links. Find the expected number of link transmissions per packet for both schemes at p = 0.2 and p = 0.5, and the p at which end-to-end recovery costs twice as much.
Encode bits as NRZ and Manchester signals in Python
Represent the high and low signal levels as H and L. Write Python that encodes the bits 10110001 with NRZ (1 = H, 0 = L) and with Manchester encoding (1 = LH, 0 = HL, the IEEE 802.3 convention), counts the level changes in each signal, and decodes the Manchester signal back to bits.