Unit II.pptx
Unit II.pptx
3
Data Link Layer
• The data link layer is the protocol layer in a program that handles the moving of
data into and out of a physical link in a network. The data link layer is Layer 2 in
the Open Systems Interconnection (OSI) architecture model for a set of
telecommunication protocols.
• Data bits are encoded, decoded, and organized in the data link layer, before they
are transported as frames between two adjacent nodes on the same LAN or
WAN. The data link layer also determines how devices recover from collisions that
may occur when nodes attempt to send frames at the same time.
• The data link layer has two sublayers: the logical link control (LLC) sublayer and
the media access control (MAC) sublayer.
4
Data Link Layer
• As described by the IEEE 802 LAN specification, the role of the LLC sublayer is to
control data flow among various applications and services, as well as provide
acknowledgment and error notification mechanisms. The LLC sublayer can then
talk to a number of IEEE 802 MAC sublayers, which control access to the physical
media for transport. It is also responsible for the physical addressing of frames.
• Two common MAC layer types include Ethernet and 802.11 wireless specifications
5
Data Link Layer
• Data link layer and error detection
• The data link layer ensures an initial connection has been set up, divides output data into
data frames, and handles the acknowledgments from a receiver that the data arrived
successfully. It also ensures incoming data has been received successfully by analyzing bit
patterns at particular places in the frames.
• If an error occurs, the data link layer notifies higher-level protocols that something has
happened to the physical link. Frame sequencing capabilities within the data link layer
permit the receiving device to reorder frames that might have been transmitted out of
sequence. The data link layer verifies that the packet is unimpaired.
• The data link layer also manages flows by enabling devices on a link to detect congestion.
Nearby devices then transmit congestion information so that traffic can be rerouted
accordingly.
6
Data Link Layer
Functions of the data link layer
7
Error Detection and Correction Techniques
• Block Coding
• Linear Block Coding
- Simple Parity Check
- Hamming Codes
• Cyclic Codes
• Checksum
8
Block Coding
• In digital electronics, block coding is a technique of
encoding data into a specific format.
9
Block Coding
• Block coding is mainly employed to create a robust method of data transmission
and storage.
• In block coding, data is encoded by splitting it into multiple blocks of a fixed size
and applying encoding techniques to each of these blocks separately
10
Block Coding (Datawords and codewords in block coding)
• In block coding, we divide our message into blocks, each of k bits, called datawords.
We add r redundant bits to each block to make the length n = k + r. The resulting
n-bit blocks are called codewords.
11
Types of Errors
• There are three types of error
1. Single bit error
2. Multiple bits error
3. Burst error
12
Types of Errors
Single Bit Error: In a received frame, there is only one bit corrupted.
13
Types of Errors
Multiple bits error − In the received frame, more than one bit is corrupted.
14
Types of Errors
Burst error − In the received frame, more than one consecutive bits are
corrupted.
15
Error Detection Techniques
• To detect errors, a common technique is to introduce redundancy bits that
provide additional information. Various techniques for error detection
include::
1. Simple Parity Check
2. Two-dimensional Parity Check
3. Checksum
4. Cyclic Redundancy Check (CRC)
16
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.
17
Simple Parity Check
18
Simple Parity Check
• Disadvantages
• Single Parity check is not able to detect even no. of bit error.
• For example, the Data to be transmitted is 101010. Codeword transmitted
to the receiver is 1010101 (we have used even parity).
Let’s assume that during transmission, two of the bits of code word flipped
to 1111101.
On receiving the code word, the receiver finds the no. of ones to be even
and hence no error, which is a wrong assumption.
19
Simple Parity Check
• Two-dimensional Parity Check
• 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.
20
Two-dimensional Parity Check
21
Redundancy: To Detect or Correct an Error
22
23
24
Example: K=2 and n=3
27
28
Two Dimensional Parity Check
29
Finding Hamming Distance between pairs of words
30
31
• Eg dataword 0100 codeword 0100011 received
codeword 0100011 (syndrome =000 no error)
32
CRC Encoder and Decoder
33
34
Eg. CRC Encoder
35
CRC Decoder No Error in Codeword
36
CRC Decoder Detecting Error
37
CRC Code Analysis
38
39
40
41
Checksum
• Set of Numbers (7, 11, 12, 0, 6),
42
checksum
• (complement) of the sum, called the checksum.
• In this case, we send (7, 11, 12,0,6, -36). The receiver can add all the numbers.
43
one's complement
44
45
Data Link Layer: Data Link Control
46
Outline
• Framing
• Byte vs. bit-oriented protocols
• Protocols
47 47
Framing
• Process of wrapping data with certain info before sending it out.
48 48
Byte vs. Bit Oriented
• Framing in byte-oriented protocols
49 49
Byte Stuffing
• Process of adding extra byte whenever there is an escape or a flag character in the
data
50 50
Bit Stuffing
• Process of adding extra bit to ensure flag sequence does not appear in the data
01111110
51
Data Link Protocols
52
"Simplest" Mechanism
• Assuming
• Noiseless channel
53
"Simplest" : Pseudo Code
• Sender
• Receiver
54
"Simplest": Flow Diagram
55
Stop-and-Wait Mechanism
• Still noiseless channel
56
Stop-and-Wait: Overview
57
Stop-and-Wait: Pseudo Code
• Sender side
58
Stop-and-Wait: Pseudo Code
• Receiver side
59
Stop-and-Wait: Flow Diagram
60
Stop-and-
Wait ARQ
61
Flow Diagram: Normal Operation
Sender Receiver
Time Time
62
Flow Diagram: Lost Frame
Sender Receiver
Timeout
Frame 1
Deliver
ACK 0
R=0
63
Time Time
Flow Diagram: Lost ACK
Sender Receiver
Deliver
ACK 0
Timeout R=0
S=1 Frame 1 Frame 0 expected;
discard
ACK 0
R=0
S=0
Time Time 64 64
Flow Diagram: Delayed ACK
Sender Receiver
Deliver
ACK 0 R=0
S=0
65
Go-Back-N ARQ
• Allows multiple frames to be sent before waiting for ACK
• These frames must be numbered differently
• Frame numbers are called Sequence numbers
• If a frame is lost, the lost frame and all of the following frames must be
retransmitted
66
Go-Back-N ARQ
• The key features of the Go-Back-N (GBN) protocol include:
• Sliding window mechanism
• Sequence numbers
• Cumulative acknowledgements
• Timeout mechanism
• NACK mechanism
• Simple implementation.
67
Go-Back-N: Animation
• https://aboelela.site/profile/projects/net-seal/animations/go-back-n-arq/
68 68
Sequence Numbers
• Frame header contains m bits for sequence number
69
Sending Window
• Sending more than one frame at once requires sender to buffer multiple frames
• Known as "sending window"
• Any of these frames in the window can be lost
70
"Sliding" Window
• Once the first frames in the
window is ACKed
• ACKed frames are removed
from the buffer
• More frames are transmitted
• Result: The window slides to
the right
71 71
Receiving Window
• Receiver expects one frame at a time
72 72
Send vs. Receive Windows
73 73
Go-Back-N: Window Sizes
• For m-bit sequence numbers
74 74
Go-Back-N: Normal Operation
75 75
Go-Back-N: Lost Frame
ACKs are
cumulative
76 76
Selective Repeat: Animation
• https://aboelela.site/profile/projects/net-seal/animations/selective-repeat-arq/
77 77
Selective Repeat ARQ
• Go-Back-N always discards out-of-order frames
• Losing one frame may result in retransmission of multiple frames
• Very inefficient in noisy link
78 78
Selective Repeat ARQ
• key features include:
• Receiver-based protocol
• Each packet is individually acknowledged by the receiver
• Only lost packets are retransmitted, reducing network congestion
• Maintains a buffer to store out-of-order packets
• Requires more memory and processing power than Go-Back-N
• Provides efficient transmission of packets.
79 79
Send and Receive Windows
• Sender and receiver share window space equally
80 80
Send Window
81 81
Receive Window
82 82
Negative ACK
• Used by receiver to
indicate missing
frame
83 83
CASE STUDY
DATA LINK CONTROL
PROTOCOLS:
HDLC AND PPP
HDLC
• High-level Data Link Control
• Bit-oriented protocol
• Support both
• Point-to-point links
• Multipoint links
86 86
Normal Response Mode
• "NRM" mode
• Used in both
point-to-point
and multi-point
link.
87 87
Asynchronous Balance Mode
• "ABM"
• Supports only point-to-point links
• Each station is both primary and secondary
88 88
HDLC Frames
•Information frame (I-frame)
89 89
PPP
• Point-to-Point Protocol
• Byte-oriented protocol
90 90
PPP Frame Format
91 91
PPP Transition States
92 92
PPP Stack
• Link Control Protocol (LCP)
93 93
LCP: Link Control Protocol
• Responsible for establishing, maintaining, configuring, and terminating links
94 94
LCP Packets
95
PPP Authentication
• Two protocols are supported:
• Password Authentication Protocol (PAP)
• Challenge Handshake Authentication Protocol (CHAP)
96 96
NCP: Network Control Protocol
• A set of control protocols to allow data from the network layer to be
encapsulated into a PPP frame
97 97
Internet Protocol Control Protocol
98