In Ad hoc networks every node plays an important part in the transmission of packets from sender to receiver. Most of the time packet delivery ratio of these networks depends on the behavior of intermediate nodes. Sometimes these intermediate nodes cooperate and forward the packets of their neighbor and some time they simply drop their packets and cheat their neighbors. We present a solution that not only detect these selfish nodes but also punish these nodes so that they avoid such misbehavior in future. To this account, we use an agent "Neighbor Monitor", running on every node, to monitor the traffic of neighbors and assign a value called "Reputation Index", associated with each node, based on its behavior.