Ad Hoc self-organizing networks, whose shortened form is Ad Hoc, is a temporary, multi-hop and self-governing distributed control network without basic network equipments and a center node, which is composed of mobile nodes with wireless network interface. Network topology change optionally and nodes in Ad Hoc also can move optionally.None center nodes and low computing ability of nodes make traditional mechanism of encryption and authentication not implement. The changes of topology, node number, trust relations and data engendered and transmitted in network, let network safe scheme, which is configured statically, including database and file system, not be applicable again. Traditional firewall can’t dispose because of blurry network boundary. Therefore, Ad Hoc security has become a hot research point.Network Intrusion detection, including misapplication detection and anomaly detection, can recognize the attacks which attempt to happen, are happening or have happened, and it is a kind of active network security protection measure. The most existing intrusion detection technologies have the deficiency of high false positive rate and negative rate, and poor real-time performance. Especially, high detection accuracy is usually based on abundant or self-contained training data.In this dissertation, Ad Hoc network key technologies and security requirements are firstly expounded. Then, PSO algorithm and QPSO algorithm are systematically introduced.Ch.4 introduced the application of K-Means clustering algorithm and QPSO algorithm in Ad Hoc anomaly detection.