Vous êtes sur la page 1sur 51

Data Link Layer

Functions of the Data Link Layer


Provide service interface to the network layer

Framing
Addressing

Access control
Dealing with transmission errors

Regulating data flow

Slow receivers not swamped by fast senders

Services provided to network layer


The principle service is to transfer data from network layer on the source machine to the network layer on the destination machine.

3 kind of services are:


Unacknowledge connectionless service.

Acknowledged connectionless service


Acknowledged connection-oriented service.

Framing:
Break bit stream into frames. Check if frames arrived correctly. If not: Discards frame. In some cases also request retransmission.

Methods of framing:
Character count. Starting and ending characters , with character stuffing. Starting and ending flags , with bit stuffing.

Framing: Using Counters


This method uses a field in the header to specify the number of character in the frame.

(a) Without errors. (b) With one error. Count can be garbled by a transmission error, which will loose synchronization, will not know where is next frame starting.

Character Stuffing:
Each frame start with ascii character sequence DLE STX (data link escape start of text) and end with DLE ETX (end of text). Character stuffing is used when binary data ,object program or floating point numbers are being transmitted. A STX DLE A
DLE

DLE

DLE

DLE ETX

DLE

Stuffed DLE(ASCII)

Bit Stuffing:
Each frames begins and ends with special pattern. Example: 01111110. When senders DLL finds 5 consecutive 1s in data stream, stuffs 0. When receiver sees 5 1s followed by 0, de-stuffs

(a) Original data. (b) Data as they appear on the line. (c) Data after de-stuffing.

Error Control:
Data can be corrupted during transmission. For reliable communication, errors must be detected and corrected.

Definition:
Error detection is the ability to detect the presence of errors caused by noise or other impairments during transmission. Error correction is the additional ability to reconstruct the original error free data.

Types of Error:
Single-Bit Error: In a single-bit error, only one bit in the data unit has changed.

Burst Error:
A burst error means that 2 or more bits in the data unit have changed. Burst error of length 5

Detection:
Redundancy Parity Check (VRC)& LRC Cyclic Redundancy Check (CRC) Checksum Correcting or detecting errors is called redundancy. Error detection uses the concept of redundancy, which means adding extra bits with data for detecting errors.

Detection methods (Redundancy checks):

Even-parity concept

In parity check, a parity bit is added to every data unit so that the total number of 1s is even (or odd for odd-parity).

Example 1
Suppose the sender wants to send the word world. In ASCII the five characters are coded as 1110111 1101111 1110010 1101100 1100100 The following shows the actual bits sent 11101110 11011110 11100100 11011000 11001001

Example 2
Now suppose the word world in Example 1 is received by the receiver without being corrupted in transmission. 11101110 11011110 11100100 11011000 11001001 The receiver counts the 1s in each character and comes up with even numbers (6, 6, 4, 4, 4). The data are accepted.

Example 3
Now suppose the word world in Example 1 is corrupted during transmission. 11111110 11011110 11101100 11011000 11001001 The receiver counts the 1s in each character and comes up with even and odd numbers (7, 6, 5, 4, 4). The receiver knows that the data are corrupted, discards them, and asks for retransmission

VRC (Vertical redundancy check)


Simple parity check can detect all single-bit errors. It can detect burst errors only if the total number of 1s in each data unit is odd. But it cannot properly indicate errors when an even number of bits have been modified. LRC (Longitudnal redundancy check)

In LRC, a block of bits is divided into rows and a redundant row of bits is added to the whole block.

Longitudnal Redundancy check(LRC):

Example 4
Suppose the following block is sent:

10101001 00111001 11011101 11100111 10101010


However, it is hit by a burst noise of length 8, and some bits are corrupted. 10100011 10001001 11011101 11100111 10101010 When the receiver checks the parity bits, some of the bits do not follow the even-parity rule and the whole block is discarded. 10100011 10001001 11011101 11100111 10101010

Two Dimensional Parity bit:

CRC (Cyclic redundancy code)


CRC is appended to frame being transmitted. Resulting polynomial divisible by G(x). When receiver gets checksummed frame, it divides it by G(x). If remainder, then error!

Steps:

1. A string of n 0s is appended to the data unit.The number n is one less than the number of bits in the predetermined divisor,which is n+1 bits. 2. The newly elongated data unit is divided by the divisor using binary division(modulo-2),The remainder resulting from this division is the CRC. 3. The CRC in step 2 replaces the appended 0s at the end of the data unit. 4. The data is then transmitted and arrives at the receiver,receiver treats the whole string as a unit and divides it by the same divisor. 5. If the string arrives without error,the CRC checker yields a remainder of zero and the data unit passes.and if it is non-zero the data unit does not pass.

Example 5

At the Receiver, compute

Note remainder = 0 no errors detected

Checksum:
The sender follows these steps: a. The unit is divided into k sections, each of n bits. b. All sections are added using ones complement to get the sum. c. The sum is complemented and becomes the checksum. d. The checksum is sent with the data. The receiver follows these steps: a. The unit is divided into k sections, each of n bits. b. All sections are added using ones complement to get the sum. c. The sum is complemented. d. If the result is zero, the data are accepted: otherwise, rejected

Example 8
Suppose the following block of 16 bits is to be sent using a checksum of 8 bits. 10101001 00111001 The numbers are added using ones complement 10101001 00111001 -----------Sum 11100010 Checksum 00011101 The pattern sent is 10101001 00111001 00011101

Now suppose the receiver receives the pattern sent in Example 8 and there is no error. 10101001 00111001 00011101 When the receiver adds the three sections, it will get all 1s, which, after complementing, is all 0s and shows that there is no error. 10101001 00111001

00011101
Sum Complement 11111111 00000000 means that the pattern is OK.

Flow control:
Flow control refers to a set of procedures used to restrict the amount of data that the sender can send before waiting for acknowledgment. The flow of data must not be allowed to over whelm the receiver. Two Categories of Flow control Stop-and-wait Sliding window

Stop-and-Wait
In this the sender sends one frame and wait for an acknowledgement before sending the next frame.
Advantage: It is simple. Each frame is checked and acknowledged before next frame is sent. Disadvantage: poor link utilization. It is slow. Long propagation delay

Sliding Window: Basics


Allows multiple frames to be in transit at the same time before needing an ACK. Receiver allocates buffer space for n frames. The sliding window is a imaginary box at both the sender and receiver end. Transmitter is allowed to send n (window size) frames without receiving ACK. The link capacity can be used efficiently.

Sliding Window: Receiver


Receiver acks frame by including sequence number of next expected frame.
Cumulative ACK: acks multiple frames.

Example: if receiver receives frames 2,3, and 4, it sends an ACK with sequence number 5, which acks receipt of 2, 3, and 4.

Transmission window shrinks each time frame is sent, and grows each time an ACK is received. The receiver window shrinks when data are received and expands when ACK are sent. Example-1:If the sequence of transmission for 7 bit frame is as follow : window size 7 ->data0 ->data1 <-ack2 ->data2 <-ack3 ->data3 ->data4 ->data5 <-ack6

Example-2:If the sequence of transmission for 7 bit frame is as follow: ->data0 ->data1 ->data2<-ack3 ->data3 <-ack4 ->data4 ->data5 ->data6

Example: 3-bit sequence number and window size 7

A (Sender) 0 1 2 3 4 5 6 7 0 1 2 3 4 0123456701234

B (Receiver)

0 1 2
ACK 3 3 ACK 4

0123456701234 0123456701234

0123456701234
0123456701234

0123456701234
0123456701234

0123456701234
0123456701234

0123456701234
4 5 0123456701234 6

Error control in the data link layer is based on automatic repeat request, which is the retransmission of data.
In three cases:

Damaged frames Lost frames Lost acknowledgment

Categories of Error Control


Stop and Wait ARQ Sliding Window ARQ Go Back n Selective Repeat

Stop and Wait ARQ


It is the form of stop and wait flow control extended to include retransmission of data in case of lost and damaged frames. 4 features are added: The sender keeps the copy of last frame transmitted. A data 0 is ackd by an ACK1 frame Sender wait until it receive ACK,If it receive NAK , it resends the frame. Both the device is equipped with a timer.

Stop and Wait ARQ:


Sender transmits one single packet: Sender sets a timeout Sender waits for acknowledgement (ACK) If no ACK is received within timeout, the sender retransmits the packet If a received packet is damaged, the receiver simply discards it. ACK-no. of frame expected NAK-no. of frame damaged

Normal Operation

Stop-and-Wait ARQ, lost frame

Stop-and-Wait ARQ, lost ACK frame

Sliding Window ARQ


3 features are added to basic flow control mechanism: The sending device keeps copies of all transmitted frames. Since sliding window is a continuous process both ACK & NAK must be numbered for identification. ACK-no. of frame expected NAK-no. of frame damaged Both the device is equipped with timer.

Go Back n ARQ
In this method if one frame is lost or damaged, all frames sent since the last frame ackd are retransmitted. For damaged frame: As soon as receiver discover an error it stops accepting subsequent frame until damaged frame is replaced.

Go-Back-N ARQ, normal operation

Go-Back-N ARQ, lost frame & lost ACK

Selective-Repeat ARQ
In this method only specific damaged or lost frame is retransmitted. If the frame is corrupted or lost, a NAK is returned and the frame is resent out of sequence. In this the receiving device must contain sorting logic to enable to reorder frame received out of sequence. A buffer in the receiver must keep previously received frames on hold until all retransmission have been sorted.

Selective Repeat ARQ, lost frame

HDLC Protocol

Frames:
HDLC has three types of frames:

Information frames(I-frame): used to transport user data and control information related to user (sequence and ack num).
Supervisory frames(s-frame): are used only to transport control information (ack num). Unnumbered frames(u-frame): are reserved for system management (information relating to managing a link).

HDLC frame
Frame in HDLC may contain upto six fields: A beginning Flag field.

An address field
A control field An information field A frame check sequence (checksum)

HDLC frame types:

END
OF DATALINK LAYER

Vous aimerez peut-être aussi