12. Data link layer tasks

The main and essential role of the data link layer is to provide higher layers with access to the transmission medium. Data moving down the stack as it passes through the layers must at some point be delivered to the medium through which it reaches its destination, the receiving host. This is the primary function of the data link layer: it stores data from higher layers on the medium.

The network layer discussed in the previous section of this course included segments with IP addresses received from the transport layer during the encapsulation process to form packets. These packets arrive at the data link layer before being sent to the destination host, and then pass through the data link layer to the transmission medium. Before this, however, the packets received further control information, this time the physical address of the device, the 48-bit MAC address.

The packets then become frames and it is these frames that go into the carrier for onward transmission to the destination host. The MAC address is assigned during the manufacture of the card and stored in the ROM. The ROM is read-only, so it is not possible to change the assigned addresses at card or hardware level. However, such addresses can be changed at the device system level, for example in the operating system. Sometimes administrators make such changes at the system level, e.g. when they do not want to reconfigure the network hardware, such as when a new computer comes on the network.

The data link layer itself is the intermediary between the transmission medium
and the network software. In the case of terminal devices, i.e. computers, servers or telephones, it is the only layer implemented not only in the software domain, but also in the hardware domain. The physical representation of the data link layer is the network card that we install in our computer. These cards are the interface between the network software and the transmission medium. Since the data link layer operates on two levels, on the hardware and software level, its functions
and tasks are also divided into two smaller sub-layers:

·         LLC (Logical Link Control),

·         MAC (media access control).

The LLC sublayer frames information about the network layer protocol in use, so that different network layer protocols, such as IPv4, IPv6 or IPX, can use the same transmission medium and network card, and its functions in the computer are performed by the network card driver. On the other hand, the MAC sublayer defines the access rules to the medium and performs the addressing functions. The MAC method was discussed in the first episode of this series.

In summary - the data link layer:

·         receive data from the network layer,

·         create frames that can be transmitted through the medium,

·         gives the physical address of the frame,

·         is responsible for controlling access to the medium.

This layer is implemented on end devices such as computers, but also on routers and switches.

Data link layer frame and communication

There are many solutions and many network standards to implement Layer 2 functionality. We have Ethernet standards, we have wireless networks, and finally we have many network protocols running over WANs such as Frame Relay. So there is no such thing as a universal frame. Each network standard has its own structure, specific to a particular solution. To summarise the topic, we can assume that a typical second level framework consists of 3 main parts:

Headline

Data

Footer


source and destination MAC addresses

frame start signal


network/Internet layer packets

end-of-frame signal

checksum


Let us now follow the process of inter-device communication, focusing on the functions of the data link layer. Suppose our computer sends a request to a web server on a remote network.

The data to send such a request is already encapsulated in a single packet with the application's port number and logical address, i.e. the IP address of the computer and server.

Before a packet enters the transmission medium, the data link layer must construct a frame with the corresponding MAC addresses of the frame's sender and receiver. In the case of the MAC address of the sender, the thing is obvious, it is just the MAC address of the computer, but what about the address of the destination host? If the computer and the web server are not on the same network and the MAC address of its network card cannot be determined, this is technically impossible. Why? Because MAC addresses are only used for communication within a network and never outside the network. Therefore, the MAC address of the router interface to which our computer is connected will be stored in the frame field containing the destination MAC address.

The frame is sent through the transmission medium to the first router. The latter, upon receiving the frame, decapsulates it so that it can read the IP address of the device to which the packet is going. IP addresses cannot be read directly from Layer 2 frames, so decapsulation is required. Once the IP address is read from the packet (once the frame is decapsulated, the data becomes a packet again), compare it with the entry in the routing table and find the entry that indicates that the server network is routed through other routers.

It will then create a new frame in which the source address will be the MAC address of the interface that connects to the other router, and the destination MAC address of that router.

The frame then passes through the medium to the second router, which encapsulates the frame again to read the IP address from the packet. It finds that the recipient of the data is a device operating on the network, directly connected to it, so the encapsulation process performed by the second router happens again, this time it enters the MAC address of its second router in the MAC address field. The interface is used as the source address and the MAC address of the address server is used as the destination address.

The frames prepared in this way go to the server, which also decapsulates them. This time, however, it is the device to which the data points, so it decapsulates them completely, that is, it additionally reads the application port number in order to send the data to the corresponding specific application, in this case a web service.

The network service then prepares the response data. The data goes first to the transport layer, where the application port number is assigned, then to the network layer, forming a packet with the corresponding IP address, and finally to the data link layer, where a frame is prepared from the packet, marked with the MAC addresses of the server and router for the connected server.

The response is then passed to the media, which is then sent to the client. During this process, it passes through two routers, which perform a decapsulation and recapsulation process, and because they have to read the IP address, they can pass on the response. Finally, the response belongs to the client. This unpacks the data, allowing the browser to display the web page.