networkinglannatlocal-network

a mechanism or protocol for a connection between nodes behind the NAT of the same public IP to switch to a local connection


Is there a mechanism or protocol for a TCP connection, or more fundamentally a UDP or IP communication session, between nodes behind the NAT of the same public IP, to discover the fact that the are in the same LAN and then switch to a shorter and faster local connection? If so, what is it?

I have tested several video/voice chatting apps and remote desktop apps. For some of them, if you cut the Internet connection, the chatting or RD session continues to work, while for some others it just stops working. The lag is very little and it doesn't feel like there is a relay server, so I assume for all of them they use a direct connection between the 2 nodes and the difference is that some of them use local connections and some others use public connections. However my assumption might be wrong. So I am wondering how this works and if I want to create an app to support this (automatically detect if 2 nodes are in the same LAN and switch to a local connection if possible) how I am going to do this.

I am a rookie in computer networks, so excuse me if there are any amateur expressions.


Solution

  • The protocol LSD (Local Service Discovery) will meet your demand. You can first use this protocol to find neighbor peers in LAN, and then use some other protocols like DHT to find peers which are not in the LAN.