If current trends continue, the U.S. will reach its fifth anniversary in Iraq having suffered about 32,000 casualties (including 3,200 combat deaths). That's about a seventh of the losses suffered by the U.S. in Vietnam during the six years of most intense combat (1966-72). There were 2-3 times as many U.S. troops in Vietnam.
As in Iraq, the U.S. broke the back of the guerilla force (the communist Viet Cong) after five years of effort. But the last gasp 1968 Tet Offensive, launched by the Viet Cong and their North Vietnam allies in a desperate attempt to reverse their slide, ended up destroying the Viet Cong as a viable organization.
But the U.S. media didn't understand what was going on, and declared Tet a communist victory. U.S. public opinion had turned against the Vietnam effort, and wanted the troops out no matter what. Most troops were gone by 1970, and all were out by 1972.
In that year, North Vietnam violated the peace deal it had agreed to, and attempted to conquer South Vietnam with a conventional invasion. That was repulsed. Another was tried in 1975, which succeeded. By then, the U.S. had cut off nearly all military aid to South Vietnam, and the subsequent weapons and ammunition shortages played a large part in the South Vietnamese defeat.
Iraq has no neighbors ready to invade right now. The main problems are internal, mainly corruption and armed factions of various persuasions (religious, ethnic and tribal) that feel they are above the law.
Currently, the Iraqi government is seeking a security deal with the U.S. similar to what NATO, Saudi Arabia, Kuwait, Bahrain, Japan and South Korea (and many other nations) have. That is, a small number of American troops stationed in the country, as a guarantee that hostile neighbors (especially Iran, but potentially Turkey as well) will not attack. Any such attack would kill some U.S. troops, and likely trigger an American military response.