All wars progress according to a logic, a pattern of cause and effect. Because of high emotions, that logic is not always clear at the time. But the victor is the one who understands the logic and uses it. For this war, the goal should be ending the use of terror against America. Winning the war — getting the logic right — will require patience, perseverance, planning and a steely resolve.Security of our homeland flows from a strategic cycle of events. Our preference is deterrence, but this takes time. Enemies are deterred when they believe their efforts will fail at a price too high to pay. But this mind-set is the cumulative result of all our actions over time. Once we have failed to instill fear of failure and punishment, we will have to work through the entire cycle before restoring it. There are no shortcuts. We can restore deterrence, but we will have to be patient and persevere.When deterrence fails, we turn to prevention. This is the sum of all the actions, small and large, that prevent or mitigate an attack. Our nation is huge and complex. A suicide attack will always find some vulnerability, but preventative efforts — from airports checks to arms control agreements to active defense systems — can minimize the damage. Prevention failed in Boston and Newark and Dulles. The cost of improving it nationwide will be high, and the system will never be perfect. But we can improve it, if we work the problem at every level from local to national. Again, we will have to show patience and perseverance.If our intelligence is good enough and if we are convinced that attack is imminent, we can pre-empt. But this is dangerous stuff. Pre-emption is hard. Some missions will fail. Some soldiers will die. Some counterstrikes against us will be planned. Some in the court of world opinion will disapprove. Pre-emption can be effective, but it will be expensive and it will take time to equip and improve our forces. And it will cause a hue and cry abroad. The ability to pre-empt with confidence is not achieved overnight. We must persevere.Because our previous actions fell short in these three areas, deterring or preventing another attack will depend upon what we do next.We are almost done with Step 4, crisis response. This began the moment we received a credible threat of attack, and will continue until we are sure this wave of destruction is over. Division of labor is important: Local agencies address local problems, while federal agencies focus on national threats. Considering the unprecedented scale of the attacks, we actually did pretty well. Buildings were evacuated, traffic was no worse than in a major snowstorm, emergency services responded well, elected officials at national, state and local level remained in control. But we should not be complacent; the attacks might not be over. We don't know, for example, if a biological attack took place at the same time as the air attacks — and we won't know for weeks. We must persevere in our determination to work through this crisis.The same is true of consequence management. This will be really hard. It will take days to evacuate the dead and wounded, weeks to clean up the sites, and years to rebuild the damage to our facilities, our economy and our psyche. Again, state and local agencies will take the local lead, while federal agencies deal with national issues like restoring the economic and transportation systems. Opening the cities and restoring "almost-normal" life are essential to show attackers that they failed. We are not as ready for this as we should be. New organizations, training and doctrine are required. But given what we had to work with this time, so far, so good — although perseverance through the hardest part is still to come.The next step, attribution, is the key to direct action against the murdering criminals who attacked us. Every resource of our intelligence and criminal justice systems and all we can borrow from our friends and allies needs to be dedicated to the search. The case does not have to be perfect, but it must be good enough for a conviction in the court of public opinion. To win this war, we must win the moral battle, and that means gathering evidence and making it public. Fortunately, this type of investigation is exactly what the FBI does best. The situation could be worse. With biological, or radiological, or cyber attacks it would be. But this time, we can succeed at attribution if we persevere.Which brings us to the president's toughest decision: retaliation. Getting this right in order to deter and prevent future attacks will require careful planning and a steely resolve. We must resist the passionate calls for widespread revenge or a declaration of war, which would give our enemies a moral and a legal standing they do not deserve. And we must resist weak pleas for understanding and negotiation.We must not be partisan or chase personalities — this must not degenerate into Bush vs. bin Laden. Instead, we must focus relentlessly on exactly what we want to achieve — destroying the terrorist network that attacked us and deterring terrorism itself.The president (with Congress in agreement) will have to decide whether this means "bringing the individuals to justice" — with its time-consuming legal mechanisms and danger of further attacks during trial and imprisonment — or the more satisfying but less accepted approach of treating them as military targets.Either way, planning will have to be detailed and precise, and the nation resolute in pressing home the attack. We must get retribution right to revive deterrence, or we will never be secure again.There is no shortcut through this cycle. If we want peace in the future, then we must work our way through the logic of homeland security to get there. This devastating attack on defenseless men and women may seem an act of madness, but it was not. It was logical and calculating. If we are to win this shadowy war and secure our homeland in the future, then our response must be logical as well.Mr. McIntyre., a retired military officer and former dean of the National War College, is the deputy director for research of the ANSER Institute for Homeland Security.