microsoft / microsoft/WSL

Applications running on host not receiving UDP multicast packets sent from WSL2

Open
#12,122 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

network
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

Windows Version

Microsoft Windows [Version 10.0.22631.4249]

WSL Version

2.0.14.0

Are you using WSL 1 or WSL 2?
  • WSL 2
  • WSL 1
Kernel Version

5.15.133.1-1

Distro Version

Ubuntu 22.04

Other Software

Wireshark Version 4.2.3

Repro Steps

First create a .wslconfig config file and set networkingMode=mirrored under [wsl2] as per https://learn.microsoft.com/en-us/windows/wsl/networking#mirrored-mode-networking. File should look like

[wsl2]
networkingMode=mirrored

Shutdown and restart wsl2
In wsl2 run program that sends UDP packets to a valid multicast address. I'm using the following python script:

import socket
import struct
import time

MULTICAST_GROUP = '224.1.1.1'  # Change to your desired multicast address
PORT = 5004  # Change to your desired port

# Create the socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)

# Set the socket option to allow multicast
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)

# Send multicast packets
while True:
    message = b'This is a multicast message'
    sock.sendto(message, (MULTICAST_GROUP, PORT))
    print(f'Sent: {message}')
    time.sleep(1)  # Send a packet every second

In separate powershell terminal, run program that reads from the same multicast address. I'm using the following python scripts:

import socket
import struct

MULTICAST_GROUP = '224.1.1.1'  # Match the address used in the sender
PORT = 5004  # Match the port used in the sender

# Create the socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('', PORT))

# Tell the operating system to add the socket to the multicast group
group = socket.inet_aton(MULTICAST_GROUP)
mreq = struct.pack('4sL', group, socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)

print(f'Ready to receive on {MULTICAST_GROUP}:{PORT}')

# Receive multicast packets
while True:
    data, addr = sock.recvfrom(1024)  # Buffer size is 1024 bytes
    print(f'Received message: {data} from {addr}')
Expected Behavior

Receiving script should correctly read packets from multicast address. When both programs are run on powershell, output of receiving script will look like this:
image
The source ip address will be the ip address from wsl2

Actual Behavior

Receiving script receives no packets. This behavior is particularly strange as Wireshark is able to see these packets
image
Note that the source ip address is that of eth1, output of ip addr in wsl2:
image

Diagnostic Logs

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. First reproduce the issue with the provided WSL2 mirrored-mode configuration and Python sender and receiver, then trace the WSL networking path involved in UDP multicast delivery. Done means the PowerShell receiver receives packets sent from WSL2, matching the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.