I read that barker sequence is used for synchronization among other uses. Barker sequences are rare and they have special properties - this part I understood. I am missing some thing when I think about how they score over simple marker sequences for synchronization. You want to know where the information bits start - start with a marker sequence preferably which does not occur in the information. And you can synchronize. How do barker sequences score over marker sequences?
A big advantage of Barker Codes over a generic marker is strong correlation when the codes are aligned and very low correlation for all other shifts, even by one sample. This offers maximum resistance to bit errors that would otherwise cause a false detection.
The presence of a Barker sequence can be optimally detected using correlation, which is the process of multiplying bit by bit the received sequence to the reference Barker code sequence at a given alignment and summing the result of the multiplications (multiply and accumulate). With a Barker sequence, you will get maximum correlation when the received sequence and reference sequence are aligned, and near 0 for all other shifts. This is an ideal characteristic for synchronization, and not a property of generic marker sequences.
Depending on the noise resistance desired, longer codes can be chosen, and/or code sequences can be repeated. Like the use of a generic marker sequence, the Barker code itself would not be an allowed pattern in the data payload, or properly escaped.
As an example, 10110111000 is an 11 chip Barker Code. As an easy way to explain the correlation as a multiply and accumulate, replace all the 0's in the sequence with -1, and all 1's in the sequence with +1. Therefore when correlating the multiplications before summing are an x-nor: 0x0 =1, 0x1=0, 1x0=0, 1x1=0. For demonstration, consider a sequence of three repeating Barker codes for a header:
received sequence 101101110001011011100010110111000
As the sequence is received, we will correlate it by shifting it against our reference sequence and performing the multiply and accumulate for each shift.
Case 1 aligned: When a reference code is aligned with the received code, the correlation (multiply and sum) is:
101101110001011... 10110111000 1x1=+1 0x0=+1 1x1=+1 1x1=+1 0x0=+1 1x1=+1 1x1=+1 1x1=+1 0x0=+1 0x0=+1 0x0=+1 Sum=+11
Case 2 misaligned by 1 sample:
01011011100010... 10110111000 1x0=-1 0x1=-1 1x0=-1 1x1=+1 0x1=-1 1x0=-1 1x1=+1 1x1=+1 0x1=-1 0x0=+1 0x0=+1 Sum = -1
The same result of -1 occurs for all shifts, except when the code aligns at which point the correlation is maximum (the length of the code). Since the length of the code is odd, the correlation cannot sum to the ideal value of 0, but gets quite close! Also note that the code can be inverted, and in that case it would sum to -11 when aligned (for a maximum distance of 22 between positive and negative copies of the code).
Maximum Length Sequences (generated with Linear Feedback Shift Registers) also have this shift-correlation property and include significantly longer sequences than Barker codes, which finds application in GPS and Direct Sequence Spread Spectrum communications where signals are received below the noise floor and recovered using these correlation techniques.
Another view from coding theory is the concept of Hamming distance.
(see https://en.wikipedia.org/wiki/Hamming_distance) To be consistent for that approach we would need to repeat what I did above with symbols 0 and 1 and use an x-or to do the multiply. If the symbols in two sequences are different a 1 is added, if they are the same 0 is added (x-or). The Hamming distance is the total addition of the x-or results between the two sequences. If every symbol didn't match (maximum negative correlation) the Hamming distance would be 11, and if every symbol matched, the Hamming distance would be 0 (for the 11 chip Barker sequence I used). Therefore the Hamming distance between 01001000111 and 10110111000 is 11 (maximum distance possible), and the Hamming distance between the code and cyclically shifted versions of the code would be approximately half way in between: For example, the Hamming distance between 01001000111 and 10010001110 = 5. In fact, since the Barker code has noise-like properties, the likelihood is highest for the distance to be near the middle for all random patterns such as what may be represented by our data payload. It is much more likely that the Barker code will have distances between 4 and 8 to patterns in our data but much less so from 0-3 and 9-11; but that still can an will happen, especially with such a short sequence, unless we encode our data to ensure those sequences do not occur unless bit errors existed. The concept of Hamming distance, and choosing code words of maximum distance is a foundation of error detection and correction. The bigger the distance, the more errors we can correct (see the reference for specific details on all of that).
One benefit is reduction of false-positives when there are bit errors. Bit errors in the sequence may increase the value of a sidelobe and even make it equal to or larger than your detection threshold. The smaller the ideal sidelobe, the less likely this is to happen.
Another benefit is that they have nice spectral properties, since their autocorrelation resembles that of white noise.