Unable to send/receive IPv6 Mutlicast packets on NWConnectionGroup using Apple NF

Hello Everyone,

I am currently using macOS 15.5 and XCode 16.4.

I am using the following code to send/receive multicast packets on multicast group ff02::1 and port 49153 using Apple NF's NWConnectionGroup.

import Network
import Foundation
// Creating a mutlicast group endpoint
let multicastIPv6GroupEndpoint: NWEndpoint = NWEndpoint.hostPort(host: NWEndpoint.Host.ipv6(IPv6Address("ff02::1")!), port: NWEndpoint.Port("49153")!)
do {
    let multicastGroupDescriptor: NWMulticastGroup = try NWMulticastGroup (for: [multicastIPv6GroupEndpoint])
    let multicastConnectionGroupDescriptor = NWConnectionGroup (with: multicastGroupDescriptor, using: .udp)
    multicastConnectionGroupDescriptor.stateUpdateHandler = { state in
        print ("🕰️ Connection Group state: \(state)")
        if state == .ready {
            multicastConnectionGroupDescriptor.send (content: "👋🏻 Hello from the Mac 💻".data (using: .utf8)) { err in
                print ("➡️ Now, I am trying to send some messages.")
                if let err = err {
                    print ("💥 Error sending multicast message: \(err)")
                } else {
                    print ("🌚 Initial multicast message sent")
                }
            }
        }
    }
    multicastConnectionGroupDescriptor.setReceiveHandler { message, content, isComplete in
        if let content = content, let messageString = String (data: content, encoding: .utf8) {
            print ("⬅️ Received message: \(messageString)")
        }
    }
    multicastConnectionGroupDescriptor.start (queue: .global())
} catch {
    print ("💥 Error while creating Multicast Group: \(error)")
}
RunLoop.main.run()

I am able to successfully create a NWConnectionGroup without any warnings/errors.

The issue occurs when the stateUpdateHandler's callback gets invoked.

It first gives me this warning:

nw_listener_socket_inbox_create_socket IPV6_LEAVE_GROUP ff02::1.49153 failed [49: Can't assign requested address

But then it shows me that the state is ready:

🕰️ Connection Group state: ready

After this, when the send is performed, it gives me a bunch of errros:

nw_endpoint_flow_failed_with_error [C1 ff02::1.49153 waiting parent-flow (unsatisfied (Local network prohibited), interface: en0[802.11], ipv4, ipv6, uses wifi)] already failing, returning
nw_socket_connect [C1:1] connectx(7, [srcif=0, srcaddr=::.62838, dstaddr=ff02::1.49153], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [48: Address already in use]
nw_socket_connect [C1:1] connectx failed (fd 7) [48: Address already in use]
nw_socket_connect connectx failed [48: Address already in use]
nw_endpoint_flow_failed_with_error [C1 ff02::1.49153 in_progress socket-flow (satisfied (Path is satisfied), interface: en0[802.11], ipv4, ipv6, dns, uses wifi)] already failing, returning

There is no other background process running on the same port. I tried using different ports as well as multicast groups but the same error persists.

The same code works fine for an IPv4 multicast group.

I have following questions:

  1. Why am I getting these errors specifically for IPv6 multicast group but not for IPv4 multicast group?
  2. Are there any configurations that needed to be done in order to get this working?
Answered by DTS Engineer in 844801022
No, I am only connected to only a single wifi interface which supports IPv6 multicast.

That’s pretty much never the case on modern Apple platforms. Here’s what I seen on my Mac (running macOS 15.5) when it’s bound to Wi-Fi:

% ifconfig | grep MULTICAST | grep -v POINTOPOINT
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
anpi2: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
anpi1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
anpi0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en4: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en6: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ap1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
awdl0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
llw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
vmenet0: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
bridge100: flags=8a63<UP,BROADCAST,SMART,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500

This is with nothing special (such as VPN and VMs) running.

This is why my advice in Broadcasts and Multicasts, Hints and Tips is to always target a specific interface when you send.


Anyway, coming back to your main issue, I played around with this today, with a focus on trying to:

  • Force the group to use a specific interface.

  • Force the group to send from the same port as it’s receiving from, as explained in this post.

I’ve explained earlier why it’s important to do the former. The reason why I was trying to do the latter is because, based on my experience investigating that other issue, I know that multicast groups run a different simpler code path when the receive and send ports line up like this.

My efforts were unsuccessful )-:

At this point I’ve run out of ideas. The next step is for you to file a bug about this.

Please post your bug number so that I can add my thoughts to the bug [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

IME NWConnectionGroup is a very finicky API. To quote Broadcasts and Multicasts, Hints and Tips:

[The API has] other limitations, but I don’t have a good feel for them.

Before we get too deep into this, I wanna get some details about the specific multicast protocol you’re trying to implement. Are you still working on the protocol you outlined in your previous thread?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Are you still working on the protocol you outlined in your previous thread?

Yes similar, my project involves multicast communication between processes running on different devices within the same network. For all my Apple devices (macOS, iOS, etc.), I am using NWConnectionGroup, which listens on an IPv6 as well as IPv4 multicast address passed through a NWMulticastGroup and a specific multicast port.

For IPv6, I am unable to send multicast packets to the IPv6 multicast group using NWConnectionGroup even though I allow the access of the local network as mentioned here.

But for IPv4, I am able to send multicast packets to the IPv4 multicast group.

Are you binding the connection group to a specific interface?

You’d do this by setting the requiredInterface property of the NSParameters to you to set up the group.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

No, I am only connected to only a single wifi interface which supports IPv6 multicast.

For IPv4, it is working fine. I am able to send/receive data using the code mentioned here:

import Network

import Foundation

// Creating a mutlicast group endpoint

But for IPv6, it is failing with the following errors/warnings:

nw_endpoint_flow_failed_with_error [C1 ff02::1.49153 waiting parent-flow (unsatisfied (Local network prohibited), interface: en0[802.11], ipv4, ipv6, uses wifi)] already failing, returning
nw_socket_connect [C1:1] connectx(7, [srcif=0, srcaddr=::.62838, dstaddr=ff02::1.49153], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [48: Address already in use]
nw_socket_connect [C1:1] connectx failed (fd 7) [48: Address already in use]
nw_socket_connect connectx failed [48: Address already in use]
nw_endpoint_flow_failed_with_error [C1 ff02::1.49153 in_progress socket-flow (satisfied (Path is satisfied), interface: en0[802.11], ipv4, ipv6, dns, uses wifi)] already failing, returning

I tried specifying the .requiredInterfaceType property as .wifi too but it didn't affect the output in both the cases.

My questions are:

  1. Why is it failing for IPv6 but not for IPv4?
  2. Are there any configurations or setup that I need to do for IPv6 to make it work?
No, I am only connected to only a single wifi interface which supports IPv6 multicast.

That’s pretty much never the case on modern Apple platforms. Here’s what I seen on my Mac (running macOS 15.5) when it’s bound to Wi-Fi:

% ifconfig | grep MULTICAST | grep -v POINTOPOINT
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
anpi2: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
anpi1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
anpi0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en4: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en6: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ap1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
awdl0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
llw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
vmenet0: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
bridge100: flags=8a63<UP,BROADCAST,SMART,RUNNING,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500

This is with nothing special (such as VPN and VMs) running.

This is why my advice in Broadcasts and Multicasts, Hints and Tips is to always target a specific interface when you send.


Anyway, coming back to your main issue, I played around with this today, with a focus on trying to:

  • Force the group to use a specific interface.

  • Force the group to send from the same port as it’s receiving from, as explained in this post.

I’ve explained earlier why it’s important to do the former. The reason why I was trying to do the latter is because, based on my experience investigating that other issue, I know that multicast groups run a different simpler code path when the receive and send ports line up like this.

My efforts were unsuccessful )-:

At this point I’ve run out of ideas. The next step is for you to file a bug about this.

Please post your bug number so that I can add my thoughts to the bug [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Unable to send/receive IPv6 Mutlicast packets on NWConnectionGroup using Apple NF
 
 
Q