Abstract: A system for determining a data stream using a variable length window for sampling of erred bits in the data stream is disclosed. A threshold maximum-allowable error rate is selected; a first window length to comprise a data stream sample is selected; the data stream is monitored for errors during the given window length; the allowable error is compared to the total number of errors detected during the monitoring step; and, if the detected error is greater than the allowable error, the window length is reduced and monitoring is continued using the reduced window length, else monitoring continues over successive window length periods. A signal degrade or signal fail condition signal is generated if the window length reaches zero. The system can be utilized to implement an automatic protection switching system for a SONET network.