Simulator ignores `NWParemeters.requiredLocalEndpoint`
Originator: | m.scott.driggers | ||
Number: | rdar://FB13686829 | Date Originated: | 2023-03-14 |
Status: | Open | Resolved: | |
Product: | Simulator | Product Version: | 15.3 |
Classification: | Reproducible: | Yes |
Simulator for iPhone and VisionOS (and probably all the rest too) ignore `NWParemeters.requiredLocalEndpoint` and instead chooses a random outbound port. Real devices respect this parameter and choose the assigned local bound port. Here’s the code that sets the `requiredLocalEndpoint`. ``` let remoteRtcpEndpoint = NWEndpoint.hostPort(host: NWEndpoint.Host(remoteRTCPAddress), port: NWEndpoint.Port(rawValue: 5150re)!) let rtcpParameters = NWParameters.udp let localEndpoint = NWEndpoint.hostPort(host: NWEndpoint.Host("0.0.0.0"), port: NWEndpoint.Port(rawValue: 6970)!) Self.logger.info("Starting rtcp with local port \(6970), remote address \(5150), endpoint \(String(describing: localEndpoint))") rtcpParameters.requiredLocalEndpoint = localEndpoint rtcpParameters.allowLocalEndpointReuse = true remoteRtcpConnection = NWConnection(to: remoteRtcpEndpoint, using: rtcpParameters) remoteRtcpConnection.start(queue: .global()) ``` And here's the code that sends the payload ``` remoteRtcpConnection.send(content: RtcpPacket.vdly(delayMs: HUGE_FIXED_VDLY_MS).packet(), completion: .contentProcessed({ error in if let error = error { Self.logger.warning("Error sending VDLY packet \(error)") continuation.resume(throwing: error) } else { Self.logger.debug("VDLY Sent \(self.HUGE_FIXED_VDLY_MS)") continuation.resume(returning: ()) } })) ``` Expected Behavior: - A UDP packet is sent from local port 6970 to remote port 5150 on all devices and simulators iPhone and MacOS Real Device Behavior (Working): - A UDP packet is sent from local port 6970 to remote port 5150 iOS and VisionOS Simulator Device Behavior (Not working): - A UDP packet is sent from a random local port to remote port 5150
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!