You are on page 1of 22

Unit 2 1. What are the basic functionalities a data link layer has to provide?

(or Design Issues of DLL) i) Services to Upper layer: Providing a well-defined service interface to the network layer. ii) Error Control: Dealing with transmission errors. iii) Flow Control: Regulating the flow of data so that slow receivers are not swamped by fast senders. (Framing is done for error control and flow control). 2. List various types of services the data link layer provides to network layer. Give appropriate examples. i) Unacknowledged Connectionless service: Used on reliable networks (like fiber optics) where error rate is low. Appropriate for voice, where delay is worse than bad data. ii) Acknowledged Connectionless service: Useful on unreliable medium like wireless. Acknowledged mails etc. iii) Acknowledged Connection-Oriented service: Most reliable service. File Transfer etc. 3. List out all four Framing techniques. Explain Character Count Technique. i) ii) iii) iv) Character count. Flag bytes with byte stuffing. Starting and ending flags, with bit stuffing. Physical layer coding violations. [04] [03] [02]

Character Count: This framing method uses a field in the header to specify the number of characters in the frame. When the data link layer at the destination sees the character count, it knows how many characters follow and hence where the end of the frame is. This technique is shown in figure (a) for four frames of sizes 5, 5, 8, and 8 characters, respectively. Advantage: easiest method to be applied. Disadvantage: the count character can be garbled by a transmission error, resulting in receiver out of synchronization with sender. As shown in figure (b): count character for second frame is changed from 5 to 7 creates all frames following it, out of synchronization. 4. Explain Byte Stuffing. In this technique, each frame start and end with special bytes, called FLAG bytes. (special bytes used in general are DLE STX-start of text and DLE ETX-end of text). As shown in figure (a) below. [04]

Here we assume, for simplicity, both starting and ending is done by FLAG byte. In this way, if the receiver ever loses synchronization, it can just search for the flag byte to find the end of the current frame. Two consecutive flag bytes indicate the end of one frame and start of the next one. A serious problem occurs with this method when binary data, such as object programs or floating-point numbers, are being transmitted. It may easily happen that the flag byte's bit pattern occurs in the data. This situation will usually interfere with the framing. 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. So, this technique is called byte stuffing or character stuffing. The data link layer on the receiving end removes the escape byte before the data are given to the network layer. It is called de stuffing of character or byte. What happens if an escape byte occurs in the middle of the data? The answer is that it, too, is stuffed with an escape byte. Thus, any single escape byte is part of an escape sequence, whereas a doubled one indicates that a single escape occurred naturally in the data. Shown in figure (b) above. Disadvantage: A major disadvantage of using this framing method is that it is closely tied to the use of 8-bit characters. Not all character codes use 8-bit characters. For example. UNICODE uses 16-bit characters. So, it is not applicable to all transmission. [04]

5. Explain Bit Stuffing. A major disadvantage of using Byte Stuffing framing method is that it is closely tied to the use of 8-bit characters. Not all character codes use 8-bit characters. For example. UNICODE uses 16-bit characters. As networks developed, the disadvantages of embedding the character code length in the framing mechanism became more and more obvious, so a new technique had to be developed to allow arbitrary sized characters. In new technique each frame begins and ends with a special bit pattern, 01111110 (in fact, a flag byte). 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. This technique is called bit stuffing. It is analogous to byte stuffing, Just like FLAG here frame starts and ends with flag byte 01111110. And instead of an escape byte is stuffed into the outgoing character stream before a flag byte in the data, here 0 is stuffed after five consecutive 1s in into the outgoing data stream, so that it guarantees that it does not contain flag byte in between the frame. When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically destuffs (i.e., deletes) the 0 bit. If the user data contain the flag pattern, 01111110, this flag is transmitted as 011111010 but stored in the receiver's memory as 01111110.

6. How Encoding Violation Framing technique works? In encoding violation technique, a single bit is sent as some combination of signal pattern. E.g. In Manchester encoding, for instance, 1-bits are represented by a high-low sequence and 0-bits by lowhigh sequences. The start/end of a frame could be represented by the signal low-low or high-high. The advantage of encoding violations is that no extra bandwidth is required as in bit or character stuffing. The IEEE 802.4 standard uses this approach.

[02]

7. Give Types of Errors. (i) Single Bit Error: In a single-bit error, only 1 bit in the data unit has changed.

[01]

(ii)

Burst Error: A burst error means that 2 or more bits in the data unit have changed.

8. Define : Codeword An n-bit unit containing data (m-bit) and check bits (r-bit) is often referred to as an n-bit codeword. 9. Define: Hamming Distance. The Hamming distance between two words is the number of differences between corresponding bits. The minimum Hamming distance is the smallest Hamming distance between all possible pairs in a set of codewords. 10. Explain Various Error Detection Techniques Error Detection Techniques: (i) Parity Bit Method. (ii) Cyclic Redundancy Check (CRC) Method. Also called Polynomial method. (iii) Checksum Method. (i) Parity Bit Method: This is the simplest error detection method. A redundant bit (parity bit) is appended to every data unit. Even (Odd) parity - the total number of 1's in the data plus parity bit must be an even(odd) number. As shown in figure below is even parity generator:

[01] [01]

[07]

Example for even parity is given here: Data #1's in data Parity Bit Codeword (data and P) Total # 1's (data and P) 110110 4 (Even) 0 1101100 4 (Even) 11111 5 (Odd) 1 111111 6 (Even) 1010100 3 (Odd) 1 10101001 4 (Even) 1111111 7 (Odd) 1 11111111 8 (Even) When receiver receives a data unit, it checks for parity of word. If parity holds correct then it is assumed to be correct transmission. Otherwise error is detected and retransmission should be done. Advantages: With the minimum number of redundancy bit, this method detects error in data for odd numbers of time. (i.e. if 1,3,5,7, etc bits are inverted during transmission then error can be detected) Disadvantage: This method is failed if even number of error occurs. Also, the method can detects error only and cannot correct it.

Modified versions of Parity Method are used: The method shown here also called LRC (Longitudinal Redundancy check). Another is VRC (Vertical Redundancy Check) method, in which the parity bit is set vertically. i.e., Data send in column-by-column manner. For each column parity is maintained. As shown in table, both VRC/LRC are applied in Two-Dimensional Parity Method. Using this method one can correct single error in a row or column. Again, if more than one error in row or column, then it cannot be corrected, but can be detected. Letter H E L L O Parity Bit (VRC) Ascii- 7-bit Parity bit (LRC) 1001000 0 1000101 1 1001100 1 1001100 1 1001111 0 1000010 0

(ii)

CRC (Cyclic Redundancy Check) Method: In Cyclic redundancy Check method, One divisor (called generator ) is selected for generation of codeword. Here, if mB/(m+r)B block coding scheme is selected (i.e. with m-bit data r-bit redundancy) then in any data word r zeros are appended at end of dataword. The newly augmented data-word is then divided by generator. Finally, the reminder is then added to augmented dataword and answer is considered as codeword to be send. E.g. As shown in figure 4B/7B block coding scheme is given. Data to be send: 1001 Generator: 1011 Final Codeword : 1001110

When this codeword is received at receiver end, receiver will divide the same code with same generator. (Generator is agreed by both sender and receiver using some algorithm.) If reminder is zero, code is accepted and data word is extracted from code. Else, codeword is rejected. E.g.

In a cyclic code, If s(x) 0, one or more bits is corrupted. If s(x) = 0, either a. No bit is corrupted. or b. Some bits are corrupted, but the decoder failed to detect them. Advantages: This method can detect burst errors. (Up to r-1 bit error). This method is also called Polynomial Method, and generator is called generator polynomial. It is represented as polynomial in single variable (say x) where 1 at position t from LSB(Least Significant Bit) denotes xt-1 with coefficient 1 and 0 denotes xt-1 with coefficient 0. i.e. in above example generator polynomial is : x3+x+1 Here, If appropriate polynomial is chosen, then one can guarantee of detecting r-1 bit burst errors. A good polynomial generator needs to have the following characteristics: a. It should have at least two terms. b. The coefficient of the term x0 should be 1. c. It should not divide xt + 1, for t between 2 and n 1. d. It should have the factor x + 1.

(iii)

