I am trying to compound 2 CRC polynomials. I have a message for which I produce a CRC using one polynomial. I then CRC the result of the first CRC in order to obtain a second result. Is there any possible way to do this in one go?
Example:
Given the message 0xC and the polynomial 0x17 I compute the CRC which is 0xA. I then take this result and another polynomial 0x13 and compute the CRC again which produces the result 0xD. I am trying to derive a new polynomial which given the message 0xC will produce the result 0xD.
I have only tried to work this on paper so I do not have any code but some code should look like this:
def CRC(message, poly):
#CRC implementation
a = CRC(0xC, 0x17)
#The value of a right now would be 0xA
b = CRC(a, 0x13)
#The value of b is 0xD right now
I am trying to obtain the same result using my initial message and one single function call
b = CRC(0xC, ???)
#I would want the value of b after this call to be 0xD
It seems like a dumb request but I find it helpful.
I have tried applying simple math specifically The quotient remainder theorem but I find multiplying in finite fields to be overly complex.
I misunderstood the question in my original answer. I'm assuming this is a single nibble message, since the second CRC only has a single nibble input, the CRC from 0x17. This could be implemented using a table with 16 entries. Using n to represent the nibble, using carryless and borrowless binary math, and hex numbers:
crc = (((n*10)%17)*10)%13 = (((n*7)%17)*3)%13
I'm wondering if instead, the goal here is to work with a message of more than one nibble. For example, say the message is {x y z}, then the encoded message would be
{x y z crc17{x y z} crc13{x y z}}
or
{x y z crc17{x y z} crc13{x y z crc17{x y z}}
Related
I am trying to understand how likely a Cyclic Redundancy Check is to fail, given a particular divisor P(x). I am specifically interested in failures resulting from an odd number of bit flips in my message, an example to follow.
Some prerequisite info:
CRC is a very commonly used way to detect errors in computer networks.
P(x), G(x), R(x), and T(x) are all polynomials under binary field arithmetic (i.e., all coefficients are mod2: 0 or 1).'
P(x) is the polynomial that we are given and that we will divide by.
E(x) is an error pattern. It is XORed with T(x) to get T'(x). G(x) is the message that we want to send.
R(x) is the remainder of G(x)/P(x) or just G(x)modP(x).
T(x) is our sent data, (x^k)G(x)+R(x), where k is the degree of P(x).
T'(x) is our received data but potentially with errors.
When T'(x) is received, if T'(x)modP(x)=0 then it is said to be error-free. It may not actually be error-free.
Proof:
Assume an odd number of errors has x + 1 as a factor.
Then E(x) = (x + 1)T(x).
Evaluate E(x) for x = 1 → E(x) = E(1) = 1 since there are odd number of terms.
But (x + 1)T(x) = (1 + 1)T(1) = 0.
Therefore, E(x) cannot have x + 1 as a factor.
Example:
Say my P(x)=x^7 +1=10000001\
Let G(x)=x^7+x^6+x^3+x+1=11001011\
So, T(x)=110010111001010\
When E(x)=011111011111111\
T'(x)=E(x)XORT(x)=101101100110101\
T'(x) modulus P(x)=0, a failure.\
I simulated the results on a particular message(T(x)), namely 11001011, and found CRC to fail 42 of the 16384 possible odd parity bit flips that I attempted. Failure means that T'(x)modP(x)=0.
I expected odd parity bit errors to be caught based on the above proof.
Is the proof wrong, or am I doing my example calculation wrong?
What I really want to know is, given P(x)=x^7 +1, what are the offs that any general message with an odd number of bit flips will be erroneous but not be caught as being erroneous?
Sorry, this is so long-winded but I just want to make sure everything is super clear.
I am in the Go environment.
I am looking for a cross platform library to use to generate my two formulas in python or F # or matlab, ...
I need to generate a mathematical formula based on two references
The manufacturer indicates that the value of a sensor is coded on a byte and is between 0 and 255.
The minimum = 0 and has the representation value -60dB
The maximum = 255 and has a representation value of +20dB
I must now generate two formulas:
RX: a mathematical formula allowing me to interpret the value coming from the sensor in value of representation in dB.
TX: the inverse of RX ie a mathematical formula allowing me to convert the value of representation in dB in value of representation of the sensor.
If you have a idea it is welcome
Youssef
I am assuming you need a linear relationship, so you can use the following code:
INPUT_MIN = 0
INPUT_MAX = 255
OUTPUT_MIN = -60
OUTPUT_MAX = 20
SLOPE = (OUTPUT_MAX - OUTPUT_MIN) / (INPUT_MAX - INPUT_MIN)
def rx(sensor_input):
return SLOPE * (sensor_input - INPUT_MIN) + OUTPUT_MIN
def tx(dbs):
return (dbs - OUTPUT_MIN) / SLOPE + INPUT_MIN
What you have to do is to find the equation of the line given those two points. There are many tutorials online about it like this one.
Once you have found the equation in which y would be the variable that represents your output, and x represent your input, you need to find x in terms of y. Finally, you just implement both functions.
Note that I haven't limited the input, so in case you want restricted input values, I encourage you to add some conditionals in the functions.
In python using numpy:
import numpy as np
def RX(input_val):
# use linspace to create lookup table
lookup_array = np.linspace(-60,20,255)
return lookup_array(int(input_val))
def TX(decibal_value):
# use linspace to create lookup table
lookup_array = np.linspace(-60,20,255)
# find the index closest to decibal value by searching for the smallest difference
index = (np.abs(spectum - decibal_value)).argmin()
return index
Can someone please explain what this part of CRC codes from Tannenbaum computer networks means!
If there has been a single-bit error, E(x) = x^i , where i determines which bit is
in error. If G(x) contains two or more terms, it will never divide into E(x), so all
single-bit errors will be detected.
And
If there have been two isolated single-bit errors, E(x) = x^i + x^j , where i > j.
Alternatively, this can be written as E(x) = x^j (x^(i − j) + 1). If we assume that G(x)
is not divisible by x, a sufficient condition for all double errors to be detected is
that G(x) does not divide x ^k + 1 for any k up to the maximum value of i − j (i.e.,
up to the maximum frame length). Simple, low-degree polynomials that give pro-
tection to long frames are known. For example, x ^15 + x ^14 + 1 will not divide
x ^k + 1 for any value of k below 32,768.
Please post in simple terms so I can understand it a bit more!. EXAMPLEs are appreciated. Thanks in advance!
A message is a sequence of bits. You can convert any sequence of bits into a polynomial by just making each bit the coefficient of 1, x, x2, etc. starting with the first bit. So 100101 becomes 1+x3+x5.
You can make these polynomials useful by considering their coefficients to be members of the simplest finite field, GF(2), which consists only of the elements 0 and 1. There addition is the exclusive-or operation and multiplication is the and operation.
Now you can do all the things you did with polynomials in high school, but where the coefficients are over GF(2). So 1+x added to x+x2 becomes 1+x2. 1+x times 1+x becomes 1+x2. (Work it out.)
Cyclic Redundancy Checks (CRCs) are derived from this approach to binary message arithmetic, where a message converted to a polynomial is divided by a special constant polynomial whose degree is the number of bits in the CRC. Then the coefficients of the remainder of that polynomial division is the CRC of that message.
Read Ross William's CRC tutorial for more. (Real CRCs are not just that remainder, but you'll see.)
i need to find acceleration of an object the formula for that given in text is a = d^2(L)/d(T)^2 , where L= length and T= time
i calculated this in matlab by using this equation
a = (1/(T3-T1))*(((L3-L2)/(T3-T2))-((L2-L1)/(T2-T1)))
or
a = (v2-v1)/(T2-T1)
but im not getting the right answers ,can any body tell me how to find (a) by any other method in matlab.
This has nothing to do with matlab, you are just trying to numerically differentiate a function twice. Depending on the behaviour of the higher (3rd, 4th) derivatives of the function this will or will not yield reasonable results. You will also have to expect an error of order |T3 - T1|^2 with a formula like the one you are using, assuming L is four times differentiable. Instead of using intervals of different size you may try to use symmetric approximations like
v (x) = (L(x-h) - L(x+h))/ 2h
a (x) = (L(x-h) - 2 L(x) + L(x+h))/ h^2
From what I recall from my numerical math lectures this is better suited for numerical calculation of higher order derivatives. You will still get an error of order
C |h|^2, with C = O( ||d^4 L / dt^4 || )
with ||.|| denoting the supremum norm of a function (that is, the fourth derivative of L needs to be bounded). In case that's true you can use that formula to calculate how small h has to be chosen in order to produce a result you are willing to accept. Note, though, that this is just the theoretical error which is a consequence of an analysis of the Taylor approximation of L, see [1] or [2] -- this is where I got it from a moment ago -- or any other introductory book on numerical mathematics. You may get additional errors depending on the quality of the evaluation of L; also, if |L(x-h) - L(x)| is very small numerical substraction may be ill conditioned.
[1] Knabner, Angermann; Numerik partieller Differentialgleichungen; Springer
[2] http://math.fullerton.edu/mathews/n2003/numericaldiffmod.html
I'm studying information theory but one thing I can't seem to work out.
I know that given a linear code C and a generator matrix M I can work out all the possible codewords of C.
However I do not understand:
What a parity check matrix is http://en.wikipedia.org/wiki/Parity-check_matrix
How to make a parity check matrix from a generator matrix
I'd really appreciate any pointers!
Thanks!
I think your link explains it fairly well, but I'll try to simplify further.
Let x be your message, a k-element row vector. Let G be your generator matrix, an k-by-n binary matrix where n > k. Let y be your n-element transmitted codeword where y = xG. Let z be your n-element received codeword.
Hopefully, z = y. But when transmitting y across a noisy channel, it is possible for y to become corrupted, e.g., z != y.
An (n-k)-by-n parity matrix H is applied to the received codeword z to check if z is valid. The vector w = zH' can detect up to a certain number of bit errors in z.
In coding theory, a parity-check matrix of a linear block code C is a generator matrix of the dual code. As such, a codeword c is in C if and only if the matrix-vector product Hc=0.
The rows of a parity check matrix are parity checks on the codewords of a code. That is, they show how linear combinations of certain digits of each codeword equal zero. For example, the parity check matrix
specifies that for each codeword, digits 1 and 2 should sum to zero (according to the second row) and digits 3 and 4 should sum to zero.
LDPC i believe uses parity check matrix. more generally error control/correction algorithms