Cyclic Code

1 / 44

# Cyclic Code - PowerPoint PPT Presentation

Cyclic Code. Linear Block Code. Hamming Code is a Linear Block Code. Linear Block Code means that the codeword is generated by multiplying the message vector with the generator matrix.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Cyclic Code' - qamra

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Cyclic Code

Linear Block Code
• Hamming Code is a Linear Block Code. Linear Block Code means that the codeword is generated by multiplying the message vector with the generator matrix.
• Minimum weight as large as possible. If minimum weight is 2t+1, capable of detecting 2t error bits and correcting t error bits.
Cyclic Codes
• Hamming code is useful but there exist codes that offers same (if not larger) error control capabilities while can be implemented much simpler.
• Cyclic code is a linear code that any cyclic shift of a codeword is still a codeword.
• Makes encoding/decoding much simpler, no need of matrix multiplication.
Cyclic code
• Polynomial representation of cyclic codes.

C(x) = Cn-1xn-1+ Cn-2xn-2+ … + C1x1 + C0x0 ,

where, in this course, the coefficients belong to the binary field {0,1}.

• That is, if the code is (1010011) (c6 first, c0 last), we write it as x6+ x4+ x+ 1.
• Addition and subtraction of polynomials – Done by doing binary addition or subtraction on each bit individually, no carry and no borrow.
• Division and multiplication of polynomials. Try divide x3+ x2+ x+ 1 by x+ 1.
Cyclic Code
• A (n,k) cyclic code can be generated by a polynomial g(x) which has degree n-k and is a factor of xn - 1. Call it the generator polynomial.
• Given message bits, (mk-1 + …+ m1 +m0 ), the code is generated simply as:
• In other words, C(x) can be considered as the product of m(x) and g(x).
Example
• A (7,4) cyclic code g(x) =x3 + x+ 1.
• If m(x) = x3 + 1 x^3+1, C(x) = x6 + x4 + x+ 1.
Cyclic Code
• One way of thinking it is to write it out as the generator matrix
• So, clearly, it is a linear code. Each row of the generator matrix is just a shifted version of the first row. Unlike Hamming Code.
• Why is it a cyclic code?
Example
• The cyclic shift of C(x) = x6 + x4 + x+ 1 is C1(x) = x5 + x2 + x+ 1.
• It is still a code polynomial, because it the code polynomial if m(x) = x2 +1.
Cyclic Code
• Given a code polynomial
• We have
• Therefore, C1(x) is the cyclic shift of C(x) and
• has a degree of no more than n-1
• divides g(x) (why?) hence is a code polynomial.
Cyclic Code
• So, to generate a cyclic code is to find a polynomial that
• has degree n-k
• is a factor of xn -1.
Generating Systematic Cyclic Code
• A systematic code means that the first k bits are the data bits and the rest n-k bits are parity checking bits.
• To generate it, we let

where

• The claim is that C(x) must divide g(x) hence is a code polynomial.
• 33 mod 7 = 6. Hence 33-6=28 can be divided by 7.
Division Circuit
• Division of polynomials can be done efficiently by the division circuit. (just to know there exists such a thing, no need to understand it)
Remaining Questions for Those Really Interested
• Decoding. Divide the received polynomial by g(x). If there is no error you should get a 0 (why?). Make sure that the error polynomial you have in mind does not divide g(x).
• How to make sure to choose a good g(x) to make the minimum degree larger? Turns out to learn this you have to study more – it’s the BCH code.
Cyclic code used in IEEE 802
• g(x) = x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1
• all single and double bit errors
• all errors with an odd number of bits
• all burst errors of length 32 or less
Other codes
• RS code. Block code. Used in CD, DVD, HDTV transmission.
• LDPC code. Also block code. Reinvented after first proposed 40 some years ago. Proposed to be used in 802.11n. Achieve close-to-Shannon bound
• Trellis code. Not block code. More closely coupled with modulation.
• Turbo code. Achieve close-to-Shannon bound.

• The communication between two machines that can directly communicate with each other.
• Basic property
• If bit A is sent before bit B, bit A will be received earlier than bit B
• Fundamental constraints
• Errors
• Computers have different capabilities
• Delay is not zero
• What the data link layer does is to encapsulate the packets from the network layer into frames and send out these frames.
• So we will discuss how to deliver these frames.
Framing
• How does the receiver know where is the start and where is the end of a frame?
• Counter. Tell the receiver how many bytes there are in this frame. Problems?
• The counter part could be corrupted and you are done.
Flag Bytes
• Add special bytes to the beginning and the end of the frame.
• What if the data contains the flag bytes?
• Add ESC byte to each flag or ESC in the data. Stuffing.
• Any time you see an ESC, the next byte is either ESC or FLAG naturally occurred in the data.
Using Bits
• More flexibility gained by sending bits. Using 01111110 as the flag bits.
• If the data contains “011111”, add a 0 after the fifth 1. When the receiver sees in the data part “0111110,” it removes the last 0.
• What if the original data contains “0111111”?
• It will be stuffed as “01111101”, and won’t be regarded as the flag. The receiver will destuff it back into “0111111.”
• What if the original data contains “0111110”?
• It will be stuffed as “01111100”. The receiver will destuff it back into “0111110.”
• So the frames are sent. At the receiver side, how do you know that you received the frame correctly?
• Using the error control code discussed last time.
• Calculate the syndrome, if it is 0, then assume no error, if it is not zero, then some error.
• Could this scheme give you the wrong judgment sometime? Can it be 100% accurate?

• Assume that the physical layer, the data link layer, and the network layer are three processes and communicate with each other.
• Assume that the sender always has enough data to send.
• Assume that the machines don’t crash.
• Assume that the data flows only one direction (simplex).
Protocol 1.
• Your protocol really depends on the world you live in.
Protocol 1
• Sender.
• Grab data from the network layer.
• Send to physical layer. Goto 1.
• Get data from the physical layer
• Give it to the network layer. Goto 1.
Protocol 2
• Now remove assumption (2). The receiver’s network layer process is not infinitely fast.
• How to design the protocol?
• Note that the receiver may not be able to process a frame if it is still working on a frame received earlier.
Protocol 2
• The receiver must provide some kind of acknowledgements. If the receiver never tells the sender anything, the sender has no way of knowing whether this speed is too high or too low.
• The simplest form of ack is the receiver sends back an ack every time he receives a frame.
• The sender waits for this ack to start sending the next frame.
• Called “stop and wait.”
Protocol 2
• Sender.
• Grab data from the network layer and send to physical layer.
• Wait (blocked here) for ack.
• After getting ACK, goto 1.
• Wait (blocked here) for data.
• After getting the data, give it to the network layer and send ack. Goto 1.
Protocol 3
• Now, let’s remove assumption (1). There is now noise in the channel and frames could be corrupted. Both the data frame and the ack frame.
• How to design your protocol? What are the considerations?
• When a frame is lost, how can the sender know?
Protocol 3
• So we can add a timer. If the sender does not receive the ack before the timer expires, he knows something is wrong and resend this frame.
• How long should the timer be set?
• Problems?
Protocol 3
• A sent B frame F.
• B received the frame. Sent ack to A. Ack got lost.
• A time out. Resend F.
Sequence Number
• Every frame has a sequence number.
• Sender says I am sending the frame with sequence number m.
• Receiver acks saying that I have successfully received the frame with sequence number m, please send me frame with sequence number m+1.
• This will solve the duplication problem.
Protocol 3
• Sender.
• Grab data from the network layer.
• Send to physical layer with the current sequence number S and start timer.
• Wait for ACK.
• If got an ACKm (expecting m+1), m:=m+1, repeat 1.
• Else, timeout, repeat 2.
• Wait for data.
• Get data from the physical layer. If it is with the expected sequence number m, give it to the network layer, m:=m+1.
• send ACKm-1 (expecting m). Goto 1.
Protocol 3
• Question 1. After sender sends frame m, will he receive Expc for lower than m? Will it receive Expc higher than m+1?
Protocol 3
• Answer. No. Because when sender sent frame m, he must have received Expc from the receiver of m. Receiver keeps the sequence number and won’t decrease it. And it will not receiver Expc higher than m+1, because m+1 has not been sent yet.
Protocol 3
• Question 2. After sending out an Expc of m+1, what are the possible frames the receiver can receive?
Protocol 3
• Answer. The only possible frames he could receive is m or m+1.
• In what case he receives m? (ACKm gets lost) In what case he receives m+1 (when everything goes fine)? Why can’t he receive m-1 (Because when sender sends m, he knows that m-1 is received correctly.)? Why can’t he receive m+2 (because sender won’t send m+2 before the receiver sends ACKm+1)?
Protocol 3
• Question 3. How many bits should the sequence number have?
Protocol 3
• Answer. 1 bit. At any time, there are only two possible frames both for the sender and the receiver.
Sliding window
• Think the frames the sender has to send as a continuous stream. The window contains the current frame being sent and is not acked yet. Every ack (Expc) moves the window forward one frame.
Correctness Part is Done!
• So our Protocol 3 will work without causing errors. ARQ. (automatic repeat request)
• So the next step is the optimization.
• Any one sees the problem?