While the physical layer is responsible for the transmission of good signal through a physical medium, the link layer is responsible for the movement of a packet of information from one node to a neighboring node. In this context, we will consider a node to be a neighbouring node if it is connected through a single communication link, regardless of whether it’s wired or wireless.

Services provided by the link layer

The link layer can provide the following services:

Framing

This process involves the encapsulation of payloads from the higher layers of the stack into the link layer packet, commonly referred to as a frame.

Link access

A physical link may be shared between multiple nodes, which means that there must be a way to mediate access to this link, so that the nodes can coordinate with each other to ensure only one of them transmits data at a given time. This is achieved through protocols known as medium access control (MAC) protocols. These protocols can be grouped into three main categories:

  • Channel partitioning protocols
  • Random access protocols
  • Taking-turn protocols

Channel partitioning protocols

Channel partitioning protocols partition the channel into parts that can be used concurrently by more than one node. There are three main types of channel partitioning protocols:

  • Time-division multiple access: This type of protocol is used to assign separate time slots to the nodes for when they are allowed to transmit.
  • Frequency-division multiple access: This type of protocol is used to assign the specific frequencies on which the nodes are allowed to transmit.
  • Code-division multiple access: In this protocol type, nodes can transmit concurrently but encode their data using a different encoding scheme.

Random access protocols

As the name implies, random access protocols allow any node to transmit at the full rate of a channel whenever they want, which means that transmissions from multiple nodes may collide and the nodes may need to retransmit that data.

There are many random access protocols, but two of the most well-known and widely adopted protocols are the ALOHA protocol and the CSMA protocol.

  • The ALOHA protocol is quite simple. When the nodes have data, they transmit it. If they receive data from other nodes while transmitting some other data, they try transmitting the same data again later.
  • The CSMA protocol, which stands for carrier sense multiple access, is slightly more elaborate since the nodes listen to the channel before transmitting, and they start transmitting only if the channel is idle.

Note: There are multiple variants of CSMA, all of which handle collisions differently, but we will not cover them in this course.

Taking-turn protocols

Taking-turn protocols allow nodes to coordinate with each other to acquire access to the medium.

Two of the main taking-turn protocols are:

  • The polling protocol: This protocol is used to designate a node as the leader node, which is responsible for passing the access to the medium sequentially through the nodes.
  • The token-passing protocol: This protocol is used where nodes work without a leader node to sequentially pass access to the medium through the nodes. They perform this task on their own by passing a special message (the token), which gives each node access to the medium.

Reliable delivery

Reliable delivery is the guarantee that the data transmitted over the medium will be received by its destination, regardless of potential complications that might happen. As is explained later on, this reliable delivery is available only at some of the higher layers, so not all of the link layer protocols provide this service.

For performance reasons reliable delivery is often provided in links that are prone to high error rates, such as wireless links. However, in order to avoid extra overhead costs, it is typically not provided for low error rate links, such as wired links.

Achieving reliable delivery

Reliable delivery is achieved through the transmission of acknowledgment messages from the recipient and retries by the sender.

Error detection and error correction

Error detection is the process used to identify the cases in which an error pops up during transmission— due to signal attenuation and electromagnetic noise. This process is also used to recover from that error, through detection of the data that were altered and in which way.

To accomplish this process of error detection and correction, the data is sent alongside an additional piece of redundant data that can be used to determine whether the data have was received as it was originally transmitted or changed in any way. There are many techniques to carry out this process but checksums and cyclic redundancy checks (CRC) are the most common ones.

Checksum technique

In checksumming techniques, the stream of data is treated as a sequence of k-bit integers, which are summed up to produce the checksum that is sent along with the data.

Cyclic redundancy checks

When we use cyclic redundancy checks, a list of bits is appended to the data that needs to be sent, so that the resulting number is exactly divisible by a pre-agreed number.

Link layer as a bridge

Note: The physical layer consists of the specifications of the hardware components, which participate in the transmission of data on a physical medium.

The link layer contains some parts that are implemented in hardware, that is, in the network interface card and other parts that are implemented in software, that is, in device drivers.

The higher layers are implemented exclusively in software. For example, they either come in as part of the kernel of the OS or in third-party libraries.

As a result, the link layer essentially forms a bridge between the hardware and the software.

Note: This is true in the general case, but there are always exceptions, and there may be more in the future given the rapid progress in the evolution of hardware components. As an example, the TCP offload engine is a technology that offloads the processing of higher layers to the network controller in order to achieve higher performance.

Get hands-on with 1400+ tech skills courses.