Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main...

56
Data link control Maria Kihl

Transcript of Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main...

Page 1: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Data link control

Maria Kihl

Page 2: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

2

Book chapters

Forouzan 4th: 10.1-5, 11.1-5, 11.7

Forouzan 5th: (9.1), 10.1-3, 10.4.1, 11.1-2, 11.4, 23.2

Kihl: 4.1-4.3, 4.5

Page 4: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

4

Data communication on a link

A stream of bits would not be very efficient or manageable.

Page 5: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

5

Data packets

Therefore, data is divided into packets before transmission.

header data trailer

Header and trailer contains control information needed

for the transmission.

Page 6: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

6

Application Protocols

Application protocol Application Application

Physical link PHY PHY

information information

bits bits

signals

Page 7: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

7

HTTP, an application protocol

HTTP = Hyper Text Transfer Protocol

HTTP request

HTTP reply

Web server

Page 8: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

8

Link layer protocol

The sender and receiver uses a link layer protocol that

provides error detection and correction for data that is

sent on a physical link.

Link

application

PHY

data

bits

Link

application

PHY

data

bits

link protocol

application protocol

Page 9: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

9

Framing

• The Physical layer protocol sends a bitstream. The

Link layer protocol needs to separate the packets.

• Therefore, the link layer protocol at the sender

packetize data in frames so that the receiver can

distinguish one frame from another.

Page 10: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

10

Bitstuffing

Bitstuffing is used so that the data cannot be interpreted

as a flag.

Page 11: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

11

The need for error control

The data packets must be received without errors.

Otherwise, the reciever cannot understand them.

110111 010011 001111 100111

Page 12: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

12

Bit errors

Due to transmission impairments, data can be

corrupted during transmission. If the receiver

interprets a 1 as a 0, a bit error has occured.

1 0 link

Page 13: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

13

Single-bit error

In a single-bit error, only 1 bit in the data unit has changed.

Page 14: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

14

Burst errors

A burst error means that 2 or more

bits in the data unit have changed.

Page 15: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

15

To find bit errors

To detect and/or correct errors, extra (redundant) bits

is added to the data message.

Data Extra bits

The value of the extra bits depends on the data.

Page 16: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

16

Error detection process

Page 17: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

17

Error detection with 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.

Page 18: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

18

Error detection schemes

Simple Parity-Check Code

Cyclic Redundancy Check

Checksum

Page 19: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

19

Simple Parity-Check Code

A k-bit dataword is changed to an n-bit codeword,

where n = k+1. In (Even) Parity-Check the extra bit is

selected to make the total number of 1s in the

codeword even.

10011100 + 0 = 100111000

A simple parity-check code can detect an odd

number of errors.

Page 20: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Simple Parity-check code

20

Page 21: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Cyclic Redundancy Check (CRC)

21

In CRC, the sender and receiver uses a predefined shared divisor

to calculate the codeword. The math behind the choice of

divisor is out of the scope of this course.

Page 22: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

22

Dataword representation

The dataword of k bits be represented by a

polynomial, d(x).

Page 23: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

23

Encoder process

The objective is to find a codeword, c(x), of n bits.

The codeword is determined with a generator polynomial

(divisor), g(x), of degree n-k.

The encoder process is quite impossible to describe in

Powerpoint, instead we will work with it in the problem

solving classes this week.

Page 24: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

24

CRC encoder process

1. Left-shift the dataword n-k bits (i.e. xn-k * d(x)).

2. Divide xn-k * d(x) with g(x) using modulo-2

division.

3. The remainder, r(x), of the division is used as

redundant bits (i.e. c(x) = xn-k * d(x) + r(x)).

Page 25: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

CRC example

Dataword: 1001

Polynomial representation:

Divisor: 1011

Polynomial representation:

Dataword multiplied with :

25

13 x

13 xx

3x 36 xx

Page 26: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

26

CRC example

Page 27: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

27

CRC at the receiver

The received codeword is c(x)+e(x) where e(x) is the

error that have occurred during the transmission.

The receiver calculates the following:

Received codeword

g(x) =

c(x)

g(x) +

e(x)

g(x)

If the result is 0, the dataword is assumed to be correct.

Page 28: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

28

Detected errors

In a cyclic code, those e(x) errors that are divisible by

g(x) are not caught.

If the generator has more than one term and the

coefficient of x0 is 1, all single errors can be caught.

If a generator cannot divide xt + 1 (t between 0 and

n – 1), then all isolated double errors can be detected.

A generator that contains a factor of x + 1 can detect

all odd-numbered errors.

Page 29: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

29

Generator polynomial

Therefore, a good polynomial generator needs to have

the following characteristics:

1. It should have at least two terms.

2. The coefficient of the term x0 should

be 1.

3. It should not divide xt + 1, for t

between 2 and n − 1.

4. It should have the factor x + 1.

