Presentation is loading. Please wait.

Presentation is loading. Please wait.

Net 221D : Computer Networks Fundamentals

Similar presentations


Presentation on theme: "Net 221D : Computer Networks Fundamentals"— Presentation transcript:

1 Net 221D : Computer Networks Fundamentals
Lecture 4: Data Link Layer Net 221D : Computer Networks Fundamentals Behrouz A. Forouzan” Data communications and Networking

2 Functions of the Data Link Layer
Data link layer is divided into: data link control (DLC) sublayer: deals with the design and procedures for communication between two adjacent nodes; node-to-node communication. DLC functions include: Addressing ( MAC / physical/ link address) Framing Flow control (Regulating the flow of data so that slow receivers are not swamped ) Error control (Dealing with transmission errors ) media access control (MAC) sublayers: coordinate access to the link when multiple noes are connected and shared a common link. This is called medium access control. Computer networks / Andrew S. Tanenbaum-- 5th ed

3 DLC and MAC sublayers Computer networks / Andrew S. Tanenbaum-- 5th ed

4 1. addressing Three types of addresses:
Unicast MAC Address: each host or each interface of a router is assigned a unicast address. It allows each single transmitting device to send a packet to another single destination device. Unicasting means one-to-one communication. In the structure of Multicast MAC address the second digit should be even. Example: A2:34:45:11:92:F1. Multicast MAC Address: it allows a source device to send a packet to a group of devices. Multicast means one-to-many communication. In the structure of Multicast MAC address the second digit should be odd. Example: A3:34:45:11:92:F1. Broadcast MAC Address: A frame with a destination broadcast address is sent to all entities in the link. Broadcasting means one-to all communication. Example: FF:FF:FF:FF:FF:FF. Computer networks / Andrew S. Tanenbaum-- 5th ed

5 2. Framing 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. Delimiter: محدد Framing in the data link layer separates a message from one source to a destination, or from other messages to other destinations, by adding a sender address and a destination address. Although the whole message could be packed in one frame, that is not normally done. One reason is that a frame can be very large, making flow and error control very inefficient. When a message is carried in one very large frame, even a single-bit error would require the retransmission of the whole message. When a message is divided into smaller frames, a single-bit error affects only that small frame. Behrouz A. Forouzan” Data communications and Networking

6 2. Framing 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. Two approaches are used for Framing: 1. Character-oriented approach 2. Bit-oriented approach

7 Character-oriented (or byte-oriented) approach
To separate one frame from the next, an 8-bit (I-byte) flag is added at the beginning and the end of a frame. The flag, composed of protocol-dependent special characters, signals the start or end of a frame. 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. Computer networks / Andrew S. Tanenbaum-- 5th ed

8 Byte Stuffing 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. Byte stuffing is the process of adding 1 extra byte whenever there is a flag or escape character in the text. Computer networks / Andrew S. Tanenbaum-- 5th ed

9 Byte Stuffing Computer networks / Andrew S. Tanenbaum-- 5th ed

10 Bit-oriented approach
Problem in Character oriented approach: The universal coding systems in use today, such as Unicode, have 16-bit and 32-bit characters that conflict with 8-bit characters. We can say that in general, the tendency is For this reason; framing can be also 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. Computer networks / Andrew S. Tanenbaum-- 5th ed

11 Bit-oriented approach
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 (removes) the 0 bit. Computer networks / Andrew S. Tanenbaum-- 5th ed

12 Note Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the data, so that the receiver does not mistake the pattern for a flag.

13 3. Error control 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.

14 Typically, the protocol calls for the receiver to send back special control frames bearing positive or negative acknowledgements about the incoming frames. 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.

15 10.# 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. 10.15

16 Error detection and correction
The correction of errors is more difficult than the detection. In error detection, we are looking only to see if any error has occurred. The answer is a simple yes or no. In error correction, we need to know the exact number of bits that are corrupted and more importantly, their location in the message. In error correction, we need to know the exact number of bits that are corrupted and more importantly, their location in the message. The number of the errors and the size of the message are important factors. If we need to correct one single error in an 8-bit data unit, we need to consider eight possible error locations; if we need to correct two errors in a data unit of the same size, we need to consider 28 possibilities. You can imagine the receiver's difficulty in finding 10 errors in a data unit of 1000 bits. Permutation of 8 by 2= P(8,2) = 54 Behrouz A. Forouzan” Data communications and Networking

17 1. Parity Check Parity check:
Simple parity check; detects single errors. Fig.10.1 Two dimensional check; detects burst errors. Figure Single-bit error Figure Burst error of length 8 Behrouz A. Forouzan” Data communications and Networking

18 Figure 10.10 Encoder and decoder for simple parity-check code

19 1. Parity Check: simple parity checking
In this code, 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 Is in the codeword even. The encoder uses a generator that takes a copy of a 4-bit dataword (a0, a1 a2 and a3) and generates a parity bit r0. If the number of 1s is even, the result is 0; if the number of 1s is odd, the result is 1.In both cases, the total number of 1s in the codeword is even. The checker at the receiver calculates the syndrome s0. s0 equals 0 when the number of Is in the received codeword is even; otherwise, it is 1. If the number of 1s is even, the result is 0; if the number of 1s is odd, the result is 1. In both cases, the total number of 1s in the codeword is even. The sender sends the codeword which may be corrupted during transmission. The receiver receives a 5-bit word. The checker at the receiver does the same thing as the generator in the sender with one exception: The addition is done over all 5 bits. The result, which is called the syndrome, is just 1 bit. The syndrome is 0 when the number of Is in the received codeword is even; otherwise, it is 1. The syndrome is passed to the decision logic analyzer. If the syndrome is 0, there is no error in the received codeword; the data portion of the received codeword is accepted as the dataword; if the syndrome is 1, the data portion of the received codeword is discarded. The dataword is not created. Behrouz A. Forouzan” Data communications and Networking

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

21 10.# Figure 10.14: CRC encoder and decoder A CRC code with C(7, 4)
Behrouz A. Forouzan” Data communications and Networking 10.21

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

23 The Process of CRC At the Receiver:
The decoder does the same division process as the encoder. The remainder 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

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

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

26 3. CHECKSUM 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. Behrouz A. Forouzan” Data communications and Networking

27 Example 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 .

28 Example Cont. 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. Behrouz A. Forouzan” Data communications and Networking

29 10.# Figure 10.16: Example 10.24 100100 36 101101 45 10 10 _________
10 _________ 10 _________


Download ppt "Net 221D : Computer Networks Fundamentals"

Similar presentations


Ads by Google