The data link layer's primary function is to ensure data is received by the correct device in a network using hardware addresses, called MAC address, and then convert that data into bits for the physical layer to transmit. It also manages error notification, flow control and network topology.
This OSI reference model layer also provides physical transmission of data by formatting messages into small pieces, called data frames, and encapsulates the frames with additional data containing the hardware address of the destination device along with the information of the source device. Every time a data packet is sent between devices, the data link layer frames it with control information, so devices such as routers and gateways can properly forward the data to the correct device.
Routers and switches also work at the data link layer to communicate and uniquely identify devices that are connected to a local network. A typical Ethernet network uses MAC addressing to communicate with devices. Without the data link layer to frame data packets, data broadcasts within a domain are prone to collision that could lead to network traffic congestion and lost data transmissions.
The data link layer resides under layer two on the OSI reference scale and is among the top three layers that define how devices and applications within a network communicate with each other and users.