Checksum Method: The concept of checksum is very simple, let us illustrate it. 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. The previous example has one major drawback. All of our data can be written as a 4-bit word (they are less than 15) except for the checksum. One solution is to use ones complement arithmetic. In this arithmetic, we can represent unsigned numbers between 0 and 2n - 1 using only n bits. If the number has more than n bits, the extra leftmost bits need to be added to the n rightmost bits (wrapping). In one's complement arithmetic, a negative number can be represented by inverting all bits (changing a 0 to a 1 and a 1 to a 0). This is the same as subtracting the number from 2n - 1.

INTERNET CHECKSUM: Traditionally, the Internet has been using a 16-bit checksum. Sender site: a. The message is divided into 16-bit words. b. The value of the checksum word is set to O. c. All words including the checksum are added ushtg one's complement addition. d. The sum is complemented and becomes the checksum. e. The checksum is sent with the data. Receiver site: a. The message (including checksum) is divided into 16-bit words. b. All words are added using one's complement addition. c. The sum is complemented and becomes the new checksum. d. If the value of checksum is 0, the message is accepted; otherwise, it is rejected. E.g.

11. Explain Error Correction Techniques Error Correction Techniques: (i) Two Dimensional Parity Bit Method (VRC/LRC Method). (ii) Hamming Code Method.

[08]

(i) Two Dimensional Parity Bit Method (VRC/LRC Method): In this method parity is set in both the way, row wise as well as column wise. Here the scheme is illustrated by example. Suppose the sender wants to send the word world. In ASCII the five characters are coded as 1110111 1101111 1110010 1101100 1100100 The following shows parity bits are added in both the direction: Data Bits Parity Bits 1110111 0 1101111 0 1110010 0 1101100 0 1100100 1 Parity 1100010 1 So, the data sent is shown here: 11101110 11011110 11100100 11011000 11001001 11000101 Now suppose the word world is received by the receiver without being corrupted in transmission. 11101110 11011110 11100100 11011000 11001001 11000101 The receiver counts the 1s in each character and comes up with even numbers (6, 6, 4, 4, 4,4). And also check column vise even parity (6,6,2,2,4,4,2,2).The data are accepted. Now suppose the word world is corrupted during transmission. 11111110 11011110 11100100 11011000 11001001 11000101 The receiver counts the 1s in each character and comes up with even and odd numbers (7, 6, 4, 4, 4, 4). The receiver knows that the data are corrupted. It then calculate column vise parity and comes up with (6,6,2,3,4,4,2,2). Here, row number 1 and column number 4 are corrupted. It means bit at (1,4) is inverted, if we change 4th bit of 1st data row (i.e. 11101110) then we will have correct answer. Advantage: Using simplest form of error correction we can have one bit error correction. It can detect multiple error (even or odd) in single data row or column. But not even data errors in both the way occur simultaneously. (ii) Hamming Code Method: In Hamming Code each Check bits (redundancy bit, or r-bit) occupy positions that are powers of 2 In the Hamming code, each r bit is the VRC bit for one combination of data bits: r1 is the VRC bit for one combination of data bits, r2 is the VRC bit for another combination of data bits, and so on. The combinations used to calculate each of the four r values for a seven-bit data sequence are as follows:

r1 : bits 1, 3, 5, 7, 9, 11 r2 : bits 2, 3, 6, 7, 10, 11 r4 : bits 4, 5, 6, 7 r5 : bits 8, 9, 10, 11 So, if sender wish to send data 1001101, the data is encoded as follows:

Now, suppose an error occurred in transmission as follow:

The error will be detected by r-bits as follow:

Now, one can even correct bit at position 7. i.e. original code again. Advantages: We want to be able to correct error with less overhead than 2D parity Hamming codes correct all single bit errors with only log(m) (where m=number of data bits) extra bits and detect double bit errors . Disadvantage: If more than one bit is in error, then a Hamming code cannot correct it. (Require 2m+1 bit to correct more errors) Hamming codes, like parity bits, are only useful on short messages.

12. Do this yourself: (i) Examples of Hamming Code Techniques (correction and detection). (ii) Examples of CRC Method (generate checksum and detect errors). (iii) Examples of checksum method and internet checksum method.

