Как установить одноранговую связь без переадресации портов?

1107
muntasir2000

Мой провайдер предоставляет мне локальный статический IP-адрес. Как я могу установить соединение с другим компьютером в Интернете без публичного IP-адреса? Я просто хочу сделать простое приложение, которое может отправлять данные туда и обратно на другой компьютер за пределами моей локальной сети. Я немного знаю о переадресации портов, но, к сожалению, мой провайдер не может переадресовать порт для меня. Действительно ли это возможно без переадресации портов? Как? Благодарю.

0
Вы проверили, работает ли UPnP? UPnP - это протокол для переадресации портов, и, если вам повезет, он работает, даже если провайдер не сообщает вам об этом. nitro2k01 10 лет назад 0

1 ответ на вопрос

1
Daniel B

If the other party can set up port forwarding (or doesn't use NAT), you're all done. A TCP connection is always duplex-capable.

If that's not possible, you could resort to "Hole Punching", a technique that tricks NAT devices into allowing an "incoming" connection, with the help of a universally reachable third party.

Taken from the linked article, the basic principle:

    • Peer A sends a SYN to Peer B
    • Peer B sends a SYN to Peer A
    • When NAT-a receives the outgoing SYN from Peer A, it creates a mapping in its state machine.
    • When NAT-b receives the outgoing SYN from Peer B, it creates a mapping in its state machine.
  1. Both SYN cross somewhere along the network path, then:

    • SYN from Peer A reaches NAT-b, SYN from Peer B reaches NAT-a
    • Depending on the timing of these events (where in the network the SYN cross), at least one of the NAT will let the incoming SYN through, and map it to the internal destination peer
  2. Upon receipt of the SYN, the peer send a SYN+ACK back and the connection is established.