Open Phanjam opened 4 months ago
Hi @Phanjam,
I'm glad to hear that my tool is helping someone else. I'm happy to answer your questions and hope it will assist gamers in playing old games, not just Torchlight 2. I'll start by explaining how Torchlight 2 works on LAN, followed by a description of how my tool operates.
From the player's perspective, a host creates a room on LAN, and other clients find and join the room. You may wonder how this actually works. After some exploration (which I will explain later), I figured out the method Torchlight 2 uses for room discovery on LAN.
Torchlight 2 uses UDP port 4549 for LAN game connection. Once a Torchlight 2 game is hosted on LAN, it starts broadcasting its room information (e.g., the room name) to other computers on LAN (destination IP = 255.255.255.255
). When a client receives this broadcast, the room appears in the Torchlight 2 LAN game room list. The player can then click the connect button, and the game handles the rest.
Specifically, the host will broadcast the 'room information' message to 255.255.255.255
under the following conditions:
A client can broadcast a 'room request' message (length = 18) on the LAN to request room information from the host. The client will broadcast a 'room request' message if:
If the room information message is not correctly delivered from host to client, the client will not be able to find the room and establish a connection with the host. The primary reason preventing clients from receiving the message is that, during the room discovery stage, all network messages are sent to the ambiguous broadcast IP 255.255.255.255
instead of direct IPs. The broadcast message may fail to pass through the VLAN due to the following reasons:
To ensure the 'room information' message is delivered from host to client, my tool operates as follows:
Please note:
Zerotier allows broadcast messages, but users may still encounter issues due to network priority. To check the network priority, a user can open cmd.exe
and type route print
. For the destination 255.255.255.255
, there might be multiple entries. The broadcast message will be sent to the interface with the lowest Metric
(hops). If that interface isn't the Zerotier network, the broadcast message won't be delivered correctly.
To fix this, one way is to use my tool. The other way is to modify the network metric. Here’s how:
By setting the Zerotier network to the lowest metric, it will become the preferred network for broadcast messages, ensuring they pass through successfully.
In this section, I'll briefly explain how I figured out the Torchlight 2 LAN game room discovery mechanism. Although different games have unique network discovery methods, I hope this provides some inspiration for other players of older games.
cmd.exe
and combine the commands tasklist
, netstat -nao
, and findstr
to find the process ID and network port that Torchlight 2 uses. I discovered that when I created a LAN game, UDP port 4549 was always occupied.Wireshark
to monitor and analyze network packets. Set the filter condition to udp.port == 4549
to inspect packets related to the LAN game. Don't forget to interact with the game to observe changes in the network traffic.BTW, I'm not a professional network programmer. I developed this tool as a practice exercise in network knowledge. It's not very difficult, and I believe anyone can learn and develop a tool like this.
Hello Huaijun Jiang.
This is not really an issue - it's just a request for more information about your tool, so I hope you don't mind I opened this issue. Please feel free to delete it if you would rather not have a discussion.
You already know that gamers who want to play multiplayer Torchlight 2 are always having trouble making and keeping a good connection with other clients. This tool of yours looks like a solution for those troubles (actually, it looks like a gift from heaven!), but I'm not a programmer and I don't know anything about net coding for internet co-operative games, so I'm not sure how to describe it correctly to other players.
My request is if you could please describe with more detail how your tool works. If you can also mention why it works, that would be so great. Like, what the problems were with the old code, and how your tool addresses those problems.
Thank you for making this tool for Torchlight 2!