How to programmatically query the forwarding port is a NAT?

There is an application server that is behind a NAT (perhaps even several), you need to accept connections from the Internet.
Google brought upon NAT-PMP Protocol and the RFC 6886
But the specifications are not very understand how to form the query, and so it is not clear whether you can request any free port or have to pick them up to succeed.
Maybe someone will throw up more references to human readable manuals in Russian/English?
July 2nd 19 at 18:06
1 answer
July 2nd 19 at 18:08
Solution
Here's the article - all painted in detail
https://habrahabr.ru/post/279969/
The basic idea is that you can all feel with WireShark

Here is an example of software implementation
https://github.com/mono/Mono.Nat
The article discussed IGD Protocol, do not tell me will it work everywhere? or still need to implement both protocols? - geovanni_Hegmann commented on July 2nd 19 at 18:11
: No IGD Protocol will not work everywhere, moreover being behind a router You most likely will not be able to send SSDP multicast request and to obtain information about the router behind Your router. Ie for forwarding through multiple routers You have to first learn the topology of the network behind Your router is to clearly know where to send the request.
Moreover, there can be cases when the router supports one or the IGD/PMP or nothing at all. - marie.Gutmann commented on July 2nd 19 at 18:14
And I would say that for my taste the PMP Protocol is easier to implement than IGD - will have to write much less code. - marie.Gutmann commented on July 2nd 19 at 18:17

Find more questions by tags SocketsNetwork administration