Network Framework Ad Hoc Connection via Ethernet

I have an iPad app that uses Network framework to allow iPads to wirelessly communicate via their built-in ad hoc network capability. However, our app is used in an enterprise environment and there's concern about them communicating wirelessly, so I've been tasked with looking into wired communication.

Question:

I've read that iOS can connect to a wifi network using an Ethernet adapter, but would this work for ad hoc networking? For ex, if I connect 2 iPads via Ethernet cables to each other (not to the wifi router), and have the NWListener start broadcasting itself, can the NWBrowser find it and establish an ad-hoc connection via the Ethernet cables (and not the wireless cards inside the iPads). The iPads don't have any wifi connections established so they wouldn't be able to communicate any other way.

My guess is no...though if they did connect, how would I know it has happening via the cables and not via the wireless ad hoc capability, because I'm guessing there's no way to turn off just the wireless part of the ad hoc feature? If you disable the wifi on an iPad, you're also disabling ad hoc, right?

I'm pretty sure there's no way to programmatically send data back and forth between iPads using a USB-C cable connection, so I'm trying to determine if Ethernet cables would work.

Answered by DTS Engineer in 846688022

I don’t use the term ad hoc when it comes to networking because it means different things to do different people. I talk about that more in Wi-Fi Fundamentals.

iOS can connect to a wifi network using an Ethernet adapter

You obviously can’t connect to a Wi-Fi network with an Ethernet adapter. I’m going to presume you meant “Ethernet network”.

but would this work [without infrastructure]?

Yes.

how would I know it has happening via the cables and not via [peer-to-peer Wi-Fi] … ?

For testing, just turn off Wi-Fi.

IMPORTANT It’s critical you do this from Settings > Wi-Fi. Turning off Wi-Fi from Control Centre doesn’t actually turn it off, allowing peer-to-peer Wi-Fi to kick in.

Programmatically, you can:

Share and Enjoy

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

I don’t use the term ad hoc when it comes to networking because it means different things to do different people. I talk about that more in Wi-Fi Fundamentals.

iOS can connect to a wifi network using an Ethernet adapter

You obviously can’t connect to a Wi-Fi network with an Ethernet adapter. I’m going to presume you meant “Ethernet network”.

but would this work [without infrastructure]?

Yes.

how would I know it has happening via the cables and not via [peer-to-peer Wi-Fi] … ?

For testing, just turn off Wi-Fi.

IMPORTANT It’s critical you do this from Settings > Wi-Fi. Turning off Wi-Fi from Control Centre doesn’t actually turn it off, allowing peer-to-peer Wi-Fi to kick in.

Programmatically, you can:

Share and Enjoy

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

That article is really helpful., thank you for that. I see why you say the terms become meaningless if not used precisely.

Hopefully I'm asking this right:

  1. What do you call the hardwired version of Wifi Direct (or Apple peer-to-peer Wi-Fi)? I know that 2 non-cellular iPads can find each other and communicate with Network Framework via Wifi Direct (Apple peer-to-peer Wi-Fi?) even without a wifi network available. Can they do this through a cable connected to each other?

  2. If it's technically possible, I assume I would need to set requiredInterfaceType to wiredEthernet like you mentioned. After that, could the cable be a USB-C to USB-C as shown in the 1st attached pic? Or would it need to be an Ethernet cable as shown in the 2nd (contrived) attached pic?

Accepted Answer

Let’s tackle your questions in reverse order.

could the cable be a USB-C to USB-C as shown in the 1st attached pic?

No. USB-C doesn’t support an Ethernet-like protocol directly; you need those two Ethernet dongles.

Note This setup would work on the Mac, assuming you replace that USB-C cable with a Thunderbolt cable. The Mac is able to run an Ethernet-like protocol over Thunderbolt.


What do you call the hardwired version of Wifi Direct (or Apple peer-to-peer Wi-Fi)?

Wow, that’s a really confusing question.

First up, Apple devices don’t support Wi-Fi Direct. They never have and, with the advent of Wi-Fi Aware, it seems unlikely that they ever will.

Apple’s peer-to-peer Wi-Fi protocol doesn’t have a public name. I generally call it Apple peer-to-per Wi-Fi, or peer-to-peer Wi-Fi when the context is obvious. You might see it referred to as AWDL — you’ll also see that string in logs and other places — but that’s not a term I use because… well… for reasons that are hard to explain without diving further into implementation details than I’m comfortable doing.

All of the above relates to the link layer, that is, how you move Ethernet frames between devices. When you have an direct Ethernet connection, all of it’s irrelevant. Ethernet connections can move Ethernet frames without the rigamarole you see with Wi-Fi [1].

Once you have the link layer established, you then start working with TCP/IP. And that brings us to Bonjour, which is an Apple term for three industry-standard protocols:

Bonjour allows devices — both Apple and non-Apple — to communicate across an Ethernet-like interface without the need for any infrastructure. So, if you take two devices, disable Wi-Fi, and connect them via Ethernet, your app running on those devices can discover and connect using Bonjour technologies.

Bonjour also works over Wi-Fi, but on Wi-Fi there are additional complexities:

  • Under normal circumstances, both devices need to be on the same infrastructure Wi-Fi. In that case, all you need is standard Bonjour protocols.

  • If the two devices are not on the same interface, you need Apple peer-to-peer Wi-Fi to bridge the gap.

Finally, at WWDC we announce support for Wi-Fi Aware, an industry standard protocol that solves the same problem that Apple peer-to-peer Wi-Fi. However, I should note that Wi-Fi Aware doesn’t literally bring up a Wi-Fi interface over which you can run Bonjour. Wi-Fi Aware has its own integrated service discovery.

Share and Enjoy

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

[1] It is possible to tweak Ethernet to offer the <snark> convenience and simplicity of Wi-Fi </snark>. For more on that, see IEEE 802.1X. However, that’s not going to be relevant to your setup.

Network Framework Ad Hoc Connection via Ethernet
 
 
Q