Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish multiplayer support #248

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from

Conversation

BernardoGomesNegri
Copy link

Allow multiplayer for more than 2 players by adding options to change MAC addresses and relevant documentation. Also add warning to not use VPNs or tunnels as well as copyright notices.
Changing MAC addresses can be done either through libretro usernames or dropping a text file on the "system" folder. Deriving MAC addresses from usernames is done with compiler-independent algorithms to guarantee portability.
Note that trying to run 3 instances of melonDS DS was too much for my CPU (on software renderer) and the game lagged too much that disconnects were frequent. I'd recommend using at least a second device to test 3 players so the CPU doesn't get overwhelmed trying to deal with both multiplayer and rendering.
With direct mode, things are a bit confusing as the DS thinks it's sending frames with a certain MAC address, but it's actually using your computer's MAC address instead. However, since direct mode is about Internet connection, it all works fine.
Should fix issues #246 #247 and #225

@JesseTG JesseTG self-assigned this Dec 29, 2024
@JesseTG JesseTG self-requested a review December 29, 2024 20:36
@JesseTG
Copy link
Owner

JesseTG commented Dec 30, 2024

Thank you so much! This week I'll do a code review and test it personally, then I'll get back to you with any notes I have.

@JesseTG JesseTG added bug Something isn't working lan For issues related to LAN-based netplay. (No, VPNs won't work. It really has to be a LAN.) labels Dec 30, 2024
Copy link
Owner

@JesseTG JesseTG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! There are some changes I'd like you to make. Once you do, I'll test the changes and get back to you with any additional feedback I have.

CHANGELOG.md Outdated Show resolved Hide resolved
LanMultiplayer.md Outdated Show resolved Hide resolved

Now, the Nintendo DS local Wi-Fi isn't the normal Wi-Fi in your house, it is a [mesh network that uses specialized hardware](https://melonds.kuribo64.net/comments.php?id=25). This means that games expect extremely low latency, which is achievable between two consoles directly connected with special hardware, but harder to achieve with two computers with a router in-between, and simply **impossible** to achieve through the Internet. **LAN multiplayer does not work through the Internet and neither with VPNs or tunnels such as Hamachi**. This is not something that can be fixed easily. **The only way to use emulated LAN Multiplayer is on an actual, low latency LAN connection**.

The latency requirements are so extreme that even in LAN, you might still have issues. If your sibling is watching Netflix and using the same router, it won't work. If the router is too far away, it won't work. If the router does not have a powerful enough CPU, it won't work. The recommended way to use the emulated Wi-Fi LAN connection is with a wired LAN connection between the computers.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests you've conducted so far...have they been in this kind of environment? When I tested your last PR, I did so with two Ethernet-connected devices on the same switch. Same network, but I don't think the packets have to go all the way to the router and back.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial tests were in localhost, with two instances of RetroArch on the same computer. When I confirmed that the basics were working, I tested extensively in a connection between my desktop computer (wired) and my phone (wireless, very close to router).
It worked but disconnects sometimes happened. Should I update this to say that the only way it works is with a wired connection?

LanMultiplayer.md Outdated Show resolved Hide resolved
src/libretro/config/constants.cpp Outdated Show resolved Hide resolved
src/libretro/config/constants.cpp Show resolved Hide resolved
src/libretro/config/definitions/network.hpp Show resolved Hide resolved
src/libretro/config/definitions/network.hpp Outdated Show resolved Hide resolved
LanMultiplayer.md Outdated Show resolved Hide resolved
@JesseTG
Copy link
Owner

JesseTG commented Jan 7, 2025

Looks good to me (minus some minor notes I just left), but before I merge this I'd like to build and test it myself. I should have a chance to do that tomorrow.

I'd also like to fix an unrelated bug in the build pipeline itself -- it turns out that PRs are being built against the wrong commit, and I didn't notice until I gave some poor bastard (what I thought was) a build of this PR to test!

Thanks for your hard work and your patience.

@JesseTG
Copy link
Owner

JesseTG commented Jan 14, 2025

I've tested this with Mario Kart DS on three simultaneous devices -- my desktop (Ethernet), my Steam Deck (Ethernet), and my brother's desktop (Wi-fi). Didn't manage to start a session. I'm gonna dig into this and figure out why.

Even once I do, I'll still need to think about the most sensible default behavior for picking a MAC address. There are two settings here that are important:

  • The system file mode (built-in vs. native)
  • The MAC address selection (existing vs. username-derived vs. loaded from file)

The problem here is twofold:

  • Some games like Pokemon use the MAC address to uniquely identify a DS and effectively restrict save data (and other features) to that console.
  • The built-in firmware uses a fixed MAC address. While changing this is easy, dealing with the consequences of doing so won't be.

This puts us in a bind:

  • If the default behavior is changed to use name-derived MAC addresses in the next release, then existing save data may break.
  • If the default behavior of using the existing LAN is preserved (as I requested), then LAN netplay becomes more complicated because everyone's gonna have to know which settings to fiddle with -- and their save data may still be jeopardized, depending on the game. And I'm the one who will have to deal with the influx of support requests!

I'm not going to ask you to change the default MAC selection behavior. For the purpose of this PR, it's fine. But we'll have to solve this problem (of reducing LAN netplay friction without breaking save data) before releasing 1.2.0.

The time for generalization has passed; I will need to investigate which exact games use the MAC address to restrict save data and wireless features (local and WFC) and how they do so.

But before that, I need to get this working with three players on my own network.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lan For issues related to LAN-based netplay. (No, VPNs won't work. It really has to be a LAN.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants