In this method attacker node have the the lowest trust value compared to other routers. The trust value given below is also called direct trust value.
C++ part :
Trust_Value[node] = forward count of data packet [node]/ received count of data packet [node]
Result :
Node 2 received_count 2 time 3.000000
Node 2 forward_count 2 time 3.016306
Node 4 received_count 2 time 3.023276
Node 4 forward_count 2 time 3.023276
Node 2 received_count 3 time 4.000000
Node 2 forward_count 3 time 4.000000
Node 4 received_count 3 time 4.006017
Node 4 forward_count 3 time 4.006017
Node 2 received_count 4 time 5.000000
Node 2 forward_count 4 time 5.000000
Node 4 received_count 4 time 5.005557
Node 4 forward_count 4 time 5.005557
Node 2 received_count 5 time 6.000000
Node 2 forward_count 5 time 6.000000
Node 4 received_count 5 time 6.005777
Node 4 forward_count 5 time 6.005777
Node 2 received_count 6 time 7.000000
Node 2 forward_count 6 time 7.000000
Node 4 received_count 6 time 7.005497
Node 4 forward_count 6 time 7.005497
Node 2 received_count 7 time 8.000000
Node 2 forward_count 7 time 8.000000
Node 4 received_count 7 time 8.005717
Node 4 forward_count 7 time 8.005717
Node 2 received_count 8 time 9.000000
Node 2 forward_count 8 time 9.000000
Node 4 received_count 8 time 9.005737
Node 4 forward_count 8 time 9.005737