Interactive echo ranging
Echo Depth Sounder
Ping the medium. Watch the pulse travel down, bounce off the target, and come back. The time it took, halved and multiplied by the speed of sound in that medium, gives you the depth. Same trick used the deck of a 1912 liner, in a bat's mouth, and inside a modern probe.
Depth is the target's real distance. The computed depth is what the sounder reports from the round-trip time. Change the speed and the same time returns a different depth. Sonar and ultrasound both depend on knowing the medium.
The 13 microseconds rule
Sound in soft tissue travels at roughly 1540 m/s. Convert that to microseconds per centimeter and you get a round trip of about 13 microseconds per centimeter of depth. Ultrasound machines assume that number as a constant. When an echo comes back 65 microseconds after a pulse leaves, the machine draws that reflector at 5 cm.
Sonar does the same job in seawater, and echolocation does it in air. The medium changes the speed, the geometry stays. That is why the same idea reaches from a shipyard hydrophone to a probe pressed on skin.