The Data Link Layer is the 2nd layer from the bottom to the top of the OSI model. Its job is to provide node-to-node delivery of data. The primary role of the data link layer is to check whether the data transmitted from one point to another node point on the physical layer is error-free or not. If any error occurs during data transmission, the data link layer will discard that data and resend the data. This layer is responsible for reliable and efficient communication between devices.
Data link layer has two sub-layers: The first sub layer is Logical Link Control (LLC) which deals with protocols, flow-control, and error control whereas second sub layer is Media Access Control (MAC) which deals with actual control of media.
For effective data communication between two directly connected transmitting and receiving stations the data link layer has to carry out a number of specific functions as follows:
1. Services provided to the network layer: A well-defined service interface to the network
layer on source machine to the network layer on destination machine.
Frame synchronization: The source machine sends data in blocks called frames to the destination machine, The starting and ending of each frame should be recognized by the destination machine,
3. Flow control: The source machine must not send data frames at a rate faster than the destination machine can accept them.
4 Error control: The errors made in bits during transmission from source to destination machines must be detected and corrected.
5. Addressing: On a multi point line, such as many machines connected together (LAN), the identity of the individual machines must be specified while transmitting the data frames.
6. Control and data on same link: The data and control information are combined in a frame and transmitted from the source to destination machine. The destination machine must be able to recognize control information from the data being transmitted.
7. Link Management: The initiation, maintenance and termination of the link between the source and destination are required for effective exchange of data. It requires co-ordination and co-operation among stations. Protocols or procedures are required for the link management.
8. Half duplex & Full Duplex: In a Full-Duplex mode, both the nodes can transmit the data at the same data. In a Half-Duplex mode, only one node can transmit the data at the same time.
9. Congestion Control: Although a link may be congested with frames, which may result in frame loss, most data-link-layer protocols do not directly use a congestion control to alleviate congestion, although some wide-area networks do. In general, congestion control is considered an issue in the network layer or the transport layer because of its end-to-end nature.
Error Detecting Techniques:
The most popular Error Detecting Techniques are:
- Single parity check
- Two-dimensional parity check
- Checksum
- Cyclic redundancy check
Simple Parity Check
Simple-bit parity is a simple error detection method that involves adding an extra bit to a data transmission. It works as:
- 1 is added to the block if it contains an odd number of 1’s, and
- 0 is added if it contains an even number of 1’s
This scheme makes the total number of 1’s even, that is why it is called even parity checking.
Drawbacks of Single Parity Checking
- It can only detect single-bit errors which are very rare.
- If two bits are interchanged, then it cannot detect the errors.
Two-dimensional Parity check bits are calculated for each row, which is equivalent to a simple parity check bit. Parity check bits are also calculated for all columns, then both are sent along with the data. At the receiving end, these are compared with the parity bits calculated on the received data.
Drawbacks Of 2D Parity Check
- If two bits in one data unit are corrupted and two bits exactly the same position in another data unit are also corrupted, then 2D Parity checker will not be able to detect the error.
- This technique cannot be used to detect the 4-bit errors or more in some cases.
Checksum
Checksum error detection is a method used to identify errors in transmitted data. The process involves dividing the data into equally sized segments and using a 1’s complement to calculate the sum of these segments. The calculated sum is then sent along with the data to the receiver. At the receiver’s end, the same process is repeated and if all zeroes are obtained in the sum, it means that the data is correct.
It is divided into two parts:
Checksum Generator
A Checksum is generated at the sending side. Checksum generator subdivides the data into equal segments of n bits each, and all these segments are added together by using one's complement arithmetic. The sum is complemented and appended to the original data, known as checksum field. The extended data is transmitted across the network.
Framing:
In the physical layer, data transmission involves synchronized transmission of bits from the source the destination. The data link layer packs these bits into frames. Data-link layer takes the packet from the Network Layer and encapsulates them into frames. If the frame size becomes too large, the then packet may be divided into small sized frames. Smaller sized frames make flow control and error control more efficient. Then, it sends each frame bit-by-bit on the hardware. At receiver's end, data link layer picks up signals from hardware and assembles them into frames. Ethernet, token ring, frame relay, and other data link layer technologies have their own frame structures. Frames have headers that contain information such as error-checking codes.
Parts of a frame: Frame has following parts
Flag |
Header |
Payload Field |
Trailer |
Flag |
Frame Header: A frame header contains information used to process the frame. In particular, it contains the source and the destination addresses of the frame
Payload field: It contains the message to be delivered and is usually much larger than the frame header. In most network technologies, the message is opaque in the sense that the network only examines the frame header. Thus, the payload can contain an arbitrary sequence of bytes that are only meaningful to the sender and receiver.
Trailer: It contains the error detection and error correction bits.
Flag: It marks the beginning and end of the frame.