This tactic only really works during peace time. The main strategy relies on the fact that the US (or whoever) isn't willing to shoot on sight. The swarm might well be able to get a good shot or two in but that would be the end of it.
Once a war is going on the you can move to a much more aggressive strategy. The US can just declare that any boats within a certain region are subject to summary attack and all shipping should steer clear. Attack aircraft can start sinking these small boats as soon as they leave harbour (or most likely cruise missiles blow them up at anchor).
I think this also is subject to the fact that today the US navy has not entered any area in force on a wartime footing. You can't just go around with your Phalanx armed if there might be anything non-hostile around you today (be it just an oil tanker of your foe - the PR by causing a massive oil spill is horrendous). A phalanx (or probably the 25mm cannons on the newest Arleigh-Burke destroyers) will quickly tear your swarm to pieces.
In the limit, we get rid of navies and stick swarms of drones in 40-ft shipping containers, and then just sail container ships with 10K+ drones aboard around.
Presumably on slow high-flying drones (think like a U-2) or on a balloon. For drones that go under 30 mph you can actually solar-power them, letting them stay aloft indefinitely.
I'd expect to see a shift toward more visual and IR sensors as well, to combat stealth technologies. Modern ultra-HD cameras + image recognition algorithms are a lot more sensitive than human eyes are, and you can field many more drones than AWACS aircraft with much less cost of a loss, letting you bring the relevant detection platforms in closer.
Visual and IR sensors don't work well in bad weather. Modern cameras have superior resolution to human eyes but dynamic range is still worse. Solar powered drones don't have the power or payload to handle useful radars. For that mission you need something like an RQ-4, which is roughly equivalent to a U-2 in performance and just as expensive.
Navies have had a counter tactic to attack by swarms of small fast boats since the beginning of the 20th century. The boats would be ripped to shreds in seconds by small calibre guns.
This fact has always nagged me in context of the breathless stories about the "war game in Persian Gulf" and IRGCs swarm of speedboats. The story of the famous war game is repeatedly mentioned (even here on HN) but rarely the facts intrude to deflate the (imo) implied message: "this is why we haven't done anything about IRI in the past 40 years." This also lets IRI push ridiculous propaganda on Iranians showing them boats circling a mock aircraft carrier. Are IQs really dropping globally?
Sometimes I swear there is a pas de deux going on between these apparent enemies.
https://gcaptain.com/can-u-s-navy-defeat-swarm-attacks/