Skip to main content
GameDev.net gamedev.net
🔒 Locked

UDP Nat & DHCP

Started by richcollins Jun 20, 2007 at 3:02 AM 4 replies 1.2k views
Original Post
richcollins
richcollins
I have a client that sends UDP packets to a server to set up NAT. The server sends back UDP to the NAT router on the port it received the packets from. When my client machine has a static LAN IP (192.168.1.10), the client receives the UDP packets from the server. However, when it has a dynamically assigned IP (192.168.1.100), it does not. Is this most likely a bug in the router's NAT software? (LinkSys WRT54G).
richcollins
richcollins
EDIT

It appears that NAT didn't flush a forwarding rule I had in for that static IP. It is, in fact, not working for static or dynamic LAN IPs.

I've read a lot of literature on NAT w/ UDP and I am almost certain I am doing it right.

1. I open a udp socket on the server and bind it to port 8010.
2. I open a udp socket on the client.
3. I send a constant (every few seconds) stream of UDP from the client to the server
4. The server inspects the packets received from the client. The IP is the IP of the router, the port changes every time I run the client, but it is the same port on the external interface of the router and the client.
5. The server sends UDP back to the external IP and port of the router.
6. The packets don't make it back to the client.
hplus0603
hplus0603
Do other games that use UDP work through that router?
If you put a network sniffer (such as WireShark) on the outside of the box, what port do the return packets have?
enum Bool { True, False, FileNotFound };
richcollins
richcollins
I actually confirmed it is this router. I went to a cafe close by and it worked. Odd that such a popular router doesn't work in this case.

I did tcpdump on the server to verify the port and ip of the sent packets. However I have not put anything in front of the router yet as that will be a pain in the ass to set up.

I do have an old BSD machine with 2 nics. I guess if I really want to have a look I can put it inline. Any free games for OS X I can download to see if they work?
Scuppy
Scuppy
Are you using unique source ports per session?
richcollins
richcollins
The source (client) port appears to be randomly assigned at the C level calls (socket or sendto maybe). Each time I restart the client it changes.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.