A hidden Markov model based intrusion detection system for wireless sensor networks