[Gambas-user] UDP hole punching

Dimitris Anogiatis dosida at gmail.com
Wed Jun 2 02:30:55 CEST 2021


Brian G,

A silly question. So in essence is hole punching just basically using an
external server S to connect two clients A and B without doing port
forwarding on each other's router?

On Tue, Jun 1, 2021 at 5:28 PM Brian G <brian at westwoodsvcs.com> wrote:

> I thought the nat took care of that..
>
> Flow:
>
> A and B each begin a UDP conversation with S; the NAT devices NA and NB
> create UDP translation states and assign temporary external port numbers
> EPA and EPB.
>
> S examines the UDP packets to get the source port used by NA and NB (the
> external NAT ports EPA and EPB).
>
> S passes EIPA:EPA to B and EIPB:EPB to A.
>
> A sends a packet to EIPB:EPB.
>
> NA examines A's packet and creates the following tuple in its translation
> table: (Source-IP-A, EPA, EIPB, EPB).
>
> B sends a packet to EIPA:EPA.
>
> NB examines B's packet and creates the following tuple in its translation
> table: (Source-IP-B, EPB, EIPA, EPA).
>
> Depending on the state of NA's translation table when B's first packet
> arrives
>    (i.e. whether the tuple (Source-IP-A, EPA, EIPB, EPB) has been created
> by the time of arrival of B's first packet),
>    B's first packet is dropped (no entry in translation table) or passed
> (entry in translation table has been made).
>
> Depending on the state of NB's translation table when A's first packet
> arrives
>    (i.e. whether the tuple (Source-IP-B, EPB, EIPA, EPA) has been created
> by the time of arrival of A's first packet),
>    A's first packet is dropped (no entry in translation table) or passed
> (entry in translation table has been made).
>
> At worst, the second packet from A reaches B; at worst the second packet
> from B reaches A.
>    Holes have been "punched" in the NAT and both hosts can directly
> communicate.
>
>
> From this it looks like your app get a message from S the go between
> containing the ip and port and then creates an outbound connection to the
> other host
> looks like you just need to read s's message and create a new udp
> connection to B.
>
> Maybe I am just miss reading or don't get what you are doing.
>
> Do you have a sample program?
>
> "Failure is the key to success;
>  each mistake teaches us something"  .. Morihei Ueshiba
> Brian G
>
> ----- On Jun 1, 2021, at 10:43 AM, Mayost Sharon sharon at 455.co.il wrote:
>
> > Hello to you
> >
> > Can it be done:
> > UDP hole punching
> > Through:
> > gb.net
> >
> > I understand that I need to change:
> > UdpSocket.SourceHost and UdpSocket.SourcePort
> > And they are for reading only
> > They cannot be changed
> >
> > Is there another way to perform: UDP hole punching
> >
> > Thank you
> >
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210601/18fc3c3d/attachment-0001.htm>


More information about the User mailing list