Top Banner
Prof . Chintan Patel [email protected] MEFGI , Rajkot
176

Unit 3 datalink layer

May 10, 2015

Download

Education

Chintan Patel

Computer network : Data link layer.......Know some thing about data link layer functionality like Flow control , error control , error detection , error correction methods...Sliding window protocols.........and many new things.......
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Unit 3 datalink layer

Prof . Chintan Patel

[email protected]

MEFGI , Rajkot

Page 2: Unit 3 datalink layer
Page 3: Unit 3 datalink layer

• Services Provided to the Network Layer

• Framing

• Error Control

• Flow Control

Page 4: Unit 3 datalink layer

• Provide service interface to the network layer

• Dealing with transmission errors

• Regulating data flow

• Slow receivers not swamped by fast senders

Page 5: Unit 3 datalink layer

Relationship between packets and frames.

Page 6: Unit 3 datalink layer

(a) Virtual communication.

(b) Actual communication.

Page 7: Unit 3 datalink layer

• Unacknowledged Connectionless service

• Acknowledged Connectionless service

• Acknowledged Connection-Oriented service

Page 8: Unit 3 datalink layer

• Losses are taken care of at higher layers

• Used on reliable medium like coax cables or optical fiber, where the error rate is low.

• Appropriate for voice, where delay is worse than bad data.

Page 9: Unit 3 datalink layer

• Useful on unreliable medium like wireless.

• Acknowledgements add delays.

• Adding ack in the DLL rather than in the NL is just an optimization and not a requirement. Leaving it for the NL is inefficient as a large message (packet) has to be resent in that case in contrast to small frames here.

• On reliable channels, like fiber, the overhead associated with the ack is not justified.

Page 10: Unit 3 datalink layer

• Most reliable,

• Guaranteed service –

Each frame sent is indeed received

Each frame is received exactly once

Frames are received in order

• Special care has to be taken to ensure this in connectionless services

Page 11: Unit 3 datalink layer

• Character Count

• Flag bytes with byte stuffing

• Flag bytes with bit stuffing

Page 12: Unit 3 datalink layer

A character stream. (a) Without errors. (b) With one error.

Page 13: Unit 3 datalink layer

• What if the count is garbled

• Even if with checksum, the receiver knows that the frame is bad there is no way to tell where the next frame starts.

• Asking for retransmission doesn’t help either because the start of the retransmitted frame is not known

• No longer used

Page 14: Unit 3 datalink layer
Page 15: Unit 3 datalink layer

Bit stuffing

(a) The original data.

(b) The data as they appear on the line.

(c) The data as they are stored in receiver’s memory after de stuffing.

Page 16: Unit 3 datalink layer

• Data can be corrupt during transmission

• There must be some application which can detect and correct the data.

Page 17: Unit 3 datalink layer

• For unacknowledged serviced , Receiver can assume that received data is correctly received.

• But for acknowledged reliable services , Received data must be error free…………

• Usual way to ensure reliable delivery is to provide the sender with some feedback about what is happening at the other end of the line.

Page 18: Unit 3 datalink layer

• Positive acknowledgement :

If the sender receives a positive acknowledgement about a frame, it knows the frame has arrived safely.

• Negative Acknowledgement :

A negative acknowledgement means that something has gone wrong and the frame must be transmitted again.

Page 19: Unit 3 datalink layer

• Hardware trouble may increase noise inside data.

• If acknowledgement frame is lost , sender does not know how to react.

• Sender , After sending a data ,must wait for acknowledgement………

• For solving lost acknowledgement problem…

Sender must start timer. When sender send a data.

• The timer is set to expire after an interval long enough for the frame to reach the destination, be processed there, and have the acknowledgement propagate back to the sender.

Page 20: Unit 3 datalink layer

• if either the frame or the acknowledgement is lost, the timer will go off, alerting the sender about problem.

• solution is to just transmit the frame again.

• when frames may be transmitted multiple times there is a danger that the receiver will accept the same frame two or more times and pass it to the network layer more than once.

• to assign sequence numbers to outgoing frames,

so that the receiver can distinguish retransmissions from originals.

Page 21: Unit 3 datalink layer

• Ultimate goal of managing the timers and sequence numbers for to ensure that each frame is ultimately passed to the network layer at the destination exactly once, no more and no less,

Page 22: Unit 3 datalink layer

• sender that systematically wants to transmit frames faster than the receiver can accept them. This situation can occur when

• the sender is running on a fast, powerful computer.

• the receiver is running on a slow, low-end machine.

• Even if the transmission is error free, the receiver may be unable to handle the frames as fast as they arrive and will lose some.

Page 23: Unit 3 datalink layer

• Two approaches

• feedback-based flow control,

the receiver sends back information to the sender giving it permission to send more data, or at least telling the sender how the receiver is doing.

• Rate-based flow control

the protocol has a built-in mechanism that limits the rate at which senders may transmit data, without using feedback from the receiver.

Page 24: Unit 3 datalink layer

• Feedback based scheme is used in both data link layer and transport layer.

• Rate based flow control is used in data link layer…

• feedback-based flow control in that protocol contains well-defined rules about when a sender may transmit the next frame.

• These rules often prohibit frames from being sent until the receiver has granted permission,

Page 25: Unit 3 datalink layer

• example,

• when a connection is set up the receiver might say:

‘‘You may send me n frames now, but after they have been sent, do not send any more until I have told you to continue.’’

Page 26: Unit 3 datalink layer

• Types of Errors ….

• Unpredictable changes can be occur because of interference.

• Single – Bit rate Error.

Only 1 bit of given data unit(like byte , character or packet) is changed from 1to 0 or 0 to 1.

Page 27: Unit 3 datalink layer

• If 1mbps speed data is sent. Each bit lasts only

1/1,000,000 s or 1 micro second.

• For to occur single bit of error , noise must have

duration of only 1 micro second. Which is very

rare;

Page 28: Unit 3 datalink layer

• 2or more bits in the data unit have changed from 1 to 0 or from 0 to 1.

Page 29: Unit 3 datalink layer
Page 30: Unit 3 datalink layer

• Length of the burst measured from the first corrupted bit to the

last corrupted bit. Some bits in between may not have been

corrupted.

Page 31: Unit 3 datalink layer

• Central concept in detecting or correcting errors is Redundancy………

• To detect or correct the errors in data, send an extra bits with out data.

• Redundant bits are added by sender and removed by receiver.

• Presence of redundant bits allows the receiver to correct or detect corrupted bits.

Page 32: Unit 3 datalink layer
Page 33: Unit 3 datalink layer

• Error detection is easy compare to error correction. …because…….

• In detection….either error occurred or not…….

• But in correction????.......

• Error is occurred..now exact no. of bits that are corrupted….location of these corrupted bits in message….

• So 1. No of the errors.

2. size of message….. Important factor

Page 34: Unit 3 datalink layer

• In single bit error in an 8 bit data…..there are 8 possible locations of error occurred..

• If in same data unit of same size, 2 errors occurred than 28 possible locations……..

• Now assume 10 bit error in 1000 bit data unit.

Page 35: Unit 3 datalink layer

• 1. Forward error correction.

Receiver tries to guess the message from the added redundant bits.

• 2. Retransmission.

Receiver detect the occurrence of error and ask the sender to retransmit the message.

Resending repeats until sender believes message arrived is error free.

Page 36: Unit 3 datalink layer

• Redundancy is achieved through various coding system.

• Sender adds redundant bits through a process that creates a relation ship between the redundant bits and the actual data.

• Receiver check the relationship between two sets of bits to detect and correct errors.

• 1. Block coding

• 2. Convolution coding

Page 37: Unit 3 datalink layer

• Process of adding redundancy for error detection or correction

• Two types:

Block codes Divides the data to be sent into a set of blocks

Extra information attached to each block

Memory less

Convolution codes Treats data as a series of bits, and computes a code over a

continuous series

The code computed for a set of bits depends on the current and previous input

Page 38: Unit 3 datalink layer
Page 39: Unit 3 datalink layer

• In modulo-N arithmetic , we use only the integers in the range 0 to N-1….

• For example in computer understands modulo -2 , so only 0 and 1 we use….

• Modulo – 12 , only 0 to 11 integers will be used…

• Suppose job starts at 11 : 00 am and takes 5 hour to finish…we can say it will finish on 16:00 or at 4 pm

Page 40: Unit 3 datalink layer

• Main operation for computing error detection/correction codes

• Similar to modulo-2 addition

Page 41: Unit 3 datalink layer

• Divides our message into blocks, Each block size is k bits, called datawords.

• Size of Redundant bit = r bit.

• So total block length is n = k + r bit…resulting n bit block called as codewords

• Example :

• With k bits …….2^k possible datawords.

• With n bits……..2^n possible codewords.

Page 42: Unit 3 datalink layer

Example : If size of message is 8 bit……….now divide it into 4 datawords …each

size is 2 bits….

Now if add 1 redundant bit with each datawords so length of n = 2(datawords) +

1(redundant) bit = 3 bit………..

So total possible data word is 2^2 = 4 and total possible codewords is 2^3 = 8.

So extra 8- 4 = 4 data words will be generated. Which are invalid .

Page 43: Unit 3 datalink layer

Data Code Data Code

0000 11110 1000 10010

0001 01001 1001 10011

0010 10100 1010 10110

0011 10101 1011 10111

0100 01010 1100 11010

0101 01011 1101 11011

0110 01110 1110 11100

0111 01111 1111 11101

k = ?

r = ?

n = ?

Page 44: Unit 3 datalink layer

• 1. Receiver has (or can find) a list of valid codewords.

• 2. The original codeword has changed to an invalid one.

Page 45: Unit 3 datalink layer

Data words codewords

00 000

01 011

10 101

11 110

k = 2 , n =3 ……now assume sender sends 011 to receiver….

1. 011 is received….valid codeword. Receiver extract it 01.

2. 111 is received….not valid codeword and discarded.

3. 000 is received….valid but not actually transmitted codeword.

“ Error Detecting codeword can detect only those errors for

which it is actually designed…other types of error may

remain undetected “

Page 46: Unit 3 datalink layer

• Receiver needs to find original code words which is sent.

• Need more redundant beet than error detection.

Page 47: Unit 3 datalink layer

Data words codewords00 00000

01 01011

10 10101

11 11110

Suppose now receiver is sending 01011, now receiver receives 01001………….

So 1. Received code word is not there inside table.

2. Compare received codeword with first codeword in table(Compare with 00000).

So receiver decides that first codeword is not there because there are two different bits.

3. Same reason original codeword can not be 3rd and 4th .

4. Original must be 2nd because only one that differs from the codeword received