[04] [04] [04]

13. What is Flow Control? List types of flow control available. [02] Flow control is the process for match the speed of the sender too that of the receiver. This is a dynamic process, as the receiving speed depends on such changing factors as the load, and availability of buffer space. There are two type of flow controls are available: (i) Feedback-based flow control: Receiver send information back to sender (given permission to give more or telling its condition) (ii) Rate-based flow control: Use a built-in mechanism to limit the rate. 14. Remember: Protocol.h file.

15. Remember: Unrestricted Simplex Protocol. Assumption Taken in Unrestricted Simplex Protocol are: The physical layer, data link layer, and network layer are independent processes that communicate by passing messages back and forth. Machine A wants to send a long stream of data to machine B, using a reliable, connection-oriented service. Data are transmitted in one direction only. A is assumed to have an infinite supply of data ready to send and never has to wait for data to be produced. Both the transmitting and receiving network layers are always ready. Processing time can be ignored. Infinite buffer space is available. Machines do not crash. That is, these protocols deal with communication errors, but not the problems caused by computers crashing and rebooting.

16. Explain Simplex Stop and wait protocol. [05] In this protocol we assume that: (i) Data are transmitted in one direction only (ii) No errors occur (iii) The receiver can only process the received information at a finite rate These assumptions imply that the transmitter cannot send frames at a rate faster than the receiver can process them. The problem here is how to prevent the sender from flooding the receiver. A general solution to this problem is to have the receiver provide some sort of feedback to the sender. The process could be as follows: The receiver send an acknowledge frame back to the sender telling the sender that the last received frame has been processed and passed to the host; permission to send the next frame is granted. The sender, after having sent a frame, must wait for the acknowledge frame from the receiver before sending another frame. This protocol is known as stop-and-wait.

17. Explain Simplex Protocol for a Noisy Channel. [05] In this protocol the unreal error free assumption in protocol 2 is dropped. Frames may be either damaged or lost completely. We assume that transmission errors in the frame are detected by the hardware checksum. One suggestion is that the sender would send a frame, the receiver would send an ACK frame only if the frame is received correctly. If the frame is in error the receiver simply ignores it; the transmitter would time out and would retransmit it. One fatal flaw with the above scheme is that if the ACK frame is lost or damaged, duplicate frames are accepted at the receiver without the receiver knowing it. Imagine a situation where the receiver has just sent an ACK frame back to the sender saying that it correctly received and already passed a frame to its host. However, the ACK frame gets lost completely, the sender times out and retransmits the frame. There is no way for the receiver to tell whether this frame is a retransmitted frame or a new frame, so the receiver accepts this duplicate happily and transfers it to the host. The protocol thus fails in this aspect. To overcome this problem it is required that the receiver be able to distinguish a frame that it is seeing for the first time from a retransmission. One way to achieve this is to have the sender put a sequence number in the header of each frame it sends. The receiver then can check the sequence number of each arriving frame to see if it is a new frame or a duplicate to be discarded. The receiver needs to distinguish only 2 possibilities: a new frame or a duplicate; a 1-bit sequence number is sufficient. At any instant the receiver expects a particular sequence number. Any wrong sequence numbered frame arriving at the receiver is rejected as a duplicate. A correctly numbered frame arriving at the receiver is accepted, passed to the host, and the expected sequence number is incremented by 1 (modulo 2)

18. Give Names of Sliding Window Protocol. A One-Bit Sliding Window Protocol A Protocol Using Go Back N A Protocol Using Selective Repeat

[02]

19. Explain Term: piggybacking, [03] In most practical situations there is a need for transmitting data in both directions (i.e. between 2 computers). A full duplex circuit is required for the operation. If protocol 2 or 3 is used in these situations the data frames and ACK (control) frames in the reverse direction have to be interleaved. This method is acceptable but not efficient. An efficient method is to absorb the ACK frame into the header of the data frame going in the same direction. This technique is known as piggybacking. When a data frame arrives at an IMP (receiver or station), instead of immediately sending a separate ACK frame, the IMP restrains itself and waits until the host passes it the next message. The acknowledgement is then attached to the outgoing data frame using the ACK field in the frame header. In effect, the acknowledgement gets a free ride in the next outgoing data frame. This technique makes better use of the channel bandwidth. The ACK field costs only a few bits, whereas a separate frame would need a header, the acknowledgement, and a checksum. A n issue arising here is the time period that the IMP waits for a message onto which to piggyback the ACK. Obviously the IMP cannot wait forever and there is no way to tell exactly when the next message is available. For these reasons the waiting period is usually a fixed period. If a new host packet arrives quickly the acknowledgement is piggybacked onto it; otherwise, the IMP just sends a separate ACK frame. 20. Explain Term: Sliding window( sending, receiving, sliding) Bidirectional protocols are considered to be a part of class called Sliding Window protocols. [01]

All sliding window protocols, each outbound frame contains a sequence number, ranging from 0 up to some maximum. The maximum is usually 2n - 1 so the sequence number fits exactly in an n-bit field. The essence of all sliding window protocols is that at any instant of time, the sender maintains a set of sequence numbers corresponding to frames it is permitted to send. These frames are said to fall within the sending window. Similarly, the receiver also maintains a receiving window corresponding to the set of frames it is permitted to accept. The sender's window and the receiver's window need not have the same lower and upper limits or even have the same size. In some protocols they are fixed in size, but in others they can grow or shrink over the course of time as frames are sent and received. The sequence numbers within the sender's window represent frames that have been sent or can be sent but are as yet not acknowledged. Whenever a new packet arrives from the network layer, it is given the next highest sequence number, and the upper edge of the window is advanced by one. (i.e. window is slide by one position, so called sliding window.) When an acknowledgement comes in, the lower edge is advanced by one. In this way the window continuously maintains a list of unacknowledged frames. E.g.

A sliding window of size 1, with a 3-bit sequence number: (a) Initially. (b) After the first frame has been sent. (c) After the first frame has been received. (d) After the first acknowledgement has been received. 21. Explain One-Bit Sliding Window Protocol. [03] The sliding window protocol with a maximum window size 1 uses stop-and-wait since the sender transmits a frame and waits for its acknowledgement before sending the next one. Under normal circumstances, one of the two data link layers goes first and transmits the first frame. The starting machine fetches the first packet from its network layer, builds a frame from it, and sends it. When this (or any) frame arrives, the receiving data link layer checks to see if it is a duplicate. If the frame is the one expected, it is passed to the network layer and the receiver's window is slid up. The acknowledgement field contains the number of the last frame received without error. If this number agrees with the sequence number of the frame the sender is trying to send, the sender knows it is done with the frame stored

in buffer and can fetch the next packet from its network layer. If the sequence number disagrees, it must continue trying to send the same frame. Whenever a frame is received, a frame is also sent back.

Assume that computer A is trying to send its frame 0 to computer B and that B is trying to send its frame 0 to A. Suppose that A sends a frame to B, but A's timeout interval is a little too short. Consequently, A may time out repeatedly, sending a series of identical frames, all with seq = 0 and ack = 1. When the first valid frame arrives at computer B, it will be accepted and frame_expected will be set to 1. All the subsequent frames will be rejected because B is now expecting frames with sequence number 1, not 0. Furthermore, since all the duplicates have ack = 1 and B is still waiting for an acknowledgement of 0, B will not fetch a new packet from its network layer. After every rejected duplicate comes in, B sends A a frame containing seq = 0 and ack = 0. Eventually, one of these arrives correctly at A, causing A to begin sending the next packet. No combination of lost frames or premature

timeouts can cause the protocol to deliver duplicate packets to either network layer, to skip a packet, or to deadlock. However, a peculiar situation arises if both sides simultaneously send an initial packet. This synchronization difficulty is illustrated by following figure. In part (a), the normal operation of the protocol is shown. In (b) the peculiarity is illustrated.

