Prevention of denial of service attacks and selfishness in mobile ad hoc networks