The exposure of IoT nodes to the internet makes them vulnerable to malicious attacks and failures. These failures affect the survivability, integrity, and connectivity of the network. Thus the detection and elimination of attacks in a timely manner become an important factor to maintain the network connectivity. Trust-based techniques are used in understanding the behavior of nodes in the network. Several researchers have proposed conventional trust models that are power-hungry and demand large storage space. Succeeding this Hidden Markov Models have also been developed to calculate trust but the survivability of network achieved from them is low. To improve the survivability selfish and malicious nodes present in the network are required to be treated separately. Hence, an improved Hidden Markov Trust (HMT) Model is developed in this paper which accurately detects the selfish and malicious nodes that illegally intercept the network. An algorithm is generalized for learning the behavior of nodes using the HMT model with the expected output. The evaluated node's likelihood functions differentiate the selfish node from the malicious node and provide independent timely treatment to both types of nodes. Further, comparative analysis for attacks such as black-hole, grey-hole, and sink-hole has been done and performance parameters have been extended to survivability-rate, power-consumption, delay, and false-alarm-rate, for different networks sizes and vulnerability. Simulation result provides a 10% higher PDR, 29% lower overhead, and 15% higher detection rate when compared to FUCEM, FTCSPM, and OADM trust models presented in the literature.