ABSTRACT:The standard MAC protocol widely used for Mobile Adhoc Networks (MANETs) is IEEE 802.11.When attacks in MAC layer are left as such without paying attention, it could possibly disturb channel access and consequently may cause wastage of resources in terms of bandwidth and power. In this paper, a swarm based detection and defense technique is proposed for routing and MAC layer attacks in MANET. Using forward and backward ants, the technique obtains mean value of nodes between the first received RREQ and RREP packets. Based on this estimation, the source node decides the node as valid or malicious. Moreover the MAC layer parameters namely number of neighbors identified by the MAC layer, number of neighbors identified by the routing layer, the number of recent MAC receptions and the number of recent routing protocol receptions are used to determine the node state. The source node uses these two node state estimation techniques to construct the reliable path to the destination. This proposed technique improves the network performance and at the same time prevents attackers intelligently.