64
1 Chapter 7 Data Link Control Read Chapter 7 & pay attention to the reasons why the Data Link Layer exists (regulates data rate among other functions).

Chapter 7 Data Link Control

  • Upload
    morna

  • View
    40

  • Download
    0

Embed Size (px)

DESCRIPTION

Chapter 7 Data Link Control. Read Chapter 7 & pay attention to the reasons why the Data Link Layer exists (regulates data rate among other functions). Source node. Destination node. Application. Application. Presentation. Presentation. Session. Session. Intermediate node. transport. - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 7 Data Link Control

1

Chapter 7Data Link Control

Read Chapter 7 & pay attention to the reasons why the Data Link Layer exists (regulates data rate among other functions).

Page 2: Chapter 7 Data Link Control

2

Physical Layer

Application

Presentation

Session

transport

Network

Data link

Physical

Application

Presentation

Session

transport

Network

Data link

Physical

Network

Data link

Physical

Source node Destination node

Intermediate node

Signals

Packets

Bits

Frames

Page 3: Chapter 7 Data Link Control

3

Data Link LayerProvides for reliable transfer of

information across physical linkIncludes:

transmission of blocks of data (“frames”)

synchronization error control flow control

Page 4: Chapter 7 Data Link Control

4

Data Link Layer Functions Frame Synchronization - Create abstraction of “frame-at-

a-time” channel for higher layer (start & end of each frame must be recognizable)

Addressing - Needed when many nodes share transmission link

Flow Control - Control rate of transmission to prevent overflow of receiver's buffers

Error Control - Correct transmission errors (by retransmission) or by error correction schemes

Sequence Control - Receiver must be able to distinguish control information from data

Link Management - Initiation, maintenance, & termination of connections

Page 5: Chapter 7 Data Link Control

5

Flow ControlNecessary when data is being sent

faster than it can be processed by receiver

Computer to printer is typical settingCan also be from computer to

computer, when a processing program is limited in capacity

Page 6: Chapter 7 Data Link Control

6

Stop-and-Wait Flow ControlSimplest form of Flow ControlSource may not send new frame

until receiver acknowledges the frame already sent

Very inefficient, especially when a single message is broken into separate frames

Page 7: Chapter 7 Data Link Control

7

Sliding-Window Flow ControlAllows multiple frames to be in transitReceiver sends acknowledgement with

sequence number of anticipated frameSender maintains list of sequence

numbers it can send, receiver maintains list of sequence numbers it can receive

ACK (acknowledgement) supplemented with RNR (receiver not ready)

Page 8: Chapter 7 Data Link Control

8

Error Control ProcessAll transmission media have

potential for introduction of errorsError control process has two

components Error detection Error correction

Page 9: Chapter 7 Data Link Control

9

Error DetectionParity CheckCyclic Redundancy Check (CRC)

Page 10: Chapter 7 Data Link Control

10

Error CorrectionTwo types of errors

Lost frame Damaged frame

Automatic Repeat reQuest (ARQ) Error detection Positive acknowledgment Retransmission after time-out Negative acknowledgment and retransmission

Page 11: Chapter 7 Data Link Control

11

Stop-and-Wait ARQOne frame received and handled at a timeIf frame is damaged, receiver discards it

and sends no acknowledgment Sender uses timer to determine whether or

not to retransmit Sender must keep a copy of transmitted frame

until acknowledgment is receivedIf acknowledgment is damaged, sender

will know it because of numbering

Page 12: Chapter 7 Data Link Control

12

Go-Back-N ARQUses sliding-window flow controlWhen receiver detects error, it sends

negative acknowledgment (REJ)Sender must begin transmitting

again from rejected frameTransmitter must keep a copy of all

transmitted frames

Page 13: Chapter 7 Data Link Control

13

Flow Control

Technique for controlling data rate so that sender does not over-run receiver

Two approaches exist: 1. Stop-and-wait 2. Sliding-window

Page 14: Chapter 7 Data Link Control

14

Stop & Wait Flow Control

1. Sender sends a frame2. Receiver receives frame & acknowledges it3. Sender waits to receive “ack” before

sending next frame (If receiver is not ready to receive another frame it holds back the ack)

* One frame at a time is sent over the transmission line

Page 15: Chapter 7 Data Link Control

15

Utilization (Efficiency) of Stop & Wait

Propagation time: time taken for signal to travel from S to R. Thus first bit transmitted at t=0 arrives at R at t = T p = d / V.

Page 16: Chapter 7 Data Link Control

16

Utilization (Efficiency) of Stop & WaitTransmission time: time taken to emit all bits of

frame at sender = T t = L / B.

In figure 7.2 Page 197, Transmission Time=1, therefore a = Propagation (Delay) Time

Page 17: Chapter 7 Data Link Control

17

Utilization (Efficiency) = U

Note: a=Tp/Tt or Tp=aTtVertical-Time

Sequence Diagram

Page 18: Chapter 7 Data Link Control

18

The effect of a on utilization

This shows that for large a (Propagation Time>Transmission Time), the line is under-utilized

Page 19: Chapter 7 Data Link Control

19

Utilization (Efficiency) of Stop & Wait

With stop & wait scheme, for high channel utilization, we need a low a (since U= 1/(1+2a))

However, in practice it is desirable to limit frame length L because– error probability increases with L– high average delay with multi-point lines– buffer size limitations

So a more efficient scheme is called for, especially with WAN/satellite communication

Page 20: Chapter 7 Data Link Control

20

Utilization (Efficiency) of Stop & Wait Examples

1). WAN using ATM L = 53 bytes = 424 bits, B= 155.52 Mbps, d=1000km T t =

424 / (155.52 x 106 ) = 2.7 x 10-6 seconds assuming optical fiber, T p = 10 6 m / (3 x 108 m/sec) = 0.33 x 10-2 seconds a = (0.33 x 10-2 )/(2.7 x 10-6 ) = 1200 U = 1/2401 = 0.0004

2). LAN d = 0.1 ~ 10 km, B = 10 Mbps, V = 2 x 108 m/sec L = 1000 bits a = 0.005 ~ 0.5 U = 0.5 ~ 0.99

3). Digital trans. vis modem over voice-grade line B = 28.8 kbps, L = 1000 bits, d = 1000 m a = (28.8 kbps *

1000 m) / (2 x 108 m/sec x 1000 bits) = 1.44 x 10-4 U = 1.0, if d = 5000 km, a = (28.8kbps x 5000km) / (2 x 108 x 1000bits) = 0.72 U = 0.4

Page 21: Chapter 7 Data Link Control

21

Sliding-Window Flow Control

Pipeline transmission of successive frames Transmit up to “N” frames if necessary without receiving acks. Wait for acks when “N” unacked frames in transit For full duplex transmission each station needs a sending window &

receiving window.

Page 22: Chapter 7 Data Link Control

22

Figure 7.4 Example of a sliding-window protocol

Page 23: Chapter 7 Data Link Control

23

Utilization: U is a function of a and N

Case 1: N > 1 + 2a : U = 1 Ack for frame 1 reaches Sender before

transmission of Nth frame continuous transmission possible

Page 24: Chapter 7 Data Link Control

24

Utilization: U is a function of a and N

Case 2: N < 1 + 2a : U = N / (1 + 2a) Wasted time

between N and 1 + 2a

Page 25: Chapter 7 Data Link Control

25

Error Detection

Basic Principle Transmitter: For a given bit stream M,

additional bits (called error-detecting code) are calculated as a function of M and appended to the end of M

Receiver: For each incoming frame, performs the same calculation and compares the two results. A detected error occurs if there is a mismatch

Page 26: Chapter 7 Data Link Control

26

Error Detection Two common techniques

Parity checks Cyclic redundancy checks (CRC)

Parity Check One extra “parity” bit is added to each word

Odd parity: bit added so as to make # of 1’s oddEven parity: makes total # of 1’s even

Single parity is very effective with white noise (noise on a line without any active signals on it; e.g., Thermal Noise, see chapter 3), but not very robust with noise bursts (which may extend over whole word duration.)

Page 27: Chapter 7 Data Link Control

27

Cyclic Redundancy Checks

Powerful error detection method, easily implemented

Message (M) to be transmitted is appended with extra frame checksum bits (F), so that bit pattern transmitted (T) is perfectly divisible by a special “generator” pattern (P) - (divisor)

At destination, divide received message by the same P. If remainder is nonzero error

Page 28: Chapter 7 Data Link Control

28

Cyclic Redundancy ChecksLet

T = (k+n)-bit frame to be transmitted, n<k

M = k-bit message, the first k bits of T F = n-bit FCS, the last n bits of T P = n+1 bits, generator pattern

(predetermined divisor)The concept uses modulo-2 arithmetic

no carries/borrows; add subtract XOR

Page 29: Chapter 7 Data Link Control

29

Cyclic Redundancy ChecksMethod

Extend M with n ‘0’s to the right (2 n M)(shift left by n bits

Divide extended message by P to get R (2 n M / P = Q + R/P)

Add R to extended message to form T (T = 2 n M + R)

Transmit T At receiver, divide T by P. Nonzero remainder

means: error QPRRQ

PR

PRQ

PRM

PT n

2

Note: R+R=0 in mod-2 arithmetic

011000

Note: Remainder

R=F=FCS in these

examples

Page 30: Chapter 7 Data Link Control

30

Cyclic Redundancy Checks Examples

M = 110011, P = 11001, R = 4 bits 1. Append 4 zeros to M, we get 1100110000

-For each stage of division, if the number of dividend bits equals number of divisor P bits, then Q=1, otherwise Q=0

-Also, see example on page 204

Page 31: Chapter 7 Data Link Control

31

Cyclic Redundancy Checks

Exercise: Compute the frame to be transmitted for message 1101011011 using P = 10011

Answer: 11010110111110

Page 32: Chapter 7 Data Link Control

32

Cyclic Redundancy Checks

Can view CRC generation in terms of polynomial arithmetic

Any bit pattern polynomial in dummy variable X as shown in the following example: e.g., M = 110011 1·X5 +1·X4 +0·X3

+0·X2 +1·X+1·X0 M(X) = X5 +X4 +X+1

Page 33: Chapter 7 Data Link Control

33

Cyclic Redundancy Checks

CRC generation in terms of polynomial Append n ‘0’s Xn M(X) Modulo 2 division Transmit Xn M(X)+R(X) = T(X) At receiver:

Page 34: Chapter 7 Data Link Control

34

Cyclic Redundancy Checks

Commonly used polynomials, P(X) CRC-16 = X16 +X15 + X2 +1 CRC-CCITT = X16 +X12 + X5 +1 CRC-32 = X32 +X26 + X23 + X22 +X16 +

X12 + X11 +X10 +X8 + X7 +X12 + X4 + X2 +X+1

Page 35: Chapter 7 Data Link Control

35

Can detect1. All single-bit errors2. All double-bit errors, as long as P(X) has a

factor with at least three terms (as long as p has at least three 1s)

3. Any odd number of errors, as long as P(X) contains a factor (X+1)

4. Any burst error for which the length of the burst is less than the length of the FCS

5. Most larger burst errors

Page 36: Chapter 7 Data Link Control

36

Why?Error can also be represented by polynomial,

E(X). Tr(X) = T(X) E(X) Error is undetectable if E(X) is divisible by P(X)

P always has at least two terms, Xn , 1 (most & least significant bits equal to 1)

1. Single-bit error: E(X) = Xi (one bit=1) P(X) = X n + … +1 Error is detectable since

E(X) is not divisible by P(X)

T=Transmitted frame

E=Error pattern with 1s in positions where errors happen

Tr=Received frame

Page 37: Chapter 7 Data Link Control

37

Why?

2. Double-bit error: E(X) = Xi +Xj = Xi (1+Xk ), k=j-i>0 P(X) does not divide into Xi

P(X) can be chosen which does not divide 1+Xk up to the maximum value of k (i.e., up to the practical frame length). (e.g., X15 + X14 +1 will not divide 1+Xk for any k below 32768)

Page 38: Chapter 7 Data Link Control

38

Why?3. No polynomial with an odd # of terms is divisible

by (X+1) Assume E(X) has an odd # of terms and is divisible

by (X+1). Then E(X) = (X+1)Q(X). E(1) = (1+1)Q(1) = 0. However, E(1) cannot be zero since it has an odd # of 1’s

4. A burst error of length r < n can be represented by Xi (Xr-1 + ··· +1). P(X) does not divide into Xi

P(X) which is a polynomial of degree n cannot divide into Xr-1 + ··· +1 since r-1<n.

Page 39: Chapter 7 Data Link Control

39

Implementation

Implemented by a circuit consisting of exclusive-or gates and a shift register The shift register contains n bits (length

of FCS) There are up to n exclusive-or gates The presence or absence of a gate

corresponds to the presence or absence of a term in P(X)

Page 40: Chapter 7 Data Link Control

40

Implementation

Page 41: Chapter 7 Data Link Control

41

Example

Shift Register Circuit for dividing by the polynomial X5 +X4 + X2 +1

Note:R=01110

see pages 206-207

Page 42: Chapter 7 Data Link Control

42

Error Control

See page 208

Page 43: Chapter 7 Data Link Control

43

Error control techniques

Forward error control: Error recovery by correction at the

receiver [Forward Error Correction (FEC)]

Backward error control: Error recovery by retransmission

[Automatic Repeat Request (ARQ)]

Page 44: Chapter 7 Data Link Control

44

ARQBased on

Error detection Positive ack Retransmission after timeout Negative ack. And retransmission

ARQ Stop-and-wait ARQ Continuous ARQ

Go-back-N ARQSelective-reject ARQ

Page 45: Chapter 7 Data Link Control

45

Stop & Wait ARQ

Simple and minimum buffer requirement, but inefficient Sender transmits message frame Receiver checks received frame for

errors; sends ACK/NAK Sender waits for ACK/NAK. NAK

retrans; ACK next frame

Page 46: Chapter 7 Data Link Control

46

Stop & Wait ARQFrame/ACK could be

lost Uses a timeout mechanism

Possibility of duplication Number frames

Only need a 1-bit frame number alternating 1 and 0 since they are sent one at a time

Page 47: Chapter 7 Data Link Control

47

Go-back-N ARQ

If the receiver detects an error on a frame, it sends a NAK for that frame. The receiver will discard all future frames until the frame in error is correctly received. Thus the sender, when it receives a NAK or timeout, must retransmit the frame in error plus all succeeding frames. (Sender must maintain a copy of each unacknowledged frame.)

Page 48: Chapter 7 Data Link Control

48

Go-back-N ARQ

Page 49: Chapter 7 Data Link Control

49

Selective-reject ARQ

The only frames retransmitted are those that receive a NAK or which timeout

Can save retransmissions, but requires more buffer space and complicated logic

See Figure 7.9b Page 212

Page 50: Chapter 7 Data Link Control

50

Maximum window size (with n-bit sequence number)Go-back-N : 2n - 1Selective-reject : 2n-1

Page 51: Chapter 7 Data Link Control

51

High-Level Data Link Control (HDLC)

A synchronous data link protocolWidely used, and basis for many other

data link control protocolsConnections can be multipoint or point-to-

pointCan be used in half-duplex or full-duplex

Page 52: Chapter 7 Data Link Control

52

Three types of stations

Primary station - (e.g., Mainframe) Controls the operation of the link, issues commands, and receives responses

Secondary station - (e.g., Terminal) Usually only communicates (responds) to a primary station

Combined station - Can be both a primary and a secondary

Page 53: Chapter 7 Data Link Control

53

Two link configurations

Unbalanced configuration - One primary and one or more secondary stations

Balanced configurations - Two combined stations

Page 54: Chapter 7 Data Link Control

54

Three data transfer modesNormal response mode (NRM) -

Unbalanced configuration Primary station always dictates who sends and receives

Asynchronous balanced mode (ABM) - Two combined stations. Either can initiate transmission

Asynchronous response mode - Unbalanced configuration Secondary station can send at any given time, but only one secondary can be active at a time

Page 55: Chapter 7 Data Link Control

55

HDLC Frame StructureThe 1st 3 fields are the header and the last 2 fields are the trailer

0

1

The first one or 2 bits identify the frame type

Page 56: Chapter 7 Data Link Control

56

Flag fields

8 bits (01111110)“Bit stuffing” is used for data transparencyBit stuffing: whenever five 1’s are

transmitted, extra zero is inserted

Page 57: Chapter 7 Data Link Control

57

Flag fields

An inverted bit could split a frame in two

An inverted bit merges 2 frames

Page 58: Chapter 7 Data Link Control

58

HDLC Frame StructureAddress field

8 bits. If needed longer address, the MSB can be set to zero and the address field is then assumed to be 8 bits longer.

All 1’s indicates this is a broadcast frame

Page 59: Chapter 7 Data Link Control

59

HDLC Frame Structure

Control field 8 bits. If the 1st bit is 0, then

“information frame”, Otherwise, 10 indicates “supervisory frame” and 11 indicates “unnumbered frame”

Information frametwo 3 bits sequence numbers, P/F bitsequence number can be extended to 7used to send data

Page 60: Chapter 7 Data Link Control

60

All of the control field formats contain the Poll/final (P/F) bit. Its use depends on context. Typically, in command frames, it is referred to as the P bit and is set to "1" to solicit (poll) a response frame from the peer HDLC entity. In response frames, it is referred to as the F bit and is set to "1" to indicate the response frame transmitted as a result of a soliciting command.

Page 61: Chapter 7 Data Link Control

61

HDLC Frame StructureControl field

Supervisory frame: bits 3 and 4 determine types00: “Receive Ready”. Used to ACK01: “Reject”. Essentially a NACK in Go-back-N

ARQ (Automatic Repeat Request)10: “Receive Not Ready”. Indicates busy

condition11: “Selective Reject”. Request for a single

frame retransmissionBit 5 is P/F. Bits 6,7,8 are sequence number

Page 62: Chapter 7 Data Link Control

62

HDLC Frame Structure

Control field Unnumbered frame:

More control functions. Has a variety of purposes, but most often used for establishing the link setup and disconnect.

Sets up the data transfer mode, sequence number size. Also used to reset the link and other miscellaneous stuff.

Page 63: Chapter 7 Data Link Control

63

HDLC Commands and responses

Page 64: Chapter 7 Data Link Control

64

Examples of Operation