Whenever a network is created using NS-2 simulator, an
advanced version of AODV is applied first to remove the
malicious nodes causing Grayhole and Blackhole attack. Then
the nodes are arranged in a spanning tree topology. Once the
network is created, communication occurs only among
authenticated neighbours. Further RSA key exchange is
applied before encryption and decryption of messages. To
improve security, encryption has been done twice. It ensures
forward and backward secrecy. Whenever the topology
change, the new neighborhood key is calculated and is given
to all authenticated neighbours.