Escolar Documentos
Profissional Documentos
Cultura Documentos
Introduction
Responsibilities of the data link layer include:
Framing
Addressing Flow control Error control, and Media access control
Datalink Layer
9/9/2011
Datalink Layer
9/9/2011
any data are transferred Each frame sent over the connection is numbered guarantees that each frame sent is indeed received
4 Datalink Layer
9/9/2011
Framing
Datalink Layer
9/9/2011
Framing
Framing in data link layer,
separates a message from one source to a destination, or from other
message
Types of framing
Fixed-Size Framing Variable-Size Framing
6 Datalink Layer 9/9/2011
Datalink Layer
9/9/2011
Datalink Layer
9/9/2011
Datalink Layer
9/9/2011
upper layer as text, graphic, audio, video and so on. Most protocols use a special 8-bit pattern flag 01111110 as the delimiter.
10
Datalink Layer
9/9/2011
11
Datalink Layer
9/9/2011
12
Datalink Layer
9/9/2011
than the receiver can accept them Flow control refers to a set of procedures used to restrict the amount of data that the sender can send before waiting for acknowledgement
Error Control
how to make sure all frames are eventually delivered to the network
layer at the destination and in the proper order. Error control in the data link layer is based on automatic repeat request, which is the retransmission of data
13 Datalink Layer
9/9/2011
Types of errors
Single-Bit Error Only 1 bit in the data unit has changed Burst Error A burst error means that 2 or more bits in the data unit have changed
14
Datalink Layer
9/9/2011
Types of errors
Single-bit error
15
Datalink Layer
9/9/2011
Types of Errors
Burst Error
A burst error means that 2 or more bits in the data unit have changed
16 Datalink Layer 9/9/2011
Redundancy
The central concept in detecting or correcting errors is
receiver
Their presence allows the receiver to detect or correct corrupted
bits
17
Datalink Layer
9/9/2011
In error correction
need to know the exact number of bits that are corrupted
18
Datalink Layer
9/9/2011
redundant bits works if the number of errors is small Uses error-detecting codes
Correction by retransmission
asks the sender to resend the message resending is repeated until a message arrives that the receiver believes is error-free Uses error-detecting codes
19 Datalink Layer
9/9/2011
Coding
Redundancy is achieved through various coding schemes.
The sender adds redundant bits through a process that creates
a relationship between the redundant bits and the actual data bits. The receiver checks the relationships between the two sets of bits to detect or correct the errors. The ratio of redundant bits to the data bits and the robustness of the process are important factors Coding schemes can be divided into two broad categories
Block Coding
Convolution Coding complex and beyond the scope
20 Datalink Layer 9/9/2011
Coding
Block Coding
Message will be divided into blocks
each block will be of k bits, called datawords r redundant bits will be added to each block to make the length
22
Datalink Layer
9/9/2011
Example
In 4B/5B block coding scheme, k = 4 and n = 5 we have 2k =
16 datawords and 2n = 32 codewords. How many codewords will be used for message transfer.
16 out of 32 codewords are used for message transfer and the
23
Datalink Layer
9/9/2011
Error Detection
Example
Let us assume that k = 2 and n = 3 and the sender encodes
the dataword 01 as 011 and sends it to the receiver. Table shows the list of datawords and codewords.
25
Datalink Layer
9/9/2011
Example
Consider the following cases: 1. The receiver receives 011.
2.
3.
26
Datalink Layer
9/9/2011
Error Correction
Example
k=2 and n=5. The sender assume dataword 01 and sends 01011.
Hamming Distance
The Hamming distance between two words is the number of
30
Datalink Layer
9/9/2011
Hamming Distance
Hamming distance between two pairs of words.
1.
2.
31
Datalink Layer
9/9/2011
distance between all possible pairs in a set of words. Find the minimum Hamming distance of the coding scheme in Table:
32
Datalink Layer
9/9/2011
Table:
Example
C(3,2) with dmin = 2
34
Datalink Layer
9/9/2011
35
Datalink Layer
9/9/2011
36
Datalink Layer
9/9/2011
Example
A code scheme has a Hamming distance dmin = 4. What is the error
Solution This code guarantees the detection of up to three errors (s = 3), but it can correct up to one error. If this code is used for error correction, part of its capability is wasted.
Error correction codes need to have an odd minimum distance (3, 5, 7, . ).
37
Datalink Layer
9/9/2011
Parity Check
A simple parity-check code is a single-bit error-detecting
Parity Check
40
Datalink Layer
9/9/2011
41
Datalink Layer
9/9/2011
42
Datalink Layer
9/9/2011
43
Datalink Layer
9/9/2011
Hamming Code
use of extra parity bits to allow the position identification of a single
error 1. Mark all bit positions that are powers of 2 as parity bits. (positions 1, 2, 4, 8, 16, etc.) 2. All other bit positions are for the data to be encoded. (positions 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, etc.) 3. Each parity bit calculates the parity for some of the bits in the code word. The position of the parity bit determines the sequence of bits that it checks.
Position 1: checks bits (1,3,5,7,9,11,...) Position 2: checks bits (2,3,6,7,10,11,14,15,...) Position 4: checks bits (4,5,6,7,12,13,14,15,20,21,22,23,...) Position 8: checks bits (8-15,24-31,40-47,...)
4.
44
Hamming Code
Bit position Encoded data bits 1 p1 2 p2 3 d1 4 p4 5 d2 6 d3 7 d4 8 p8 9 d5 10 d6 11 d7 12 d8 13 d9 14 d10 15 d11 16 p16
p1
p2 Parity bit coverage p4 p8 p16
X
X
X
X X
X
X X X
X
X X X
X
X
X
X X
X
X X X X X
X
X X X X .
45
Datalink Layer
9/9/2011
1 0 1 1 1 2 3 4 5 6 7 p1 p2 d1 p4 d2 d3 d4
p1 = d1 + d2 + d4 = 1 + 0 + 1 = 0 p2 = d1 + d3 + d4 = 1 + 1 + 1 = 1 p4 = d2 + d3 + d4 = 0 + 1 + 1 = 0
Codeword : 1011010
46 Datalink Layer 9/9/2011
0 1 1 0 0 1 0 1 2 3 4 5 6 7 p1 p2 d1 p4 d2 d3 d4
p1 = d1 + d2 + d4 = 1 + 0 + 0 = 1 p2 = d1 + d3 + d4 = 1 + 1 + 0 = 0 p4 = d2 + d3 + d4 = 0 + 1 + 0 = 1
Error is in p1, p2 and p4 bit, i.e., 1+ 2 + 4 = 7th bit (d4) is erroneous
47 Datalink Layer 9/9/2011
Cyclic Codes
Cyclic codes are special linear block codes with one extra
property
In a cyclic code, if a codeword is cyclically shifted (rotated), the
1011000 0110001
Cyclic codes are used to correct the errors in networks (LAN
48
Datalink Layer
9/9/2011
49
Datalink Layer
9/9/2011
50
Datalink Layer
9/9/2011
CRC Encoder
51
Datalink Layer
9/9/2011
CRC Decoder
52
Datalink Layer
9/9/2011
Polynomials
A better way to understand cyclic codes and how they can be
Polynomials
54
Datalink Layer
9/9/2011
polynomial or simply the generator. Dataword: d(x) Syndrome: s(x) Codeword: c(x) Error: e(x) Generator: g(x)
In a cyclic code, If s(x) 0, one or more bits is corrupted. If s(x) = 0, either a. No bit is corrupted. or b. Some bits are corrupted, but the decoder failed to detect them.
55
Datalink Layer
9/9/2011
56
Datalink Layer
9/9/2011
Checksum
The checksum is used in the Internet by several protocols
although not at the data link layer
We send (7, 11, 12, 0, 6, 36), where 36 is the sum of original no.
If we send (7, 11, 12, 0, 6, -36), called the checksum
57
Datalink Layer
9/9/2011
1 0 0 1
1 1 1 1 0 0 0 0
58
Datalink Layer
9/9/2011
Internet Checksum
Uses 16-bit checksum
Sender site:
1.
2.
3. 4. 5.
The message is divided into 16-bit words. The value of the checksum word is set to 0. All words including the checksum are added using ones complement addition. The sum is complemented and becomes the checksum. The checksum is sent with the data.
59
Datalink Layer
9/9/2011
Checksum
Receiver uses following steps for error detection
Receiver site:
The message (including checksum) is divided into 16-bit words. 2. All words are added using ones complement addition. 3. The sum is complemented and becomes the new checksum. 4. If the value of checksum is 0, the message is accepted; otherwise, it is rejected.
1.
60
Datalink Layer
9/9/2011
Protocols
61
Datalink Layer
9/9/2011
Protocols
Noiseless Channels
62
Datalink Layer
9/9/2011
Simplest Protocol
63
Datalink Layer
9/9/2011
Simplest Protocol
Flow diagram
64 Datalink Layer 9/9/2011
Stop-and-Wait Protocol
65
Datalink Layer
9/9/2011
Stop-and-Wait Protocol
66
Datalink Layer
Flow diagram
9/9/2011
Protocols
Noisy Channels
67
Datalink Layer
9/9/2011
Stop-and-Wait ARQ
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.
announces in modulo-2 arithmetic the sequence number of the next frame expected.
68
Datalink Layer
9/9/2011
Stop-and-Wait ARQ
69
Datalink Layer
9/9/2011
Stop-and-Wait ARQ
70
Datalink Layer
Flow diagram
9/9/2011
Stop-and-Wait ARQ
Efficiency Protocol is inefficient if our channel is thick and long
Thick channel has a large bandwidth
The product of these two is called bandwidth-delay product The bandwidth-delay product
is a measure of the number of bits we can send out of our system
71
Datalink Layer
9/9/2011
Example
Assume that, in a Stop-and-Wait ARQ system, the bandwidth of the
line is 1 Mbps, and 1 bit takes 20 ms to make a round trip. What is the bandwidth-delay product? If the system data frames are 1000 bits in length, what is the utilization percentage of the link?
Solution The bandwidth-delay product is
The link utilization is only 1000/20,000, or 5 percent
72
Datalink Layer
9/9/2011
Example
What is the utilization percentage of the link in Example if we have
a protocol that can send up to 15 frames before stopping and worrying about the acknowledgments?
Solution The bandwidth-delay product is
The link utilization is only 15,000/20,000, or 75 percent
73
Datalink Layer
9/9/2011
Go-Back-N ARQ
To improve the efficiency of transmission (filling the pipe),
multiple frames must be
acknowledgement
In this protocol
we can send several frames before receiving acknowledgements
Sequence numbers are modulo-2m (i.e. 0 to 2m-1) Sliding window is an abstract concept that defines the range of
Go-Back-N ARQ
75
Datalink Layer
9/9/2011
Go-Back-N ARQ
Go-Back-N ARQ
77
Datalink Layer
9/9/2011
Go-Back-N ARQ
78
Datalink Layer
9/9/2011
Go-Back-N ARQ
79
Datalink Layer
9/9/2011
Go-Back-N ARQ
80
Datalink Layer
9/9/2011
transmission
Selective Repeat ARQ does not resend N frames when only one
81
Datalink Layer
9/9/2011
82
Datalink Layer
9/9/2011
83
Datalink Layer
9/9/2011
84
Datalink Layer
Flow diagram
9/9/2011
Piggybacking
The three protocols we discussed in this section
data frames flow in only one direction although control info-rmation such
it can also carry control information about arrived (or lost) frames from
it can also carry control information about the arrived (or lost) frames
from A
85
Datalink Layer
9/9/2011
Piggybacking
86
Datalink Layer
9/9/2011
87
Datalink Layer
9/9/2011
HDLC
It is a bit-oriented protocol for communication over point-
to-point and multipoint links. Configuration and Transfer modes: HDLC provides two common transfer modes that can be used in different configurations:
normal response mode (NRM)
asynchronous balanced mode (ABM)
88
Datalink Layer
9/9/2011
HDLC
Normal Response Mode (NRM)
89
Datalink Layer
9/9/2011
HDLC
Asynchronous Balanced Mode (ABM)
90
Datalink Layer
9/9/2011
HDLC
Frames Three types of frames
Information frames (I-frames) Used to transport user data and control information relating to user data Supervisory frames (S-frames) Used to transport only control information Unnumbered frames (U-frames) Reserved for system management
91
Datalink Layer
9/9/2011
HDLC
HDLC Frames
92 Datalink Layer 9/9/2011
HDLC
93
Datalink Layer
9/9/2011
HDLC
Control field for S-Frames Receive Ready (RR)
Code: 00, N(R): acknowledgement number
Reject (REJ)
Code: 01, N(R): negative acknowledgement number
94
Datalink Layer
9/9/2011
HDLC
95
Datalink Layer
9/9/2011
HDLC
96
Datalink Layer
9/9/2011
HDLC
Example of piggybacking without error
97
Datalink Layer
9/9/2011
HDLC
Example of piggybacking with error
98
Datalink Layer
9/9/2011