Network

Network connections send and receive data using transport and security protocols.

Network Documentation

Posts under Network tag

703 results found
Post marked as unsolved
115 Views

How to determine if the iPhone is roaming?

I am working on an iPhone application and would really like to determine if the device is roaming so that I can smartly avoid costing my users expensive connections, if they are out of their home network. I tried to explore Core Telephony framework but did not find anything fruitful. Is there any API by which I can determine if the user is roaming? Any help is appreciated, Thanks in advance!!!
Asked
Last updated .
Post marked as unsolved
32 Views

Unity Project's XCode Export

Hi, I exported my MacOS game project I made in Unity as an XCode project. But when I build that project in XCode, I get some network error. My network builds results are 0 kb/sn. So I think there is some problem with my network settings or the NetworkExtension framework. Also, I created Hardened Runtime in the sandbox. And I checked, check box of Incoming and Outgoing connections settings. So, My app not running, not notarising, and not signing. How can I stabilize my unity project's Xcode export?
Asked
Last updated .
Post marked as unsolved
7 Views

How to support permessage-deflate on NWProtocolWebSocket

     let options = NWProtocolWebSocket.Options()     let parameters: NWParameters     if url.scheme == "ws" {       parameters = .tcp     } else {       parameters = .tls     }     options.setAdditionalHeaders([       ("sec-webSocket-extensions", "permessage-deflate; client_max_window_bits; server_max_window_bits=15"),       ("accept-encoding", "gzip, deflate")     ]) I want to support permessage-deflate on NWProtocolWebSocket, but websocket connection is always been closed, and returns this error server response contains a permessage-deflate extension that was not negotiated nw_protocol_copy_ws_definition_block_invoke [C1.1:1] nw_ws_validate_server_response
Asked
Last updated .
Post marked as solved
37 Views

NWEthernetChannel crash when interface is reconnected to the system

I am developing a service that implements a custom L3 protocol using NWEthernetChannel API from Network.framework. I have noticed that when network interface (e.g. USB Ethernet dongle) is physically disconnected from the system, and then connected back, my application crashes with the following call stack: (lldb) thread backtrace thread #6, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)   * frame #0: 0x00000001002d5115 libdispatch.dylib`_dispatch_assert_queue_fail + 99     frame #1: 0x00000001002d50aa libdispatch.dylib`dispatch_assert_queue + 122     frame #2: 0x00007fff6f826209 libnetwork.dylib`nw_path_evaluator_create_flow + 121     frame #3: 0x00007fff6fa7c6f0 libnetwork.dylib`__nw_ethernet_channel_handle_path_update_locked_block_invoke + 2896     frame #4: 0x00007fff6fb7ccbf libnetwork.dylib`nw_path_enumerate_interface_options + 175     frame #5: 0x00007fff6fa7b661 libnetwork.dylib`nw_ethernet_channel_handle_path_update_locked + 161     frame #6: 0x00007fff6fa7b4e0 libnetwork.dylib`__nw_ethernet_channel_start_block_invoke + 512     frame #7: 0x00007fff6f9239b4 libnetwork.dylib`__nw_path_necp_update_evaluator_block_invoke + 388     frame #8: 0x00000001002d2844 libdispatch.dylib`_dispatch_call_block_and_release + 12     frame #9: 0x00000001002d3826 libdispatch.dylib`_dispatch_client_callout + 8     frame #10: 0x00000001002dadd7 libdispatch.dylib`_dispatch_lane_serial_drain + 777     frame #11: 0x00000001002dbbc1 libdispatch.dylib`_dispatch_lane_invoke + 487     frame #12: 0x00000001002d5c9a libdispatch.dylib`_dispatch_queue_override_invoke + 539     frame #13: 0x00000001002e7391 libdispatch.dylib`_dispatch_root_queue_drain + 334     frame #14: 0x00000001002e7e03 libdispatch.dylib`_dispatch_worker_thread2 + 127     frame #15: 0x000000010036131b libsystem_pthread.dylib`_pthread_wqthread + 220     frame #16: 0x000000010036049b libsystem_pthread.dylib`start_wqthread + 15 Is this behaviour expected, or is this a bug in the API implementation? As a workaround, I currently delete the NWEthernetChannel object when its state changes to nw_ethernet_channel_state_failed. But given that it is a high-level API, I would expect it to resume automatically when the interface is reconnected, or at least not crash.
Asked
by ragafonov.
Last updated .
Post marked as unsolved
24 Views

what network ports to remain open for HomePod pairing and watchOS update?

What are the specific network ports that should be open on my internet connection broadband to enable the following: ) Pairing of HomePod with iPhone. ) Downloading and updating of watchOS. I have already checked the following links, but they do not provide the details for the above mentioned port requirements: https://support.apple.com/en-us/HT202068 https://support.apple.com/en-us/HT202944 The ports mentioned for Airplay and Homekit etc in these links are already open, yet I am unable to perform the activities mentioned. iPhone is already updating on the network, but watchOS is not updating on same network. Changing network completes both activities. Please help.
Asked
by uandme72.
Last updated .
Post marked as unsolved
113 Views

NWConnection -no Echo from connection.send(content: data, completion : .idempotent)

I'm using peer-to-peer and I successfully connect one client to another but when I send the echo to the individual connection the receiving client doesn't get a response. Initial send let data = NYKeyedArchiver.... let message = NWProtocolWebSocket.Metadata(opcode: .text) let context = NWConnection.ContentContext(identifier: "send",                                                   metadata: [message]) connection.send(content: data, contentContext: context, isComplete: true, completion: .contentProcessed({ (error) in if let error = error { return } print("Sent") })) Receive data and send Echo response func receivedIncoming(connection) { connection.receive(minimumIncompleteLength: 1, maximumLength: 65535) { (data, context, isComplete, error) in if let err = error { print(err) // never gets hit return } if let data = data, !data.isEmpty { // do something with data if let color = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor { // this should only run on the other device once echo is received after 5 secs         self?.view.backgroundColor = color } let randomColor = UIColor.random // func create random color        let colorData = randomColor.encode() // func encode color to data DispatchQueue.main.asyncAfter(deadline: .now() + 5) { connection.send(content: colorData, completion : .idempotent) // I've also tried let message = NWProtocolWebSocket.Metadata(opcode: .text)            let context = NWConnection.ContentContext(identifier: "send", metadata: [message]) connection.send(content: colorData, contentContext: context, isComplete: true, completion: .contentProcessed({ (error) in if let error = error { return } print("Color data sent") // this always prints })) } } else { print("data is empty") // never gets hit } } } NWConnection weak var delegate: PeerConnectionDelegate? var connection: NWConnection? // Outgoing Connection init(endPoint: NWEndpoint, delegate: PeerConnectionDelegate) { self.delegate = delegate let tcpOptions = NWProtocolTCP.Options() tcpOptions.enableKeepalive = true tcpOptions.keepaliveIdle = 2 let parameters = NWParameters(tls: nil, tcp: tcpOptions) parameters.includePeerToPeer = true parameters.allowLocalEndpointReuse = true connection = NWConnection(to: endPoint, using: parameters)     startOutgoingConnection() } // Incoming Connection init(connection: NWConnection, delegate: PeerConnectionDelegate) { self.delegate = delegate self.connection = connection startIncomingConnection() } func startIncomingConnection() { connection?.stateUpdateHandler = { (nwConnectionState) in case .ready:         self.delegate?.receivedIncoming(connection) // ... } Why is the echo data being sent but not received?
Asked
by lance145.
Last updated .
Post marked as solved
81 Views

NWConnection endPoint info duplicated

I'm not native to networking so maybe I'm misunderstanding how endPoint information is gathered. Device_A is browsing and discovers Device_B or the other way around, it doesn't matter because they will both discover each other and send data to open a connection. Because the Network framework does not resolve ipAddresses, - https://developer.apple.com/forums/thread/129644 when a connection is first made I use either the remoteEndPoint (connection.currentPath?.remoteEndpoint // fe80::9821:7fff:fcea:74c4%awdl0.10059) or the endPoint description (connection.endpoint.debugDescription // myApp (2)._myApp._tcplocal.) as a uniqueID for the connection. I send the data and some other info across the wire, if successful I then place either endPoint inside an ivar dictionary as the key with another value so that I know which device to map a response to once a device responds back. Right now I only have 2 devices connected, the issue is when I receive a response from Device_B, I'm actually getting the incorrect endPoint information. For some reason I keep getting the endPoint info from Device_A back. It seems like the same endPoint information is getting sent twice. Once to Device_A and then again to Device_B. This exact same thing occurs on Device_B but in reverse. I'm confused as to why this is happening. For example Device_A first discovers itself, the remoteEndPoint is *fe80::9821:7fff:fcea:74c4%awdl0.10059*, it sends the data. When Device_A receives its own message, I filter it out using the userId and I see the same endPoint info. But when Device_A discovers Device_B, the remoteEndPoint is *fe80::9821:7fff:fcea:74c4%awdl0.27788*. When I receive a response from Device_B, the endPoint information is showing the first one from Device_A *fe80::9821:7fff:fcea:74c4%awdl0.10059*. The same remoteEndPoint info is duplicated. The same exact thing is happening if I use endpoint.debugDescription. This issue occurs on both devices. NWBrowser: browser.browseResultsChangedHandler = { (results, changes) in for change in changes { switch change { case .added(let browseResult): switch browseResult.endpoint { case .service(let name, let type,_,_): let connection = PeerConnection(to: browseResult.endpoint) // ... } PeerConnection: var connection: NWConnection? init(to endPoint: NWEndpoint) { // tcpOptions ... // params ... // initialize connection and delegate that sends out data connection.stateUpdateHandler = { (nwConnectionState) in case .ready: self.delegate.sendOutgoing(connection) } Send Data: var dict = [String:String]() var endPointArr = [String]() func sendOutgoing(_ connection: NWConnection) { let endPoint = connection.currentPath?.localEndpoint?.debugDescription or let endPoint = connection.currentPath?.remoteEndpoint?.debugDescription // encode the endPoint and currentUserId with some other info, then send it across the wire, if successful make the endPoint a key inside a dictionary and add it to an array to keep track of what endPoints were received connection.send(content: encodedData, contentContext: context, isComplete: true, completion: .contentProcessed({ [weak self](error) in { if let error = error { return } self?.dict[endPoint] = someUniqueValue self?.endPointArr.append(endPoint) })) } Receiving a response connection.receive(minimumIncompleteLength: 1, maximumLength: 65535) { [weak self](data, context, isComplete, error) { if let err = error { return } if let data = data, !data.isEmpty { self?.received(data) } } func received(_ data) { guard let retrievedData = try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? MyModel else { return } guard let endPoint = retrievedData.endPoint as? String, let userID = retrievedData.userId as? String else { return } print(endPoint) // fe80::9821:7fff:fcea:74c4%awdl0.10059 if userID == Auth.auth().currentUser?.uid { dict[endPoint] = nil return } endPointArr.forEach { (endPoint) in print(endPoint) // prints both fe80::9821:7fff:fcea:74c4%awdl0.10059 and fe80::9821:7fff:fcea:74c4%awdl0.27788 } // this never runs because the key just got set to nil above because Device_B has the same endPoint info for (key, value) in dict where key == endpoint { print("key=\(key) : value=\(value)") // someUniqueValue // show response that this is a response from whichever device has this endPoint break } } [1]: https://developer.apple.com/forums/thread/129644
Asked
by lance145.
Last updated .
Post marked as unsolved
85 Views

How to receive broadcast packets with NWEthernetChannel

Hi, We have been able to successfully use NWEthernetChannel to send and receive packets with our custom protocol. However, we don't see any incoming packets (with our protocol) if they have the broadcast destination (ff:ff:ff:ff:ff:ff). I have verified that the packets in question are being received by the lower layers by doing a network capture with tcpdump - just that they don't show up on the NWEthernetChannel's receive handler. Also there are no log entries from any layers (enabled --debug --info). Is there something special that we need to do to enable receiving broadcast packets? Thanks. Devendra.
Asked
by dparakh.
Last updated .
Post marked as unsolved
29 Views

NWConnection configuration after start

Before creating nw_connection_t we can configure it through nw_parameters_configure_protocol_block_t which allows to set some tcp/tls options for more precise connection configuration After creating connection I start it using nw_connection_start(m_connection); method So is there any way to change the parameters of the connection after it was started ?
Asked
by ilinykh.
Last updated .
Post marked as unsolved
40 Views

correct use of App Sandbox Properties watchos

Hello, I hope someone can explain me how to use the Sandbox properties correctly. As I understand this properties, they are used to tell what the App is allowed to do/use. For example on: https://developer.apple.com/documentation/foundation/nsstream is written that the NSStream for TCP connection is available for iOS and watchOS 2.0+. On: https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_network_client is written that this property allows TCP sockets. But this property seems not to be available for watchOS or iOS. On an iPhone it works without changing some properties. On a watch it doesn't work. So how can I use some functionalities if I can not allow the use of it? Is editing this property even necessary for using some functionalities? Thanks.
Asked
Last updated .
Post marked as unsolved
2.6k Views

VoLTE Server Registration Security Agreement Issue

This is the third place I have been told to ask this question as both the normal phone and chat support have been unable to answer my question in full.Here is the issue:I am a research assistant at Cleveland State University and I am trying to set up a mock VoLTE (yes a mock cellular LTE) network using the following equipment:An iPhone 6 Plus running the most recent version of iOS.An Agilent E6621A PXT Wireless Communications Test Set (company now known as Keysight)Agilent's E6966A SIP Server Software (Provides the Management Entity for the VoLTE)And this is what is happening:The iPhone is able to connect to the mock network just fine. For example, I would be able to stream a YouTube video using mobile data on the iPhone using only the mock network. In other words, it follows the steps of a VoLTE setup, up until the next step:The iPhone sends out a SIP "REGISTER" message that contains a "sec-agree" header to the SIP Server SoftwareThe SIP software rejects the REGISTER request since there is no "sec-agree" requirement to match on the SIP Server Software since the parameters of the sec-header are not known in order to be put into the SIP Server Software.Step 2 and 3 repeat till a timer value it is met.Settings on the iPhone:Data usage set to Data and Voice (aka, the VoLTE setting)Roaming EnabledInternet APN set to "ims" (could this be the problem?)All other fields blankWifi disabled at time of connectionAny help, whether from an Apple Engineer or fellow developer is much appreciated.By helping me, you will allow for research that will create a more secure mobile network for the future by helping uncover the vulnerabilities of existing networks. Thank you!Side-note: VoLTE is NOT the same thing as VoIP. VoIP uses a different set of protocols. Please don't get the 2 confused when responding.
Asked
Last updated .
Post marked as unsolved
220 Views

Network Reachability In Network extension

Hi I am developing App proxy network system extension on 10.15.5. Reachability callaback is registered using below method but reachability_callback is never called. 		sockaddr_in ipv4{}; 		ipv4.sin_family = AF_INET; 		ipv4.sin_len = sizeof(sockaddr_in); 		ipv4.sin_addr.s_addr = 0x08080808; /*dummy ip*/ 		SCNetworkReachabilityRef	reachableTarget = SCNetworkReachabilityCreateWithAddress(NULL, (sockaddr *)&ipv4); 		 Boolean ok = SCNetworkReachabilitySetCallback(reachableTarget, reachability_callback, NULL); 		ok = SCNetworkReachabilityScheduleWithRunLoop(reachableTarget, 																									CFRunLoopGetMain(), 																									kCFRunLoopDefaultMode 																									); } I know "defaultPath" can be used to detect the network change. I am trying to understand underlying root cause of this issue. Does reachability callback not work with CFRunLoopGetMain? Regards, Anand Choubey
Asked
Last updated .
Post marked as unsolved
78 Views

URLSessionWebSocketTask does not notify delegate when connection fails

I observe the following behavior: Have a mac connected to the internet via wifi. Establish a websocket connection with some variation of URLSession.shared.webSocketTask(with ...) . After the socket is established, disconnect your wifi (eg. by disabling from the menu bar). Result: Session/Task delegate is informed about a timeout after a long delay (observed delay between 60s-3m). Expected: Delegate is informed immediately about the connection error. Notes: I tried to listen to all available delegate methods for URLSessionWebSocketTask, URLSessionTask, and URLSession. I tried many configuration option that seemed like they could be related (like adjusting timeoutIntervalForRequest of the session or request, the networkServiceType, etc) The underlaying network framework seems to notice the error immediately, as there is a log like this showing up: Connection 1: encountered error(1:53) Sending ping frames every 10 seconds does not change the situation either (simply no pong is returned until the timeout error occurs). There does not seem to be an upside to this delayed error reporting, since even if you reconnect the network immediately, the connection still fails with the timeout error after the delay. My question: Might there be a configuration option that I overlooked that gives me the behavior I want? Or do I misunderstand something fundamental about how this API is supposed to work?
Asked
by mkeiser.
Last updated .
Post marked as unsolved
41 Views

rvictl fails starting on Big Sur (Intel) and iOS 12.5.2)

Hi there, attempting to use Wireshark to debug a faulty app, I am struggling to use rvictl to create a virtual interface. Macbook Air 2015 running Big Sur 11.2.3 iPhone 6 running iOS 12.5.2 Xcode 12.4 installed Manually installed mobiledevice.pkg and mobiledevciedevelopment.pkg packages in Applications/Xcode-beta.app/Contents/Resources/Packages issued command sudo launchctl load -w /Library/Apple/System/Library/LaunchDaemons/com.apple.rpmuxd.plist which throws "Load failed: 37: Operation already in progress" When issuing the command (with or without sudo): rvictl -s phone-UID It throws: Starting device phone-UID [FAILED] I have executed sudo installer -pkg /Applications/Xcode.app/Contents/Resources/Packages/MobileDeviceDevelopment.pkg -target / which returns: installer: Package name is MobileDeviceDevelopment installer: Upgrading at base path / installer: The upgrade was successful. Any idea?
Asked
by DevZer0.
Last updated .
Post marked as unsolved
95 Views

Why am I able to extend and override methods of NWConnection (which is a final class)?

The answer may be too obvious, and I may be asking a s*i*l*l**y* question. Please help me out understanding the issue. As per Swift documentation, final classes can be extended, but you can not override the already declared methods etc. However, it seems like I am able to do that on NWConnection. I want to understand why it is possible. Here is my code. import Network extension NWConnection { // My new method     func hello() {         print("Hello")     }     func start(queue: DispatchQueue) {         os_log("My Version is called") //Hypothetical state modification         self.stateUpdateHandler?(.setup)     } }
Asked
by myakici.
Last updated .