Reputation: 635
I've tested the program locally using a program called "Packet Tester"
I downloaded UDP Receiver/Sender for my mobile. Using the java program on my computer I was able to send packets to the mobile server and it was working great. I just typed in the mobiles IP address and the port number it was listening for.
When I tried running my UDP peer to peer on my Laptop and Computer they could not chat at all.
Does anyone know if it is to do with the fact the same router is being used or what not. It should not be since my mobile is receiving messages from the laptop and computer. ]
The Java app can retrieve UDP packets locally, but not from the laptop or mobile. The mobile can retrieve udp packets from the laptop and mobile. The tests show confusing results which have lead me to a wall.
I would appreciate what your thoughts on this are.
Thank you.
Upvotes: 0
Views: 437
Reputation: 1670
The problem might be because of Network Address Translation done by the router.
I believe you are sending packets to correct IP address but the port is not correct. The port to which you might be sending the packets is the local port to the machine. You need to send the packets to the port assigned by the router.
When the packet goes from a computer A to computer B through the router, the router maps the local port of computer to some random port.
So, if computer B needs to send a packet to computer A, then the computer B needs to send it to the IP:port assigned by the router. The router will then forward it to the local IP:port of computer A.
I suggest first understand how this mapping is created when UDP packets travel through a router within or external to the network. Read about Network Address Translation, UDP holepunching.
These source may help:
RFC 4787 NAT Behavioral Requirements UDP
Upvotes: 1