Hi I want to develop a project in peer to peer file transfer from one computer to another computer which have different nat or different ISP without middle server (only Stun Server allowed ). Even though we have to use Tcp for file transfer I just want to try it in UDP.
I studied this paper http://brynosaurus.com/pub/net/p2pnat/ for peer to peer connection basic view and i tried some practical things in UDP connection by using a aws ec2 free tier .
Case 1 : ( socket tcp server in aws using python )
Opened a tcp connection in a port 1234 in local machine and also opened a UDP connection in the same port in the same machine . Got the public ip and port by making a tcp connection to the aws server and maintained the connection . Then by using sendTo function by copying the external address from the terminal of the aws (Ssh connection). I sent a UDP packet to the public address of the remote computer from my local machine
Below is the code to send the udp packet :
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.sendTo(b'Message',('publicIp',PublicPort))
Result : Failed , ok acceptable
Case 2: ( socket UDP server binded on 1234 port in aws using python )
The server code in aws will maintain the list of established connection , so if more than 2 connection is there it will send the list of established connection to all the client in list of established connection .
so i am receiving the list of established connection in every connection console .
After that i used the public address of the udp connection to send data to the connection using sendTo function . Below is the code to send the udp packet :
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.sendTo(b'Message',('publicIp',PublicPort))
But I failed in this case also .
After that i thought that nat time out for the udp connection so i send a new UDP data to the server , But i recieved the list of extablished connection in all the connections .
So the Nat time out didnt happen , I must be technically wrong since the server can send the udp data to the clients and also udp is connection less .
So the logic must be , if i know the public address of the udp connection made to the aws server I can able to send udp data to that public address right .
Please help me to understand this logic , I tried searching google but i dont know the keywords to search in google .
Keywords I used to search in google:
Udp hole punching Tcp hole punching Udp hole punching using pyp2p
But I couldn't find solution .