Commercial time-of-flight (TOF) ultrasonic flowmeters are rapidly expanding in the general industry. Among the different techniques that can be applied to determine the TOF of ultrasonic waves, the cross-correlation method presents numerous advantages, such as robustness for weak signals and noise suppression. However, the selection of an appropriate reference wave is presumably a key element in the precise measurement of TOF. In the present paper, an algorithm to compute an accurate TOF is proposed. The form of the electric signal received by the transducer is obtained from an acoustically-forced underdamped oscillator model, and the analytical solution of the model is proposed as a reference wave. In order to validate the effectiveness of this procedure, an ultrasonic flowmeter system is designed and tested in a flowmeter calibration test rig. It is demonstrated that the use of the presented scheme overcome the average method limitations, and turns out to be a convenient solution in a wide range of conditions. Robust measurements of near-zero flow values are acquired, which allow the achievement of a high dynamic range. The error curve of the proposed system have been obtained, revealing that the absolute value of the relative errors are lower than 2% within all the spectrum of flow rates considered (from 0.2 to 150 m 3 /h). Results demonstrate that the algorithm provides high-precision measurements within a wide dynamic range. The algorithm is portable and versatile: it can be adapted to different types of transducers without the need of additional measurements, allowing to adjust parameters on-the-fly for an optimal performance of the ultrasonic flowmeter system.