Professional Documents
Culture Documents
Virtual communication.
Actual communication.
Three possible services: 1. Unacknowledged connectionless service. 2. Acknowledged connectionless service. 3. Connection-oriented service.
3. 4.
Many of the principles at the data link layer, such as error control and flow control, are also found in transport and other layers and protocols as well.
6
Framing
What is framing ? The process of breaking the bit stream offered by the physical layer into discrete segments (frames). Why framing ? a) For computing the checksum for each frame. b) For acknowledging the lost frames. How to do framing ?
7
A character stream
Flag bytes
(a)
Disadvantages: closely tied to 8-bit characters and the ASCII character code.
9
Bit stuffing
(a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in receivers memory after destuffing.
10
11
Flow control: What to do with a sender that systematically wants to transmit frames faster than the receiver can accept them ? Some kind of feedback mechanism is needed so that the sender can be made aware of whether or not the receiver is able to keep up. This is frequently integrated with error handling for convenience.
12
Error-Correcting Codes
Basic idea: Including redundant information along with each block of data sent to enable the receiver to deduce what the transmitted character must have been. An unit containing m bits of data and r bits of redundancy, or check bits, is referred to as an m + r bits codeword. The number of bit positions in which two codewords differ is called the Hamming distance. Two d apart codewords require d single-bit errors to convert one into the other. The minimum Hamming distance between any two codewords from a list of codewords is the distance of the complete list. To detect d errors, a distance of d + 1 is needed because with such a code there is no way that d single-bit errors can change a valid codeword into another valid codeword. To correct d errors, a distance of 2d + 1 is needed because that way the legal codewords are so far apart that even with d changes, the original codeword is still closer than any other codeword, so it can be uniquely determined.
14
Hamming code
At the sending side: 1. The bits of the codeword are numbered consecutively, starting with bit 1 at the left end. 2. The bits that are powers of 2 (1, 2, 4, 8, 16, etc.) are check bits. The rest (3, 5, 6, 7, etc.) are filled up with the data bits. 3. Check bit forces the parity of the following bits to be even (or odd): the check bit itself, and all data bits whose position number has an element of 2**i when it is expended into a sum of powers of 2. E.g., for check bit 1, the following data bits are checked: 3 = 1 + 2, 5 = 1 + 4, 7 = 1 + 2 + 4, ... One data bit is checked by all and just those check bits occurring in its expansion.
15
Hamming code
At the receiver side:
1. A counter is initialized into zero. 2. Each check bit k (= 1, 2, 4, ...) and its checked data bits are examined to see if the parity is correct. 3. If not, k is added into the counter. 4. If the counter is zero at the end, the codeword is accepted as valid. Otherwise, it contains the number of the incorrect bit.
E.g., if the parities were wrong when examining check bits 1, 2, 4, then the counter-value = 7 = 1 + 2 + 4 , we can conclude that data bit 7 was inverted since bit 7 is the only one checked by bits 1, 2, and 4.
16
If a burst error of length occurs, at most 1 bit in each codeword will be effected, which can be corrected by the Hamming code. 17
Error-detecting codes
Error-correcting codes are suitable for simplex channels where no retransmission can be requested. Error-detection plus retransmission is often preferred because it is more efficient. For comparison, consider a channel with error rate of 10**(-6) per bit. Let block size be 1000 bits.
To correct a single error (by Hamming code), 10 check bits per block are needed. To transmit 1000 blocks, 10,000 check bits (overhead) are required. To detect a single error, a single parity bit per block will suffice. To transmit 1000 blocks, only one extra block (due to the error rate of 10**(-6) per bit) will have to be retransmitted, giving the overhead of only 2001 (= 1000 + 1001) bits.
Simple hardware has been built to compute and verify the CRC checksum.
20
2.
3.
4.
Protocol Definitions
Continued
Some definitions needed in the protocols to follow. These are located in the file protocol.h.
22
Some definitions needed in the protocols to follow. These are located in the file protocol.h.
23
24
25
3.
What is the fatal flaw in the above scheme ? Loss of an acknowledgement duplicated frame. How to distinguish a frame being seen for the first time from a retransmission ? Use a sequence number in the header of each frame.
Continued
26
Piggybacking: temporarily delay outgoing acknow-ledgements so that they can get a free ride on the next outgoing data frame. Save bandwidth, number of interrupts and buffers. How long should the receiver wait for an outgoing frame onto which to piggyback the acknowledgement ? An ad hoc scheme: waiting a fixed number of msec (timer).
28
A sequence number is assciated with each transmitted frame. Sequence numbers range from 0 up to some maximum (2**n - 1) circularly. A window is a list of consecutive sequence numbers. The size of a window is determined by two pointers: the lower edge and the higher edge. The size can be fixed or dynamically extended and shrunk. The sender maintains a sending window with consecutive sequence numbers corresponding to frames sent but has 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. When an acknowledgement comes in, the lower edge is advanced by one. The size of the sender's window is a dynamical one.
The receiver maintains a receiving window with consecutive sequence numbers corresponding to frames it is permitted to accept.
When a frame whose sequence number is equal to the lower edge of the window is received, it is passed to the network layer, an acknowledgement is generated, and the window is rotated by one. The receiver's window always remains at its initial size.
29
(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.
30
Continued
31
32
Two scenarios for protocol 4. (a) Normal case. (b) Abnormal case. The notation is (seq, ack, packet number). An asterisk indicates where a network layer accepts a packet.
33
Consequently, the sender is blocked during the above period, which can be very large in channels with long round-trip propagation delay. How to solve this problem ? The pipelining solution: Set the maximum sender's window size (the number of outstanding frames) so large that the sender is allowed to transmit multiple frames until the acknowledgement for the first frame comes back. Thereafter, acknowledgements will arrive one after another, so the sender always gets permission to transmit. What to do if a frame in the middle of a long stream is damaged or lost ?
34
2.
(b) The selective repeat strategy: 1. The receiver buffers correct subsequent frames, but sending no acknowledgements (or Nak). The receiver's window size is larger than 1. 2. After time out (or receiving Nak), the sender retransmits the damaged or lost frame.
35
Continued
36
Continued
37
Continued
38
39
Continued
41
Continued
42
Continued
43
44
(a) Initial situation with a window size seven. (b) After seven frames sent and received, but not acknowledged. (c) Initial situation with a window size of four. (d) After four frames sent and received, but not acknowledged.
45
50
The frame is delimited with flag sequence 01111110. Address can be used to identify a terminal on multidrop lines or to distinguish commands from responses for point-to-point lines. Control is used for sequence numbers, acknowledgements, and others. Data can be arbitrarily long. Checksum uses CRC-CCITT. 51
Three kinds of frames distinguished by the control field: (a) An information frame. (b) A supervisory frame. (c) An unnumbered frame.
52
54
In summary, PPP is a multi-protocol framing mechanism suitable for use over modems, HDLC bit-serial lines, SONET, and other physical layers. It supports error detection, option negotiation, header compression, and optionally, reliable transmission using HDLC framing.
56