0

Suppose I connect my iPhone (12.4) to a Wi-Fi network and turn on personal hotspot, which requires me to turn on Cellular. Now if I connect the Mac via lightning cable, I see "1 connection" in the blue strip.

How can I check which one of Wi-Fi and mobile data is being shared?

Hint: I use organizational Wi-Fi.

3

Regardless of how you connect to your iPhone acting a a personal hotspot, whether it be via WiFi or tethered via cable, you are sharing the cellular data connection.

So, using your example, where your iPhone is initially connected to the corporate WiFi and then you enable the Personal Hotspot feature, you will disconnect from the corporate WiFi and a private (NAT) network will be created with a gateway configured through your cellular network. Whether you use WiFi or connect via USB, this network will be created

From Apple Support:

A Personal Hotspot lets you share the cellular data connection of your iPhone or iPad (Wi-Fi + Cellular) when you don't have access to a Wi-Fi network.

Why is this the case? Your iPhone can only connect to a single WiFi network at any given time. The Personal Hotspot is designed to provide a WiFi signal where you don't have one. This configuration cannot be changed.


Finding your Gateway....

If you want to see which connection you’re using (which has priority) for the Internet you just need to get the IP addresses of you adapters and run a trace route to see the path.

(Values below are from my iMac; en0 is wired, en1 is WiFi connected to hotspot. Your values will differ.)

$ ifconfig en0 | egrep -iw inet
inet 192.168.1.54 netmask 0xffffff00 broadcast 192.168.1.255

$ ifconfig en1 | grep -iw inet
inet 172.20.10.3 netmask 0xfffffff0 broadcast 172.20.10.15

$ traceroute apple.com | head -n 1
 1  pfsense (192.168.1.1)  0.481 ms  0.312 ms  0.329 ms

You will get a output telling you which gateway is being used for Internet traffic. In my case, it's showing me that I'm going through my en0 or wired network adapter.

You could use the netstat -rn command to get your default gateway, but I've found that you can have multiple gateways.

$ netstat -rn | egrep default
 default            192.168.1.1        UGSc          125      109     en0
 default            172.20.10.1        UGScI           7        0     en1

This is why I like to use traceroute to actually (and quickly) "see" where the traffic is going.

Measuring Bandwidth....

The only way to measure bandwidth is to use a utility (service) like vnStat. It's available via MacPorts or Homebrew. The system, by default is not measuring bandwidth usage so you'll need a service that gets loaded at boot (or at the users request) to begin logging this data.

A sample output (assuming 2 interfaces) would look like the following:

(with 2 interfaces) $ vnstat

                      rx      /      tx      /     total    /   estimated
 Internet (eth1):
       2018-09     31.90 GiB  /   28.05 GiB  /   59.95 GiB
       2018-10    281.04 MiB  /   99.45 MiB  /  380.49 MiB  /   12.05 GiB
     yesterday      1.23 GiB  /  473.23 MiB  /    1.69 GiB
         today    281.04 MiB  /   99.45 MiB  /  380.49 MiB  /     397 MiB

 Local (eth0):
       2018-09     25.13 GiB  /  116.94 GiB  /  142.07 GiB
       2018-10    234.75 MiB  /    5.03 GiB  /    5.26 GiB  /  170.76 GiB
     yesterday    520.55 MiB  /    2.21 GiB  /    2.72 GiB
         today    234.75 MiB  /    5.03 GiB  /    5.26 GiB  /    5.51 GiB
3
  • Your Mac will have 2 connections - WiFi to Corp. network and USB to iPhone. If your iPhone has two, can you list them? – Allan Dec 31 '19 at 7:21
  • Ahhh...when you turn on personal hotspot, your iPhone shouldn’t be connected to the Corp WiFi any more. It becomes a WAP for your shared cell network. Check the IP addresses on the iPhone to confirm this. As for checking the data used on the Mac, you can still use netstat – Allan Dec 31 '19 at 10:43
  • I left WiFi in for completeness. It's for the next person coming for an answer, they can see what the sample output should be. It in no way changes what you will see. If your WiFi doesn't exist and you're only connected to USB, use that interface. This is also why I said, "your values will differ." Also, I don't have a tether and that image doesn't give me the interface alias to use (i.e. en0, en1 etc.) – Allan Jan 4 '20 at 18:43
0

I thought of two ways:

  • Check if any intranet webpage is reachable on the Mac. It wouldn't be, that confirms cellular data usage.

  • Check "What is my ip" on the iPhone once while using cellular, once using Wi-Fi. Then match those with the one on the Mac. It matches with cellular's. One can also use utilities listed in Allan's answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .