In today's era security is one of the main concerns in every field particularly in wireless sensor networks. Resource limitation is a main concern of sensor nodes in wireless sensor networks. There are many security threats which are affecting the functionality, security and network life time of wireless sensor networks. Our goal is to create an IDS such that the throughput of the system must be efficiently increased and PDR must be improved. The constraint of the system with our protection scheme must be comparable with the system without having any attack. We implement two algorithms simultaneously to detect the nodes which are acting as true nodes and fake other true nodes to be misbehaving.