Back Multiplayer guides
Networking Explained7 min

How LAN Multiplayer Works: UDP Broadcasts, Layer 2 Broadcast Domains, and Virtual LAN Encapsulation

Explore how LAN game rooms are discovered: UDP broadcasts and subnet masks, broadcast-storm isolation by Layer 3 routers, TAP/TUN virtual adapter encapsulation, and P2P NAT traversal for remote players.

In multiplayer games, a LAN Game offers a zero-latency experience without relying on centralized third-party matchmaking servers. Yet many players wonder: why can you find a room instantly behind the same router? Why does switching Wi-Fi networks or crossing the Internet prevent a room from appearing in the lobby, even when you know its IP address? Starting with low-level computer networking protocols, this article explains how LAN room discovery and virtual networking work.


1. The Core of LAN Room Discovery: UDP Limited Broadcasts

When creating a room, traditional LAN games, including Counter-Strike 1.6, Red Alert 2, Warcraft III, and Minecraft with Open to LAN enabled, do not know the specific IP addresses of receivers on the local network.

To let other players discover the room, the host client sends UDP broadcast packets onto the network:

  • Destination IP address: 255.255.255.255, the limited broadcast address, or the current subnet's directed broadcast address, such as 192.168.1.255.
  • Destination MAC address: The Layer 2 Ethernet broadcast address FF:FF:FF:FF:FF:FF.
  • Protocol and port: Usually the connectionless, low-overhead UDP protocol, such as Minecraft's default broadcast port UDP 4445 or Warcraft III's UDP 6112.

When a switch, a Layer 2 network device, receives a broadcast frame, it performs flooding: it copies and forwards the frame indiscriminately to every physical port in the same VLAN or on the same switch. Other computers' adapters on the LAN receive the frame, decapsulate it, and pass it to the game process above. The game list then displays the host's nickname, map, and port information in real time.


2. Why Can't LAN Broadcasts Cross the Internet?

If broadcasting solves device discovery, why can't it be used to find friends directly across the Internet?

1. Broadcast Domain Isolation by Layer 3 Routers

One of Ethernet's design principles is that routers, which are Layer 3 devices, block all Layer 2 broadcast frames and 255.255.255.255 packets by default.

If core Internet routers allowed broadcast packets through, broadcasts sent by billions of connected devices worldwide would rapidly cause broadcast storms, exhausting backbone bandwidth and router CPU queues. A router's physical interfaces therefore form absolute boundaries for broadcast domains.

2. The NAT Barrier

Home routers generally use Network Address Translation (NAT) to share a single public IPv4 address. External devices can only see the router's public-facing IP address. They cannot proactively cross its NAT table to probe a particular internal host's random high-numbered ports.


3. How Virtual LAN (VLAN) Tools Work Underneath

To let players thousands of miles apart connect as though they were sitting in the same Internet café, virtual LAN tools, such as early Hamachi, Radmin VPN, and modern LanGame OS Orbit, build an overlay network between the operating system and the network protocol stack:

JSON
[ Game application ] (Sends a UDP broadcast: 255.255.255.255)
     ↓
[ Virtual adapter (TAP Driver) ] (Captures the original Layer 2 Ethernet frame)
     ↓
[ Networking engine (P2P Client) ] (Encrypts and encapsulates it in a public-network unicast UDP packet)
     ↓
[ Public-network transport (STUN/ICE traversal tunnel) ]
     ↓
[ Remote virtual adapter ] (Decrypts and unpacks the packet, restoring the original broadcast frame)
     ↓
[ Friend's game application ] (Successfully discovers the room in the lobby list)

1. The TAP Virtual Adapter Driver

The networking tool installs a virtual network adapter, or TAP adapter, inside the operating system. The game application passes broadcast data to the OS protocol stack, which routes the frame to the virtual adapter driver according to its routing table and interface metrics.

2. Packet Encapsulation and Tunneling

The virtual adapter has no physical cable. Instead, it connects to a P2P networking daemon running in the background. The daemon takes the intercepted Layer 2 frame as its payload, adds an outer public-network UDP header, and sends it by targeted unicast to your friend's public IP through a P2P traversal tunnel established beforehand using STUN/TURN/ICE protocols.

3. Remote Reconstruction and Layer 2 Reinjection

When the daemon on your friend's computer receives the public-network UDP packet, it removes the outer header, extracts the original LAN broadcast packet, and injects it directly into the friend's virtual adapter. The friend's game process is unaware of the tunneling. It simply sees that the virtual adapter has received a local broadcast, allowing it to display the remote room in the lobby.


4. The Evolution of Modern Multiplayer Architecture

As modern network security standards advance, multiplayer solutions are gradually evolving:

  1. Compatibility with older games: These games depend heavily on Layer 2 Ethernet multicast and broadcast traffic, requiring TAP drivers to capture broadcast packets;
  2. Direct connections to modern dedicated servers: Modern independent games, such as Palworld and V Rising, have shifted fully to unicast IP:Port connections or official relay codes. They no longer rely on broadcast discovery, significantly improving network stability and resilience to packet loss.