Abstract. In peer-to-peer (P2P) overlay networks, the mechanism of a peer randomly joining and leaving a network, causes a topology mismatch between the overlay and the underlying physical topology. This causes a large volume of redundant traffic in the underlying physical network as well as an extra delay in message delivery in the overlay network. Topology mismatch occurs because overlay networks are not aware of their underlying physical networks. In this paper we present a mathematical model for topology awareness of overlay networks (degree of matching between an overlay and its underlying physical network) and the efficiency of message delivery on them. We also after determining the computational complexity of the model, propose an optimization heuristic algorithm to increase topology awareness of P2P overlay networks. Then we present the results of running the algorithm on different kinds of random graphs and show, how we can implement the algorithm over P2P networks.