This paper presents a two-terminal traveling-wave-based protection algorithm applied to non-homogeneous transmission lines comprising any number of sections with different topologies and considering the effect of the sampling rate. Existing two-terminal traveling wave protection functions cannot protect the line under close-in faults and present limitations in non-homogeneous transmission lines. However, the effects of the sampling rate, considered in the proposed method, result in well-defined protection and unprotected zones, essential for protection security and coordination to deal with the issue of close-in faults in non-homogeneous transmission lines. Furthermore, the algorithm can accurately detect the faulted section, allowing its use in advanced protection functions such as adaptive automatic auto-reclosing and high-speed protection schemes. A protection device was modeled considering a sampling frequency equal to 1 MHz, including functions to detect traveling waves via wavelet transform, and the proposed protection algorithm to discriminate line internal from external faults, and to select the faulted section. The algorithm was evaluated using a large number of ATP fault simulations. The results show that the algorithm is robust and reliable for protection devices installed in non-homogeneous lines.