Just prior to transmission, the entire SONET signal, with the exception of the framing bytes and the section trace byte, is scrambled. Scrambling randomizes the bit stream is order to provide sufficient 0–>1 and 1–>0 transitions for the receiver to derive a clock with which to receive the digital information.
Actually every add/drop multiplexer sample incoming bits according to a particular clock frequency. Now this clock frequency is recovered by using transitions between 1s and 0s in the incoming OC-N signal. Suppose, incoming bit stream contains long strings of all 1s or all 0s. Then clock recovery would be difficult. So to enable clock recovery at the receiver such long strings of all 1s or 0s are avoided. This is achieved by a process called Scrambling.
Scrambler is designed as shown in the figure given below:-
It is a frame synchronous scrambler of sequence length 127. The generating polynomial is 1+x6+x7. The scrambler shall be reset to ‘1111111’ on the most significant byte following Z0 byte in the Nth STS-1. That bit and all subsequent bits to be scrambled shall be added, modulo 2, to the output from the x7 position of the scrambler, as shown in Figure above.Example:
The first 127 bits are:
111111100000010000011000010100 011110010001011001110101001111 010000011100010010011011010110 110111101100011010010111011100 0101010
The same operation is used for descrambling. For example, the input data is 000000000001111111111.
00000000001111111111 <-- input data 11111110000001000001 <-- scramble sequence -------------------- <-- exclusive OR (scramble operation) 11111110001110111110 <-- scrambled data 11111110000001000001 <-- scramble sequence -------------------- <-- exclusive OR (descramble operation) 00000000001111111111 <-- original data
The framing bytes A1 and A2, Section Trace byte J0 and Section Growth byte Z0 are not scrambled to avoid possibility that bytes in the frame might duplicate A1/A2 and cause an error in framing. The receiver searches for A1/A2 bits pattern in multiple consecutive frames, allowing the receiver to gain bit and byte synchronization. Once bit synchronization is gained, everything is done, from there on, on byte boundaries – SONET/SDH is byte synchronous, not bit synchronous.
An identical operation called descrambling is done at the receiver to retrieve the bits.
Scrambling is performed by XORing the data signal with a pseudo-random bit sequence generated by the scrambler polynomial indicated above. The scrambler is frame synchronous, which means that it starts every frame in the same state.
Descrambling is performed by the receiver by XORing the received signal with the same pseudo random bit sequence. Note that since the scrambler is frame synchronous, the receiver must have found the frame alignment before the signal can be descrambled. That is why the frame bytes(A1A2) are not scrambled.
References:http://www.electrosofts.com/sonet/scrambling.html