Intrusion Detection for Defense at the MAC and Routing Layers of Wireless Networks