A method including determining, by a first device in communication with a second device in a mesh network, an optimal midpath node to be utilized for communicating meshnet data between the first device and the second device; transmitting, by the first device to the second device, coordination information including identification information that identifies the optimal midpath node and timing information that indicates a time associated with connecting with the optimal midpath node; receiving, by the second device, the coordination information; and transmitting, by the first device and the second device, connection information to connect with the optimal midpath node based at least in part on utilizing the identification information and the timing information. Various other aspects are contemplated.