The internet of things (IoT) is vulnerable to attacks due to its unique characteristics and numerous limitations, and it is highly prone to attack due to sensitive applications. Most of these attacks are aimed at routing and data transmission (which are the most vital pillars of IoT). So far, many research studies have been proposed to improve the security of routing and data transmission, and most of these methods have been developed based on trust models. Trust models are considered as a powerful and complementary tool for security systems that provide the ability to detect malicious nodes. However, most of these researches to advance their goals are only focused on examining the behavior of nodes during data transmission, and based on this, the trust value of nodes is calculated. This way of assessing trust is not enough due to the widespread attacks of malicious nodes. In this paper, a reliable routing method based on the optimization of IPv6 routing protocol for low power and lossy networks (RPL) routing protocol and trust models is introduced called TARRP (Trust Aware RPL Routing Protocol). TARRP is a two-step method in which the purpose of the first stage is to create a trusty and reliable topology. The second stage is to assess the trust and identify malicious nodes. In addition to implementing trust, TARRP also manages related recommendations and attacks. The results of simulations using cooja in different scenarios showed the superiority of TARRP in improving routing trust and data exchange compared to previous work.