Page 30: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

30

Some standard CRC polynomials

Page 31: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

31

Checksum

The checksum is used in the Internet by several

protocols although not at the data link layer.

The main principle is to divide the data into segments

of n bits. Then add the segments and use the sum as

redundant bits.

Page 32: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Checksum process

32

Page 33: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Checksum example

Message: 1100 0101 1010

Checksum using 4 bits:

1100+0100+1010 => 12+4+10=29 => 11101

11101 is more than 4 bits. Use one’s complement

addition: 0001 1101 => 0001+1101 = 1110

The checksum is complemented to help the receiver. 33

Page 34: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

34

Checksum (another example)

1

1 1

0

Page 35: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

35

Link layer protocol

The link layer protocol should make sure that the data

is correctly transmitted over the physical link.

Link

application

PHY

data

bits

Link

application

PHY

data

bits

link protocol

application protocol

Page 36: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

36

The need for Error control

When a corrupted packet has been detected, the error

must be corrected in some way.

Two basic principles:

Forward Error Correction (FEC)

Extra bits are added in the data that makes it possible for the

receiver to correct bit error.

FEC is not included in this course

Retransmission of the data

The data is retransmitted until correctly received

Rules for retransmission is needed

Page 37: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

The need for Flow control

The receiver must be able to handle all recieved

frames. If the transmission rate is too high, the

receiever may become overloaded and drop frames

due to full buffers.

37

Page 38: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

38

Error and flow control

The basic principle in error and flow control is that the

receiver acknowledges all correctly received packets.

Data

ACK

Page 39: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

39

Automatic Repeat Request (ARQ)

schemes

Stop-and-wait ARQ

Go-back-N ARQ

Selective Repeat ARQ

Unfortunately, Fouruzan 5th edition has become rather confused on these schemes

with descriptions in two different chapters. Please follow the lecture slides for a more

compact view.

Page 40: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

40

Stop-and-wait ARQ

The receiver sends an ACK for every data packet that is correctly received.

The sender transmits the next packet when it has received an ACK for the previous one.

The sender uses a time-out for each packet. If the time-out expires (i.e. no ACK has arrived), the packet is retransmitted.

Packets are identified with a sequence number, alternating between 0 and 1.

Page 41: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

41

Stop-and-Wait, example

Page 42: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

42

Go-back-N ARQ

The sender can transmit several packets without an

ACK from the receiver.

The receiver ACKs all packets that are correctly

received in the right order.

The sender can transmit new packets when ACKs are

received for previous packets.

This is called pipelining.

Page 43: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

43

Sequence numbers

The packets are identified with a seqence number.

If the header allows m bits for the sequence number, the numbers can range from 0 to 2m-1.

This means that the maximum number of outstanding packets (transmitted packets that haven’t been ACKed) is 2m-1.

A sliding window defines the range of sequence numbers that currently concerns the sender and receiver.

Page 44: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

44

Sliding window at sender

Page 45: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

45

Importance of window size

Page 46: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

46

Go-back-N, example (lost ACK)

Page 47: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

47

Go-back-N, example (lost data)

Page 48: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

48

Selective repeat ARQ

Works as Go-back-N as long as there are no lost

packets.

The receiver sends a negative acknowledgment (NAK)

when it detects a lost packet.

Only the lost packets are retransmitted.

Page 49: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

49

Send and receive windows

Page 50: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

50

Selective repeat, example

Page 51: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Point-to-Point Protocol (PPP)

Point-to-point protocol (PPP) is one of the classical

Internet protocols, and it is in this course used as an

example of the function of a link layer protocol.

It is a byte-oriented (character-oriented) protocol, that

is, everything in the frame is treated in bytes.

Frame format:

Page 52: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Byte stuffing

When the flag appears in the data field, it needs to be

escaped.

Since PPP is a byte-oriented protocol, byte stuffing is

used.

Every time the flaglike pattern appears in the data

field, the escape byte 01111101 is stuffed to tell the

receiver that the next byte is not a flag.

Page 53: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Error and flow control

• PPP uses a 2 or 4 byte CRC for error detection.

• However, no further error or flow control is

provided.

53

Page 54: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Transition phases

A PPP connection goes through a number of phases:

Page 55: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Help protocols

PPP uses a set of other protocols to manage the connection:

Link Control Protocol (LCP) is responsible for establishing,

maintaining, configuring, and terminating links.

Password Authentication Protocol (PAP) and Challenge Handshake

Authentication Protocol (CHAP) are used in the authentication process.

A Network Control Protocol (NCP) configures the link for the network

protocol. One example is Internet Protocol Control Protocol (IPCP) for

Internet.

Page 56: Data link control - Lunds tekniska högskolaprotocols although not at the data link layer. The main principle is to divide the data into segments of n bits. Then add the segments and

Other protocols in PPP