Java UDP, exemplo de perfuração - conexão através de firewall
Digamos que eu tenho dois computadore
Eles se conhecem IPs públicos e privados viaice4j
.
Um cliente escuta e o outro envia uma strin
Eu gostaria que isso acontecesse via perfuração UPD:
Let A be the client requesting the connection
Let B be the client that is responding to the request
Let S be the ice4j STUN server that they contact to initiate the connection
--
A sends a connection request to S
S responds with B's IP and port info, and sends A's IP and port info to B
A sends a UDP packet to B, which B's router firewall drops but it still
punches a hole in A's own firewall where B can connect
B sends a UDP packet to A, that both punches a hole in their own firewall,
and reaches A through the hole that they punched in their own firewall
A and B can now communicate through their established connection without
the help of S
Poderia alguém postar pseudo-exemplos de como fazer perfurações através de NAT simétrico? Supondo que haverá um servidor S que ajudará a adivinhar os números da porta e estabelecer a conexão entre o cliente A e B.Seria bom se você também considerasse o dobro do NA
NOTA Você pode usar o STUN para descobrir o IP e a porta, mas precisa escrever seu próprio código que enviaria a porta IP: para o servidor viakeepalive
técnica.
Uma vez que um cliente identifique o outro por meio de ID exclusivo no servidor, ele receberá o IP do cliente do outro: informações da porta para o furo UDP perfurar os dados necessários para enviar e recebe
Pequena atualização: Há uma biblioteca que está aparecendo no horizonte para java, confira:
https: //github.com/htwg/UCE#readm