§6.1Introduction to the Link Layer

Link layer Kurose & Ross pp. 449–453 · ~15 min read

  • node
  • link
  • framing
  • medium access control protocol
  • network adapter
  • broadcast link

Where you are

  • Application layer
  • Transport layer
  • Network layer
  • Link layer you are here
  • Physical layer

The link layer moves a datagram across one link, and it is the first layer whose answers depend on what that link physically is.

Words you will meet

  • Node — in this chapter, any device that runs a link-layer protocol: a host, a router, a switch, a WiFi (IEEE 802.11 wireless LAN) access point.

  • Link — the communication channel joining two adjacent nodes.

  • Framing — wrapping a datagram in a frame before putting it on the link.

  • Medium access control protocol — written MAC (Media Access Control) : the rules that say when a node may transmit.

  • Broadcast link — one shared channel that every node on it hears.

  • Network adapter — written NIC (Network Interface Controller) : the chip that does most of the link layer.

Why this matters

Chapters 4 and 5 delivered a datagram from any host to any other host in the world. They never said how it crossed a single cable.

That sounds like a detail and it is not. A datagram crossing the Internet is re-wrapped at every hop, by a different protocol each time. The properties of those protocols differ enormously. Some check for errors, some retransmit, and some have to negotiate for permission to speak at all.

This is also the first chapter where the answer is partly a piece of hardware. Everything above has been software.

The book’s opening example is a datagram travelling from a wireless host to a server inside one company network. It crosses six links.

Figure 6.1 — six link-layer hops between a wireless host and a server
Hop 1 · a WiFi linkstep 1 of 6
wireless hostaccess pointswitchrouterrouterswitchserverone datagram · six links · four different link-layer protocols1802.11

The sending host has no cable. It encapsulates the datagram in an 802.11 frame and transmits it to the access point. Chapter 7 covers this link properly; here it is just the first of six.

The datagram is the same all the way across. What changes at every hop is the frame it travels inside, and the protocol that puts it there.

Read all steps as text
  1. Hop 1 · a WiFi linkThe sending host has no cable. It encapsulates the datagram in an 802.11 frame and transmits it to the access point. Chapter 7 covers this link properly; here it is just the first of six.
  2. Hop 2 · an Ethernet linkThe access point strips the 802.11 frame, takes the datagram out, wraps it in an Ethernet frame, and sends it to the link-layer switch. Same datagram, completely different frame.
  3. Hop 3 · switch to routerAnother link, another frame. The switch is not the datagram’s destination and never looks at its IP address — section 6.4.3 explains how it forwards without doing so.
  4. Hop 4 · router to routerThis is the hop chapters 4 and 5 spent their time on. To the link layer it is one more link, with one more frame, and it may use a protocol none of the others use.
  5. Hops 5 and 6 · Ethernet, twice moreRouter to switch, then switch to server. Six hops in total, and the datagram that arrives at the server is byte for byte the datagram the wireless host sent.
  6. What was constant, and what was notCONSTANT: the datagram, and the two IP addresses in its header. NOT CONSTANT: the frame, the frame’s addresses, the protocol, the rate of the link, and whether anybody was checking for errors. Every node in the middle unwrapped one frame and wrote a new one.

Over each link, the transmitting node encapsulates the datagram in a frame and transmits the frame into the link. Over the next link, some other node does it again, with a different frame.

One packet, four names — learn these now

The book uses a different word at each layer, and it is never careless about which. Neither is this site.

Layer Call it a… Looks like Its header says
application message M What the application actually wants to send.
transport segment Ht M Which program on the far host, plus error-detection bits.
network datagram Hn Ht M The addresses of the two hosts.
link frame Hl Hn Ht M How to cross this one link — and it changes at every hop.

M is the application's message. Ht, Hn and Hl are the transport, network and link headers. Each layer treats everything handed down to it as one opaque payload and puts its own header in front.

The four words, one last time. This chapter owns the bottom row — and it is the only row whose unit is rebuilt at every hop.

Everyday picture

The book’s own analogy, and it is a good one. A travel agent plans a trip from Princeton, New Jersey to Lausanne, Switzerland. A limousine from Princeton to JFK airport, then a plane from JFK to Geneva, then a train from Geneva to Lausanne.

Once the three reservations are made, each company is responsible for its own segment and nothing else. Each segment is direct, between two adjacent places, and the three use entirely different means of transport.

The tourist is the datagram. Each segment is a link. Each mode of transport is a link-layer protocol. The travel agent is a routing protocol.

Where the picture stops. The tourist survives the journey unchanged, and so does a datagram — but a real tourist is not put in a new box at every stage. A datagram is: the limousine company would have to unpack the traveller from a car-shaped container and repack them in a plane-shaped one.

The two kinds of link, and why the chapter divides this way
Point-to-point linkone sender, one receiverBroadcast linkmany nodes, one shared channel
Who is on it
Deciding when to transmit
Who hears a transmission
Examples
Where the chapter deals with it

Cells marked ⓘ have a reason behind them — click to read it.

Almost every design decision in this chapter follows from which column a link is in. Click any cell.

In plain words

The word broadcast here does not mean television.

Traditional broadcasting is one fixed transmitter and many receivers. On a broadcast link every node can both send and receive, over the same shared channel, and that is what creates the problem: two of them may speak at once.

The book’s better analogy is a room full of people at a party, or a classroom. The air is the shared channel, everyone can hear everyone, and the whole difficulty is working out who talks and when.

The four services a link-layer protocol may offer
ServiceWhat it means

Cells marked ⓘ have an explanation — click to read it.

Only the first is universal. Every other row is a choice, and the choices are what make one link-layer protocol different from another. Click a cell marked ⓘ.

Reliable delivery at two layers is not duplication

TCP (Transmission Control Protocol) already provides reliable delivery, end to end. So why would a link do it too?

Because the two repair different things. A link-layer retransmission fixes an error on the link where it happened, without the sender ever learning. A TCP retransmission crosses the whole path again.

On a wireless link, where errors are common, fixing them locally is far cheaper. On fibre, where they are rare, it is overhead for nothing — and many wired link-layer protocols therefore do not offer it at all.

Both can be right. It depends on the link, which is the theme of this whole chapter.

Figure 6.2 — where the link layer actually lives
The stack, as you have been drawing itstep 1 of 4
HostApplicationTransportNetworkLink

Four layers in a column, each one software running on the host. That picture has been true for every chapter so far.

The first diagram in this book that answers a question about hardware. Every layer above has been software; this one is mostly not.

Read all steps as text
  1. The stack, as you have been drawing itFour layers in a column, each one software running on the host. That picture has been true for every chapter so far.
  2. But a host is a machineIt has a CPU, memory, and a bus between them. The application, transport and network layers all run as software on that CPU, using that memory.
  3. And the link layer is mostly a chipThe network adapter — a network interface controller — implements framing, link access and error detection in hardware. Ethernet capability is either integrated into the motherboard chipset or sits on a low-cost dedicated chip.
  4. The link layer straddles the linePart of it is software on the CPU: assembling addressing information, activating the controller, responding to its interrupts, handling errors and passing datagrams up. Part of it is the controller. The book’s phrase is exact — the link layer is the place in the protocol stack where software meets hardware.

For the most part the link layer is implemented on a chip called the network adapter , also known as a network interface controller. Ethernet capability is either integrated into the motherboard chipset or provided by a low-cost dedicated chip.

On the sending side, the controller takes a datagram that the higher layers left in host memory. It encapsulates that datagram in a frame, fills in the frame’s fields, and transmits it following the link-access protocol. On the receiving side, a controller receives the whole frame and extracts the datagram. If error detection is used, the sending controller sets the bits and the receiving controller checks them — the host CPU (Central Processing Unit) is not involved either time.

But part of the link layer is software on the CPU. It assembles link-layer addressing information and activates the controller hardware. It also responds to controller interrupts, handles error conditions, and passes datagrams up to the network layer.

In plain words

The book’s sentence is worth memorising, because no earlier chapter could have written it:

the link layer is a combination of hardware and software — the place in the protocol stack where software meets hardware.

Everything above the link layer is a program. Everything below it is physics. This layer is where the two are joined. Several of its design decisions make sense only once you know a chip is doing the work: a CRC (Cyclic Redundancy Check) instead of a checksum, and error detection in the frame at all.

Check yourself

Check yourself

0 of 6 answered
  1. 1.In this chapter, what is a "node"?

  2. 2.predictA datagram crosses six links on its way from a wireless host to a server. How many times is it encapsulated in a frame?

  3. 3.Which link-layer service is provided by almost every link-layer protocol?

  4. 4.TCP already provides reliable delivery from end to end. Why would a link-layer protocol provide it too?

  5. 5.Where is most of the link layer implemented?

  6. 6.What makes a link a "broadcast" link?

What to remember

  • A datagram is re-framed at every hop. Six links means six frames, and the protocols need not be the same. The datagram itself is unchanged end to end; the frame around it is not.
  • Four possible services: framing, link access, reliable delivery, and error detection and correction. Only framing is universal.
  • Reliable delivery at the link layer is not redundant with TCP. It repairs an error where it happens, which is worth doing on a wireless link and wasteful on fibre.