-2

I'm working on a multiplayer module of my game engine. I don't have any code to post because both the server and the client are sending and receiving what I want, so this is a much more theoretical question. I've been trying to find the answer on the internet, but nothing has seemed to point me in the right direction.

Basically, I have a base server that one is able to connect to in order to see stats, connect to other GAME servers, and so on. This entire client-server model is TCP. However, the problem comes with my game server. In this case, TCP connection between all players and the server is established on a certain port, and I send packets to and from the server on another port through UDP. The reason for this is that so I can seperate important messages from less important "State" updates. Locally, this works fine, however when I try this "over the internet", the packets are sent but not received.

The TCP connection does get established over the internet, but the UDP packets do not arrive at their location. I have tried adding rules in Windows Firewall (outbound and inbound), and I've done port forwarding on all systems. I know for a fact its not a problem with my code.

Both systems are running on 64-bit Windows 7. I'm sending 64 Byte packets 40 times a second and not one is getting through, so its not a "packet drop" problem.

Finally, my question is: What are some other things that could block UDP packets? What are things that I need to take into consideration? I'm past the forgetting to bind() stage and such.

I understand that this is a very theoretical question and broad question, but I'm not sure what else to do as the problem does not lie within the code any more. I must be missing something simple. Any recommendations or advice is greatly appreciated. Again, sorry for how broad the question is, but this is my last resort.

Thanks!

4

3 回答 3

3

The first thing I do in situations like this is I fire up WireShark and watch my packets going out - just to be sure that everything is okay. If you have the ability to run a packet grabber on the remote end, that may tell you far more - like whether the receiving OS is blocking you for some reason. If you're seeing packets leaving the source but not arriving at the destination, they are being dropped en route. This can happen at any number of firewalls or routers.

My home router is configured to block all inbound UDP traffic. This is a more common situation than you might think. Most home network appliances (and, probably, windows firewall) will block inbound UDP traffic, unless they have already seen outbound traffic with the same (sourceip, destip, sourceport, destport) signature.

What's the network configuration look like at each end of this communication? What UDP port are you using?

于 2013-07-13T00:02:50.770 回答
2

Delivery of UDP packets is not guaranteed. There are a hundred reasons why they're getting lost, ranging from congestion to policy blocking to...

UDP is a lightweight protocol intended for applications where the data is changing, or state is not important. For example, VOIP will often use UDP since the datastream is dynamic, and it doesn't matter what got dropped half a second ago.

In short, if you need guaranteed delivery you must use TCP - that's what it's for.

于 2013-07-13T00:00:50.690 回答
1

The first thing I would try in your case is to use netcat in UDP mode (nc -u) between two machines over your internet connection and make that work. This way you are double sure this is no problem in your software.

From your description I would assume it is a firewall problem. Make sure UDP packets get through the firewall OK first. There may be multiple settings in your firewall which block UDP packets. The stateful packet tracking of Linux alone will block all incoming UDP packets even if this is mentioned nowhere explicitly in the rule.

于 2013-07-13T00:01:36.783 回答