Ad hoc networks are a new paradigm of wireless communication for mobile hosts. Security is an important issue for ad hoc networks, especially for those security-sensitive applications. The salient features of ad hoc networks pose both challenges and opportunities in achieving security goals. One such goal is to consider not only malicious attacks launched from outside a network, but also take into account the attacks from within the network by compromised nodes. Various ways are possible to overcome vulnerabilities in Wireless Ad hoc Networks from attacks and threats. One of the most widely used solution is designing an intrusion detection system (IDS) that suites the security needs and characteristics of ad hoc networks for effective and efficient performance against intrusions. This paper investigates the serious and harmful attack, "denial of service" (DoS) that exhibit in multiple forms across different layers of protocol stack. To defend against this attack, we propose a novel approach "cross layer based intrusion detection system"(CIDS) that performs accurate diagnosis of malicious attacks by analyzing the pattern of trace files, overcome the demerits such as false positives present in traditional IDS, thereby providing secure communication between nodes that communicate with each other to route the traffic from source to destination and also increase the efficiency of the network performance. The simulations conducted in ns2 and proved that our work achieved high performance with fewer overheads.