Module 4 Data Link Layer
Module 4 Data Link Layer
• The data-link layer, on the other hand, needs to pack bits into frames,
so that each frame is distinguishable from another
• Byte stuffing is the process of adding one extra byte whenever there is
a flag or escape character in the text
• In byte stuffing (or character stuffing), a special byte is added to the
data section of the frame when there is a character with the same
pattern as the flag.
• The data section is stuffed with an extra byte.
• This byte is usually called the escape character (ESC) and has a
predefined bit pattern.
• Whenever the receiver encounters the ESC character, it removes it
from the data section and treats the next character as data, not as a
delimiting flag.
Bit-Oriented Framing
Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the data, so that
the receiver does not mistake the pattern 0111110 for a flag.
• A parity-check code can detect
an odd number of errors
Cyclic Codes
• In a cyclic code, if a codeword is cyclically shifted (rotated), the result
is another codeword.
• For example, if 1011000 is a codeword and we cyclically left-shift,
then 0110001 is also a codeword.
• In this case, if we call the bits in the first word a0 to a6, and the bits in
the second word
• b0 to b6, we can shift the bits by using the following:
• b1 = a0 b2 = a1 b3 = a2 b4 = a3 b5 = a4 b6 = a5 b0 = a6
Cyclic Redundancy Check [https://www.youtube.com/watch?v=-oUrtqvUA2o ]
• We can create cyclic codes to correct errors.
• A type of cyclic codes called the cyclic redundancy check (CRC) that
is used in networks such as LANs and WANs.
Steps
• dataword has k bits (4 here);
• the codeword has n bits (7 here).
• The size of the dataword is augmented by adding n − k (3 here) 0s to the right-hand side
• of the word.
• The n-bit result is fed into the generator.
• The generator uses a divisor of size n − k + 1 (4 here), predefined and agreed upon.
• The generator divides the augmented dataword by the divisor (modulo-2 division).
• The quotient of the division is discarded;
• the remainder (r2r1r0) is appended to the dataword to create the codeword.
• The decoder receives the codeword (possibly corrupted in transition).
• A copy of all n bits is fed to the checker, which is a replica of the generator.
• The remainder produced by the checker is a syndrome of n − k (3 here) bits, which is fed to the
decision logic analyzer. The analyzer has a simple function. If the syndrome bits are all 0s, the 4
leftmost bits of the codeword are accepted as the dataword (interpreted as no error);
• otherwise, the 4 bits are discarded (error).
Sender
Reciver
Checksum
• Checksum is an error-detecting technique that can be applied to a
message of any length.
• In the Internet, the checksum technique is mostly used at the network
and transport layer rather than the data-link layer
• At the source, the message is first divided into m-bit units.
• The generator then creates an extra m-bit unit called the checksum,
which is sent with the message.
• At the destination, the checker creates a new checksum from the
combination of the message and sent checksum.
• If the new checksum is all 0s, the message is accepted; otherwise, the
message is discarded .
• Note that in the real implementation, the checksum unit is not
necessarily added at the end of the message; it can be inserted in the
middle of the message.
Traditional checksum
45
CSMA/CD (CSMA with Collision Detection)
Delay: B
Delay: C Time
Nodes B & C sense
the medium
Nodes C starts
Nodes B resenses the medium transmitting.
and transmits its frame.
Node C freezes its counter.
50
CSMA/CA Explained
51
CSMA/CA with ACK
• Immediate Acknowledgements from receiver
upon reception of data frame without any need
for sensing the medium.
• ACK frame transmitted after time interval SIFS
(Short Inter-Frame Space) (SIFS < DIFS)
• Receiver transmits ACK without sensing the
medium.
• If ACK is lost, retransmission done.
52
CSMA/CA/ACK
DIFS Time
Data
Source
SIFS
ACK
Destination
DIFS Contention window
Next Frame
Other
Defer access Backoff after defer
53
CSMA/CA with RTS/CTS
• Transmitter sends an RTS (request to send) after
medium has been idle for time interval more than
DIFS.
• Receiver responds with CTS (clear to send) after
medium has been idle for SIFS.
• Then Data is exchanged.
• RTS/CTS is used for reserving channel for data
transmission so that the collision can only occur in
control message.
54
CSMA/CA with RTS/CTS (Cont’d)
DIFS SIFS
RTS Data Time
Source
SIFS SIFS
CTS ACK
Destination
DIFS
Contention window
Next Frame
Other
55
RTS/CTS
Node A Node B
Propagation delay
RTS
CTS
Data
ACK
56
CONTROLLED ACCESS
In controlled access, the stations consult one another to find which station has the
right to send. A station cannot send unless it has been authorized by other stations.
We discuss three popular controlled-access methods.
Reservation
Polling
Token Passing
:
Polling
Token passing
IEEE 802.3Ethernet
1.IEEE STANDARDS
IEEE has subdivided the data-link layer into two sublayers: