Jump to content

  • Log In with Google      Sign In   
  • Create Account


UDP packets from server to client


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Wilhelm van Huyssteen   Members   -  Reputation: 925

Like
0Likes
Like

Posted 26 April 2013 - 02:45 AM

Hi.

 

my game uses an UDP and a TCP connection to its server. Some data gets sent over UDP and some over TCP both from server to client and client to server. 

 

Sending UDP packets from client to server is never a problem since the server is never behind some arbitrary router that's not in my control but what about the other way around? Can I expect to lose potential players if I use UDP from server to client or can I accept that virtually 100% of routers out there will be able to properly deliver the packets back to the client. Using UDP from server to client gains me little so its not worth it at all if I'm blocking out even a small amount of players.

 

Thanks in Advance!



Sponsor:

#2 starbasecitadel   Members   -  Reputation: 699

Like
1Likes
Like

Posted 26 April 2013 - 06:48 AM

I use UDP in both directions. 

 

I've tested at least 20 different places, including coffee shops, libraries, restaurants, 3g/4g cellular and never had a problem with firewalls/router incompatibility.   Maybe my sample size is too small, I'd really like to have about 200 different places tested before calling it a day (that's what Beta is for), but that has been my experience. 

 

While I haven't hit any router issues yet, I certainly have seen differences in packet loss and latency.  A couple Starbucks location are the worse: they average about 15% packet loss, 1200ms ping.



#3 frob   Moderators   -  Reputation: 19635

Like
4Likes
Like

Posted 26 April 2013 - 10:35 AM

Can I expect to lose potential players if I use UDP from server to client or can I accept that virtually 100% of routers out there will be able to properly deliver the packets back to the client.

Not 100%, but a very high percentage. There is a Wikipedia article that covers the four major types of NAT traversal.  

 

For almost all NAT classes, if the NAT-protected client sends an outgoing message to public address, then for a brief (configurable) time that machine can send messages back on the same address:port pair.  It does not matter if this is TCP or UDP for most devices.

 

Some strict environments, such as certain corporate and government systems, will lock down NAT traversal.  Also some badly-configured devices will prevent NAT traversal when it is wanted.

 

Most consumer and corporate NAT devices will let the communications go through.  Just make sure they are always on the same address:port pair and the connection is kept active.

 

On the few that it won't work those people should already know about the restrictions.


Check out my personal indie blog at bryanwagstaff.com.

#4 hplus0603   Moderators   -  Reputation: 5074

Like
3Likes
Like

Posted 26 April 2013 - 12:32 PM

If the server is publicly available, then any client that can send UDP packets out, will receive them back in, barring outright bugs in their network. If this wasn't true, then the DNS service wouldn't work.
The reason this works is that router/firewall/gateways implement NAT, where, once a packet goes out, a response to that packet will be routed back in. All the server has to do is to respond to the incoming packet using sendto() to the address that the packet had when you called recvfrom().
enum Bool { True, False, FileNotFound };

#5 Wilhelm van Huyssteen   Members   -  Reputation: 925

Like
0Likes
Like

Posted 03 May 2013 - 04:57 AM

Thnx!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS