The speed of sound in the ocean varies with depth, but with a twist. And in that twist the United States Navy held a three decade technical lead in submarine detection.
The scenario, below, presents a case where a submarine is emitting a sound. It is immersed in a liquid that is layered with denser water above and below a region known as the SOFAR Channel. The submarine is in the top, dense layer. Within the graphic, the SOFAR Channel is the light blue layer with the converging strong lines of sound from the submarine. Note the shape of the lines are not straight lines. They bend due to the variation in water density like a lens. Within this channel, sound will propagate with far less attenuation (fading), and travel many hundreds of miles to remote detectors.
There are a number of dashed rays of sound that encounter loss in reflection from the bottom, or are situated along a path that does not lead into the interior of the SOFAR Channel.
For those who want actual numbers, the speed of sound varies in the following manner: