Skip to content

DEV9: Add EthUDPPorts config for inbound UDP in Sockets mode#14285

Draft
fjtrujy wants to merge 2 commits intoPCSX2:masterfrom
fjtrujy:dev9-udp-inbound-sockets
Draft

DEV9: Add EthUDPPorts config for inbound UDP in Sockets mode#14285
fjtrujy wants to merge 2 commits intoPCSX2:masterfrom
fjtrujy:dev9-udp-inbound-sockets

Conversation

@fjtrujy
Copy link
Copy Markdown
Contributor

@fjtrujy fjtrujy commented Apr 12, 2026

Description of Changes

Add an EthUDPPorts setting (comma-separated port list) that pre-binds UDP ports on the host when using Sockets mode. This allows inbound UDP traffic from the host to reach the emulated PS2.

Currently in Sockets mode, UDP ports are only bound when the PS2 sends a packet first. PS2 software that listens for incoming UDP without sending first (e.g. ps2link on port 18194) cannot receive traffic from the host. This change creates UDP_FixedPort entries at adapter initialization with an isListening flag that accepts packets from any source.

A "UDP Ports" text field is added to the Network & HDD settings page (Intercept DHCP tab) so users can configure this from the UI.

Also fixes two issues with received IP packets:

  • Set TTL=64 (was 0, which could cause the PS2 network stack to discard packets)
  • Use configured PS2IP for destination routing on listening ports (dhcpServer.ps2IP is always 192.0.2.100 in Sockets mode, which doesn't match the PS2's static IP)

Rationale behind Changes

Enables ps2client (the standard PS2 development tool) to communicate with ps2link running inside PCSX2, which is essential for PS2 homebrew development workflows. Previously, ps2client commands like execee and reset could only work on real hardware because the Sockets adapter didn't support inbound UDP.

With this change, developers can use:

ps2client -h 127.0.0.1 execee host:program.elf
ps2client -h 127.0.0.1 reset

Suggested Testing Steps

  1. Go to Settings > Network & HDD
  2. Set Ethernet Device Type to Sockets, enable Ethernet
  3. In the Intercept DHCP tab: enable Intercept DHCP, set PS2 Address to match your ps2link IPCONFIG.DAT (e.g. 192.168.1.10), and set UDP Ports to 18194
  4. Boot ps2link in PCSX2
  5. Verify ports are bound: lsof -nP -c PCSX2 | grep UDP should show *:18194
  6. Run ps2client -h 127.0.0.1 execee host:hello.elf — the ELF should load and execute
  7. Run ps2client -h 127.0.0.1 reset — ps2link should process the reset command (note: PCSX2's IOP recompiler may crash on the soft reboot, which is a pre-existing limitation)

Did you use AI to help find, test, or implement this issue or feature?

Yes. Claude (Anthropic) was used to analyze the DEV9 Sockets adapter architecture, implement the changes, and iteratively debug the packet routing (destination IP mismatch and TTL=0 issues).

In Sockets mode, UDP ports are only bound when the PS2 sends a packet
first. PS2 software that listens for incoming UDP without sending first
(e.g. ps2link on port 18194) cannot receive traffic from the host.

Add an EthUDPPorts setting (comma-separated port list) under [DEV9/Eth]
in PCSX2.ini. The SocketAdapter pre-creates UDP_FixedPort entries at
initialization, binding real host sockets so incoming packets are
forwarded to the emulated PS2.

UDP_FixedPort gains an isListening flag that:
- Accepts packets from any source without requiring a child session
- Prevents auto-close when all child sessions disconnect
- Survives socket errors without tearing down the port

Also fixes two issues with received IP packets:
- Set TTL=64 (was 0, causing lwIP to discard packets)
- Use configured PS2IP for destination routing on listening ports
  (dhcpServer.ps2IP is always 192.0.2.100 in Sockets mode, which
  doesn't match the PS2's static IP from IPCONFIG.DAT)

Example PCSX2.ini config for ps2link/ps2client support:
  [DEV9/Eth]
  EthUDPPorts = 18194
  PS2IP = 192.168.1.10
  InterceptDHCP = true

Then use: ps2client -h 127.0.0.1 execee host:program.elf
@github-actions github-actions bot added the DEV9 label Apr 12, 2026
Add a text field for EthUDPPorts in the Intercept DHCP tab of the
Network & HDD settings page, so users don't need to manually edit
PCSX2.ini to configure pre-bound UDP ports.
@TheLastRar
Copy link
Copy Markdown
Contributor

Does #13391 serve the same purpose?
I hadn't worked on much as I wasn't sure of demand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants