The US cause was doomed because there was LACK OF A CLEAR MILITARY MISSION AND STRATEGY , JUST LIKE IN AFGHANISTAN.
In Vietnam the right course should have been to overrun North Vietnam , the centre of gravity , just like in Afghanistan now the centre of gravity of the insurgents is in Pakistan.
US Goverment did not have the strategic resolution to go inside North Vietnam just like US lacks guts to go inside Pakistan.
A solution was possible if fire and sword had been carried inside Vietnam.
Where there are two extremely different types of war being waged the state actor supporting the non state actor has to be overrun and here international law should be trampled.In any case moralists will find everything immoral in USAs conduct of war . So why bother about morality !
In Afghan war if the USSR had just overrun parts of Pakistan or helped India do so Afghan war would have been a USSR success story.
Even in case of Iran the US has to physically overrun Iran in case it has to be nuclearised.It is entirely feasible to overrun Iran via Afghanistan.The war can be made cheaper by promising Pashtun Afghans all to take home in booty that they can carry be it fixed material or human assets.
It is important to forget about morality and do this or when the US withdraws the other side will proclaim it as a great victory of Islam ( real BS claim but one in which the nuts will believe)
Lastly the US media was greatest enemy of US war in Vietnam.I think since Vietnam US government has learned tricks to control the media.