Ultrasonic distance sensor measures distance by sending ultrasound (40 kHz) and this ultrasound will bounce off the obstacle and return to the sensor.
Distance is measured by time it takes the ultrasound to travel from the sensor and back to the sensor.