Data and Computer Communications. The Data Link Layer.

42
Data and Computer Data and Computer Communications Communications

Transcript of Data and Computer Communications. The Data Link Layer.

Page 1: Data and Computer Communications. The Data Link Layer.

Data and Computer Data and Computer CommunicationsCommunications

Page 2: Data and Computer Communications. The Data Link Layer.

The Data Link LayerThe Data Link Layer

Page 3: Data and Computer Communications. The Data Link Layer.

Data Link Layer Design IssuesData Link Layer Design Issues

• Network layer servicesNetwork layer services• FramingFraming• Error controlError control• Flow controlFlow control

Page 4: Data and Computer Communications. The Data Link Layer.

Data Link LayerData Link Layer

Algorithms for achieving:Algorithms for achieving: Reliable, +Reliable, + Efficient, Efficient,

communication of a whole units – frames (as opposed to bits – communication of a whole units – frames (as opposed to bits – Physical Layer) between two machines.Physical Layer) between two machines.

Two machines are connected by a communication channel that acts Two machines are connected by a communication channel that acts conceptually like a wire (e.g., telephone line, coaxial cable, or conceptually like a wire (e.g., telephone line, coaxial cable, or wireless channel).wireless channel).

Essential property of a channel that makes it Essential property of a channel that makes it ““wire-likewire-like”” connection connection is that the bits are delivered in exactly the same order in which they is that the bits are delivered in exactly the same order in which they are sent.are sent.

Page 5: Data and Computer Communications. The Data Link Layer.

Data Link LayerData Link Layer

For ideal channel (no distortion, unlimited bandwidth and no delay) For ideal channel (no distortion, unlimited bandwidth and no delay) the job of data link layer would be trivial.the job of data link layer would be trivial.

However, limited bandwidth, distortions and delay makes this job However, limited bandwidth, distortions and delay makes this job very difficult. very difficult.

Page 6: Data and Computer Communications. The Data Link Layer.

Data Link Layer Design Data Link Layer Design IssuesIssues

Physical layer delivers bits of information to and from data link layer. Physical layer delivers bits of information to and from data link layer. The functions of Data Link Layer are:The functions of Data Link Layer are:

1.1. Providing a well-defined service interface to the network layer.Providing a well-defined service interface to the network layer.

2.2. Dealing with transmission errors.Dealing with transmission errors.

3.3. Regulating the flow of data so that slow receivers are not Regulating the flow of data so that slow receivers are not swamped by fast senders.swamped by fast senders.

Data Link layer Data Link layer Takes the packets from Physical layer, and Takes the packets from Physical layer, and Encapsulates them into Encapsulates them into framesframes

Page 7: Data and Computer Communications. The Data Link Layer.

Data Link Layer Design Data Link Layer Design IssuesIssues

Each frame has a Each frame has a frame header – a field for holding the packet, andframe header – a field for holding the packet, and frame trailer.frame trailer.

Frame Management is what Data Link Layer does.Frame Management is what Data Link Layer does.

See figure in the next slide:See figure in the next slide:

Page 8: Data and Computer Communications. The Data Link Layer.

Packets and FramesPackets and Frames

Relationship between packets and frames.Relationship between packets and frames.

Page 9: Data and Computer Communications. The Data Link Layer.

Services Provided to the Services Provided to the Network LayerNetwork Layer

Principal Service Function of the data link layer is to transfer the Principal Service Function of the data link layer is to transfer the data from the network layer on the source machine to the network data from the network layer on the source machine to the network layer on the destination machine.layer on the destination machine.

Process in the network layer that hands some bits to the data link Process in the network layer that hands some bits to the data link layer for transmission.layer for transmission.

Job of data link layer is to transmit the bits to the destination machine Job of data link layer is to transmit the bits to the destination machine so they can be handed over to the network layer there (see figure in so they can be handed over to the network layer there (see figure in the next slide).the next slide).

Page 10: Data and Computer Communications. The Data Link Layer.

Network Layer ServicesNetwork Layer Services

(a) (a) Virtual communication. Virtual communication. (b) (b) Actual Actual communication.communication.

Page 11: Data and Computer Communications. The Data Link Layer.

Possible Services OfferedPossible Services Offered

1.1. Unacknowledged connectionless service.Unacknowledged connectionless service.

2.2. Acknowledged connectionless service.Acknowledged connectionless service.

3.3. Acknowledged connection-oriented service.Acknowledged connection-oriented service.

Page 12: Data and Computer Communications. The Data Link Layer.

Unacknowledged Unacknowledged Connectionless ServiceConnectionless Service

It consists of having the source machine send independent frames It consists of having the source machine send independent frames to the destination machine without having the destination machine to the destination machine without having the destination machine acknowledge them.acknowledge them.

Example: Ethernet, Voice over IP, etc. in all the communication Example: Ethernet, Voice over IP, etc. in all the communication channel were real time operation is more important that quality of channel were real time operation is more important that quality of transmission. transmission.

Page 13: Data and Computer Communications. The Data Link Layer.

Acknowledged Acknowledged Connectionless ServiceConnectionless Service

Each frame send by the Data Link layer is acknowledged and the Each frame send by the Data Link layer is acknowledged and the sender knows if a specific frame has been received or lost.sender knows if a specific frame has been received or lost.

Typically the protocol uses a specific time period that if has passed Typically the protocol uses a specific time period that if has passed without getting acknowledgment it will re-send the frame.without getting acknowledgment it will re-send the frame.

This service is useful for commutation when an unreliable channel is This service is useful for commutation when an unreliable channel is being utilized (e.g., 802.11 WiFi).being utilized (e.g., 802.11 WiFi).

Network layer does not know frame size of the packets and other Network layer does not know frame size of the packets and other restriction of the data link layer. Hence it becomes necessary for restriction of the data link layer. Hence it becomes necessary for data link layer to have some mechanism to optimize the data link layer to have some mechanism to optimize the transmission. transmission.

Page 14: Data and Computer Communications. The Data Link Layer.

Acknowledged Connection Acknowledged Connection Oriented ServiceOriented Service

Source and Destination establish a connection first.Source and Destination establish a connection first. Each frame sent is numberedEach frame sent is numbered

Data link layer guarantees that each frame sent is indeed received.Data link layer guarantees that each frame sent is indeed received. It guarantees that each frame is received only once and that all frames It guarantees that each frame is received only once and that all frames

are received in the correct order.are received in the correct order. Examples: Examples:

Satellite channel communication,Satellite channel communication, Long-distance telephone communication, etc.Long-distance telephone communication, etc.

Page 15: Data and Computer Communications. The Data Link Layer.

Acknowledged Connection Acknowledged Connection Oriented ServiceOriented Service

Three distinct phases:Three distinct phases:

1.1. Connection is established by having both side initialize variables and Connection is established by having both side initialize variables and counters needed to keep track of which frames have been received counters needed to keep track of which frames have been received and which ones have not.and which ones have not.

2.2. One or more frames are transmitted.One or more frames are transmitted.3.3. Finally, the connection is released – freeing up the variables, buffers, Finally, the connection is released – freeing up the variables, buffers,

and other resources used to maintain the connection. and other resources used to maintain the connection.

Page 16: Data and Computer Communications. The Data Link Layer.

ServicesServices

Page 17: Data and Computer Communications. The Data Link Layer.

Asynchronous and Asynchronous and Synchronous TransmissionSynchronous Transmission

timing problems require a mechanism to timing problems require a mechanism to synchronizesynchronize the transmitter and receiver the transmitter and receiver receiver samples stream at bit intervalsreceiver samples stream at bit intervals if clocks not aligned, drifting will sample at if clocks not aligned, drifting will sample at

wrong time after sufficient bits are sentwrong time after sufficient bits are sent two techniques to synchronizetwo techniques to synchronize

asynchronous transmissionasynchronous transmission synchronous transmissionsynchronous transmission

Page 18: Data and Computer Communications. The Data Link Layer.

Asynchronous TransmissionAsynchronous Transmission

Page 19: Data and Computer Communications. The Data Link Layer.

Asynchronous - BehaviorAsynchronous - Behavior

simplesimple cheapcheap overheadoverhead of 2 or 3 bits per char (~20%) of 2 or 3 bits per char (~20%) Stop element 1.5 time unit Stop element 1.5 time unit good for data with large gaps (keyboard)good for data with large gaps (keyboard) 6% error. 6% error. Framing error – in picture the last (8Framing error – in picture the last (8thth) bit ) bit

can be mistaken as a start bitcan be mistaken as a start bit

Page 20: Data and Computer Communications. The Data Link Layer.

Synchronous TransmissionSynchronous Transmission block of data block of data transmitted, sent as a frametransmitted, sent as a frame clocks must be synchronizedclocks must be synchronized

can use separate clock linecan use separate clock line or embed clock signal in dataor embed clock signal in data

need to indicate start and end of blockneed to indicate start and end of block use preamble and post-ambleuse preamble and post-amble

