In the last few years, peer-to-peer networks have become important very rapidly. Thankfully for this technology, the Internet has turned into a real multimedia network. However, because of the short history of the peer-to-peer technology, the existent systems are not enough accomplished yet. By way of illustration, they induce heavy traffic on the physical network. The efficiency of the peer-to-peer networks could be improved through controlling the topology. Mobile agents can provide a nice distributed solution to this problem, while keeping the original advantages of the P2P networks, e.g. robustness and scalability. This work introduces the details of the used algorithms and the implementations. By means of the measurements on our special testbed we present how much the efficiency can be improved.