by 1 bit.

Page 48: Unit 3 datalink layer

• “Hamming distance between two words of same size is the number of difference between the corresponding bits”.

• Hamming distance between two words x and y is d(x , y).

• What is need of finding hamming distance ?

Hamming distance will give how many number of bits are changed during transmission.

Page 49: Unit 3 datalink layer

• How to calculate hamming distance??

If we apply XOR operation on the two words and count the number of 1’s in result

• Find hamming distance between 000 and 011 ?

• Find hamming distance between 10101 and 11110 ?

Page 50: Unit 3 datalink layer

• How sender will select code words.??

• What is minimum hamming distance??

• How minimum hamming distance is related with code words??

• Minimum hamming distance : “ Minimum hamming distance is smallest hamming distance between all pairs possible in set of words ”

Page 51: Unit 3 datalink layer

code words codewords Hamming distance

000 011 2

000 101 2

000 111 3

011 010 2

011 001 2

011 100 3

101 100 1

101 011 2

Dmin is 1 here…….

Page 52: Unit 3 datalink layer

• 1. Codeword of size n,

• 2. Datawords of size k,

• 3. Dmin .

• Coding scheme C(5,2) Means here datawords size is 2 bits and codewords size is 5 bit.

• Which have minimum hamming distance is 3. It can be change.

Page 53: Unit 3 datalink layer

• When ever codeword is corrupt during transmission , Hamming distance between the sent and received codewords is the number of bits affected by the error.

• So hamming distance is no. of bits corrupted during transmission.

• If 000000 was sent by sender and receiver receives 011101. so hamming distance here is 4 which is no. of bits affected.

Page 54: Unit 3 datalink layer

Datawords Code words

00 000

01 011

10 101

11 110

1. What is minimum hamming distance between code words?

2. Suppose if you will transmit 101 ,

• If single bit error occurred it can be 100 or 001 0r 111.

• If two bit error occurred it can be 110, 011 , 000.

• Even through received codeword is not correct in two bit

error it will find in valid codewords.

Page 55: Unit 3 datalink layer

Data words codewords00 00000

01 01011

10 10101

11 11110

1. What is minimum hamming distance between code words?

2. Suppose if you will transmit 01011 ,

• If single bit error occurred ?.

• If two bit error occurred ?

• If 3 bit error occurred?

• Even through received codeword is not correct in two bit

error it will find in valid codewords.

Page 56: Unit 3 datalink layer

• If our code is to detect s errors , than minimum distance between the valid codes must be s+1. so the received code word does not match valid code words.

• If Dmin = s + 1 than its guarantee that up to s bit error can be detected.

• In special cases only more than s errors can be detected but not guaranteed.

Page 57: Unit 3 datalink layer

To guarantee the detection of up to s errors in all cases, the minimum

Hamming distance in a block

code must be dmin >= s + 1.

To guarantee correction of up to t errors in all cases, the minimum

Hamming distance in a block code

must be dmin >= 2t + 1.

Example : A code scheme has a Hamming distance dmin = 4.

What is the error detection and correction capability of this

scheme?

Page 58: Unit 3 datalink layer

• All most all block codes used today belongs to subset called linear block codes.

• Non linear block codes for error correction and detection is not wide spread because of theoretical structure and implementation difficulty.

• “Linear block code is code in which “The Exclusive OR operation of two valid codewords creates another valid codewords””

Page 59: Unit 3 datalink layer

Linearity:

if m1 -> c1 and m2 -> c2 than

m1 exor m2 -> c1 exor c2

where m is a k-bit information sequence c is an n-bit codeword.

Linear code: The sum of any two codewords is a codeword.

Observation: The all-zero sequence is a codeword in every linear codeword

Page 60: Unit 3 datalink layer

Data words codewords

00 000

01 011

10 101

11 110

011 Exor 101 = 110 , so its also valid codeword

Data words codewords00 00000

01 01011

10 10101

11 11110

Page 61: Unit 3 datalink layer

• Minimum hamming distance for a linear block codes is the “ No of 1s in the nonzero valid codeword with the smallest no of 1s”

• Find dmin ??

Data words codewords00 00000

01 01011

10 10101

11 11110

Page 62: Unit 3 datalink layer

• 1. Simple parity-check codes :

• K bit datawords is changed to n bit codeword where n = k + 1.

• One extra bit which is added is called as a parity bit.

• How to select parity bit ??????

• “Select a parity bit so that total no of 1s in codeword become even.”

Page 63: Unit 3 datalink layer

• This , simple parity check code can detect only single bit error and it can not correct any error.

Data words codewords

00 000

01 011

10 101

11 110

Page 64: Unit 3 datalink layer
Page 65: Unit 3 datalink layer

Encoder and decoder for simple parity check code

Page 66: Unit 3 datalink layer

• Encoder uses a generator that takes a copy of a 4 bit dataword and generates a parity bit R0.

• Now 4bit dataword + 1 bit parity bit will create 5 bit codeword.

• Sender sends 5 bit codewords. Which can be corrupt during transmissions.

• Receiver receives code word and with the help of all 5 bit it will calculate syndrome, is just 1 bit.

• The syndrome is 0 when no of 1s in received codeword is even else syndrome is 1

Page 67: Unit 3 datalink layer

• R0 = a3 + a2 + a1 + a0

• If number of 1 is even result will be 0.

• If number of 1 is odd result will be 1.

• Example : for dataword 0011 , what is the result???

• For dataword 0111, what is the result???

Page 68: Unit 3 datalink layer
Page 69: Unit 3 datalink layer

• S0 = b3 + b2 + b1 + b0 + q0

• If number of 1 is even result will be 0.

• If number of 1 is odd result will be 1.

• Example : for dataword 0011 , what is the result???

• For dataword 0111, what is the result???

Page 70: Unit 3 datalink layer

• Example : Assume sender want to send 1011.

• 1 : what will be codeword ?

• 2 : No error occurs, Received 10111. what is S0 ?

• 3 : Received 10011 . What is syndrome S0?

• 4 : Received 10110 (R0 is changed , no data part is corrupted) . What is S0 ? …Even though data part is not corrupt dataword will not be generated.

Page 71: Unit 3 datalink layer

• 5. Received codeword is 00110 ( R0 and a3 is changed)….what will be s0? What will be dataword generated ?

• 6. Received 01011 , (a1,a2,a3 is changed).what will be syndrome s0?...

• Observation : “Simple parity check can detect any odd no. errors but can not detect even no. of errors”

Page 72: Unit 3 datalink layer

• 5 , 7 bit bytes are putted in separate rows.

• For each raw and each column , 1 parity-check bit is calculated.

• Hall table is sent to receiver which finds syndrome for each row and column.

• It can detect up to 3 errors , how ever 4 bit error may not be detected. And it can correct error up to 1 bit

Page 73: Unit 3 datalink layer
Page 74: Unit 3 datalink layer
Page 75: Unit 3 datalink layer
Page 76: Unit 3 datalink layer

• This codes where originally designed with

• Dmin = 3, means it can detect up to 2 errors and correct one single error.

• Finding relation among n (codeword) and k(dataword) .

Choose m >= 3 so n = 2^m – 1;

K = n – m;

Check bit or redundant bit r = m;

• If m = 3 then n = 7 and k = 4 . This hamming code C(7,4) With

• dmin = 3.

Page 77: Unit 3 datalink layer

Hamming code C(7, 4)

Data words Codewords datawords codewords

0000 0000000 1000 1000110

0001 0001101 1001 1001011

0010 0010111 1010 1010001

0011 0011010 1011 1011100

0100 0100011 1100 1100101

0101 0101110 1101 1101000

0110 0110100 1110 1110010

0111 0111001 1111 1111111

Page 78: Unit 3 datalink layer
Page 79: Unit 3 datalink layer

• Generator will calculate 3 parity check r0 , r1 , r2 from 4 bit datawords

• R0 = a2 + a1 + a0

• R1 = a3 + a2 + a1

• R2 = a1 + a0 + a3

• Each parity bits handles 3 out of 4 bits of dataword. Total no. of 1s in each 4 combination must be even.

Page 80: Unit 3 datalink layer

• The checker in decoder creates a 3 bit syndrome (s2,s1,s0) in which each bit is the parity check for 4 out of 7 bits codewords.

• S0 = b2 + b1 + b0 + q0

• S1 = b3 + b2 + b1 + q1

• S2 = b1 + b0 + b3 + q2

Page 81: Unit 3 datalink layer

Hamming code C(7, 4)

Data words Codewords datawords codewords

0000 0000000 1000 1000110

0001 0001101 1001 1001011

0010 0010111 1010 1010001

0011 0011010 1011 1011100

0100 0100011 1100 1100101

0101 0101110 1101 1101000

0110 0110100 1110 1110010

0111 0111001 1111 1111111

Page 82: Unit 3 datalink layer

• 3 bit syndrome creates 8 different bit pattern from 000 to 111. That can represents 8 different conditions.

• If qo is in error than only affected bit is s0.

• If b2 is in error than affected bit is s0 and s1.

Page 83: Unit 3 datalink layer

• 1 . If 0100 dataword ….than calculate codeword?

• 2. if received codeword is 0100011 ..calculate syndrome ???

• 3. if 0111 is dataword than calculate codeword??

• 4. if received code word is 0011001 find syndrome ? What place error is there?

• 5. if 1101 dataword is there calculate syndrome??

• 6. if received codeword is 0001000 , what will syndrome ??

Page 84: Unit 3 datalink layer

• A checksum or hash sum is a small-size data number computed from an arbitrary block of digital data for the purpose of detecting errors that may have been introduced during its transmission.

• Its error detection method.

Page 85: Unit 3 datalink layer

• Suppose our data is a list of five 4-bit numbers that

we want to send to a destination. In addition to

sending these numbers, we send the sum of the

numbers. For example, if the set of numbers is (7,

11, 12, 0, 6), we send (7, 11, 12, 0, 6, 36), where 36

is the sum of the original numbers. The receiver

adds the five numbers and compares the result with

the sum. If the two are the same, the receiver

assumes no error, accepts the five numbers, and

discards the sum. Otherwise, there is an error

somewhere and the data are not accepted.

Page 86: Unit 3 datalink layer

• We can make the job of the receiver easier if we

send the negative (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 received

(including the checksum). If the result is 0, it

assumes no error; otherwise, there is an error.

Page 87: Unit 3 datalink layer

• We can represent unsigned number between 0 and 2^n -1 using n bits.

• Example : 1. To represent 15 , how many bits

require?

2. To represent 25 , how many bits

require?

3. To represent 48, how many bits

require?

Page 88: Unit 3 datalink layer

• If number has more than n bits….

• Example : if you want to represent 21 using 4 bits???? Than???

• Solution : The extra left most bits need to be added to the n rightmost bits.

• In one’s complement arithmetic, a negative number can be represented by inverting all bits.

• (changing a 0 to 1 and a 1 to 0).

Page 89: Unit 3 datalink layer

• How to represent number 21 in one’s complement arithmetic using only 4 bits?

• Binary of 21 : 10101 (5 bits).

• To represent in 4 bits : 0101 + 1 = 0110 = 6.

Page 90: Unit 3 datalink layer

• Positive 6 = 0110

• Negative 6 = 1001 = 9(unsigned number)

• So complement of 6 is 9

• (15 – 9 = 6)…..so another method of one’s complement is to subtract number from 2^n -1.

Page 91: Unit 3 datalink layer
Page 92: Unit 3 datalink layer
Page 93: Unit 3 datalink layer

The sender follows these steps:

•The unit is divided into k sections, each of n bits.

•All sections are added using one’s complement to get the sum.

•The sum is complemented and becomes the checksum.

•The checksum is sent with the data.

The receiver follows these steps:

•The unit is divided into k sections, each of n bits.

•All sections are added using one’s complement to get the sum.

•The sum is complemented.

•If the result is zero, the data are accepted: otherwise, rejected.

Page 94: Unit 3 datalink layer

Suppose the following block of 16 bits is to be sent using a checksum of 8 bits.

10101001 00111001

The numbers are added using one’s complement

10101001

00111001------------

Sum 11100010

Checksum 00011101

The pattern sent is 10101001 00111001 00011101

Page 95: Unit 3 datalink layer

Now suppose the receiver receives the pattern sent in Example 7 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 11111111

Complement 00000000 means that the pattern is OK.

Page 96: Unit 3 datalink layer

Now suppose there is a burst error of length 5 that affects 4 bits.

10101111 11111001 00011101

When the receiver adds the three sections, it gets

10101111

11111001

00011101

Partial Sum 1 11000101

Carry 1

Sum 11000110

Complement 00111001 the pattern is corrupted.

Page 97: Unit 3 datalink layer

Internet Checksum

Traditionally internet is using 16bit checksum

Sender site:

1. The message is divided into 16-bit words.

2. The value of the checksum word is set to 0.

3. All words including the checksum are

added using one’s complement addition.

4. The sum is complemented and becomes the

checksum.

5. The checksum is sent with the data.

Page 98: Unit 3 datalink layer

Receiver site:

1. The message (including checksum) is

divided into 16-bit words.

2. All words are added using one’s

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.

Internet Checksum

Page 99: Unit 3 datalink layer

• Note

When adding numbers, a carryout from the most significant bit needs to be added to the result

• Example: add two 16-bit integers

1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1

1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0

1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1

wraparound

sum

checksum

Page 100: Unit 3 datalink layer
Page 101: Unit 3 datalink layer

• Calculate checksum : Fo ro uz an

Page 102: Unit 3 datalink layer

• Not strong as CRC for error checking . Example : if the value of one word is incremented and value of another word is decremented by same amount…..it can not be detected because value of sum and checksum will remains same.

• “solution is weighted sum”.

Page 104: Unit 3 datalink layer

• When data link layer accept the packet it will encapsulate the packet in a frame by adding a data link layer header and trailer.

• Header : control information

• Trailer : Checksum

Page 105: Unit 3 datalink layer

• “to_physical_layer” : To send a frame

• “from_physical_layer” : To receive a frame.

• Transmitting hardware computes the checksum and add into trailer,

Page 106: Unit 3 datalink layer

• Initially receiver will wait for an event : “wait_for_event(&event)”.

• It will returns when frame has arrived.

• After receiving frame : Receiver hardware computes the checksum .

• If the checksum is incorrect . There is transmission error. “event = cksum_err”.

• If the arrived frame is undamaged “event = frame_ arrival”.

Page 107: Unit 3 datalink layer

• After acquiring undamaged frame , it checks the control information in the header.

• If all right passes only “Packet portion to network layer”.

• Frame header will not be given to n/w layer.

• Why????

• “To keep the network layer and data link layer protocol completely separate”.

Page 108: Unit 3 datalink layer

• 1. “boolean” : Returns “true” or “false”.

• 2. “seq_nr” : small integer used to number the frames . It can be 0 to MAX_SEQ.

• 3. “packet” : Unit of information exchanged between network layer and data link layer.

• It out model its MAX_PKT bytes but in reality it will be of variable length.

Page 109: Unit 3 datalink layer

• Frame :

• FRAME HEADER = kind + seq + ack + info.

• First three used as a control information and info will contains actual data to be transferred.

• Kind field : Tells weather any data is there or not in the frame .

• Why it needs : some protocols distinguish frames containing only control info. From those containing data.

Page 110: Unit 3 datalink layer

• seq and ack fields used for sequence number and acknowledgements.

• info : contains a single packet.

• to_network_layer and from_network_layer : to pass the packet between data link layer and network layer.

• to_network_layer and from_network_layer : deals with interface between 2nd and 3rd layer.

• from_physical_layer and to_physical_layer : deals with interface between 1st and 2nd .

Page 111: Unit 3 datalink layer

• start_timer : to start the timer or Reset the timer.

• stop_time : to Off the timer.

Page 112: Unit 3 datalink layer

• Noise less channel protocol are not used in real life but that are basics

for understanding the protocols of noisy channels.

Page 113: Unit 3 datalink layer

• Protocols we are going to discuss have data frames which travels from one node called sender to another node called Receiver.

• Discussed protocols for unidirectional implementation.

• In Real life , data link control protocols are implemented as bidirectional.

• Data flow can be in both direction.

Page 114: Unit 3 datalink layer

• Piggybacking : Acknowledgement frame is included in data frame….

• Example : when ever you request for logged in to yahoo..you will logged in as well as get message of successful login.

Page 115: Unit 3 datalink layer

• Assumption : Channel is ideal in which no frames are lost, duplicated or corrupted.

• Simplex protocol : No flow control.

• Stop and wait protocol : Flow control

• No error control : noiseless channel, we assume.

Page 116: Unit 3 datalink layer

• Unidirectional protocol : Only data frame is there which is travelling in one direction called sender to receiver.

• Assuming that receiver will accept the frame with negligible processing time and handover it to network layer after removing header and trailer ,immediately.

Page 117: Unit 3 datalink layer
Page 118: Unit 3 datalink layer

Algorithm Sender-site algorithm for the simplest protocol

Page 119: Unit 3 datalink layer

Algorithm Receiver-site algorithm for the simplest protocol

Page 120: Unit 3 datalink layer

Example of communication using this protocol. It is very simple. The sender sends a

sequence of frames without even thinking about the receiver. To send three frames, three

events occur at the sender site and three events at the receiver site. Note that the data

frames are shown by tilted boxes; the height of the box defines the transmission time

difference between the first bit and the last bit in the frame.

Page 121: Unit 3 datalink layer

• If data frames arrives at the receiver site faster than they can be processed , frame must be stored.

• If receiver have more than one sender than it may not have enough space . so we have to tell sender for slow down.

• Stop-and-wait protocol : sender sends one frame and stops until it receives conformation from the receiver.

• Unidirectional only :

• data : sender to receiver at one time

• Acknowledgement : Receiver to sender at another time.

• Half duplex link is used.

Page 122: Unit 3 datalink layer
Page 123: Unit 3 datalink layer

Algorithm Sender-site algorithm for Stop-and-Wait Protocol

Page 124: Unit 3 datalink layer

• After a frame is sent, algorithm must ignore another request from network layer until that frame is acknowledged.

• Handle with the help of “canSend”

• If canSend = false , frame is sent but not acknowledged.

• If canSend = true , ACK is received, and allows the sending of next frame.

Page 125: Unit 3 datalink layer

Algorithm Receiver-site algorithm for Stop-and-Wait Protocol

Page 126: Unit 3 datalink layer

Figure shows an example of communication using this protocol. It is still

very simple. The sender sends one frame and waits for feedback from the

receiver. When the ACK arrives, the sender sends the next frame. Note

that sending two frames in the protocol involves the sender in four events

and the receiver in two events.

Page 127: Unit 3 datalink layer

• A sliding window protocol is a feature of packet-based datatransmission protocols. Sliding window protocols are used where reliable in-order delivery of packets is required, such as in the Data Link Layer (OSImodel) as well as in the Transmission Control Protocol (TCP).

• Conceptually, each portion of the transmission (packets in most data linklayers, but bytes in TCP) is assigned a unique consecutive sequence number,and the receiver uses the numbers to place received packets in the correctorder, discarding duplicate packets and identifying missing ones. Theproblem with this is that there is no limit on the size of the sequencenumbers that can be required.

• A sliding window protocol allows an unlimited number of packets to becommunicated using fixed-size sequence numbers.

Page 128: Unit 3 datalink layer

• Automatic Repeat reQuest (ARQ), also known as Automatic RepeatQuery, is an error-control method for data transmission thatuses acknowledgements (messages sent by the receiver )and timeouts (specified periods of time allowed to elapse before anacknowledgment is to be received) to achieve reliable data transmissionover an unreliable service. If the sender does not receive anacknowledgment before the timeout, it usually re-transmits theframe/packet until the sender receives an acknowledgment or exceeds apredefined number of re-transmissions.

• The types of ARQ protocols include

Stop-and-wait ARQ

Go-Back-N ARQ

Selective Repeat ARQ

• All three protocols usually use some form of sliding window protocol totell the transmitter to determine which (if any) packets need to beretransmitted.

Page 129: Unit 3 datalink layer

• Adds Simple Error Correction method in Stop-and-wait Protocol.

• To detect and correct corrupted frames we need to add Redundancybits in data frame, When it is coming to receiver and if its corrupted,it is silently discarded.

• IMP : Detection of error in this protocol is manipulated by silenceof receiver.

• If receiver receives a frame out of order means frames were eitherlost or duplicated, Lost or corrupted frame need to retransmit in thisprotocol.

• Solution : Sender keeps the copy of sent frames and at the same timestarts the timer. If ACK is not received before time out , sender willresend the data packet and keeps copy of frame and starts the timeragain.

Page 130: Unit 3 datalink layer

• Stop-and-wait ARQ is a method used in telecommunications to sendinformation between two connected devices. It ensures that information isnot lost due to dropped packets and that packets are received in thecorrect order. It is the simplest kind of automatic repeat-request (ARQ)method.

• A stop-and-wait ARQ sender sends one frame at a time; it is a special caseof the general sliding window protocol with both transmit and receivewindow sizes equal to 1. After sending each frame, the sender doesn'tsend any further frames until it receives an acknowledgement (ACK)signal. After receiving a good frame, the receiver sends an ACK. If the ACKdoes not reach the sender before a certain time, known as the timeout,the sender sends the same frame again.

Page 131: Unit 3 datalink layer

• Another problem is when the transmission medium has such along latency that the sender's timeout runs out before the framereaches the receiver. In this case the sender resends the same packet.Eventually the receiver gets two copies of the same frame, and sends an ACKfor each one. The sender, waiting for a single ACK, receives two ACKs,which may cause problems if it assumes that the second ACK is for thenext frame in the sequence.

• To avoid these problems, the most common solution is to define a 1bit sequence number in the header of the frame. This sequence numberalternates (from 0 to 1) in subsequent frames. When the receiver sends anACK, it includes the sequence number of the next packet it expects. Thisway, the receiver can detect duplicated frames by checking if the framesequence numbers alternate. If two subsequent frames have the samesequence number, they are duplicates, and the second frame isdiscarded. Similarly, if two subsequent ACKs reference the same sequencenumber, they are acknowledging the same frame.

Page 132: Unit 3 datalink layer

• Range of sequence number : to minimize frame size , We needsmallest range for sequence number such that it providesunambiguous communication.

• if we decide that field is m bit long , the sequence number can befrom 0 to 2^m – 1and than repeated.

• Example : Assume that sender sends sequence number 1(x) , we onlyneed to use 2(x+1) after that , we do not need 3(x+2). To show thisassume that sender sends a frame with sequence number 1(x).3Things can happen.

Page 133: Unit 3 datalink layer

• 1 : Frame arrives at receiver safe and sound . Receiver sendsacknowledgement causing the sender to send the next framenumbered 2 (x+1).

• 2 : Frame arrives at receiver side safe and sound , Receiver sendsACK , But ACK is corrupted or lost. Sender resends a frame 1(x) aftertime out. Now receiver receives duplicate frame so it can identify thatI was expecting 2(x+1) but received 1(x).

• 3 : Frame is corrupted or lost, Sender resends the frame after timeout.

Page 134: Unit 3 datalink layer

• Need for sequence number 1(x) and 2(x+1) only is there because receiver needs to distinguish frame but no need of 3(x+2).

• If x and x+1 only need than let X = 0 and X+1 = 1. This means that in SWP ARQ sequence number will be 0,1,0,1,0,1,0,1.

• In SWP ARQ Sequence number is based on Modulo-2 Arithmetic.

• Acknowledgement Number : Always announce the sequence number of next frame expected by receiver.. If received frame is 0 , ACK will be 1 and if received packet is 1 than ACK Will be 0.

• In SWP ARQ , ACK also use Modulo-2 arithmetic sequence number.

• This is possible only in SWP.

Page 135: Unit 3 datalink layer
Page 136: Unit 3 datalink layer

• Sending device will keep copy of the last frame transmitted until it receives ACK for that frame.

• Seqno = Sequence no.

• ackNo = acknowledgement no

• Sn : Sender next frame to send

• Rn : Receiver , next frame expected.

• When a frame is sent , the value of Sn is incremented , Which means if it is 0 , it becomes 1 and vice versa for Receiver side.

• Sn : points to the slot that matches the sequence number of the frame that has been sent.

• Rn : Points to the slot that matches the sequence number of the expected frame.

Page 137: Unit 3 datalink layer

Algorithm Sender-site algorithm for Stop-and-Wait ARQ

Page 138: Unit 3 datalink layer
Page 139: Unit 3 datalink layer

Algorithm Receiver-site algorithm for Stop-and-Wait ARQ Protocol

Page 140: Unit 3 datalink layer

An example of Stop-and-Wait ARQ. Frame 0 is sent and acknowledged. Frame 1 is lost

and resent after the time-out. The resent frame 1 is acknowledged and the timer stops.

Frame 0 is sent and acknowledged, but the acknowledgment is lost. The sender has no

idea if the frame or the acknowledgment is lost, so after the time-out, it resends frame 0,

which is acknowledged.

Page 141: Unit 3 datalink layer

• Bandwidth delay product : Maximum no of bits can send out of our system.

• Band width delay product = Bandwidth * total delay (Possible Round trip time ).

• 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?

Page 142: Unit 3 datalink layer

• System can sends only 1000 bits.

• Utilization of link = 1000 / 20,000 , or 5 %.

• If 15 frame is sending , calculate utilization of link in percentage

• Observation : If bandwidth is high or delay is more , SWP ARQ wastes the capacity of the link

Solution

The bandwidth-delay product is

Page 143: Unit 3 datalink layer

• Example

• 1.5Mbps link x 45ms RTT = 67.5Kb (8KB)

• 1KB frames implies 1/8th link utilization

• Can we do something else while waiting for an ACK?

• Pipelining : A Task is often begun before the previous task has ended.

• No pipelining in SWP ARQ.

• Why???

Page 144: Unit 3 datalink layer

• Go-Back-N ARQ is a specific instance of the automatic repeatrequest (ARQ) protocol, in which the sending process continues tosend a number of frames specified by a window size even withoutreceiving an acknowledgement (ACK) packet from the receiver.

• Uses the concept of Pipelining.

• Send several frame before receiving ACK. Keeps the copy of all framestill we receive ACK.

Page 145: Unit 3 datalink layer

• If the header of frames allows m bits for the sequence number. Range of sequence number is from 0 to 2m -1 .

• If m = 4, sequence number can be 0 to 15.

• “In GBN , sequence number is of modulo- 2m

,where m is size of sequence number field in bits.”

Page 146: Unit 3 datalink layer

• Sliding window is an abstract concept which defines range of sequence number for sender and receiver.

• The range which is concern for sender is called, send sliding window.

• The range which is concern with receiver is called receiver sliding window

Page 147: Unit 3 datalink layer
Page 148: Unit 3 datalink layer

• Window will divide possible sequence number in four regions.

• 1st : Frames that are already acknowledge.

• 2nd : Frames sent but no ACK.

• 3rd : Frames that can be sent.

• 4th : Sequence number that can not be used until window slides.

• Sf = send window , first outstanding frame

• Sn = send window , next frame to be sent.

• Ssize = sender window size.

• “Sender window size in GBN is 2m -1 with Sf , Sn ,”

• Sender window can slide one or more slots when valid ACK arrives.

Page 149: Unit 3 datalink layer
Page 150: Unit 3 datalink layer

• Receiver window makes sure that correct data frame arrived and that correct ACK is sent.

• Size of Receiver window in GBN is always 1.

• Any frame arrives out of order, will be discarded and needs to resent.

• Rn = Receiver window next frame expected.

• Sequence number , left to the Rn is already received and ACK..

• Sequence number , Right to the Rn can not be received.

• Frame which have sequence number Rn will be accepted , remaining all will be discarded.

• Receiver windows slides only one place when correct frame is received.

Page 151: Unit 3 datalink layer

• Timer : timer for first outstanding frame at sender will expire first , so we send all outstanding frames when timer expires.

• ACK. : if correct frame received , receiver sends ACK. Else if frame is damaged , or out of order, Receiver is silent and discards all sub sequent frames until expected frame receives.

• Silence of receiver , will cause expire of timer at sender , which causes sender to go back and resend all frames.

• Example : if sender sended frame 6 but timer expires for frame 3. than it ill resends 3,4,5,6….That why protocol is called Go-Back-N ARQ

Page 152: Unit 3 datalink layer
Page 153: Unit 3 datalink layer
Page 154: Unit 3 datalink layer
Page 155: Unit 3 datalink layer

11.155

Algorithm Go-Back-N receiver algorithm

Page 156: Unit 3 datalink layer

• GBN , Don’t accept out of order packet.

• GBN is not use full in very noisy links , in a noisy link frame has a higher probability of damage , means resending of multiple frames.

• Resending uses up to bandwidth and slow downs the transmission.

• SR ARQ : Do not send N frames if one frame is damaged , just resend damaged frames.

• More efficient in noisy link , Complex structure at receiver side.

Page 157: Unit 3 datalink layer

PROTOCOL SENDER WINDOW RECEIVER WINDOW

Stop and wait 1 1

Go Back N 2m -1 1

Selective Repeat 2m-1 2m-1

Page 158: Unit 3 datalink layer

• It will be 2m-1

• If m = 4 means , possible no. of sequence is 0 to 15 and sender window size = 8.

Page 159: Unit 3 datalink layer

• Allows as many frames as the size of receiver windows to arrive out of order and be kept until there is a set of in-order frames to be delivered to N/W layer.

• Receiver never deliver out of order packet to N/W layer.

Page 160: Unit 3 datalink layer

Design of Selective Repeat ARQ

Page 161: Unit 3 datalink layer

• In selective repeat ARQ, the size of the sender and receiver windows must

be at most one half of 2m

Page 162: Unit 3 datalink layer

Algorithm 11.9 Sender-site Selective Repeat algorithm

(continued)

Page 163: Unit 3 datalink layer

(continued)

Page 164: Unit 3 datalink layer
Page 165: Unit 3 datalink layer

Algorithm Receiver-site Selective Repeat algorithm

Page 166: Unit 3 datalink layer
Page 167: Unit 3 datalink layer

GATE

Page 168: Unit 3 datalink layer
Page 169: Unit 3 datalink layer
Page 170: Unit 3 datalink layer

• If N is maximum available sequence number

Size of sender window and receiver in GBN and SR ARQ

• If N is maximum sequence number..

Size of sender window and receiver in GBN and SR ARQ

• If k no of bits are there for sequence number..

Size of sender window and receiver in GBN and SR ARQ

Page 171: Unit 3 datalink layer

• High-level data link control is a bit oriented protocol used for communication over point-to-point link and multipoint link.

Page 172: Unit 3 datalink layer

• Configuration and Transfer mode : Provides two transfer mode with different

configuration.

1. Normal Response mode

2. Asynchronous balanced mode

Page 173: Unit 3 datalink layer

• Station configuration is unbalanced

• One primary station and multiple secondary station is there.

• Primary station can send command and secondary station can only

response.

• Used for both Point-to-point and multiple-point links

Page 174: Unit 3 datalink layer

• Configuration is balanced.

• Pont to point link and each station can function as a primary and secondary

Page 175: Unit 3 datalink layer

• Information frame (I-frame) = used to transport Data + Control info

• Supervisory frame (S-Frame) = used to transport only control info

• Unnumbered frame (U-Frame) = Used for managing the link

Page 176: Unit 3 datalink layer