more efficient (more efficient (lower overheadlower overhead) than ) than asynchronousasynchronous

Page 21: Data and Computer Communications. The Data Link Layer.

Types of ErrorTypes of Error

an error occurs when a bit is altered between an error occurs when a bit is altered between transmission and receptiontransmission and reception

single bit single bit errorserrors only one bit alteredonly one bit altered caused by caused by whitewhite noise noise

burst burst errorserrors contiguous contiguous sequence of sequence of BB bits in which first, last and bits in which first, last and

any number of intermediate bits are in errorany number of intermediate bits are in error caused by caused by impulseimpulse noise or by fading in wireless noise or by fading in wireless effect is greater at higher data rateseffect is greater at higher data rates

Page 22: Data and Computer Communications. The Data Link Layer.

Error DetectionError Detection will have errorswill have errors detect using detect using error-detectingerror-detecting code code added by transmitteradded by transmitter recalculated and checked by receiverrecalculated and checked by receiver still chance of undetected errorstill chance of undetected error parityparity

parity bit set so frame has even number of ones parity bit set so frame has even number of ones ((even parityeven parity) or odd number of ones () or odd number of ones (odd parityodd parity))

even number of bit errors goes undetectedeven number of bit errors goes undetected

Page 23: Data and Computer Communications. The Data Link Layer.

Error Detection ProcessError Detection Process

Page 24: Data and Computer Communications. The Data Link Layer.

Error DetectionError Detection

PPbb= Probability a = Probability a bitbit is received in error, Bit is received in error, Bit

Error Rate (Error Rate (BERBER)) PP11= Probability a = Probability a frameframe is received with no is received with no

error error PP22= Probability a frame is received with = Probability a frame is received with

undetected errorundetected error F = number of bits / frameF = number of bits / frame Then, PThen, P11= (1- P= (1- Pbb))FF , P , P22= (1- P= (1- P11))

Page 25: Data and Computer Communications. The Data Link Layer.

Error DetectionError Detection

## ISDN has 64 Kbps channel, 1 frame with ISDN has 64 Kbps channel, 1 frame with undetected error per day is expected, (1 undetected error per day is expected, (1 frame = 1000 bits), Calculate the number frame = 1000 bits), Calculate the number of Frames / day and Pof Frames / day and P22..

If actual PIf actual Pbb= 10= 10-6-6, can we achieve the , can we achieve the

above Pabove P22??

Page 26: Data and Computer Communications. The Data Link Layer.

Cyclic Redundancy CheckCyclic Redundancy Check

one of most common and powerful checksone of most common and powerful checks for block of for block of kk bits, transmitter generates an bits, transmitter generates an

n-kn-k bit frame check sequence ( bit frame check sequence (FCSFCS)) Transmits Transmits nn bits which is exactly divisible bits which is exactly divisible

by some numberby some number receiver divides frame by that numberreceiver divides frame by that number

if no remainder, assume no errorif no remainder, assume no error for math, see Stallings chapter 6for math, see Stallings chapter 6

Page 27: Data and Computer Communications. The Data Link Layer.

Cyclic Redundancy CheckCyclic Redundancy Check

Basis: Modulo-2 arithmetic (Basis: Modulo-2 arithmetic (X-orX-or for + or -) for + or -) MessageMessage, M = 1010001101, M = 1010001101 PatternPattern, P = 110101 (MSB & LSB = , P = 110101 (MSB & LSB = ‘‘11’’)) FCSFCS = ? (5 bits) (01110) = ? (5 bits) (01110) MultiplyMultiply the Message by 2 the Message by 255, then , then dividedivide by by

the Pattern. Remainder is the Pattern. Remainder is addedadded with the with the Message and transmitted.Message and transmitted.

P is one bit longer than FCS.P is one bit longer than FCS.

Page 28: Data and Computer Communications. The Data Link Layer.

Cyclic Redundancy CheckCyclic Redundancy Check

Selection of polynomial P:Selection of polynomial P:

- Should not be divisible by X- Should not be divisible by X

- Should be divisible by X+1- Should be divisible by X+1

Benefits:Benefits:- Detects all burst errors that affect Detects all burst errors that affect odd odd

numbernumber of bits of bits- Detects all burst errors of Detects all burst errors of lengthlength less than less than

or equal to degree of the polynomial (FCS)or equal to degree of the polynomial (FCS)

Page 29: Data and Computer Communications. The Data Link Layer.

Cyclic Redundancy CheckCyclic Redundancy Check- Detects, with Detects, with highhigh probability, all burst probability, all burst