Two scenarios for One-Bit Sliding Window Protocol. (a) Normal case. (b) Abnormal case. The notation is (seq, ack, packet number). An asterisk indicates where a network layer accepts a packet. If B waits for A's first frame before sending one of its own, the sequence is as shown in (a), and every frame is accepted. However, if A and B simultaneously initiate communication, their first frames cross, and the data link layers then get into situation (b). In (a) each frame arrival brings a new packet for the network layer; there are no duplicates. In (b) half of the frames contain duplicates, even though there are no transmission errors. Similar situations can occur as a result of premature timeouts, even when one side clearly starts first. In fact, if multiple premature timeouts occur, frames may be sent three or more times. 22. What is pipelining? Pipelining allows a sender to send out multiple packets without waiting for acknowledgment. But all packets that have been sent must be retained until they are acknowledged in case they need to be resent. To limit the number of packets that need to be retained, pipelined protocols need to set a bound on the number of packets in the pipeline (sent but not yet acknowledged). This bound imposes a "window" on the sequence numbers for packets in the pipeline. 23. Explain Go-Back N Protocol. [05] The receiver window is one frame wide; on a frame error the receiver discards the frame and all subsequent fames and sends no acks. Eventually the sender will timeout and resend the damaged frame and all subsequent frames. This can waste a lot of bandwidth if the error rate is high. The following figure shows a Go-back-N ARQ protocol; for simplicity the sequence numbers are shown as continuously ascending. Sequence number 2 is received with an error and discarded and all subsequent frames are discarded (sequence numbers 3 to 5). Eventually sequence number 2 timeouts and is resent together with all subsequent frames.

Note that: (a) the sender must store a message and all subsequence messages until an ack arrives for the first, (b) the receiver only needs to store a single frame which can then be passed to the host.
Note that although that are MaxSeq + 1 sequence numbers (0 to MaxSeq) only MaxSeq frames can be outstanding at any time. Consider the case where a three bit sequence number is being used with sequence numbers ranging from 0 to 7 and we can have 8 frames outstanding:

the sender sends frames 0 to 7 the receiver receives each frame (0 to 7) in turn and passes message to the host, advances its window and sends an ack the ackS for frames 0 to 7 are all lost (lightning strike on comms line) the receiver is now expecting frame sequence number 0 after timeout the sender resends frames 0 to 7 the receiver thinks these are the next 8 frames and passes them to the host, etc. To avoid this a gap is introduced in the sequence numbers to ensure no overlap, i.e.:

the sender sends frames 0 to 6 the receiver receives each frame (0 to 6) in turn and passes message to the host, advances its window and sends an ack the acks for frames 0 to 6 are all lost (lightning strike on comms line) the receiver now is expecting frame sequence number 7 after timeout the sender resends frames 0 to 6 the receiver discards all these frames (outside its window) but sends acks the sender gets acks for 0 to 6 and sends frame 7, etc.

24. What is ARQ? The general strategy of using acknowledgements and timeouts to implement reliable delivery is called automatic repeat request (ARQ).

[01]

25. Explain Selective Repeat Protocol. [06] In this protocol rather than discard all the subsequent frames following a damaged or lost frame, the receiver's data link layer simply stores them in buffers. When the sender does not receive an acknowledgement for the first frame it's timer goes off after a certain time interval and it retransmits only the lost frame. Assuming error - free transmission this time, the sender's data link layer will have a sequence of a many correct frames which it can hand over to the network layer. Thus there is less overhead in retransmission than in the case of Go Back n protocol. In case of selective repeat protocol the window size may be calculated as follows. Assume that the size of both the sender's and the receiver's window is w. So initially both of them contain the values 0 to (w-1). Consider that sender's data link layer transmits all the w frames, the receiver's data link layer receives them correctly and sends acknowledgements for each of them. However, all the acknowledgements are lost and the sender does not advance it's window. The receiver window at this point contains the values w to (2w-1). To avoid overlap when the sender's data link layer retransmits, we must have the sum of these two windows less than sequence number space. Hence, we get the condition Maximum Window Size = Sequence Number Space / 2

26. In selective repeat explain the dilemma of window size. (OR, why window size of sender is selected half of sequence number in selective repeat protocol). [04] DO IT YOUR SELF 27. What is the key idea of Stop & Wait Protocol? After transmitting one frame, the sender waits for an acknowledgment before transmitting the next frame. If the acknowledgement does not arrive after a certain period of time, the sender time out and retransmits the original frame. 28.

You might also like