The data link layer is the protocol layer in a program that handles how data moves in and out of a physical link in a network. The data link layer is Layer 2 in the Open Systems Interconnection (OSI) architecture model for a set of telecommunication protocols.
The data link layer encodes, decodes and organizes data bits in the data link layer before it transports the data bits as frames between two adjacent nodes on the same local area network (LAN) or wide area network. The data link layer also determines how devices recover from collisions that might occur when nodes attempt to send frames at the same time.
The data link layer has two sublayers: the logical link control (LLC) sublayer and the media access control (MAC) sublayer.
The IEEE 802 LAN specification dictates the LLC sublayer controls data flow among various applications and services, as well as provides acknowledgement and error notification mechanisms. The LLC sublayer can then talk to a number of IEEE 802 MAC sublayers, which control access to the physical media for transport. It is also responsible for the physical addressing of frames.
Two common MAC layer types are Ethernet and 802.11 wireless specifications.
The data link layer has three main functions:
The data link layer ensures an initial connection has been set up, divides output data into data frames and handles the acknowledgements from a receiver that confirms if data has successfully arrived. It also analyzes bit patterns at special places in the frames, which ensures incoming data has been successfully received.
If an error occurs, the data link layer notifies higher-level protocols that something has happened to the physical link. Frame sequencing capabilities within the data link layer permit the receiving device to reorder frames that might have been transmitted out of sequence. The data link layer verifies the packet isn't impaired.
The data link layer also manages flows because it can enable devices on a link to detect congestion. Nearby devices then transmit congestion information, so traffic can accordingly reroute on the network.
Editor's note: This article was reformatted to improve the reader experience.
16 Nov 2023