The job of data link layer is divided into two sub-layers
Logical Link Control (LLC):
It communicates with the upper layer and finds the network layer protocol being used.
Encapsulating the packet from network layer with some header information it creates the data link layer PDU, frame.
Media Access Control (MAC):
It adds the host and destination MAC (physical address) to the frame.
The MAC is used in only inside the local network. So a network connected to a router uses its own MAC as source MAC and the MAC of the default gateway as destination MAC. The router uses the MAC of its fast Ethernet port as source MAC and the fast Ethernet port of another router as destination MAC, when transmitting the same data packet. So it’s important to note that MAC is valid inside the local network.
Media Access Control is done in two ways:
• Controlled: Each device connected to a network has its own time to send data like token passing.
• Contention based: The device senses if there is any data ion the media (physical wire), if there is not any device can communicate any time.
Two common contention based methods are:
CSMA/CD: Ethernet uses it
CSMA/CA: Wireless networks use it. It senses the media, if available then sends a signal that tells other devices that one device is transmitting.
If several device transmits at the same type then collision occurs. When collision occurs then the connected hosts send Jam signal so that the amplitude of the voltage increases and other hosts refrain from transmitting. Also all the hosts wait a random amount of time (called Back off time) after which they try to communicate again.
The data link layer PDU contains a field called Frame check sequence to determine if there’s any error in the data. It only detects error, not correct them. If error detected then the frame is dropped.
Data Link Layer Protocols: