Very simple : be sweeping it.
When the initial contact is made between the modem and the DSLAM ( the central office : Digital Subscriber Line Access Multiplexer) there is a period of training. The modem sends a 'medley'.
ADSLl uses a QAM (quadrature modulation : phase and amplitude) signal on individual carriers . This is called DMT : Discrete Multi-Tone
You need to think of the DSL signal as a number of carrier waves that each carry up to 4 bits of information. These are spaced apart in the available bandwidth.
The modem sends a pure sinewave carrier by carrier. the DSLAM takes a measurement of the amplitude and distortion and reports a signal back : Up or Down. ( meaning : we get too much power , or not enough power for this 'tone')
Once this is established the modem knows what the gain setting needs to be , per tone, in the spectrum. Since a phone line is a static element this will not change for the lifetime of the cable. So it only needs to be done whenever there was a power loss , or you unplugged the modem from the line .
And then we start transmitting .
If we get bit errors these are cause by temporary disturbances in the spectrum. For example if the neighbours pimply-faced kid takes his , badly dampened, dirt bike out and goes pweeeeeeeee. : that shows up as error in specific channels (base + some harmonics )
That is seen as channel errors. Feedback tells the modem : this channel gets a lot of errors : drop from 8 to 4 or 2 bits or stop using this channel and use an alternate ( only 192 of the 256 are in use. the rest are 'spares' to be able to hop around 'bad' channels.
Depending on where you live some channels may always be bad due to noise sources. In that case we permanently allocates some of the spares.