Chapter3(NEP)
Chapter3(NEP)
DATALINK LAYER
The data link layer, or layer 2, is the second layer of the seven-layer OSI model reference model. This layer
describes the techniques to access a shared communication channel and to ensure reliable transmission of
data frame in computer communication environment
• The data link layer takes the data bits and “frames,” and creates packets of the data to
guarantee reliable transmission.
• This layer adds source and destination addresses to the data stream as well as information to
detect and control transmission errors.
5. Error Control:Error control is achieved by adding a trailer at the end of the frame. Duplication of
frames is also prevented by using this mechanism. Data Link Layers adds mechanism to prevent
duplication of frames.
Error detection:Errors can be introduced by signal attenuation and noise. Data Link Layer
protocol provides a mechanism to detect one or more errors. This is achieved by adding error
detection bits in the frame and then receiving node can perform an error check.
Error correction: Error correction is similar to the Error detection, except that receiving node not
only detects the errors but also determine where the errors have occurred in the frame.
6. Access Control:Protocols of this layer determine which of the devices has control over the link
at any given time, when two or more devices are connected to the same link.
7. Reliable delivery:Data Link Layer provides a reliable delivery service, i.e., transmits the network
layer datagram without any error. A reliable delivery service is accomplished with transmissions
and acknowledgements. A data link layer mainly provides the reliable delivery service over the
links as they have higher error rates and they can be corrected locally, link at which an error occurs
rather than forcing to retransmit the data.
8. Half-Duplex & Full-Duplex: In a Full-Duplex mode, both the nodes can transmit the data at the
same time. In a Half-Duplex mode, only one node can transmit the data at the same time.
A. Framing
How does Framing Work?
Framing works by breaking data into smaller, manageable units called frames. Each frame
consists of a header (containing control information) and a payload (the actual data). The sender
adds the header and sends the frame over the network. The receiver then extracts the header,
processes the data, and checks for errors to ensure proper delivery. This process allows for efficient
and reliable data transmission between devices.
Framing is essential for efficient data transfer because it allows for error detection and
recovery. By dividing the data into smaller frames, if any frame is lost or corrupted during
transmission, only that specific frame needs to be retransmitted rather than the entire data packet.
Additionally, the header information helps in error checking and ensuring that the data is delivered
accurately to the intended recipient. This process ensures reliable communication between devices
in a network.
Parts of a Frame
• Frame Header A frame header contains the destination address, the source address and
control field. The conntrol field determines how to control the communications
process. There are three control fields namely, kind, seq, and ack serving the following
purposes:
o Kind: This field states whether the frame is a data frame or it is used for control
functions like error and flow control or link management etc.
o seq: This contains the sequence number of the frame for rearrangement of out – of –
sequence frames and sending acknowledgements by the receiver.
o ack: This contains the acknowledgement number of some frame, particularly when
piggybacking is used.
• Payload field − It contains the message to be delivered.
• Trailer − It contains the error detection and error correction bits.
• Flag − It marks the beginning and end of the frame.
• Frame Check Sequence (FCS) - is generally used for identification of errors i.e., error
detection.
• Simplest Protocol
It is very simple. The sender sends a sequence of frames without even thinking about the
receiver. Data are transmitted in one direction only. Both sender & receiver always ready. Processing
time can be ignored. Infinite buffer space is available. And best of all, the communication channel
between the data link layers never damages or loses frames. This thoroughly unrealistic protocol,
which we will nickname ‘‘Utopia,’’ .The utopia protocol is unrealistic because it does not handle
either flow control or error correction
• Stop-and-wait Protocol
It is still very simple. The sender sends one frame and waits for feedback from the receiver.
When the ACK arrives, the sender sends the next frame. It is Stop-and-Wait Protocol because the
sender sends one frame, stops until it receives confirmation from the receiver (okay to go ahead),
and then sends the next frame. We still have unidirectional communication for data frames, but
auxiliary ACK frames (simple tokens of acknowledgment) travel from the other direction. We add
flow control to our previous protocol.
NOISY CHANNELS
Although the Stop-and-Wait Protocol gives us an idea of how to add flow control to its
predecessor, noiseless channels are nonexistent. We can ignore the error (as we sometimes do), or
we need to add error control to our protocols. We discuss three protocols in this section that use
error control.
Lost frames are more difficult to handle than corrupted ones. In our previous protocols, there
was no way to identify a frame. The received frame could be the correct one, or a duplicate, or a
frame out of order. The solution is to number the frames. When the receiver receives a data frame
that is out of order, this means that frames were either lost or duplicated
The lost frames need to be resent in this protocol. If the receiver does not respond when there
is an error, how can the sender know which frame to resend? To remedy this problem, the sender
keeps a copy of the sent frame. At the same time, it starts a timer. If the timer expires and there is
no ACK for the sent frame, the frame is resent, the copy is held, and the timer is restarted. Since the
protocol uses the stop-and-wait mechanism, there is only one specific frame that needs an ACK
Error correction in Stop-and-Wait ARQ is done by keeping a copy of the sent frame and
retransmitting of the frame when the timer expires
In Stop-and-Wait ARQ, we use sequence numbers to number the frames. The sequence numbers
are based on modulo-2 arithmetic.
better understanding, we took the running sequence numbers, i.e., 0,1,2,3,4,5,6,7,8,9,10. Let's
consider the window size as 4, which mean that the four frames can be sent at a time before
expecting the acknowledgment of the first frame.
Step 1: Firstly, the sender will send the first four frames to the receiver, i.e., 0,1,2,3, and now the sender
is expected to receive the acknowledgment of the 0th frame.
Step 2:Let's assume that the receiver has sent the acknowledgment for the 0 frame, and the receiver
has successfully received it.
Step 3:The sender will then send the next frame, i.e., 4, and the window slides containing four frames
(1,2,3,4).
Step 4:The receiver will then send the acknowledgment for the frame no 1. After receiving the
acknowledgment, the sender will send the next frame, i.e., frame no 5, and the window will slide
having four frames (2,3,4,5).
Step 5:Now, let's assume that the receiver is not acknowledging the frame no 2, either the frame is
lost, or the acknowledgment is lost. Instead of sending the frame no 6, the sender Go-Back to 2,
which is the first frame of the current window, retransmits all the frames in the current window, i.e.,
2,3,4,5.
If the receiver receives a corrupt frame, it does not directly discard it. It sends a negative
acknowledgment to the sender. The sender sends that frame again as soon as on the receiving
negative acknowledgment. There is no waiting for any time-out to send that frame.
B. Error Detection
Error
A condition when the receiver’s information does not matches with the sender’s information.
During transmission, digital signals suffer from noise that can introduce errors in the binary bits
travelling from sender to receiver. That means a 0 bit may change to 1 or a 1 bit may change to
0.
Error Detecting Codes (Implemented either at Data link layer or Transport Layer of OSI Model)
Whenever a message is transmitted, it may get scrambled by noise or data may get corrupted.
To avoid this, we use error-detecting codes which are additional data added to a given digital
message to help us detect if any error has occurred during transmission of the message.
Basic approach used for error detection is the use of redundancy bits, where additional bits
are added to facilitate detection of errors. Some popular techniques for error detection are:
a. Simple Parity check
b. Two-dimensional Parity check
c. Checksum
d. Cyclic redundancy check
a. Simple Parity check
Blocks of data from the source are subjected to a check bit or parity bit generator form, where
a parity of : 1 is added to the block if it contains odd number of 1’s, and0 is added if it contains even
number of 1’s.
This scheme makes the total number of 1’s even, that is why it is called even parity checking.
b. Checksum
• In checksum error detection scheme, the data is divided into k segments each of m bits.
• In the sender’s endthesegmentsareadded using1’s complement arithmetic to get the sum.
The sum is complemented to get the checksum.
• The checksum segment is sent along with the data segments.
• At the receiver’s end, all received segments are added using 1’s complement arithmetic to
get the sum. The sum is complemented.
• If the result is zero, the received data is accepted; otherwise discarded.
C. Error Correction
Error Correction codes are used to detect and correct the errors when data is transmitted from
the sender to the receiver.
Error Correction can be handled in two ways:
Backward error correction:Once the error is discovered, the receiver requests the sender to
retransmit the entire data unit.
Forward error correction:In this case, the receiver uses the error-correctingcode which
automatically corrects the errors.A single additional bit can detect the error, but cannot correct it.
For correcting the errors, one has to know the exact position of the error. For example, If we
want to calculate a single-bit error, the error correction code will determine which one of seven bits
is in error. To achieve this, we have to add some additional redundant bits.
Suppose r is the number of redundant bits and d is the total number of the data bits. The
number of redundant bits r can be calculated by using the formula:
2r>=d+r+1
The value of r is calculated by using the above formula. For example, if the value of d is 4,
then the possible smallest value that satisfies the above relation would be 3.
To determine the position of the bit this is in error, a technique developed byR.W Hamming
is Hamming code which can be applied to any length of the data unit and uses the relationship
between data units and redundant units.
Hamming Code
Parity bits: The bit which is appended to the original data of binary bits so that the total number of
1s is even or odd.
Even parity:To check for even parity, if the total number of 1s is even, then thevalue of the parity bit
is 0. If the total number of 1s occurrences is odd, then the value of the parity bit is 1.
Odd Parity:To check for odd parity, if the total number of 1s is even, then thevalue of parity bit is 1.
If the total number of 1s is odd, then the value of parity bit is 0.
• Step 1 - The position of the data bits and the number of redundant bits in the original data.
The number of redundant bits is deduced from the expression [2^r >= d+r+1].
• Step 2 - Fill in the data bits and redundant bit, and find the parity bit value using the
expression [2^p, where, p - {0,1,2, …… n}].
• Step 3 - Fill the parity bit obtained in the original data and transmit the data to the receiver
side.
GFGC Tiptur Page 12
Unit-3 The Data Link Layer
• Step 4 - Check the received data using the parity bit and detect any error in the data, and in
case damage is present, use the parity bit value to correct the error.
c) P4 parity bit is deduced by checking all the bits with 1’s in the third significant location.
P4: 4, 5, 6, 7
• P4 - P4, 1, 0, 1
• P4 - 0
d) P8 parity bit is deduced by checking all the bits with 1’s in the fourth significant location.
P8: 8, 9, 10, 11
• P8 – P8, 1, 0, 1
• P8 - 0
Parity values obtained in the above deduction vary from the originally deduced parity values,
proving that an error occurred during data transmission.
To identify the position of the error bit, use the new parity values as,
• [0111]
• [0+2^2+2^1+2^0]
D. Access Control
Access control mechanisms in the data link layer primarily address the issue of multiple
devices attempting to use a shared communication medium simultaneously. This is essential in
shared communication environments to avoid collisions and ensure efficient data transmission. Two
main access control methods in the data link layer are: