UDP Through Closed ports!?

There is this game I am modaling my game after, but I have no clue how it
does it… but the game client (players) can log into the server and the
server is able to send UDP packets to the client. The client creates a
random UDP port. the clients can be behind a router or firewall but it
still get the UDP packets. BUT To host a game server from behind a router
you first have to portforward TCP and UDP ports for players to connect to,
yet you have to do none of this if connecting to a server (obviously not
for TCP since thats outbound).

Again, the players need no configuration to receive UDP packets from you.
I have no clue how this is done because if you host a server you must
porforward or unblock a specific port in the firewall. I’m trying to do
this with SDL_Net. It is critical players receive UDP packets without
router configuration. But am unable to figure this out. Any ideas? thanks.

http://www.google.com/search?q=udp+nat&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official

The first hit looks likely.

Cheers
BradOn 4/11/06, norco at ten-arc.net wrote:

There is this game I am modaling my game after, but I have no clue how it
does it… but the game client (players) can log into the server and the
server is able to send UDP packets to the client. The client creates a
random UDP port. the clients can be behind a router or firewall but it
still get the UDP packets. BUT To host a game server from behind a router
you first have to portforward TCP and UDP ports for players to connect to,
yet you have to do none of this if connecting to a server (obviously not
for TCP since thats outbound).

Again, the players need no configuration to receive UDP packets from you.
I have no clue how this is done because if you host a server you must
porforward or unblock a specific port in the firewall. I’m trying to do
this with SDL_Net. It is critical players receive UDP packets without
router configuration. But am unable to figure this out. Any ideas? thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

So is it easy to use NAT with SDL?

Isn’t NAT transparent to whatever software is using it?? IE you don’t
interface sdl to NAT at all, your os/hardware/router whatever will handle
that for you right?> ----- Original Message -----

From: sdl-bounces+atrix2=cox.net@libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of
norco at ten-arc.net
Sent: Tuesday, April 11, 2006 5:06 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] UDP Through Closed ports!?

So is it easy to use NAT with SDL?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

i created a udp server, behind a nat on port 31337 (port forwarded on
router). then I create a udp client behind a nat on port 31337. client can
send to server, but server can’t send to client. im stuck> Isn’t NAT transparent to whatever software is using it?? IE you don’t

interface sdl to NAT at all, your os/hardware/router whatever will handle
that for you right?

-----Original Message-----
From: sdl-bounces+atrix2=cox.net at libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of
@norco_at_ten-arc.net
Sent: Tuesday, April 11, 2006 5:06 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] UDP Through Closed ports!?

So is it easy to use NAT with SDL?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

NAT typically works by using port translation. This basically means
that only if host A on port X, who is behind a NAT box, sends a UDP
datagram to host B on port Y, who is not behind a NAT or has a NAT/
firewall with proper port-forwarding, host B can send a datagram to
host A. However, host B has to send the datagram a new address, C
(the address of the NAT), and a new port number, Z, where Z is a
random port number picked by the NAT box. When the NAT box receives
the packet addressed to (C,Z), it will translate the packet’s
destination address and forward it on to host A on port X.

Diagrammatically, we have

A — (A:X,B:Y,data1) --> NAT — (C:Z,B:Y,data1) --> B
A <-- (B:Y,A:X,data2) — NAT <-- (B:Y,C:Z,data2) — B

where (source address:port, destination address:port, data payload)
is our (structurally simplified) UDP packet.

This only works because the host behind the NAT sends the first
packet, because NAT maintains a translation table to map C:Z to A:X,
but this mapping only gets made when there is outbound traffic first.

So what you have to do is have the server (B) has to examine the
packet and determine what C and Z are (what the client’s address and
port number are), rather than send the data to a fixed port number.
Im pretty sure that the client code can basically stay the same though.

Also, if youre trying to figure out how a particular game’s network
protocol works, i highly recommend using ethereal, which lets you
look at individual IP packets.

hope this helps
spencerOn Apr 11, 2006, at 7:00 PM, norco at ten-arc.net wrote:

There is this game I am modaling my game after, but I have no clue
how it
does it… but the game client (players) can log into the server and
the
server is able to send UDP packets to the client. The client creates a
random UDP port. the clients can be behind a router or firewall but it
still get the UDP packets. BUT To host a game server from behind a
router
you first have to portforward TCP and UDP ports for players to
connect to,
yet you have to do none of this if connecting to a server
(obviously not
for TCP since thats outbound).

Again, the players need no configuration to receive UDP packets
from you.
I have no clue how this is done because if you host a server you must
porforward or unblock a specific port in the firewall. I’m trying
to do
this with SDL_Net. It is critical players receive UDP packets without
router configuration. But am unable to figure this out. Any ideas?
thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thanks a lot! it all made sense> NAT typically works by using port translation. This basically means

that only if host A on port X, who is behind a NAT box, sends a UDP
datagram to host B on port Y, who is not behind a NAT or has a NAT/
firewall with proper port-forwarding, host B can send a datagram to
host A. However, host B has to send the datagram a new address, C
(the address of the NAT), and a new port number, Z, where Z is a
random port number picked by the NAT box. When the NAT box receives
the packet addressed to (C,Z), it will translate the packet’s
destination address and forward it on to host A on port X.

Diagrammatically, we have

A — (A:X,B:Y,data1) --> NAT — (C:Z,B:Y,data1) --> B
A <-- (B:Y,A:X,data2) — NAT <-- (B:Y,C:Z,data2) — B

where (source address:port, destination address:port, data payload)
is our (structurally simplified) UDP packet.

This only works because the host behind the NAT sends the first
packet, because NAT maintains a translation table to map C:Z to A:X,
but this mapping only gets made when there is outbound traffic first.

So what you have to do is have the server (B) has to examine the
packet and determine what C and Z are (what the client’s address and
port number are), rather than send the data to a fixed port number.
Im pretty sure that the client code can basically stay the same though.

Also, if youre trying to figure out how a particular game’s network
protocol works, i highly recommend using ethereal, which lets you
look at individual IP packets.

hope this helps
spencer

On Apr 11, 2006, at 7:00 PM, @norco_at_ten-arc.net wrote:

There is this game I am modaling my game after, but I have no clue
how it
does it… but the game client (players) can log into the server and
the
server is able to send UDP packets to the client. The client creates a
random UDP port. the clients can be behind a router or firewall but it
still get the UDP packets. BUT To host a game server from behind a
router
you first have to portforward TCP and UDP ports for players to
connect to,
yet you have to do none of this if connecting to a server
(obviously not
for TCP since thats outbound).

Again, the players need no configuration to receive UDP packets
from you.
I have no clue how this is done because if you host a server you must
porforward or unblock a specific port in the firewall. I’m trying
to do
this with SDL_Net. It is critical players receive UDP packets without
router configuration. But am unable to figure this out. Any ideas?
thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I?ve implemented this into my net code and I still cant get it.

client A behind broadband router.
-internal ip = 192.168.1.43
-external ip = 24.542.32.223

server S behind broadband router and accepting TCP/UDP on port 31337
-internal ip = 192.168.1.47
-external ip = 141.25.74.118

A send UDP packet to S

S Receives A then
-ip = SDLNet_UDP_GetPeerAddress(sockudp, 0);

ip.host is something like 1.0.0.127 which looks looks like a reverse local
ip, must be the way I sprinted it…

ip.port becomes 49245

so then following a one time function I make a new IPaddress and UDPSocket
for sending from S to A:

char* hostS = “24.542.32.223”
-sockudp2=SDLNet_UDP_Open(0);
-SDLNet_ResolveHost(&ip2,hostS, ip.port);
-SDLNet_UDP_Bind(sockudp2, 0, &ip2);

WPE shows it sending to some NULL address, the client gets nothing. I’m
out of ideas. You guys are a great help, hope you can spare some more.
thanks.> NAT typically works by using port translation. This basically means

that only if host A on port X, who is behind a NAT box, sends a UDP
datagram to host B on port Y, who is not behind a NAT or has a NAT/
firewall with proper port-forwarding, host B can send a datagram to
host A. However, host B has to send the datagram a new address, C
(the address of the NAT), and a new port number, Z, where Z is a
random port number picked by the NAT box. When the NAT box receives
the packet addressed to (C,Z), it will translate the packet’s
destination address and forward it on to host A on port X.

Diagrammatically, we have

A — (A:X,B:Y,data1) --> NAT — (C:Z,B:Y,data1) --> B
A <-- (B:Y,A:X,data2) — NAT <-- (B:Y,C:Z,data2) — B

where (source address:port, destination address:port, data payload)
is our (structurally simplified) UDP packet.

This only works because the host behind the NAT sends the first
packet, because NAT maintains a translation table to map C:Z to A:X,
but this mapping only gets made when there is outbound traffic first.

So what you have to do is have the server (B) has to examine the
packet and determine what C and Z are (what the client’s address and
port number are), rather than send the data to a fixed port number.
Im pretty sure that the client code can basically stay the same though.

Also, if youre trying to figure out how a particular game’s network
protocol works, i highly recommend using ethereal, which lets you
look at individual IP packets.

hope this helps
spencer

On Apr 11, 2006, at 7:00 PM, @norco_at_ten-arc.net wrote:

There is this game I am modaling my game after, but I have no clue
how it
does it… but the game client (players) can log into the server and
the
server is able to send UDP packets to the client. The client creates a
random UDP port. the clients can be behind a router or firewall but it
still get the UDP packets. BUT To host a game server from behind a
router
you first have to portforward TCP and UDP ports for players to
connect to,
yet you have to do none of this if connecting to a server
(obviously not
for TCP since thats outbound).

Again, the players need no configuration to receive UDP packets
from you.
I have no clue how this is done because if you host a server you must
porforward or unblock a specific port in the firewall. I’m trying
to do
this with SDL_Net. It is critical players receive UDP packets without
router configuration. But am unable to figure this out. Any ideas?
thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

ok, I just installed Etherreal it shows Client A to be port: 2151 so I
need to send to that port I suppose. The problem is, how do I
programmicaly know that port is 2151 because when I use the
UDP_GetPeerAddress function on the receiving UDP fucting on the server it
shows it to be 49245… almost there just need to get the REAL port from
the UDP socket.> I?ve implemented this into my net code and I still cant get it.

client A behind broadband router.
-internal ip = 192.168.1.43
-external ip = 24.542.32.223

server S behind broadband router and accepting TCP/UDP on port 31337
-internal ip = 192.168.1.47
-external ip = 141.25.74.118

A send UDP packet to S

S Receives A then
-ip = SDLNet_UDP_GetPeerAddress(sockudp, 0);

ip.host is something like 1.0.0.127 which looks looks like a reverse local
ip, must be the way I sprinted it…

ip.port becomes 49245

so then following a one time function I make a new IPaddress and UDPSocket
for sending from S to A:

char* hostS = “24.542.32.223”
-sockudp2=SDLNet_UDP_Open(0);
-SDLNet_ResolveHost(&ip2,hostS, ip.port);
-SDLNet_UDP_Bind(sockudp2, 0, &ip2);

WPE shows it sending to some NULL address, the client gets nothing. I’m
out of ideas. You guys are a great help, hope you can spare some more.
thanks.

NAT typically works by using port translation. This basically means
that only if host A on port X, who is behind a NAT box, sends a UDP
datagram to host B on port Y, who is not behind a NAT or has a NAT/
firewall with proper port-forwarding, host B can send a datagram to
host A. However, host B has to send the datagram a new address, C
(the address of the NAT), and a new port number, Z, where Z is a
random port number picked by the NAT box. When the NAT box receives
the packet addressed to (C,Z), it will translate the packet’s
destination address and forward it on to host A on port X.

Diagrammatically, we have

A — (A:X,B:Y,data1) --> NAT — (C:Z,B:Y,data1) --> B
A <-- (B:Y,A:X,data2) — NAT <-- (B:Y,C:Z,data2) — B

where (source address:port, destination address:port, data payload)
is our (structurally simplified) UDP packet.

This only works because the host behind the NAT sends the first
packet, because NAT maintains a translation table to map C:Z to A:X,
but this mapping only gets made when there is outbound traffic first.

So what you have to do is have the server (B) has to examine the
packet and determine what C and Z are (what the client’s address and
port number are), rather than send the data to a fixed port number.
Im pretty sure that the client code can basically stay the same though.

Also, if youre trying to figure out how a particular game’s network
protocol works, i highly recommend using ethereal, which lets you
look at individual IP packets.

hope this helps
spencer

On Apr 11, 2006, at 7:00 PM, @norco_at_ten-arc.net wrote:

There is this game I am modaling my game after, but I have no clue
how it
does it… but the game client (players) can log into the server and
the
server is able to send UDP packets to the client. The client creates a
random UDP port. the clients can be behind a router or firewall but it
still get the UDP packets. BUT To host a game server from behind a
router
you first have to portforward TCP and UDP ports for players to
connect to,
yet you have to do none of this if connecting to a server
(obviously not
for TCP since thats outbound).

Again, the players need no configuration to receive UDP packets
from you.
I have no clue how this is done because if you host a server you must
porforward or unblock a specific port in the firewall. I’m trying
to do
this with SDL_Net. It is critical players receive UDP packets without
router configuration. But am unable to figure this out. Any ideas?
thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Im more familiar with BSD sockets programming than SDL_net, but here
are two other ideas that might help:

1.) In the server, instead of using UDP_GetPeerAddress(), check the
address field of the UDPpacket structure that you get from UDP_recv()
to authoritatively get the address that a particular packet came from.

2.) Try sending packets from the server through the same port (and
thus the same socket) through which they were received. Its possible
that more intelligent NAT boxes will filter incoming packets that
dont match its translation table exactly.

spencerOn Apr 11, 2006, at 11:56 PM, norco at ten-arc.net wrote:

ok, I just installed Etherreal it shows Client A to be port: 2151 so I
need to send to that port I suppose. The problem is, how do I
programmicaly know that port is 2151 because when I use the
UDP_GetPeerAddress function on the receiving UDP fucting on the
server it
shows it to be 49245… almost there just need to get the REAL port
from
the UDP socket.

I?ve implemented this into my net code and I still cant get it.

client A behind broadband router.
-internal ip = 192.168.1.43
-external ip = 24.542.32.223

server S behind broadband router and accepting TCP/UDP on port 31337
-internal ip = 192.168.1.47
-external ip = 141.25.74.118

A send UDP packet to S

S Receives A then
-ip = SDLNet_UDP_GetPeerAddress(sockudp, 0);

ip.host is something like 1.0.0.127 which looks looks like a
reverse local
ip, must be the way I sprinted it…

ip.port becomes 49245

so then following a one time function I make a new IPaddress and
UDPSocket
for sending from S to A:

char* hostS = “24.542.32.223”
-sockudp2=SDLNet_UDP_Open(0);
-SDLNet_ResolveHost(&ip2,hostS, ip.port);
-SDLNet_UDP_Bind(sockudp2, 0, &ip2);

WPE shows it sending to some NULL address, the client gets
nothing. I’m
out of ideas. You guys are a great help, hope you can spare some
more.
thanks.

NAT typically works by using port translation. This basically means
that only if host A on port X, who is behind a NAT box, sends a UDP
datagram to host B on port Y, who is not behind a NAT or has a NAT/
firewall with proper port-forwarding, host B can send a datagram to
host A. However, host B has to send the datagram a new address, C
(the address of the NAT), and a new port number, Z, where Z is a
random port number picked by the NAT box. When the NAT box receives
the packet addressed to (C,Z), it will translate the packet’s
destination address and forward it on to host A on port X.

Diagrammatically, we have

A — (A:X,B:Y,data1) --> NAT — (C:Z,B:Y,data1) --> B
A <-- (B:Y,A:X,data2) — NAT <-- (B:Y,C:Z,data2) — B

where (source address:port, destination address:port, data payload)
is our (structurally simplified) UDP packet.

This only works because the host behind the NAT sends the first
packet, because NAT maintains a translation table to map C:Z to A:X,
but this mapping only gets made when there is outbound traffic
first.

So what you have to do is have the server (B) has to examine the
packet and determine what C and Z are (what the client’s address and
port number are), rather than send the data to a fixed port number.
Im pretty sure that the client code can basically stay the same
though.

Also, if youre trying to figure out how a particular game’s network
protocol works, i highly recommend using ethereal, which lets you
look at individual IP packets.

hope this helps
spencer

On Apr 11, 2006, at 7:00 PM, norco at ten-arc.net wrote:

There is this game I am modaling my game after, but I have no clue
how it
does it… but the game client (players) can log into the server and
the
server is able to send UDP packets to the client. The client
creates a
random UDP port. the clients can be behind a router or firewall
but it
still get the UDP packets. BUT To host a game server from behind a
router
you first have to portforward TCP and UDP ports for players to
connect to,
yet you have to do none of this if connecting to a server
(obviously not
for TCP since thats outbound).

Again, the players need no configuration to receive UDP packets
from you.
I have no clue how this is done because if you host a server you
must
porforward or unblock a specific port in the firewall. I’m trying
to do
this with SDL_Net. It is critical players receive UDP packets
without
router configuration. But am unable to figure this out. Any ideas?
thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Yep, I did get to the udp in->address->host and port. host was correct,
port was wrong. the client continuously sends udp packets to the server
but the serverudp receive pack has right address but wrong port. I actully
debugged the server and entered in the port reported by Etherreal in
runtime and either real then showed the server sending to the client with
destination port the same as whats being received by the client, but the
client still received no packets. but if i went into the router setting
and portforwarded the port i was sending to then it would get the
packets… err> Im more familiar with BSD sockets programming than SDL_net, but here

are two other ideas that might help:

1.) In the server, instead of using UDP_GetPeerAddress(), check the
address field of the UDPpacket structure that you get from UDP_recv()
to authoritatively get the address that a particular packet came from.

2.) Try sending packets from the server through the same port (and
thus the same socket) through which they were received. Its possible
that more intelligent NAT boxes will filter incoming packets that
dont match its translation table exactly.

spencer

On Apr 11, 2006, at 11:56 PM, @norco_at_ten-arc.net wrote:

ok, I just installed Etherreal it shows Client A to be port: 2151 so I
need to send to that port I suppose. The problem is, how do I
programmicaly know that port is 2151 because when I use the
UDP_GetPeerAddress function on the receiving UDP fucting on the
server it
shows it to be 49245… almost there just need to get the REAL port
from
the UDP socket.

I?ve implemented this into my net code and I still cant get it.

client A behind broadband router.
-internal ip = 192.168.1.43
-external ip = 24.542.32.223

server S behind broadband router and accepting TCP/UDP on port 31337
-internal ip = 192.168.1.47
-external ip = 141.25.74.118

A send UDP packet to S

S Receives A then
-ip = SDLNet_UDP_GetPeerAddress(sockudp, 0);

ip.host is something like 1.0.0.127 which looks looks like a
reverse local
ip, must be the way I sprinted it…

ip.port becomes 49245

so then following a one time function I make a new IPaddress and
UDPSocket
for sending from S to A:

char* hostS = “24.542.32.223”
-sockudp2=SDLNet_UDP_Open(0);
-SDLNet_ResolveHost(&ip2,hostS, ip.port);
-SDLNet_UDP_Bind(sockudp2, 0, &ip2);

WPE shows it sending to some NULL address, the client gets
nothing. I’m
out of ideas. You guys are a great help, hope you can spare some
more.
thanks.

NAT typically works by using port translation. This basically means
that only if host A on port X, who is behind a NAT box, sends a UDP
datagram to host B on port Y, who is not behind a NAT or has a NAT/
firewall with proper port-forwarding, host B can send a datagram to
host A. However, host B has to send the datagram a new address, C
(the address of the NAT), and a new port number, Z, where Z is a
random port number picked by the NAT box. When the NAT box receives
the packet addressed to (C,Z), it will translate the packet’s
destination address and forward it on to host A on port X.

Diagrammatically, we have

A — (A:X,B:Y,data1) --> NAT — (C:Z,B:Y,data1) --> B
A <-- (B:Y,A:X,data2) — NAT <-- (B:Y,C:Z,data2) — B

where (source address:port, destination address:port, data payload)
is our (structurally simplified) UDP packet.

This only works because the host behind the NAT sends the first
packet, because NAT maintains a translation table to map C:Z to A:X,
but this mapping only gets made when there is outbound traffic
first.

So what you have to do is have the server (B) has to examine the
packet and determine what C and Z are (what the client’s address and
port number are), rather than send the data to a fixed port number.
Im pretty sure that the client code can basically stay the same
though.

Also, if youre trying to figure out how a particular game’s network
protocol works, i highly recommend using ethereal, which lets you
look at individual IP packets.

hope this helps
spencer

On Apr 11, 2006, at 7:00 PM, @norco_at_ten-arc.net wrote:

There is this game I am modaling my game after, but I have no clue
how it
does it… but the game client (players) can log into the server and
the
server is able to send UDP packets to the client. The client
creates a
random UDP port. the clients can be behind a router or firewall
but it
still get the UDP packets. BUT To host a game server from behind a
router
you first have to portforward TCP and UDP ports for players to
connect to,
yet you have to do none of this if connecting to a server
(obviously not
for TCP since thats outbound).

Again, the players need no configuration to receive UDP packets
from you.
I have no clue how this is done because if you host a server you
must
porforward or unblock a specific port in the firewall. I’m trying
to do
this with SDL_Net. It is critical players receive UDP packets
without
router configuration. But am unable to figure this out. Any ideas?
thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

So is it easy to use NAT with SDL?

A router does NAT, SDL doesn’t know, or care, about NAT.
Bob PendletonOn Tue, 2006-04-11 at 19:05 -0500, norco at ten-arc.net wrote:


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

Yes, Spencer has made that perfectly clear. I have even made a winsock
application to test out my routers nat. I had no problems gettings the udp
port from the sending client to send back to. but with SDL I am unable to.
I can do everything else for this game I’m writing, most of the game is
done. but I can’t figure out how to get source ports from the packet. and
even if I obtain them with eitherreal and edit the code with the nat port
during debug-time I simply cant get any packets through it SDL wont let
me… I REALLY need examples badly and I spent hours googling and cant find
any…> On Tue, 2006-04-11 at 19:05 -0500, @norco_at_ten-arc.net wrote:

So is it easy to use NAT with SDL?

A router does NAT, SDL doesn’t know, or care, about NAT.
Bob Pendleton


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

What about the SDL_Net examples? There’s a UDP ftp client/server in there,
and clearly each has to do 2-way communication to ensure a file gets sent
correctly.

GregoryOn Wed, 12 Apr 2006, norco at ten-arc.net wrote:

Yes, Spencer has made that perfectly clear. I have even made a winsock
application to test out my routers nat. I had no problems gettings the udp
port from the sending client to send back to. but with SDL I am unable to.
I can do everything else for this game I’m writing, most of the game is
done. but I can’t figure out how to get source ports from the packet. and
even if I obtain them with eitherreal and edit the code with the nat port
during debug-time I simply cant get any packets through it SDL wont let
me… I REALLY need examples badly and I spent hours googling and cant find
any…

norco at ten-arc.net wrote:

Yes, Spencer has made that perfectly clear. I have even made a winsock
application to test out my routers nat. I had no problems gettings the udp
port from the sending client to send back to. but with SDL I am unable to.
I can do everything else for this game I’m writing, most of the game is
done. but I can’t figure out how to get source ports from the packet. and
even if I obtain them with eitherreal and edit the code with the nat port
during debug-time I simply cant get any packets through it SDL wont let
me… I REALLY need examples badly and I spent hours googling and cant find
any…

Maybe you know all these, maybe I don’t know what I am
talking about since I am not a networking expert but anyway…

IMHO you can’t initiate a connection to a server behind
NAT in a default setup.

You must somehow tell the router to forward the connections
to the specific port to the host with the NATed address, and
then you try to connect to the router which has a valid IP and
not directly to the NATed host.

hope that helps

  .bill

norco at ten-arc.net wrote:

Yep, I did get to the udp in->address->host and port. host was correct,
port was wrong. the client continuously sends udp packets to the server
but the serverudp receive pack has right address but wrong port. I actully
debugged the server and entered in the port reported by Etherreal in
runtime and either real then showed the server sending to the client with
destination port the same as whats being received by the client, but the
client still received no packets. but if i went into the router setting
and portforwarded the port i was sending to then it would get the
packets… err

Try to place your server with a direct net connection first and test if it
works.

Also, if your UDP packets are too big, some routers will drop them without
notice. It is possible that the packets sent by the client are small enouth
to pass but all the packets sent by the server are too big.

Yes, Spencer has made that perfectly clear. I have even made a winsock
application to test out my routers nat. I had no problems gettings the udp
port from the sending client to send back to.

I’m sorry, but I am not following you. The udp port number is set by the
application developer. When you create the receive socket you give it a
port number to receive on and it does that. The sender specifies the
IP/Port pair to address the destination. If you want to send back then
the other side needs to be listening on an agreed upon port.

When you configure address and port forwarding on a NATing router you
also specify the protocol so that the router preserves the information
needed to make the connection work. It leaves the UDP port numbers alone
because it has to.

This has nothing to do with SDL or limitations in SDLnet.

You can save your self a lot of hassle by looking at
http://gameprogrammer.com/net2/net2-0.html Yes, I wrote it, and it makes
writing networked games much much easier.

	Bob PendletonOn Wed, 2006-04-12 at 13:00 -0500, norco at ten-arc.net wrote:

but with SDL I am unable to.
I can do everything else for this game I’m writing, most of the game is
done. but I can’t figure out how to get source ports from the packet. and
even if I obtain them with eitherreal and edit the code with the nat port
during debug-time I simply cant get any packets through it SDL wont let
me… I REALLY need examples badly and I spent hours googling and cant find
any…

On Tue, 2006-04-11 at 19:05 -0500, norco at ten-arc.net wrote:

So is it easy to use NAT with SDL?

A router does NAT, SDL doesn’t know, or care, about NAT.
Bob Pendleton


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

I think I just realised what I’m doign wrong. For some reason I thought if
I sent a packet to the nat port of the peer socket listening on 12345 the
nat would send it to that port… What im going do now is when TCP server A
gets a packet udp from B it sends B with TCP B’s source port to host on.
tell me if I’m wrong> On Wed, 2006-04-12 at 13:00 -0500, @norco_at_ten-arc.net wrote:

Yes, Spencer has made that perfectly clear. I have even made a winsock
application to test out my routers nat. I had no problems gettings the
udp
port from the sending client to send back to.

I’m sorry, but I am not following you. The udp port number is set by the
application developer. When you create the receive socket you give it a
port number to receive on and it does that. The sender specifies the
IP/Port pair to address the destination. If you want to send back then
the other side needs to be listening on an agreed upon port.

When you configure address and port forwarding on a NATing router you
also specify the protocol so that the router preserves the information
needed to make the connection work. It leaves the UDP port numbers alone
because it has to.

This has nothing to do with SDL or limitations in SDLnet.

You can save your self a lot of hassle by looking at
http://gameprogrammer.com/net2/net2-0.html Yes, I wrote it, and it makes
writing networked games much much easier.

  Bob Pendleton

but with SDL I am unable to.
I can do everything else for this game I’m writing, most of the game is
done. but I can’t figure out how to get source ports from the packet.
and
even if I obtain them with eitherreal and edit the code with the nat
port
during debug-time I simply cant get any packets through it SDL wont let
me… I REALLY need examples badly and I spent hours googling and cant
find
any…

On Tue, 2006-04-11 at 19:05 -0500, @norco_at_ten-arc.net wrote:

So is it easy to use NAT with SDL?

A router does NAT, SDL doesn’t know, or care, about NAT.
Bob Pendleton


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I think I just realised what I’m doign wrong. For some reason I thought if
I sent a packet to the nat port of the peer socket listening on 12345 the
nat would send it to that port…

NAT is invisible to applications, just ignore it. If your router is set
up so that your server gets TCP or UDP connections correctly it will
work.

What im going do now is when TCP server A
gets a packet udp from B it sends B with TCP B’s source port to host on.
tell me if I’m wrong

A server listening on a TCP socket on port X does not receive UDP
packets, it can only receive TCP connections. If you want receive UDP
packets you have to be listening on a UDP socket.

I do understand how hard it is to get this right, it gave me fits the
first time I saw it.

	Bob PendletonOn Wed, 2006-04-12 at 14:28 -0500, norco at ten-arc.net wrote:

On Wed, 2006-04-12 at 13:00 -0500, norco at ten-arc.net wrote:

Yes, Spencer has made that perfectly clear. I have even made a winsock
application to test out my routers nat. I had no problems gettings the
udp
port from the sending client to send back to.

I’m sorry, but I am not following you. The udp port number is set by the
application developer. When you create the receive socket you give it a
port number to receive on and it does that. The sender specifies the
IP/Port pair to address the destination. If you want to send back then
the other side needs to be listening on an agreed upon port.

When you configure address and port forwarding on a NATing router you
also specify the protocol so that the router preserves the information
needed to make the connection work. It leaves the UDP port numbers alone
because it has to.

This has nothing to do with SDL or limitations in SDLnet.

You can save your self a lot of hassle by looking at
http://gameprogrammer.com/net2/net2-0.html Yes, I wrote it, and it makes
writing networked games much much easier.

  Bob Pendleton

but with SDL I am unable to.
I can do everything else for this game I’m writing, most of the game is
done. but I can’t figure out how to get source ports from the packet.
and
even if I obtain them with eitherreal and edit the code with the nat
port
during debug-time I simply cant get any packets through it SDL wont let
me… I REALLY need examples badly and I spent hours googling and cant
find
any…

On Tue, 2006-04-11 at 19:05 -0500, norco at ten-arc.net wrote:

So is it easy to use NAT with SDL?

A router does NAT, SDL doesn’t know, or care, about NAT.
Bob Pendleton


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

norco at ten-arc.net wrote:

I think I just realised what I’m doign wrong. For some reason I thought if
I sent a packet to the nat port of the peer socket listening on 12345 the
nat would send it to that port… What im going do now is when TCP server A
gets a packet udp from B it sends B with TCP B’s source port to host on.
tell me if I’m wrong

Looking at the SDL_net API, I can see what is the problem. It looks like
what you are trying to do is impossible because of a bug in the API.

Let’s see how it should work. Server opens a socket and listens for incoming
packets. Let’s assume the client can reach the server and so he sends a
packet. The server will receive the data and he will also get to know the
IP address and the port used to send the packet. That information is very
important because the NAT will expect you to send back packets on that
IP:Port socket. Unfortunately, the UDPpacket struct doesn’t store the Port
information, only the IP information.