How does an ultrasonic distance sensor work?
Some US sensors send a continuous sinus signal, that is therefore reflected and received by US sensor. Due to the fact, that signal needs some time to travel, the received sinus will be phase-shifted. 



Consider red sine wave as transmitted signal and blue sine wave as received. They are shifted related to each other.
This phase-shift can be computed using autocorrelation.

Other sensors may send single pulses and then calculate the difference between transmitted and received time. Then the distance can be computed as follows:



where v is the speed of sound. Computed distance is divided by  2 because the sound had to travel from the sensor to the object and then back from the object to the sensor.