Reducing Latency for a Real time peer to peer android game on WifiDirect

Started by
2 comments, last by hplus0603 6 years, 10 months ago

Hi everyone,

I will explain my current scenario and the issues that I am facing. I have been assigned to add multiplayer in a single player game which exists on android platform. For connectivity I used android's Wifi Peer to Peer API which allows devices to get connected via WIFI Direct.

Logic is pretty much implemented and data does get transferred using UDP, however I am facing latency issues which is making game unplayable. I should mention 2 things that I observed

1. Latency is more apparent on low end devices, meanwhile on high end devices movements seems to be in sync.

2. Latency keeps on increasing gradually.

I am referring to Gaffer on Games blog for networking aspects. As per that blog I did implement logic to find out round times for packets.

Strangely RTT values oscillate between 300 to 1000 ms when tried using one high end and one low end device. When tried with one high end and a device with moderate specs, RTT values don't climb above 700ms. Surprisingly, I am not facing much packet loss or out of order packets. Packets are sent at the rate of 30 per second. I tried reducing the packet size and it didn't give any different result.

What all can I do to mitigate this latency ?

I was looking into client side prediction to counter this latency, but not sure how it will be implemented considering the extent to which this latency climbs.

Thanks.

Nishant

Advertisement
1000 ms for local WiFi sounds off.
Are you wire WiFi Peer to Peer is actually the right solution?
How about using regular IP networking with a connected WiFi access point, or even internet play?
If you're on WiFi, a UDP broadcast should let peers find each other and be ready to play.
The latency of two peers connected to the same access point should be much lower than what you're seeing on WiFi Peer to Peer.
enum Bool { True, False, FileNotFound };

Most real time peer to peer games on play store do not support WiFi Direct. They either use bluetooth ,Local Wifi or internet . The games that do work on Wifi Direct are mostly turn based. So should I infer that its not possible or extremely difficult to get a real time multiplayer game working on Wifi Direct ?

https://sites.google.com/site/androidmultiplayergames/home

I did realize that the wifi p2p api does some extra processing on the group owner due to which it increases latency.

So should I infer that its not possible or extremely difficult to get a real time multiplayer game working on Wifi Direct ?


That seems prudent, yes.

I don't think the extra latency is because of processing, but because of something else, such as hardware limitations.
1000ms is a LOT of processing, even on an old Android phone.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement