dannagle / PacketSender

Network utility for sending / receiving TCP, UDP, SSL, HTTP
https://packetsender.com
GNU General Public License v2.0
2.34k stars 365 forks source link

When sending UDP packet the source port is different than expected sometimes. #184

Open wmanning opened 4 years ago

wmanning commented 4 years ago

What OS?

Windows 10 x64

Description of issue

  1. I go into File > Settings: 1.(a) check Enable UDP Servers 1(b) put say "20601" for UDP Server Ports.

When I send a packet to my server, the server says the source (aka "From Port" using packetsender's terminology") port is different than 20601. I'm wondering if somehow the port is taken and packetsender just picks an available port at random. I would expect a warning in that case but did not get one.

dannagle commented 4 years ago

Thanks for submitting this ticket.

Packet Sender will pop a warning if a port is taken. You can see this happening by launching a second instance of Packet Sender. See screenshot:

image

If you proceed with a failed bind, Packet Sender, as you suspect, will then use random UDP ports to send. I hoped this effect was clear by showing the UDP server button as disabled. See screenshot:

image

I agree passively choosing a random port is not great, but I wouldn't want to disable UDP completely if port failed to bind (there are uses to 1-way UDP tests). I could put an additional bottom-left notification whenever a random source port is chosen. That would keep functionality and not make the UI too noisy.

wmanning commented 4 years ago

I don't get that port bind popup. It also does not say "UDP Server Disabled". For instance I just set the port now to 20700. I don't get a warning and it displays "UDP: 20700 in the status at the bottom of the main window but the port it picked was 10934. I test by sending a command to my server.

Here are the settings I used: image

wmanning commented 4 years ago

This is the main window. You can see the source port is 20700. But that is not what the server sees. To be clear, I'm not sure if this issue is due to the port being taken or not (I was just guessing that was the reason). Maybe there is another reason.

packetsendermain

wmanning commented 4 years ago

It also seems to change the source port if there is a few minutes elapsed between sending the next UDP. At first it was using port 11384. I went on to do something else for a few minutes and came back to it and sent another UDP. It is now using 11929. That doesn't happen when I manually sending messages back to back (within a few seconds of each other).

The status at the bottom still says "UDP: 20700".

dannagle commented 4 years ago

I'm going to try to recreate this. Are you sending to a device on your LAN (192.168.1.x)?

wmanning commented 4 years ago

No, to a server hosted on AWS.