peer to peer ping

Started by
6 comments, last by quack 14 years, 10 months ago
scenario (2 player game) example List of rooms on server RoomA 10.23.14.5 RoomB 34.32.55.2 RoomC 23.54.23.1 where the room name is followed by the players IP. This IP address is the players external IP, most likely a router. a user enters the lobby and the game pings each room address to see which ones the fastest or just display ping times. question: do most routers in the real world respond to external pings? If not how do peer to peer games show you ping times without entering the room like in Company of hero's. I use raknet which can natpunch each room to cause a real connection to each user but that can take up to 10 seconds per user and the flood of request from a real lobby seems unreal. optionally i could have the user join the room to see the ping. please help me peer to peer experts.
www.autodefrost.com/~travisSignature Virus cleaned by McAfee
Advertisement
Quote:Original post by quack
do most routers in the real world respond to external pings?
Not "most", no.
Quote:If not how do peer to peer games show you ping times without entering the room like in Company of hero's.
There's a difference between ICMP Ping (the ping command you're probably thinking of) and what's going on here. The user already has a connection open to the server. The server simply sends a command down that connection saying "respond to this", then times how long it takes for the client to respond.
Quote:Original post by Sneftel
Quote:Original post by quack
do most routers in the real world respond to external pings?
Not "most", no.
Quote:If not how do peer to peer games show you ping times without entering the room like in Company of hero's.
There's a difference between ICMP Ping (the ping command you're probably thinking of) and what's going on here. The user already has a connection open to the server. The server simply sends a command down that connection saying "respond to this", then times how long it takes for the client to respond.


icmp is what I'm talking about (real world routers ignore that?), the issue is i'm not interested in the time to ping the lobby server but rather how long the ping is from user to user without a natpunch. the game disconnects from the lobby server when starting a game and the users are connected peer to peer. the library maker mentions an option is location based ip lookup. Of course once the users natpunch to eachother i can figure the ping myself. Anyone work on company of hero's and want to spill the beans :)
www.autodefrost.com/~travisSignature Virus cleaned by McAfee
Routers often do not respond to ICMP pings, for many good and some bad reasons, so you can't rely on that. Also, the ping time to the router does not necessarily reflect ping time to the machine behind the router, as it might be connected via WLAN or similar means to the router. Or they might simply have a bad network card...

I guess the following algorithm might be sufficient (it sure is efficient).

*) In the following text, "ping" means a a ping implementation with your own protocol, not ICMP.
*) Potential servers need to register at the lobby servers anyway.
*) Lobby servers "ping" the registered servers at certain intervals and save the response times
*) Client "ping"s the lobby servers and finds the one with the best response time.
*) Then it asks the lobby server for a server list including response times.

The theory behind this is, that the response times logged at the lobby server with the best response time will very likely resemble the response times when connecting to the servers directly.

In general, I wouldn't worry too much about the accuracy of ping times anyway, because they are only a very vague measure of connection quality. Additionally, connection quality will fluctuate over time.
Quote:Original post by Rattenhirn
Routers often do not respond to ICMP pings, for many good and some bad reasons, so you can't rely on that. Also, the ping time to the router does not necessarily reflect ping time to the machine behind the router, as it might be connected via WLAN or similar means to the router. Or they might simply have a bad network card...

Of course I just need an estimate.


Quote:Original post by Rattenhirn
I guess the following algorithm might be sufficient (it sure is efficient).

*) In the following text, "ping" means a a ping implementation with your own protocol, not ICMP.
*) Potential servers need to register at the lobby servers anyway.
*) Lobby servers "ping" the registered servers at certain intervals and save the response times
*) Client "ping"s the lobby servers and finds the one with the best response time.
*) Then it asks the lobby server for a server list including response times.

The theory behind this is, that the response times logged at the lobby server with the best response time will very likely resemble the response times when connecting to the servers directly.

If the lobby server is 5000 miles away and I'm playin my friend (server) on my same router the lobby server would show horrible pings for us, but when we are connected directly It would be nil.

Quote:Original post by Rattenhirn
In general, I wouldn't worry too much about the accuracy of ping times anyway, because they are only a very vague measure of connection quality. Additionally, connection quality will fluctuate over time.

if you have an average 350ms ping I'd rather let the user know before they enter the room where I can provide an accurate average ping time.

Thanks guys so far for the responses but really I don't think there's any options to get an estimate done besides the two ways I mentioned. ip geolocation and (natpunching every room). Where geolocation is very rough but I'm sure that's how COH does it as once you enter the room ping times change a lot.



www.autodefrost.com/~travisSignature Virus cleaned by McAfee
Even if you could use ICMP, I wouldn't recommend it. Your server's processing time will undoubtably be much higher than the Windows Background Server, and so for a more accurate "ping", implement a ping directly in your protocol. Quite easy to do too, just set a timer, send off the packet, wait for a reply, and when you do, obtain the amount of time passed using the timer. This'll be a more accurate ping than that provided by using ICMP, as it accounts for your own server's overhead too p_o
I think you're over-thinking this design, unless you will have tens of thousands of simultaneous players. On Steam, you select your general geographic area (US-West, Europe, etc), and there's a lobby server per geographic area, so that the lobby ping will resemble your own ping. After all, the experience is not only dependent on your own ping, but on the other players having a similar ping to you.

If you want to, you could get a list of servers from the lobby server, and then ask the lobby server to introduce you to each of the servers in turn, and use UDP through NAT punch-through to get a better estimate of your own ping. Typically, you'll be doing this while showing the list of servers, though, so that the player doesn't have to wait for a long time to see the list when first connecting to the lobby.
enum Bool { True, False, FileNotFound };
Quote:Original post by hplus0603
I think you're over-thinking this design, unless you will have tens of thousands of simultaneous players. On Steam, you select your general geographic area (US-West, Europe, etc), and there's a lobby server per geographic area, so that the lobby ping will resemble your own ping. After all, the experience is not only dependent on your own ping, but on the other players having a similar ping to you.

I wish I could have lobby servers all over :)

Quote:Original post by hplus0603
If you want to, you could get a list of servers from the lobby server, and then ask the lobby server to introduce you to each of the servers in turn, and use UDP through NAT punch-through to get a better estimate of your own ping. Typically, you'll be doing this while showing the list of servers, though, so that the player doesn't have to wait for a long time to see the list when first connecting to the lobby.

I think we already covered this option. nat punching each peer. multiple nat punch request to the same peer isn't in my scope for someone browsing the lobby. its not a matter of hiding it it's just 20 people in a lobby will try to nat punch one poor guy.

Anyways thanks all for the help I'm going with geo location for rough estimate, maxmind offers site licenses for an IP database.
www.autodefrost.com/~travisSignature Virus cleaned by McAfee

This topic is closed to new replies.

Advertisement