On Sun, 2015-05-24 at 14:14, Uriel Fanelli wrote:
> Hello all
>
> I am trying to develop a UDP server and I am falling into some strange
> issue.
>
> First: the configuration is
>
> MACHINE ==> UDP NAT ==> INTERNET ==> PEER
>
> Given that, I am trying to use
http://tools.ietf.org/html/rfc4787 (almost
> all routers are implementing it) , which means my "MACHINE" should
> answer to "PEER" using the same port the "MACHINE" uses to receive.
>
> Basically "MACHINE" sends some UDP packet to "PEER". "UDP NAT" remembers
> this, and associates the port to a NAT. So, then PEER answers back, the
> UDP packet is forwarded.
>
> Now, this is the problem.
>
> I can open a listener on "MACHINE"
> (
https://github.com/uriel-fanelli/tribes/blob/master/3be/UDP_server.go )
> and it works perfectly.
>
> Being a non-connection protocol, I expected I was permitted also to send
> packet FROM the port I use for listening: given there is no connection, how
> can i answer back from the open port, by example?
>
> But, this is not what happens. After I open a listener and I receive a
> packet, there is no way to answer re-using this source:port UDPConn.
>
> *Or: "is there a way to answer re-using the same udpConn?" *
>
> As it is, seems I can only read from a UDP Listener, but not answer using
> this port.
>
> Seems UDP was implemented *one-direction only*, or I am missing something.
> How can I compose and send a UDP datagram having as a origin a port I am
> listening at?
UDP (a protocol) is connection-less i.e. does not handle retransmission,
recovery, reordering or reassembly of packets. It 'throws packet to the
net' and forget about it. It does not expect any response from the
receiving end.
All this (retransmission, recovery, reordering or reassembly) must be
implemented at the application level if one needs that.
I didn't worked with low level networking in go (so I cannot provide
example) but from my reading of go docs it looks like this should be
easy.