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

Add packet capture for multiplayer traffic #2146

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

liclac
Copy link

@liclac liclac commented Aug 29, 2024

This adds support for logging network traffic in tcpdump (.pcap) format. You can enable this in Config -> Emu -> Devtools.

This seems to work fine when capturing traffic between two multiplayer instances, verified by booting two instances to firmware, opening Pictochat and comparing the logs to promiscuous mode captures of real hardware doing the same.

However, when a game connects to the internet, you'll currently get a partial log - the Platform::MP_Send* hooks are called for outgoing packets, but the Platform::MP_Recv* ones aren't called for the incoming ones. The Platform::Net_Recv* hooks are called for them, but they're just passed the source/destination IP, packet type and contents, not the full WiFi frame, which isn't enough to log them.

I don't understand the WiFi emulation code nearly well enough to figure out quite what the right behaviour or thing to do here is, so hopefully somebody who does could help me out here.

You can reproduce this very easily by enabling packet capture, booting up any game with WFC support and tapping Nintendo WFC Settings -> Nintendo WiFi Connection Settings -> Connection 1 -> Test Connection. If you open the pcap file in Wireshark, you'll see an outgoing DNS query for conntest.nintendowifi.net, followed by a HTTP GET request, but the responses are missing.

Anyway, this is what Config -> Emu -> Devtools looks like now:
image

(The .pcap files for secondary multiplayer instances are named myrom.2.pcap, rather than myrom.pcap.2 as is the case for other files, simply so that they show up in eg. Wireshark's file picker and have the right extension when opened by an external program. I can change this for consistency if wanted.)

Logging is started when booting either a ROM or the firmware menu, and
stopped + flushed on eject or shutdown.

For secondary MP instances, the logs are named eg. ".2.pcap" rather than
".pcap.2" (like saves are), since this is a file meant to be opened in an
external program.
@lnee94
Copy link

lnee94 commented Sep 11, 2024

If you fork and run the github actions this a post the builds it genrates here (note im on linux) I can test it

@lnee94
Copy link

lnee94 commented Sep 11, 2024

I tested and reslsed that I need more attention

@liclac
Copy link
Author

liclac commented Sep 11, 2024

I'm not sure how to do that, but happy to do so if you could tell me how?

But if you're on Linux, would it not be easier to download the archive of this branch and build it from source?

@liclac
Copy link
Author

liclac commented Sep 11, 2024

Also whoops, now that CI has run I see that it's failing to build on Windows. It's a quick fix, so I'll probably get to it later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants