Views: 262,382 Homepage | Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search 09-26-18 02:57 AM
Guest:

0 users reading How do I do multiplayer? | 1 bot

Main - General - How do I do multiplayer? New reply


Videogamer555
Posted on 09-08-18 12:40 AM Link | #661
I see there is only one setting relating to network multiplayer, and it says "Wifi: bind socket to any address". There's no setting in the emulator that lets me connect to any other running emulators. Please tell me how to use this feature. I want to have 2 instances of the emulator running on my PC, and establish a link between them, so that I can play multiplayer games.

StapleButter
Posted on 09-08-18 06:23 AM Link | #662
Posted by Videogamer555
I want to have 2 instances of the emulator running on my PC, and establish a link between them, so that I can play multiplayer games.

that's how it works. just run two instances, the games should find eachother and connect without having to do much more.

that being said, it might or might not work-- not all games work.

Videogamer555
Posted on 09-08-18 09:03 PM Link | #663
Posted by StapleButter
that's how it works. just run two instances, the games should find eachother and connect without having to do much more.

that being said, it might or might not work-- not all games work.


I've not found anything it works on, other than Pictochat (which comes built-in to the BIOS). I've even tried Metroid Prime Hunters. I tried both LAN modes with Metroid Prime Hunters, which are Singlecartridge and Multicartridge.

In single cartridge mode, one system runs the game, while the other system remains in the BIOS, and you need to click the download button. Once the download has finished, the game should start. However in the emulator I have found that the download never completes. It remains indefinitely in the "downloading" state.

In multi cartridge mode, both systems have a copy of the cartridge, and both are running the game. One system initiates a multiplayer match, and then the other system connects to that match. At least that's how it is supposed to work. However, in the emulator I found that the second system keeps getting disconnected, even before the match can start.

Every time the connection fails, I've discovered it corrupts firmare.bin, and I need to delete the old file and replace it with a new working copy.


There are several things that could pose a connection problem. One is that both instances of the emulator share the same firmware file. The second problem is that both instances of the emulator share the same save file (which has the same name as the ROM, but with a .sav file extension instead of .nds). To attempt to fix both of these problems, I created 2 separate copies of the emulator and the ROM, then in the BIOS boot on each I edited the settings to give each copy of the emulator a different username in the firmware. After that, I deleted all the save files, and restarted both emulators. I booted the game in one emulator from one copy of the ROM, and in the other copy of the emulator I booted the game from the other copy of the ROM. I thought that would fix it, but it didn't. I'm sure that this is part of the total fix that needs to be done, but something else clearly also needs to be done.

Here's the final step, but I can't do it myself, since I don't have access to the emulator's source code, and this fix must be done in the emulator's programming. I believe each instance of the emulator must be able to bind to a different port, and also each instance of the emulator must be able to set the remote port for the connection in the settings menu. For example, if one copy of the emulator is on port 1111 and the other copy of the emulator is on port 2222, the copy of the emulator on port 1111 must have its remote port set to 2222, and the copy of the emulator on port 2222 must have its remote port set to 1111. But right now, such functionality is not even present in the emulator. I can't set either the bound port or the destination port. I hope this fix can be added to the emulator quite soon, because I think this will be the key in making the multiplayer work correctly.

In fact, it's amazing that even Pictochat works, or that the emulator doesn't crash completely. The reason is, because the way it works right now, all instances of the emulator bind to the same port. I discovered that by using the utility program Curr Ports, which shows the ports that programs are currently using on the computer. And what it showed, should have not even been possible. It showed both instances of Melon DS bound to the same port on the same loopback adapter (127.0.0.1). As far as I know, that violates how networking is supposed to work, and in every other program I've used this causes the program to pop up an error message (if correct error handling is used) or to outright CRASH (if correct error handling isn't used). In all cases, the Windows API call used to establish the port binding, should fail on the second instance of the program, and not bind to that port, and therefore not show up in a listing of ports currently in use by the software.

The fact that not only was there no error or crash, but that both port bindings actually appeared to work perfectly (which they should NOT have done), suggests this isn't using standard Windows API networking functions, but rather some kind of hack. I still have no idea how it works, but depending on a hack to make your program run is a BAD IDEA. Two reasons for this. 1 If the glitch that was exploited by the hack is ever patched, it won't work anymore. 2 There's no guaranty that the hack itself is a stable way of accessing network functionality, and it certainly violates networking protocol, so its exact behavior shouldn't be trusted as reliable. That may also be part of the problem that prevents the 2 instances of the emulator from connecting properly, because the network functionality itself appears to be based on some kind of hack.

A correctly implemented networking functionality in your program, would include at least 3 values in the settings (local port, remote port, remote address), or possibly 4 values (also including the local address to set which network adapter you want to bind to).

StapleButter
Posted on 09-09-18 10:08 AM (rev. 3 of 09-10-18 08:08 AM) Link | #664
https://github.com/StapleButter/melonDS/blob/master/src/libui_sdl/Platform.cpp#L181

it's not a hack, the 'all instances using the same port' bit is how it's meant to work. the idea is that all running instances can participate into multiplayer games without requiring emu-side config. that being said, you brought to my attention that the multicast implementation there is flawed. nah, we're doing broadcast and that's fine

that being said, I'm still pretty sure most of the issues with wifi connection are due to the incomplete emulation of the DS wifi device, esp. its multiplayer features. and also the insane rates at which data frames are sent during multiplayer. to give you an idea: this blog post describes well how the shito works.

Videogamer555
Posted on 09-14-18 02:10 AM (rev. 2 of 09-14-18 02:11 AM) Link | #669
Posted by StapleButter
https://github.com/StapleButter/melonDS/blob/master/src/libui_sdl/Platform.cpp#L181

it's not a hack, the 'all instances using the same port' bit is how it's meant to work. the idea is that all running instances can participate into multiplayer games without requiring emu-side config. that being said, you brought to my attention that the multicast implementation there is flawed. nah, we're doing broadcast and that's fine

that being said, I'm still pretty sure most of the issues with wifi connection are due to the incomplete emulation of the DS wifi device, esp. its multiplayer features. and also the insane rates at which data frames are sent during multiplayer. to give you an idea: this blog post describes well how the shito works.


Very interesting. However, making it so you can't set a destination IP address also makes it so it cannot communicate between computers. This limits it to running 2 copies of the emulator on the same PC, and not allowing a LAN connection between PCs.

As for multicast if that's what you are trying, as you said in your post, I see what the problem is there. Multicast is only designed to work on a specific group of addresses, known as "multicast addresses". The addresss that are used in this emulator are not a multicast addresses. It's either 127.0.0.1 (localhost) or 0.0.0.0 (all addresses), depending on how the emulator's network setting is configured. I think for multicast to work correctly, the address it's bound to must be explicitly a multicast address. I think these are like 224.0.0.1 or something like that.


Main - General - How do I do multiplayer? New reply

Page rendered in 0.014 seconds. (2048KB of memory used)
MySQL - queries: 29, rows: 84/84, time: 0.009 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.