0

I have a networked game I'm testing on a LAN. I'm using RakNet as my networking library.

Generally everything works fine, but sometimes the client (an iPhone) seems to get "confused" when initiating a connection to the server (a Macbook on the same LAN -- both connected wirelessly).

Once the client has connected, everything works fine. It will maintain the connection indefinitely. But sometimes the call to connect() just sits and spins and never seems to get anywhere, even after about 30 seconds. I will start receiving "No route to host" and "Host is down" messages on the client side.

What I've found is that, during this waiting period that won't resolve itself, if I initiate a ping from the server (the Macbook) to the client (the iPhone), immediately the client will connect. It could be 28 seconds into waiting and as soon as I try to ping it everything resolves.

During periods where the connection is acting up, I've also found that trying to ping from the iPhone to the Macbook doesn't work.

Does this sound like some kind of router issue? It's really intermittent -- things will work just fine for a few minutes and then I can repeatedly reproduce the inability to connect. Then I ping the client and everything is working again.

It's incredibly frustrating and I'd love some guidance about what may be causing the issues!

UPDATE 1

@PedroPerez commented that this may be related to an ARP issue. To try to get some data on this, I ran the following tests in promiscuous mode and tried to find ARP packets to look at:

  1. WireShark running on Macbook (server)
  2. WireShark running on iPhone (client)

When capturing data on the server, I found that every 20-50 seconds, I would see a pair of ARP calls with the router requesting the MAC address of the server's IP followed by an immediate response. Every 70 seconds, my Macbook (the server) would request the MAC address of my Apple TV. That was it for the "steady state" ARP traffic on the server. It would repeat itself like clockwork. Here's a screenshot:

Steady state server ARP traffic

When capturing data through the virtual interface on the client (which I created through a call to rvictl in the terminal), the picture was a bit more muddy. First of all, for some reason the ARP packets were not coming through to WireShark as ARP packets, even though the contents appeared to be the same (42 bytes). They just appeared as "Raw packet data". By examining the contents of the raw packets, I could see that every five seconds (seems excessive?!) the iPhone (client) was receiving an ARP reply packet (seemingly unsolicited?) from the router giving it stating its correct IP address. I'm not sure why the frequency is so high or why the router seems to be sending replies without requests. Here's a screenshot of that process.

Client ARP Packets Raw

I've also managed to capture ARP packets during this extraordinarily long timeout period and noticed that just before the connection succeeds (after waiting around for 20-30s), one of the (likely 'steady-state') broadcast packets goes out from the Macbook requesting the (completely unrelated!) MAC address of the Apple TV. However, the broadcasted request from the Macbook includes both its IP and MAC address, so perhaps since the iPhone client is able to "hear" that broadcasted request it updates its ARP table as soon as it sees that request? But then why is it forgetting it again?

aardvarkk
  • 103
  • 5
  • 1
    It sounds like a potential ARP issue. Is there any chance you can get a network capture while the issue happens? You would either see the iPhone not sending an ARP request for the MacBook's IP address or that request getting dropped / ignored. – Pedro Perez Jun 22 '16 at 00:06
  • @PedroPerez Good tip on ARP -- I'll look into it. Wanted to know, though, when you say "get a network capture", what exactly you mean? I'm messing around with WireShark and tcpdump, but what I'm finding is that when I run that on my Macbook only the traffic destined for the Macbook is logged, whereas I'm really interested in seeing the traffic from the client (the iPhone) into the network. I'm not sure how to capture that traffic? – aardvarkk Jun 22 '16 at 00:54
  • I believe you might be able to capture all traffic on the wireless lan if you set your network interface to promiscuous mode when running Wireshark or tcpdump. I'm afraid I can't give you instructions on how to do that on Mac as I have basically no idea :-) – Pedro Perez Jun 22 '16 at 01:41
  • @PedroPerez Another question: would the ARP issue more likely be on the wireless access point or on the client device itself? I managed to create a virtual interface that I can capture wireless data using Wireshark with. I'll post the results as an update. – aardvarkk Jun 22 '16 at 02:55
  • @PedroPerez Updated with some newer results. Not really sure what to do with the data. I guess maybe I need to somehow get a peek at the ARP table on the iPhone itself to check its status? – aardvarkk Jun 22 '16 at 03:33
  • Just had a look at your results and I'm of the same opinion as you; not really sure what to make of it. I agree that dumping the ARP table from the iPhone (I guess every few seconds?) would help painting the full picture. – Pedro Perez Jun 22 '16 at 06:43

0 Answers0