The second layer of the OSI model is the data link layer. It provides reliable and efficient communication between two or more devices on a local network (LAN) or a wide area network (WAN) by using a unique identification of each device. It also corrects errors that may occur in the physical layer by having the sender break up the input data into data frames and transmit them sequentially. Before the delivery of each package (frame), a header – at the beginning – and a trailer – is added at the end. Data headers are added by other layers, but the trailer is only added at the data link level. It is used for error detection and marks the end of the frame. Duplication of frames is also prevented by using this mechanism.
The data link layer is often divided into two sublayers to support a wide variety of network functions:
- Logical Link Control Layer (LLC) – responsible for transferring the packets to the Network layer of the receiver. It also identifies the address of the network layer protocol from the header and provides flow control.
- Media Access Control Layer (MAC) – it is a link between the Logical Link Control layer and the network’s physical layer and it is used for transferring the packets over the network. It determines who is allowed to access the media by using MAC address which uniquely identifies a device of the network.
Defining physical addresses, finding a host in a local network, specifying standards and methods to access the media are the primary functions of the data link layer. Switches and bridges work in this layer. HDLC, PPP, and Frame Relay are example protocols used in it.