Chapter 2 Data-Link Layer
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 2 Data-link layer Problem Statement To transmit data over physical links from one node to another or more nodes effectively and efficiently, there is much more to do than simply modulating bit stream into signal. Transmission impairments, such as crosstalk between two adjacent pairs, can unexpectedly change transmission signal and hence result in errors. The transmitter may transmit faster than the receiver can afford. If there are multiple stations that share common transmission media, an arbitration mechanism is required to determine who can transmit its own data. The transmitter has to somehow indicate the destination, and usually needs to name itself so that the receiver knows where the source is. These problems need to be addressed by a set of functions above the physical layer. In the Open Systems Interconnection (OSI) seven-layer model, a specific layer, named data-link layer, provides the service of controlling data communications over a physical link. This layer provides solutions to the above problems. In addition, upper layers are therefore exempt from the duty of controlling parameters in a physical network. These services greatly alleviate upper-layer protocol design and make it virtually independent of physical transmission characteristics. Throughout this chapter, we intend to equip readers with fundamental background about (1) services and functions provided in the data-link layer, (2) real-world examples of popular data-link protocols, and (3) open source implementation in Linux. Frankly, there are too many real-world examples to choose. Some are legacy or much less popular nowadays. Some are in the mainstream and still some others are under development. It is nearly impossible to enumerate all of them. We subjectively offer a list of well-known data-link protocols in Table 2.1. Among these protocols, we introduce PPP as it is widely used in dial-up services. Network devices, say routers, also run PPP to carry various network layer protocols over point-to-point links among them. Ethernet technology has occupies more than 95 percent of all local area networks. It is also poised to be ubiquitous in the MAN and WAN. It is undoubtedly a technology we have to know. Wireless links allow greater mobility to make life easy. More devices, such as notebooks, Personal Data Assistant (PDA), cellular phones, and so on, are equipped with the 1 capability to access the Internet. In contrast with desktop PCs, which usually use wired links, these devices are mobile, and hence wireless links are preferred. We choose one typical example for wireless local area network, IEEE 802.11, and another for wireless personal local area network, Bluetooth in this chapter. PAN/LAN/MAN WAN Token bus (802.4) X.25 Token ring (802.5) Frame Relay DQDB (802.6) ATM HIPPI Legacy or SMDS Fiber Channel Minor Isochronous (802.9) Demand Priority (802.12) ATM FDDI ISDN Ethernet (802.3) Ethernet (802.3) Resilient Packet Ring (802.17) Resilient Packet Ring (802.17) Mainstream Point-to-Point Protocol (PPP) Point-to-Point Protocol (PPP) or HDLC Under DOCSIS development Wireless PAN/LAN/MAN (802.15/11/16) Bluetooth HIPERLAN HomeRF Table 2.1 data-link protocols Section 2.1 provides a general introduction of the functions in data-link layer. Specifically, they include framing, addressing, error control, flow control, and access control. We primarily explain why and how in this section, and leave technical details in specific protocols to later sections as possible. Section 2.2 introduces the Point-to-Point Protocol (PPP). The PPP is a standard protocol that carries multi-protocol packets in the upper layer over a point-to-point link. We present the open-source implementation so that the readers can know how the protocol operates in a real system. Following it is Section 2.3, which introduces the dominating LAN technology, Ethernet. Having evolved more than twenty years, Ethernet is rich in its physical specifications. However, this section will focus more on its functions in the data-link layer, and leaves the physical details in further reading. We also provide open Verilog code to be familiar with the implementation. Section 2.4 discusses wireless LAN. The nature of wireless media, such as mobility and lack of reliability, brings new impact in design different from wired media. Two typical examples, IEEE 802.11 and the Bluetooth technology, will be introduced in this section. Section 2.5 illustrates general concepts of device drivers in Linux. We will go deeply into Ethernet and PPP driver implementations, and list a map to indicate the source codes of the other drivers for the readers to 2 study further. In Section 2.6, we indicate common pitfalls and fallacies. There is much more to learn than the book can cover, we refer the readers to further reading in Section 2.7. 2.1 General Issues We have presented possible problems over physical communication in the prelude. Sandwiched between the physical layer and the network layer, the data-link layer provides control to physical communications and services to upper network abstraction. The major functions to address these problems in this layer include Major Functions Framing Control information comes along with the bit stream itself to specify the destination node, indicate the upper-layer protocol, check possible error, and so on. To be convenient, data are sent and processed in units of frames. A typical frame usually contains two main parts: control information and the data. Control information is referred to during frame processing by the data-link protocols. The data part comes from upper layers and is encapsulated with the control information into a whole frame. The data-link layer service should somehow delimit bit stream into frames and convert frames into bit stream. Notice that the two terms, packets and frames, are usually used interchangeably. To be more specific, here we refer to the data unit in the data-link layer as frames. Addressing We need an address when writing a letter to our friends. We also need a phone number when dialing up to them. Addressing is needed for the same reason in the data-link layer. The identities of the involved stations are indicated by an address, often presented in a numeric form of some length. Error control Data transmitted over physical media are subject to errors. The errors must be detected by the receiver. The receiver may somehow inform the transmitter that there are errors so that the transmitter knows to retransmit the data. Flow control The transmitter may send at a rate faster than the receiver can afford. In this situation, the receiver has to discard the frames, making the transmitter retransmits the dropped frames. However, this is inefficient. Flow control provides a way to let the receiver slow down the transmitter. Medium Access control There must be an arbitration mechanism when there are multiple stations that want to transmit data over shared media. For a good arbitration mechanism, the access to a shared medium should be fair and the 3 utilization of the shared medium must keep high if many stations are intended to transmit simultaneously. This section raises general functions in the data-link layer. After these preliminaries, we will exemplify the operations in popular data-link layer protocols in later sections. 2.1.1 Framing Frame Delimiting Because data are transmitted in raw bit stream in the physical layer, the data-link layer must somehow tell the beginning and the end of a frame. It must also convert frames into raw bit stream for physical transmission. This is called framing. There are many ways to delimit frames. Depending on the basic unit of a frame, which can be byte (or octet) or bit, called byte-oriented or bit-oriented frames, we may use special sentinel characters or bit pattern to mark the frame boundary. We introduce how framing is achieved with examples of bit-oriented HDLC frames and legacy BISYNC frames. There are still other ways to delimit frames. For examples, some Ethernet systems use special physical encoding to mark frame boundary while others identify the boundary simply by the presence or absence of signal1. A bit-oriented frame can specify a special bit pattern, say 01111110 in HDLC, while a byte-oriented frame can specify special characters, say SOH (start of header) and STX (start of text) to mark the beginning of frame header and data. There may be an ambiguity when normal data characters or bits are the same as the special characters or pattern. A technique called byte- or bit-stuffing is used to solve the ambiguity, as illustrated in Fig. 2.1. A special escape character, namely DLE (data link escape), precedes a special character to indicate the next character is normal data in a byte-oriented frame. Of course, DLE itself is also a special character. Two consecutive DLEs represent a normal character the same as DLE. For bit-oriented frames, the bit pattern 01111110 is used in HDLC. When there are five consecutive 1’s in the normal data bits, a 0 is stuffed after the five 1’s so that the pattern 01111110 never appears in the normal data bits. Both the transmitter and the receiver follow the same rule and hence the ambiguity is solved. A different approach is in the Ethernet. For example, 100BASE-X can use special encoding to mark the boundary because after 4B/5B encoding (See Section 1.1.1), there are 32 (= 25) codes that can be transmitted over physical 1 Ethernet uses the term ‘stream’ to refer to physical encapsulation of a frame. Strictly speaking, special encoding or presence of signal delimit stream, not frame.