Hamming distance is said to be the number of bits that differ between two codewords. If two code words differ by a distance of d, then up to d-1 bit flips can be detected.
The example given for such an explanation is as follows:
Assume two codewords c1 and c2 where c1 = 10110 and c2 = 10011. Here, the Hamming distance d = 2.
So I can detect up to 2 bit errors because flipping three bits **will result in another valid codeword, so an error can't be detected**
My question is, how do we even know what the list of possible codewords even are to begin with? Isn't the transmitter free to send any data it wants? How do we know in real time, what the codewords are? In the previous example, if I do a 2 bit flip, I get 11010 - what if this was a valid code word?
Here is an excerpt from the book Computer Networks Fifth Edition by Tanenbaum and Wetherall
How do we even know what the legal codewords are?
In most data transmission applications, all 2^m possible data messages are
legal, but due to the way the check bits are computed, not all of the 2^n possible
codewords are used. In fact, when there are r check bits, only the small fraction
of 2^m /2^n or 1/2^r of the possible messages will be legal codewords. It is the
sparseness with which the message is embedded in the space of codewords that allows
the receiver to detect and correct errors