NET 221D : COMPUTER NETWORKS FUNDAMENTALS LECTURE 4: DATA LINK LAYER Behrouz A. Forouzan” Data communications and Networking 1.

Slides:



Advertisements
Similar presentations
11-1 FRAMING The data link layer needs to pack bits into frames, so that each frame is distinguishable from another. Our postal system practices a type.
Advertisements

11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Data Link Control We want to minimize the amount of error correcting and detecting we need to do.
Chapter 11 Data Link Control
Data link control. Data Link Control –Flow Control how much data may sent –Error Control How can error be detected and corrected.
Flow and Error Control. Flow Control Flow control coordinates the amount of data that can be sent before receiving acknowledgement It is one of the most.
11-5 NOISY CHANNELS Although the Stop-and-Wait Protocol gives us an idea of how to add flow control to its predecessor, noiseless channels are nonexistent.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Chapter 11 Data Link Control and Protocols.
The two main functions of the data link layer are data link control and media access control. Data link control deals with the design and procedures for.
11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
NETWORKING CONCEPTS. ERROR DETECTION Error occures when a bit is altered between transmission& reception ie. Binary 1 is transmitted but received is binary.
The Data Link Layer Chapter 3. Position of the data-link layer.
Error Detection and Correction
11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 PART III: DATA LINK LAYER ERROR DETECTION AND CORRECTION 7.1 Chapter 10.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction.
11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Data Link Layer - 1 Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS School of Computing, UNF.
1 Data Link Layer Lecture 20 Imran Ahmed University of Management & Technology.
PART III DATA LINK LAYER. Position of the Data-Link Layer.
British Computer Society
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Data Link Control and Protocols.
ICOM 6115©Manuel Rodriguez-Martinez ICOM 6115 – Computer Networks and the WWW Manuel Rodriguez-Martinez, Ph.D. Lecture 14.
11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Data Link Layer PART III.
Error Detection and Correction
Chapter 11 Data Link Control
11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Eighth Edition by William Stallings Chapter 7 – Data Link Control Protocols Data Link Control Protocols need layer of logic above Physical to manage exchange.
11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Computer Communication & Networks Lecture 9 Datalink Layer: Error Detection Waleed Ejaz
Lecture Focus: Data Communications and Networking  Data Link Layer  Error Control Lecture 19 CSCS 311.
CHAPTER 3: DATA LINK CONTROL Flow control, Error detection – two dimensional parity checks, Internet checksum, CRC, Error control, Transmission efficiency.
10.1 Chapter 10 Error Detection and Correction Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2000 PART III: DATA LINK LAYER ERROR DETECTION AND CORRECTION 7.1 Chapter 10.
Lecture Focus: Data Communications and Networking  Data Link Layer  Data Link Control Lecture 22 CSCS 311.
Chapter 11 Data Link Control.
10.1 Chapter 10 Error Detection and Correction Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Part III: Data Link Layer Error Detection and Correction
Part III. Data Link Layer Chapter 11. Data Link Control COMP 3270 Computer Networks Computing Science Thompson Rivers University.
DATA LINK CONTROL. DATA LINK LAYER RESPONSIBILTIES  FRAMING  ERROR CONTROL  FLOW CONTROL.
11.1 Chapter 11 Data Link Control Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 9: Data Link Control Business Data Communications, 4e.
Data Link Layer.
Net 221D:Computer Networks Fundamentals
Network Models. 2.1 what is the Protocol? A protocol defines the rules that both the sender and receiver and all intermediate devices need to follow,
Data Link Control. The two main functions of the data link layer are data link control and media access control. The first, data link control, deals with.
Powerpoint Templates Data Communication Muhammad Waseem Iqbal Lec # 15.
2.10 Flow and Error Control Before that ...
Data Link Layer Flow Control.
Part III Datalink Layer 10.
Chapter 11 Data Link Control
Net 221D : Computer Networks Fundamentals
Data Link Layer.
Chapter 11 Data Link Control
Chapter 11 Data Link Control
CIS 321 Data Communications & Networking
Instructor Mazhar Hussain
Data Link Layer What does it do?
Chapter 3 Data Link Layer.
Part III Datalink Layer 10.
Data Link Layer: Data Link Control
Net 221D : Computer Networks Fundamentals
Net 221D : Computer Networks Fundamentals
Chapter 11 Data Link Control
Error Detection and Correction
Data Link Layer. Position of the data-link layer.
Presentation transcript:

NET 221D : COMPUTER NETWORKS FUNDAMENTALS LECTURE 4: DATA LINK LAYER Behrouz A. Forouzan” Data communications and Networking 1

Functions of the Data Link Layer The data link layer uses the services of the physical layer to send and receive bits over communication channels. It has a number of functions, including: 1. Addressing ( MAC / physical address) 2. Framing 3. Flow control (Regulating the flow of data so that slow receivers are not swamped ) 4. Error control (Dealing with transmission errors ) 5. Media access control. 2 Computer networks / Andrew S. Tanenbaum-- 5th ed

Cont. 3 To accomplish these goals, the data link layer takes the packets it gets from the network layer and encapsulates them into frames for transmission. Each frame contains a frame header, a payload field for holding the packet, and a frame trailer Frame Header contains the physical address of the next receiving node Computer networks / Andrew S. Tanenbaum-- 5th ed

A ) Framing Behrouz A. Forouzan” Data communications and Networking 4  The data link layer needs to pack bits into frames, so that each frame is distinguishable from another. Example :  Our postal system practices a type of framing.  The simple act of inserting a letter into an envelope separates one piece of information from another; the envelope serves as the delimiter.

Cont. 5 A good design ( for Breaking up the bit stream into frames ) must make it easy for a receiver to find the start of new frames while using little of the channel bandwidth.  We will look at three methods:  Byte count.  Flag bytes with byte stuffing.  Flag bits with bit stuffing. Computer networks / Andrew S. Tanenbaum-- 5th ed

1. Byte count A character stream. (a) Without errors. (b) With one error. The first framing method uses a field in the header to specify the number of bytes in the frame. 6 Computer networks / Andrew S. Tanenbaum-- 5th ed

2. Flag bytes with byte stuffing  A flag byte, 8-bit flag, is inserted as both the starting and ending delimiter.  Two consecutive flag bytes indicate the end of one frame and the start of the next. 7 Computer networks / Andrew S. Tanenbaum-- 5th ed

Byte Stuffing 8  However, there is a still a problem we have to solve.  It may happen that the flag byte occurs in the data, especially when binary data such as photographs or songs are being transmitted.  One way to solve this problem is to have the sender’s data link layer insert a special escape byte (ESC) just before each ‘‘accidental’’ flag byte in the data.  The data link layer on the receiving end removes the escape bytes before giving the data to the network layer.  This technique is called byte stuffing. Computer networks / Andrew S. Tanenbaum-- 5th ed

3. Flag bits with bit stuffing.  Framing can be also be done at the bit level, so frames can contain an arbitrary number of bits made up of units of any size.  Each frame begins and ends with a special bit pattern, or 0x7E in hexadecimal.  Whenever the sender’s data link layer encounters five consecutive 1s in the data, it automatically stuffs a 0 bit into the outgoing bit stream (bit stuffing)  When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically de-stuffs (i.e., deletes) the 0 bit. 9 Computer networks / Andrew S. Tanenbaum-- 5th ed

B) Error control 10  How to make sure all frames are eventually delivered to the network layer at the destination and in the proper order.  Assume for the moment that the receiver can tell whether a frame that it receives contains correct or faulty information (using error detection and correction techniques)  The 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.  Typically, the protocol calls for the receiver to send back special control frames bearing positive or negative acknowledgements about the incoming frames. Computer networks / Andrew S. Tanenbaum-- 5th ed

Cont. 11  If the sender receives a positive acknowledgement about a frame, it knows the frame has arrived safely.  On the other hand, a negative acknowledgement means that something has gone wrong and the frame must be retransmitted again. Computer networks / Andrew S. Tanenbaum-- 5th ed

Error detection and correction Behrouz A. Forouzan” Data communications and Networking 12

10.13 Redundancy redundancy The central concept in detecting or correcting errors is redundancy. To be able to detect or correct errors, we need to send some extra bits with our data. These redundant bits are added by the sender and removed by the receiver. Their presence allows the receiver to detect or correct corrupted bits.

1. Parity Check Behrouz A. Forouzan” Data communications and Networking 14  The most common and least expensive.  It can be Simple or Two Dimensional. How does it work? A k-bit dataword is changed to an n-bit codeword where n = k + 1. The extra bit, called the parity bit, is selected to make the total number of 1s in the codeword even Note : there is either even parity or odd parity. Example: Assume the sender sends the dataword Since the number of 1's is odd then the parity bit is equal to 1 and the codeword for this dataword is

Behrouz A. Forouzan” Data communications and Networking 15  Simple parity check can detect all single-bit errors. It can detect burst errors only if the total number of errors in each data unit is odd.  A better approach is the two-dimensional parity check which organizes the data units into table (rows and columns). The parity bit for each column is Calculated and added to the table as a new row (column parity)

Two-dimensional parity check Behrouz A. Forouzan” Data communications and Networking 16

2. Cyclic Redundancy Check Behrouz A. Forouzan” Data communications and Networking 17  In a cyclic code, if a codeword is cyclically shifted (rotated), the result is another codeword.  Example: if is a codeword and we cyclically left- shift, then is also a codeword.

10.18 Figure 10.14: CRC encoder and decoder Behrouz A. Forouzan” Data communications and Networking 18

Table 10.6 : A CRC code with C(7, 4) Behrouz A. Forouzan” Data communications and Networking

The Process of CRC At the Sender: 1. The encoder, the dataword has k bits (4 here).The codeword has n bits ( 7). 2. The size of the dataword is augmented by adding n-k (3 here) 0s to the right-hand size of the word. 3. The generator uses a divisor of size n-k+1 (4 here), predefined and agreed upon. 4. The generator divides the augmented dataword by the divisor ( modulo-2 division). 5. The reminder is appended to the dataword to create the codeword. Behrouz A. Forouzan” Data communications and Networking

The Process of CRC At the Receiver: 1. The decoder does the same division process as the encoder. 2. The reminder of the division is the syndrome. If the syndrome is all 0s, there is no error, the dataword separated from the received codeword and accepted. Otherwise, everything is discarded. Behrouz A. Forouzan” Data communications and Networking

Figure 10.15: Division in CRC encoder Behrouz A. Forouzan” Data communications and Networking

Figure 10.16: Division in the CRC decoder for two cases Behrouz A. Forouzan” Data communications and Networking

3. CHECKSUM Behrouz A. Forouzan” Data communications and Networking 24  Checksum is an error-detecting technique that can be applied to a message of any length.  Like CRC, checksum based on the concept of redundancy.

Example 25 Suppose the message 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, A sender wants to send the set of numbers (7, 11, 12, 0, 6) the process will be as follow:  Sum up the numbers = = 36  Then convert the decimal number 36 in binary = (100100)2.  To change it to a 4-bit number ( as the sending numbers) we add the extra leftmost bit to the right four bits as shown below. This is called sum in one’s complement.

Example Cont. Behrouz A. Forouzan” Data communications and Networking 26  Then complements the result to get the checksum.  6= ( 0110) 2, the complement of 6 = = 9 Or (1001) 2 = 9 = (1001 )2  The sender sends the five data numbers and the checksum (7, 11, 12, 0, 6, 9).  If there is no corruption in transmission, the receiver receives (7, 11, 12, 0, 6, 9) and adds them in one’s complement to get 15.

Figure 10.16: Example _________ _________

C) Flow Control Behrouz A. Forouzan” Data communications and Networking 28  Another important design issue that occurs in the data link layer (and higher layers as well) is what to do with a 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 and the receiver is running on a slow, low-end machine.

Cont. 29  Two approaches are commonly used.  In the first one, 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.  In the second one, 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.  In this chapter we will study feedback-based flow control schemes, primarily because rate-based schemes are only seen as part of the transport layer

Flow control schemes Behrouz A. Forouzan” Data communications and Networking 30

NOISELESS CHANNELS Behrouz A. Forouzan” Data communications and Networking 31  Let us first assume we have an ideal channel in which no frames are lost, duplicated, or corrupted.  We introduce two protocols for this type of channel.  Simplest Protocol  Stop-and-Wait Protocol

Figure 11.6 The design of the simplest protocol with no flow or error control Behrouz A. Forouzan” Data communications and Networking

11.33 Algorithm 11.1 Sender-site algorithm for the simplest protocol Behrouz A. Forouzan” Data communications and Networking Algorithm 11.2 Receiver-site algorithm for the simplest protocol

Figure 11.7 Flow diagram for Example 11.1 Behrouz A. Forouzan” Data communications and Networking

Stop-and-Wait Protocol Figure 11.8 Design of Stop-and-Wait Protocol Sender sends one frame, until it receives confirmation from the receiver and then sends next frame

Figure 11.9 Flow diagram Behrouz A. Forouzan” Data communications and Networking

NOISY CHANNELS Behrouz A. Forouzan” Data communications and Networking 37  Although the Stop-and-Wait Protocol gives us an idea of how to add flow control to its predecessor, noiseless channels are nonexistent.  We discuss three protocols in this section that use error control.  Stop-and-Wait Automatic Repeat Request(ARQ)  Go-Back-N ARQ  Selective Repeat ARQ ) - any time an error is detected in an exchange, specified frames are retransmitted Automatic Repeat Request (ARQ ) - any time an error is detected in an exchange, specified frames are retransmitted

1. Stop-and-Wait ARQ Behrouz A. Forouzan” Data communications and Networking 38  Error correction in Stop-and-Wait ARQ is done by keeping a copy of the sent frame and retransmitting of the frame when the timer expires.  We use sequence numbers to number the frames.  The sequence numbers are based on modulo-2 arithmetic.  The acknowledgment number always announces in modulo-2 arithmetic the sequence number of the next frame expected.

Figure Design of the Stop-and-Wait ARQ Protocol Behrouz A. Forouzan” Data communications and Networking

Figure shows 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. Example 11.3 Behrouz A. Forouzan” Data communications and Networking

Figure Flow diagram for Example 11.3 Behrouz A. Forouzan” Data communications and Networking

2. Go-Back-N ARQ Behrouz A. Forouzan” Data communications and Networking 42  In the Go-Back-N Protocol, the sequence numbers are modulo 2 m, where m is the size of the sequence number field in bits.  Sliding window defines the range of sequence numbers that is the concern of the sender and receiver - sender and receiver deals with only a part of the range of sequence numbers  The send window is an abstract concept defining an imaginary box of size 2 m − 1 with three variables: Sf, Sn, and S size.  The send window can slide one or more slots when a valid acknowledgment arrives.

Cont. Behrouz A. Forouzan” Data communications and Networking 43  The receive window is an abstract concept defining an imaginary box of size 1 with one single variable R n.  The window slides when a correct frame has arrived; sliding occurs one slot at a time. ● ACKs are cumulative - more than one frame can be acknowledged by a single ACK

Figure Send window for Go-Back-N ARQ Behrouz A. Forouzan” Data communications and Networking

Figure Receive window for Go-Back-N ARQ Behrouz A. Forouzan” Data communications and Networking

Figure Design of Go-Back-N ARQ Behrouz A. Forouzan” Data communications and Networking

Figure Window size for Go-Back-N ARQ Behrouz A. Forouzan” Data communications and Networking

In Go-Back-N ARQ, the size of the send window must be less than 2 m ; the size of the receiver window is always 1. Note Behrouz A. Forouzan” Data communications and Networking

Figure shows what happens when a frame is lost. Frames 0, 1, 2, and 3 are sent. However, frame 1 is lost. The receiver receives frames 2 and 3, but they are discarded because they are received out of order. The sender receives no acknowledgment about frames 1, 2, or 3. Its timer finally expires. The sender sends all outstanding frames (1, 2, and 3) because it does not know what is wrong. This means that when ACK 2 arrives, the sender is still busy with sending frame 3. Example 11.7 Behrouz A. Forouzan” Data communications and Networking

Figure Flow diagram for Example 11.7 Behrouz A. Forouzan” Data communications and Networking

3. Selective Repeat ARQ 51  Go-Back-N ARQ simplifies the process at the receiver site.  The receiver keeps track of only one variable, and there is no need to buffer out-of-order frames; they are simply discarded.  However, this protocol is very inefficient for a noisy link. In a noisy link a frame has a higher probability of damage, which means the resending of multiple frames.  This resending uses up the bandwidth and slows down the transmission. For noisy links, there is another mechanism that does not resend N frames when just one frame is damaged; only the damaged frame is resent.  This mechanism is called Selective RepeatARQ. Computer networks / Andrew S. Tanenbaum-- 5th ed

Figure Send window for Selective Repeat ARQ Figure Receive window for Selective Repeat ARQ

Figure Design of Selective Repeat ARQ Behrouz A. Forouzan” Data communications and Networking

This example is similar to Example 11.3 in which frame 1 is lost. We show how Selective Repeat behaves in this case. Figure shows the situation. One main difference is the number of timers. Here, each frame sent or resent needs a timer, which means that the timers need to be numbered (0, 1, 2, and 3). The timer for frame 0 starts at the first request, but stops when the ACK for this frame arrives. The timer for frame 1 starts at the second request, restarts when a NAK arrives, and finally stops when the last ACK arrives. The other two timers start when the corresponding frames are sent and stop at the last arrival event. A NAK is sent once for each window position and defines the first slot in the window. In Selective Repeat, ACKs are sent when data are delivered to the network layer. If the data belonging to n frames are delivered in one shot, only one ACK is sent for all of them. Example 11.8 Behrouz A. Forouzan” Data communications and Networking

Figure Flow diagram for Example 11.8 Behrouz A. Forouzan” Data communications and Networking

56