Академический Документы
Профессиональный Документы
Культура Документы
Framing
Framing by character count.
Framing (2)
(a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after stuffing.
Problem: Too tied to the 8-bit per character format ... UNICODE uses 16-bits/char
Frames that need to be send in a bit stream: Flag The sender sends the following bit stream: Flag Esc Flag
The receiver will ignore this flag. Frames that need to be send in a bit stream: Esc The sender sends the following bit stream: Esc Esc Flag Esc Flag Flag
The receiver will ignore this Esc, and accept the flag.
Framing (3)
The goal is to have 01111110 as a unique bit pattern.
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.
Now is a 00100 is received, what do we do ? Obviously this is not a codeword. So we have detected a error. Now let's see the hamming distance of the received word from all code words: d(00100,00000) = 1, d(00100,00111) = 2, d(00100,11001) = 4, d(00100,11110) = 3. So hamming distance to codeword for 00 is least. Hence it is most likely that the code transmitted codeword was 00000 and hence the data was 00. So now we have,with high probability, corrected the error.
If received word was 01010, then this has min hamming distance d(01010,00000) = 2 and d(01010, 11110) = 2 from 2 valid code words. So in this case we can detect the error, but cannot correct it.
Consider pairwise hamming distances between codewords: d(00000,00111) = 3; d(00000,11001) = 3; d(00000,11110) = 4; d(00111,11001) = 4; d(00111,11110) = 3; d(11001,11110) = 3; Minimum distance between valid codewords = 3; Single bit error will cause invalid codeword at distance 1 from a valid codeword and at least distance 2 from all other valid codewords. So we can always correct single bit errors. We can always detect two bit errors, but we might not aways be able to detect 3 bit errors.
Design goals:
(1) Given k and n we would like to design codewords that are farthest away from each other. (2) Codewords should be easy to encode and decode. (3) Extra bits (n-k), should be as small as possible.
The bits of the codeword are numbered consecutively, starting with bit 1 at the left end, and so on. The bits that are powers of 2 (1, 2, 4, 8, 16, ) are check bits. The rest (3, 5, 6, 7, 9, ) are data bits. Each check bit forces the parity of some collection of bits, including itself, to be even. To see which check bits the data bit in position k contributes to, rewrite k as a sum of power of 2, e.g.,: 11 = 1 + 2 + 8 and 29 = 1 + 4 + 8 + 16
1001000
is encoded as
00110010000
When a codeword arrives, the receiver examines each check bit for the correct parity.
If check bits 1, 2, and 8 are in error, the inverted bit is 11, because: 11 = 1 + 2 + 8
Error-Correcting Codes
Error-Detecting Codes
Error-correcting codes are widely used on wireless links that are noisy.
However, they generate too large transmission overhead for reliable links such as copper wire or fiber. Therefore, here error-detection codes are used.
When error is detected, the data is retransmitted. The goal for error correcting codes it to add redundancy to the data so that the errors are not only detected but can be at the same time corrected (without retransmission). For error-detecting codes the goal is to only detect the errors with the minimal transmission overhead. They are based on polynomial code also known as CRC (Cyclic Redundancy Check)
A k-bit frame is regarded as polynomial with coefficients 0 and 1 with terms from xk-1 to x0
For example: 110001 -> x5 + x4 + x0
Polynomial arithmetic is done modulo 2 using the rules of algebraic field theory. Both addition and subtraction are identical to exclusive OR. For exampe: 10011011 +11001010 -------------01010001 11110000 -10100110 ------------01010110
The sender and receiver must agree on a generator polynomial G(x). G(x) must have the first and last bit equal to 1. For a given frame, we consider its polynomial M(x) (longer than G(x)). The checksum is the reminder from the division M(x)*xr / G(x), where r is the degree of G(x). Polynomial T(x) obtained as M(x)*xr - checksum represents the check-summed frame that is divisible by G(x). An example division is shown on the next page, where the frame is 1101011011 (corresponds to M(x)) and the generator polynomial G(x) = x4 + x + x0 -> 10011. M(x)*xr -> 11010110110000 (we added 4 zeros at the end)
Upon receiving the check-summed frame, the receiver divides it by G(x): [T(x) + E(x)] / G(x) Since T(x) / G(x) is always zero, the result is always E(x) / G(x).
The errors containing G(x) as a factor will slip by, all other errors will be caught.
Single bit errors will be detected: We have E(x)=xi for a single bit error, E(x) / G(x) will not be zero, since G(x) must have the first and last bit equal to 1. All errors consisting of an odd number of inverted bits will be detected if G(x) is divisible by (x + 1). E(x) consists of odd number of terms, e.g., x5 + x2 + x0 and therefore, cannot be divisible by (x+1). Since E(x) has an odd number of terms E(1)=1. If E(x) = (x + 1) Q(x), then E(1) = (1 + 1) Q(1) = 0, a contradiction. The polynomial G(x) used in IEEE 802 standard is x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x1 + 1
The main difference between this protocol for simple stop-and-wait is that the receiver knows which seq num to expect and sender known which seq num to send. This technique is called Automatic Repeat Request (ARQ)
Continued
a) A One-Bit Sliding Window Protocol b) A Protocol Using Go Back N c) A Protocol Using Selective Repeat
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.
Pipelining
Consider a 50 kbps channel to a satellite with round-trip propagation delay 500 msec. Using window size 1: At t = 0 sender starts sending first bit of 1000 bit frame At t = 20 msec frame completely sent At t = 270 frame completely received At t = 520 ack received by sender Sender busy for 20/520 = 4% of time ... very inefficient. Why ? Sender has to wait till a frame is acked before sending the next frame. Solution: Allow sender to send up to w (>1) frames without waiting for ack.
So from t = 0 to t = 520, sender could have sent 26 frames, so let w should be atleast 26.
Need for large window occurs when the bw x delay is big .... think about this !! bw x delay determines how many frames can fit in the pipe. We will revisit this later.
Sender will detect loss of frames only after many successive frames have already been transmitted. So, does the sender retransmit all frames (lost and successive) or just lost ? The buffer at the receiver decides.
Pipelining and error recovery. Effect on an error when (a) Receivers window size is 1. (b) Receivers window size is large.
Protocol Verification
Finite state machines and Petri nets are used.