Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lucky

UDP packet tunneling?

This topic is 6308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks, my first post.. thx for reading I''m using winsock API with UDP packets for a little test program I''m working on (checking out the feasibility of various methods.. may want to try a multiplayer game in the future). The only problem I''m running into is with people using some sort of connection sharing (wingate, microsoft ICS, etc). I receive packets from them, not a problem, but when I transmit packets back it seems they''re lost in the routing.. somehow the gateway computer doesn''t know where it should be sending the packet. Is there anything I should be specifying in the UDP header to enable accurate routing by the gateway? I''ve read about tunneling, and it looks like it may work (wrapping an extra IP header around the packet so both the internet IP address and the LAN IP address are seperately specified), but I don''t want to bother coding it (have to use raw sockets) and testing it, if that''s not the answer Any help would be... helpful! Lucky Lucky''''s VB Gaming Site http://rookscape.com/vbgaming

Share this post


Link to post
Share on other sites
Advertisement
All of the ICS / NAT programs work by creating a map of which client (behind the NAT gateway) has connected to what host (outside the NAT gateway) on what port etc...

After a client has sent a packet to a host, the NAT gateway creates an entry in it''s NAT cache. Then, when a packet from a host (outside the gateway) sends a packet to the gateway it forwards those packets to the correct client by looking them up in the NAT cache.

As long as you have a typical client-server setup (i.e. your client initiates the connection to the host, not the other way around) and you use the same port to send back to the client that it uses to connect... you SHOULD be ok.

If you''re doing the above and still having problems, we''re probably gonna need to see your init and recv code for both the client and server.

Share this post


Link to post
Share on other sites
Thanks for the reply Jon, it was helpful. I had been looking around the net for some indication as to how NATs determine routing, and you''ve cleared that up.

The only problem that remains for me is this: My current methods for determining the client''s IP always return his LAN IP address, not the IP address of the gateway computer. Obviously the server won''t know where to send the packets if this is the case. Is there a method for determining the gateway IP from the client?

If not, am I then forced to "Connect" to the server in order to be able to send return packets to the proper IP? Or is there some other way of extracting that info from the IP header itself?

See, I''d rather not "Connect" if I don''t have to... that way I can receive all incoming packets on a single host port. Otherwise I''d have to dynamically track the receive ports for the various connected clients, would I not?

Thanks for the help so far!


Lucky

Lucky''s VB Gaming Site

Share this post


Link to post
Share on other sites
Alright, that explains it...

Since you''re using UDP and not connecting, you should be using sendto / recvfrom. Instead of determining the client''s IP address on the client and sending it to the server, you should use the SOCKADDR you get from recvfrom() and use that in your sendto() call.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!