The Link Layer and Local Area Networks

The Link Layer and Local Area Networks

So far we have learned that the network layer provides a communication service between two hosts. As illustrated in Figure 1, this communication path comprises a series of communication links, starting at the source host, passing through a series of routers, and ending at the destination host. As we continue to proceed down the protocol stack, from the network layer to the link layer, we naturally wonder how packets are sent across the individual links that make up the end-to-end communication path. How are the network-layer datagrams encapsulated in the link-layer frames for transmission over a single link? Can link-layer protocols provide router-to-router reliable data transfer? Can different link-layer protocols be used in the different links along the communication path? We'll answer these and other important questions in this section.

In discussing the link layer, we'll find that there are two basically different types of link-layer channels. The first type consists of broadcast channels, which are common in local area networks (LANs), wireless LANs, satellite networks, and hybrid fiber-coaxial cable (HFC) access networks. For a broadcast channel, many hosts are connected to the same communication channel, and a so-called medium access protocol is needed to coordinate transmission and avoid collisions among transmitted frames. The second type of link-layer channel is the point-to-point communication link, such as between two routers, or between a residential dial-up modem and an ISP router. Coordinating access to a point-to-point link is trivial, but there are still important issues surrounding framing, reliable data transfer, error detection, and flow control.

The link layer

We'll look at various important link-layer technologies in this section. We'll take an in-depth look at Ethernet, by far the most prevalent wired LAN technology. We'll also consider point-to-point protocol (PPP), the protocol of choice for dial-up residential hosts. Although WiFi, and more generally wireless LANs, are certainly link-layer topics, we'll postpone our study of this important topic until "Wireless and Mobile Networks", which is devoted to wireless computer networking and mobility.

Link Layer: Introduction and Services

Let's begin with some useful terminology. We'll find it convenient in this section to refer to the hosts and the routers simply as nodes since, as we'll see shortly, we will not be particularly concerned whether a node is a router or a host. We will also refer to the communication channels that connect adjacent nodes along the communication path as links. In order for a datagram to be transferred from source host to destination host, it must be moved over each of the individual links in the end-to-end path. Over a given link, a transmitting node encapsulates the datagram in a link-layer frame and transmits the frame into the link; the receiving node then receives the frame and extracts the datagram.

The Services Provided by the Link Layer

A link-layer protocol is used to move a datagram over an individual link. The link-layer protocol defines the format of the packets exchanged between the nodes at the ends of the link, as well as the actions taken by these nodes when the packets are sent and received. Recall from "Computer Networks and the Internet" that the units of data exchanged by a link-layer protocol are called frames, and that each link-layer frame typically encapsulates a network-layer datagram. As we'll see shortly, the actions taken by a link-layer protocol when sending and receiving frames include error detection, retransmission, flow control, and random access. Examples of link-layer protocols include Ethernet, 802.11 wireless LANs (also known as WiFi), token ring, and PPP. We'll cover many of these protocols in detail in the latter half of this section.
 
Whereas the network layer has the end-to-end job of moving transport-layer segments from the source host to the destination host, a link-layer protocol has the somewhat simpler, node-to-node job of moving network-layer datagrams over a single link in the path. An important characteristic of the link layer is that a datagram may be carried by different link-layer protocols on the different links in the path. For instance, a datagram may be carried by Ethernet on the first link, PPP on the last link, and a link-layer WAN protocol in the intermediate links. It is important to note that the services provided by the different link layer protocols along an end-to-end path may be different. For instance, some link-layer protocols provide reliable delivery whereas others do not. Thus, the network layer must be able to accomplish its end-to-end job in the presence of a heterogeneous set of individual link-layer services.

In order to gain insight into the link layer and how it relates to the network layer, let's consider a transportation analogy. Consider a travel agent who is planning a trip for a tourist traveling from Princeton, New Jersey, to Lausanne, Switzerland. The travel agent decides that it is most convenient for the tourist to take a limousine from Princeton to JFK airport, then a plane from JFK airport to Geneva's airport, and finally a train from Geneva's airport to Lausanne's train station. Once the travel agent makes the three reservations, it is the responsibility of the Princeton limousine company to get the tourist from Princeton to JFK; it is the responsibility of the airline company to get the tourist from JFK to Geneva; and it is the responsibility of the Swiss train service to get the tourist from Geneva to Lausanne. Each of the three segments of the trip is "direct" between two "adjacent" locations. Note that the three transportation segments are managed by different companies and use entirely different transportation modes (limousine, plane, and train). Although the transportation modes are different, they each provide the basic service of moving passengers from one location to an adjacent location. In this transportation analogy, the tourist is a datagram, each transportation segment is a communication link, the transportation mode is a link-layer protocol, and the travel agent is a routing protocol.

Although the basic service of any link layer is to move a datagram from one node to an adjacent node over a single communication link, the details of the provided service can vary from one link-layer protocol to the next. Possible services that can be offered by a link-layer protocol include:

●  Framing. Almost all link-layer protocols encapsulate each network-layer datagram within a link-layer frame before transmission over the link. A frame consists of a data field, in which the network-layer datagram is inserted, and a number of header fields. (A frame may also include trailer fields; however, we will refer to both header and trailer fields as header fields.) The structure of the frame is specified by the link-layer protocol. We'll see several different frame formats when we examine specific link-layer protocols in the second half of this section.

●  Link access. A medium access control (MAC) protocol specifies the rules by which a frame is transmitted onto the link. For point-to-point links that have a single sender at one end of the link and a single receiver at the other end of the link, the MAC protocol is simple (or nonexistent) - the sender can send a frame whenever the link is idle. The more interesting case is when multiple nodes share a single broadcast link - the so-called multiple access problem. Here, the MAC protocol serves to coordinate the frame transmissions of the many nodes; we'll study MAC protocols in detail in "Multiple Access Protocols".

●  Reliable delivery. When a link-layer protocol provides reliable delivery service, it guarantees to move each network-layer datagram across the link without error. Recall that certain transport-layer protocols (such as TCP) also provide a reliable delivery service. Similar to a transport-layer reliable delivery service, a link-layer reliable delivery service is often achieved with acknowledgments and retransmissions (see "Principles of Reliable Data Transfer"). A link-layer reliable delivery service is often used for links that are prone to high error rates, such as a wireless link, with the goal of correcting an error locally - on the link where the error occurs - rather than forcing an end-to-end retransmission of the data by a transport- or application-layer protocol. On the other hand, link-layer reliable delivery can be considered an unnecessary overhead for low bit-error links, including fiber, coax, and many twisted-pair copper links. Therefore, many wired link-layer protocols do not provide a reliable delivery service.

●  Flow control. The nodes on each side of a link have a limited amount of frame buffering capacity. This is a concern when a receiving node may receive frames at a rate faster than it can process them. Without flow control, the receiver's buffer can overflow and frames can get lost. Similar to the transport layer, a link-layer protocol can provide flow control in order to prevent the sending node on one side of a link from overwhelming the receiving node on the other side of the link.

●  Error detection. The link-layer hardware in a receiving node can incorrectly decide that a bit in a frame is zero when it was transmitted as a one, and vice versa. Such bit errors are introduced by signal attenuation and electromagnetic noise. Because there is no need to forward a datagram that has an error, many link-layer protocols provide a mechanism to detect such bit errors. This is done by having the transmitting node include error-detection bits in the frame, and having the receiving node perform an error check. Recall from "Transport Layer" and "The Network Layer" that the Internet's transport layer and network layers also provide a limited form of error detection - the Internet checksum. Error detection in the link layer is generally more sophisticated and is implemented in hardware.

●  Error correction. Error correction is similar to error detection, except that a receiver not only detects when bit errors have occurred in the frame but also determines exactly where in the frame the errors have occurred (and then corrects these errors). Some protocols provide link-layer error correction for the packet header rather than for the entire packet. We'll cover error detection and correction in "Error-Detection and -Correction Techniques".

●  Half-duplex and full-duplex. With full-duplex transmission, the nodes at both ends of a link may transmit packets at the same time. With half-duplex transmission, a node cannot both transmit and receive at the same time.

As noted above, many of the services provided by the link layer have strong parallels with services provided at the transport layer. For instance, both the link layer and the transport layer can provide reliable delivery. Although the mechanisms used to provide reliable delivery in the two layers are similar (see "Principles of Reliable Data Transfer"), the two reliable delivery services are not the same. A transport protocol provides reliable delivery of segments between two processes on an end-to-end basis; a reliable link-layer protocol provides reliable delivery of frames between two nodes connected by a single link. Likewise, both link-layer and transport-layer protocols can provide flow control and error detection; again, flow control in a transport-layer protocol is provided on an end-to-end basis, whereas it is provided in a link-layer protocol on a node-to-adjacent-node basis.

Where Is the Link Layer Implemented?

Before diving into our detailed study of the link layer, let's consider the question of where the link layer is implemented. We'll focus here on an end system, since we learned in "The Network Layer" how the link layer is implemented in a router's line card. Is a host's link layer implemented in hardware or software? Is it implemented on a separate card or chip, and how does it interface with the rest of a host's hardware and operating system components?

Figure 2 illustrates a typical host architecture. For the most part, the link layer is implemented in a network adapter, also sometimes known as a network interface card (NIC). At the heart of the network adapter is the link-layer controller, generally a single, special-purpose chip that implements many of the link-layer services (framing, link access, flow control, error detection, etc.) identified in the previous section.

Network adapter. its relationship to other host components and to protocol stack functionality

In this way, much of a link-layer controller's functionality is implemented in hardware. For instance, Intel's 8254x controller [Intel 2009] implements the Ethernet protocols we'll study in "Ethernet"; the Atheros AR5006 [Atheros 2009] controller implements the 802.11 WiFi protocols we'll study in "WiFi: 802.11 Wireless LANs". Until the late 1990s, most network adapters were physically separate cards (such as a PCM-CIA card or a plug-in card fitting into a PC's PCI card slot) but increasingly, network adapters are being integrated onto the host's motherboard - a so-called LAN-on-motherboard configuration.

On the sending side, the controller takes a datagram that has been created and stored in host memory by the higher layers of the protocol stack, encapsulates the datagram in a link-layer frame (filling in the frame's various fields), and then transmits the frame into the communication link, following the link-access protocol. On the receiving side, a controller receives the entire frame, and extracts the network-layer datagram. If the link layer performs error detection, then it is the sending controller that sets the error-detection bits in the frame header and it is the receiving controller that performs error detection. If the link layer is flow controlled, then the sending and receiving controllers exchange flow-control information so that the sender sends frames at a rate that the receiver is able to handle.

Figure 2 illustrates a network adapter attaching to a host's bus (e.g., a PCI or PCI-X bus), where it looks much like any other I/O device to the other host components. Figure 2 also illustrates that while most of the link layer is implemented in hardware on the interface card, part of the link layer is implemented in software that runs on the host's CPU. The software components of the link layer usually implement higher-level link-layer functionality such as receiving the datagram from the network layer, assembling link-layer addressing information, and activating the controller hardware. On the receiving side, link-layer software responds to interrupts from the controller (e.g., due to the receipt of one or more frames), handling error conditions and passing the datagram up to the network layer. Thus, the link layer is a combination of hardware and software - the place in the protocol stack where software meets hardware. [Intel 2009] provides a readable overview (as well as a detailed description) of the 8254x controller from a software-programming pint of view.

Figure 3 shows the sending and receiving adapters. With the main functionality of the link-layer protocol being implemented by the controller, the adapters are semi-autonomous units whose job is to transfer a frame from one adapter to another. A number of researchers have investigated the possibility of pushing more functionality (beyond link-layer processing) to the network adapters. The 8254x controller, for instance, can compute the TCP/UDP checksum and the IP header checksum in hardware - network- and transport-layer functionality being implemented by the link-layer controller.

Network adaptors communicating. a network-layer datagram encapsulated within a link-layer frame

While this may seem like an egregious violation of the layering principle, the advantage is that checksums can be computed much faster in hardware than in software, so much so that one may be tempted to ignore this violation of principle. [Mogul 2003] provides an interesting discussion of the pros and cons of performing TCP processing on an adapter. [Kim 2005] investigates performing even higher-layer functionality (HTTP caching) on the adapter.


Tags

network layer, routers, link layer, frames, network adapter

Copy Right

The contents available on this website are copyrighted by TechPlus unless otherwise indicated. All rights are reserved by TechPlus, and content may not be reproduced, published, or transferred in any form or by any means, except with the prior written permission of TechPlus.