The continued success of diesel electric subs against modern warships, even those with well trained crews and good ASW (anti-submarine warfare) equipment, makes one wonder how one can protect major surface ships (like aircraft carriers.) These subs have been able to get within torpedo range (less than 20 kilometers). Get even closer (under 10 kilometers), and you can launch torpedoes at their highest speed, making detection and use of torpedo decoys less likely to succeed. The basic problem here is the need to find out when these very quiet boats are headed your way.
The best defense, then, is the search for the subs before your surface ships are located by the subs. Diesel electric subs spend most of their time on the surface, or near it (with just an exhaust device above the water, to let air in and diesel exhausts out). When on or near the surface, these boats can be much more easily detected from the air. Diesel Electric boats are also quite vulnerable when still in port, and any foe would strive to use bombs or missiles to destroy these subs before they can put to sea. This is when the subs are most vulnerable, and training exercises demonstrate this so frequently, that ASW training instead concentrates on the hard part, finding a submerged sub that is stalking surface ships.
If you know, or suspect, that a sub is headed your way, there are a number of new techniques that can even the odds. For example, there are new types of sonobuoys (dropped from helicopters or patrol aircraft) that don't just use sonar (active or passive) but sense other things (light or the presence of metal). The U.S. Navy has been putting a lot of money and effort into new sonobuoy designs, and finding new ways to detect quiet diesel electric subs moving underwater on electric power.
Even more dangerous submarines are those using a non-nuclear AIP (air independent propulsion) system. This enables the sub to stay under longer, thus making the sub much harder to find. AIP allows the sub to travel under water for at least 4-5 days (and sometimes weeks) at low speed (5-10 kilometers an hour). While nuclear subs also have AIP, their nuclear power plant is noisier, and the subs are larger. Both of these elements make nuclear boats easier (but not very easy) to detect. Some of the newer AIP designs allow boats to stay under for several weeks. If such boats are equipped with good (and very expensive) passive (silent) sensors, they can be the most difficult subs to detect.
No one is issuing any press releases on how research in ASW (Anti-Submarine Warfare) is going. But the surface warfare people are taking it very seriously, if only because the submarine community keeps putting on demonstrations of how close they can get to the big surface ships, without being detected.