errors of errors of lengthlength greater than the degree of greater than the degree of the polynomialthe polynomial

Page 30: Data and Computer Communications. The Data Link Layer.

Cyclic Redundancy CheckCyclic Redundancy Check## CRC-12 (X CRC-12 (X1212+ X+ X1111+X+X33+X+1)+X+1)

Degree:Degree: 12 12

Detects all burst errors that affects Detects all burst errors that affects odd odd

numbernumber of bits, Detects all burst errors of of bits, Detects all burst errors of

lengthlength less than or equal to 12, Detects less than or equal to 12, Detects

(99.97 percent of) all burst errors of (99.97 percent of) all burst errors of lengthlength

more than or equal to 12.more than or equal to 12.

Page 31: Data and Computer Communications. The Data Link Layer.

Error CorrectionError Correction

correctioncorrection of detected errors of detected errors usually requires usually requires correctcorrect data block to be data block to be retransmittedretransmitted

not appropriate for wireless applicationsnot appropriate for wireless applications bit error rate is high causing lots of retransmissionsbit error rate is high causing lots of retransmissions when propagation delay long (satellite) compared with when propagation delay long (satellite) compared with

frame transmission time, resulting in retransmission of frame transmission time, resulting in retransmission of frame in error plus many subsequent framesframe in error plus many subsequent frames

instead instead need to correct need to correct errors on basis of bits errors on basis of bits receivedreceived

error correction provides thiserror correction provides this

Page 32: Data and Computer Communications. The Data Link Layer.

Error Correction ProcessError Correction Process

Page 33: Data and Computer Communications. The Data Link Layer.

Error CorrectionError Correction 2-dimensional Parity:2-dimensional Parity: ““Data is arranged in 2-dimensional array and Data is arranged in 2-dimensional array and

parity bit is added for each row and columnparity bit is added for each row and column”” PPVV

0 1 1 0 0 1 1 0 00 ““Detects and Detects and CorrectsCorrects all single all single 1 0 1 0 1 0 1 0 0 0 bit errorsbit errors””

1 1 1 0 1 1 1 0 11 ““Detects all odd number of Detects all odd number of 0 1 1 1 0 1 1 1 1 1 bit errors and some even bit errors and some even 0 1 0 1 0 1 0 P 0 1 0 PH H

number of bit errorsnumber of bit errors””

Page 34: Data and Computer Communications. The Data Link Layer.

How Error Correction WorksHow Error Correction Works

adds adds redundancyredundancy to transmitted message to transmitted message can deduce original despite some errorscan deduce original despite some errors e.g. block error correction codee.g. block error correction code

map map k k bit input onto an bit input onto an n n bit codewordbit codeword each each distinctly differentdistinctly different if get error, assume codeword sent was if get error, assume codeword sent was

closestclosest to that received to that received for math, see Stallings chapter 6for math, see Stallings chapter 6 Much reduced effective data rateMuch reduced effective data rate

Page 35: Data and Computer Communications. The Data Link Layer.

Block Code PrinciplesBlock Code Principles Hamming distance = difference in Hamming distance = difference in # of bits# of bits,, p = 011011, q = 110001, d (p,q) = ?p = 011011, q = 110001, d (p,q) = ? DataData CodeCode 0000 0000000000 0101 0011100111 1010 1100111001 1111 1111011110 # # Find the distance between all the valid codes (in Find the distance between all the valid codes (in

pairs) on this slide. pairs) on this slide.

Page 36: Data and Computer Communications. The Data Link Layer.

Block Code PrinciplesBlock Code Principles Received 00100, valid? Can it be corrected?Received 00100, valid? Can it be corrected? Find distances and the minimum.Find distances and the minimum. ‘‘Select the valid code at the Select the valid code at the minimumminimum

distancedistance’’ Received 00100, correct word?Received 00100, correct word? More than one More than one minimum distance!!!minimum distance!!! 01010 (Invalid) => valid 00000 and 1111001010 (Invalid) => valid 00000 and 11110 ‘‘Equidistance of 2Equidistance of 2’’ => => can detect, not correctcan detect, not correct

Page 37: Data and Computer Communications. The Data Link Layer.

Hamming ECCHamming ECC

‘‘use of use of extra parity bits extra parity bits to allow the to allow the positionposition identification of a single error identification of a single error’’

1. Mark all bit positions that are 1. Mark all bit positions that are powers of powers of 22 as parity bits. (positions 1, 2, 4, 8, 16, as parity bits. (positions 1, 2, 4, 8, 16, etc.) etc.)

2. All 2. All other bit positions other bit positions are for the data to are for the data to be encoded. (positions 3, 5, 6, 7, 9, 10, 11, be encoded. (positions 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, etc.) 12, 13, 14, 15, etc.)

Page 38: Data and Computer Communications. The Data Link Layer.

Hamming ECCHamming ECC 3. Each parity bit calculates the parity for some of 3. Each parity bit calculates the parity for some of

the bits in the code word. The the bits in the code word. The position of the parity position of the parity bit determines the sequence of bits that it checks.bit determines the sequence of bits that it checks.

Position 1Position 1: checks bits (1,3,5,7,9,11,...) – : checks bits (1,3,5,7,9,11,...) – Alternate Alternate Position 2Position 2: checks bits (2,3,6,7,10,11,14,15,...) – : checks bits (2,3,6,7,10,11,14,15,...) – Alternate 2-bitsAlternate 2-bits

Position 4Position 4: checks bits : checks bits (4,5,6,7,12,13,14,15,20,21,22,23,...)(4,5,6,7,12,13,14,15,20,21,22,23,...) -Alternate 4- -Alternate 4-bitsbits

Page 39: Data and Computer Communications. The Data Link Layer.

Hamming ECCHamming ECC Position 8: checks bits (8-15,24-31,40-Position 8: checks bits (8-15,24-31,40-

47,...) – 47,...) – Alternate 8-bits Alternate 8-bits 4. Set the parity bit to create 4. Set the parity bit to create even parityeven parity..

A byte of data: 10011010A byte of data: 10011010 Place the data word, leaving spaces for Place the data word, leaving spaces for

the parity bits: _ _ 1 _ 0 0 1 _ 1 0 1 0the parity bits: _ _ 1 _ 0 0 1 _ 1 0 1 0Calculate the parity bits. Calculate the parity bits.

Page 40: Data and Computer Communications. The Data Link Layer.

Hamming ECCHamming ECC Position 1 checks bits 1,3,5,7,9,11: Position 1 checks bits 1,3,5,7,9,11: ?? _ _ 11 _ _ 00 0 0 11 _ _ 11 0 0 11 0. set position 1 to a 0. set position 1 to a 00: : 00 _ _ 11 _ _ 00 0 0 11 _ _ 11 0 0 11 0 0

Position 2 checks bits 2,3,6,7,10,11:Position 2 checks bits 2,3,6,7,10,11:0 0 ?? 1 1 _ 0 _ 0 0 10 1 _ 1 _ 1 0 10 1 0. set position 2 to a 0. set position 2 to a 11: : 0 0 1 11 1 _ 0 _ 0 0 10 1 _ 1 _ 1 0 10 1 0 0

Position 4 checks bits 4,5,6,7,12:Position 4 checks bits 4,5,6,7,12:0 1 1 0 1 1 ?? 0 0 1 0 0 1 _ 1 0 1 _ 1 0 1 00. set position 4 to a . set position 4 to a 11: : 0 1 1 0 1 1 1 0 0 1 1 0 0 1 _ 1 0 1 _ 1 0 1 00

Page 41: Data and Computer Communications. The Data Link Layer.

Hamming ECCHamming ECC Position 8 checks bits 8,9,10,11,12:Position 8 checks bits 8,9,10,11,12:

0 1 1 1 0 0 1 0 1 1 1 0 0 1 ?? 1 0 1 0 1 0 1 0. set position 8 to a . set position 8 to a 00: 0 1 1 1 0 0 1 : 0 1 1 1 0 0 1 0 1 0 1 00 1 0 1 0

FinalFinal code word: 011100101010. code word: 011100101010. Finding and fixing a corrupted bit:Finding and fixing a corrupted bit: Suppose that the word was received as Suppose that the word was received as

011100101110 instead. 011100101110 instead. The method is to verify each check bit.The method is to verify each check bit.

Page 42: Data and Computer Communications. The Data Link Layer.

Hamming ECCHamming ECC Parity bits 2 and 8 are incorrect. It is 2 + 8 = 10, Parity bits 2 and 8 are incorrect. It is 2 + 8 = 10,

that bit position 10 is the location of the bad bit that bit position 10 is the location of the bad bit and needs to be inverted.and needs to be inverted.

# # Test if these Hamming-code words are correct. Test if these Hamming-code words are correct. If one is incorrect, indicate the correct If one is incorrect, indicate the correct code wordcode word. . Also, indicate what the original Also, indicate what the original data data was. was.

010101100011 010101100011 111110001100 111110001100 000010001010 000010001010