When data is being transmitted from one machine to another, it may possible that data become corrupted on its way. Some of the bits may be altered, damaged or lost during transmission. Such a condition is known as error.
Another important design issue that occurs in the data link layer (and higher layers as well) is what to do with a sender that systematically wants to transmit frames faster than the receiver can accept them.
This situation can easily occur when the sender is running on a fast (or lightly loaded) computer and the receiver is running on a slow (or heavily loaded) machine.
The sender keeps pumping the frames out at a high rate until the receiver is completely swamped. Even if the transmission is error free, at a certain point the receiver will simply be unable to handle the frames as they arrive and will start to lose some. Clearly, something has to be done to prevent this situation.
Error control function of data link layer detects the error in transmitted frames and retransmits all the erroneous frames.
Therefore error control function of data link layer helps in dealing with data frames that are damaged in transmit, data frame lost in transmit and the acknowledgment frame that are lost in transmission.
The method is used for error control is called Automatic Repeat Request (ARQ).
The sending device keeps a copy of the last frame transmitted until it receives an acknowledgment for that frame. Keeping this copy helps the sender in retransmission of lost or damaged frames later on.
Both data frames and ACK frames are numbered alternately 0 and 1 for identification purpose.
Whenever receiver sees a damaged data frame it sends NAK indicating the number of that frame. the NAK indicates that all the frames received prior to this frame are intact and the frame whole number is specified in NAK damaged.
Whenever receiver gets damaged frame it stops accepting any subsequent data frames and sends NAK to sender.
Whenever NAK is received by the sender it retransmit all the data.
In sliding window the data frames must be transmitted sequentially
Receiving any frame, the receiver checks the identifying number on each frame. If any of the frame is lost & is missing in sequence, the receiver sends NAK indicating the number of that frame & discard all other frames that are received out of order.
When a receiver gets damaged frame it sends NAK for that particular frame. This NAK acknowledges the intact receipt of a previously unacknowledged data frames and also indicates an error in current frame.