19. : Describe the three possible categories of services provided by the data-link layer.
Unacknowledged connectionless service: ——————-
– is appropriate when error rate is very low, so recovery is left to higher layers
– is appropriate for real-time traffic, such as voice, in which late data are worse than bad data
Acknowledged connectionless service: ————————
– there are no logical connections used, but each frame sent is individually acknowledged.
– thus, the sender knows whether a frame has arrived correctly or been lost. If it has not arrived within a specified time interval, it can be sent again.
– this service is useful over unreliable channels, such as wireless systems. 802.11 (WiFi) for example.
Acknowledged connection oriented: ————————————-
– the most sophisticated service the data link layer can provide to the network layer is connection-oriented service – it is done in 3 phases:
o the connection is established by having both sides initialize variables and counters needed to keep track of which frames have been received and which ones have not.
o Transmission of one or more frames are done.
o the connection is released, freeing up the variables, buffers, and other resources.

20.The following character encoding is used in a data link protocol: A: 01000111 B: 11100011 FLAG: 01111110 ESC: 11100000. Show the bit sequence transmitted (in binary) for the fourcharacter frame “A B ESC FLAG” when each of the following framing methods is use.
a. Byte code:

00000101 01000111 11100011 11100000 01111110
  5                  A              B               ESC      FLAG

b. Flag bytes with byte stuffing 
01111110 01000111 11100011 11100000 11100000 11100000 01111110 01111110
FLAG        A                B               ESC         ESC          ESC        FLAG     FLAG 
21. (a) The following data fragment occurs in the middle of a data stream for which the byte stuffing algorithm described in the text is used: A B ESC C ESC FLAG FLAG D. What is the output after stuffing? (b) What is the maximum overhead in byte-stuffing algorithm and when can it happen? (c) A bit string, 0111101111101111110, needs to be transmitted at the data link layer. What is the string actually transmitted after bit stuffing?
(a) Output after stuffing will be:
(b) The maximum overhead occurs when the payload consists of only ESC and FLAG bytes. In this case, there will be 100% overhead.
(c) After five 1s in the data, a 0 is added, therefore, the output is 011110111110011111010.
22. You may want to optimize the frame having one starting flag-byte only instead of both at the beginning and at the ending, as the next frame’s starting flag-btye will do the job of the ending flag-byte of the current frame. Why possibly it has not been already followed?
If you could always count on an endless stream of frames, one flag byte might be enough. However, what if a frame ends (without a flag byte) and there are no new frames for 15 minutes? How will the receiver know that the next byte is actually the start of a new frame and not just noise on the line? Thus, the protocol is much simpler with starting and ending flag bytes.
23. To provide more reliability than a single parity bit can give, an error-detecting coding scheme uses one parity bit for checking all the odd-numbered bits and a second parity bit for all the even-numbered bits. What is the Hamming distance of this code?
Making one change to any valid character cannot generate another valid character due to the nature of parity bits. Making two changes to even bits or two changes to odd bits will give another valid character, so the distance is 2.
24. Consider a typical LAN-channel where errors are isolated and the rate is 10 -6 . If the block size is 1000 bits for error correction we will require about 10 check bits per blocks. One the other hand, we will need 1 bit /block if we use parity to just detect error? Quantitatively compared and explain for 1 Mega-bit (Mb) of data transmission, why will you prefer error detection rather than correction?
Detection: For 1Mb data, there will be 10^6 /1000 = 1000 bit parity overhead. Then, for 1 retransmission overhead is 1001 bits. Therefore, total overhead will be 2001.
Correction: For 1Mb data, there will be 10^6/1000 => 10^3 * 10 or, 10,000 bits of overhead (since, 10 check bits per blocks).
Thus, correction will have (10000/2001) or, 5 times less overhead per Mb of data transmission.
25. Suppose that a message 1001 1100 1010 0011 is transmitted using Internet Checksum (4-bit word). What is the value of the checksum?
The ones complement sum is same as sum modulo 24 and adding any overflow of high order bits back into low-order bits: 
0011 + 1010 = 1101 
1101 + 1100 = 1001 + 1 = 1010
1010 + 1001 = 0011 + 1 = 0100.
the Internet checksum is the ones complement of 0100, which is “1011”.
26. Write down the steps to compute the Internet checksum to be sent.
1. Arrange the 1500 bytes data as rows of 16 bit words of stack.
2. In the last row, the checksum is added with all 16 ‘0’ bits.
3   a. Add the rows.       b. Carryover (if any) is added to previous result (the 16bit wide block).
4. Take 1s complement of the checksum.