This is a little off-topic, so I'm moving the thread to the e-mail hall, but the other thing to bear in mind is that source port numbers are used by NAT routers and can therefore change as the packet pops out onto the internet.
NAT (Network Address Translation) is used by routers where you have more than one computer on the "user" side of the router but only one address on the "internet" side of the router.
If one of my computers sends a request to the internet (say my POP3 server) it creates a request with the destination IP address and port number (110) and the source IP address (me) and port number. The source IP address is my computer's address on my network (say) 192.168.1.3. However this address is not a valid address on the internet, only on my network [*], so the router takes the 192.168.1.3 off and puts its own address on (194.247.44.171) and then sends the request to the server still addressed to port 110.
The server puts together the reply and sends it back to the IP address
and port that was in the original request.
How does the router know which of the computers on my network to return the reply to? That's where the port number comes in. When the router has taken the source IP address off and added its own before sending the request on its way, it changes the source port number too. When the reply comes back, the router looks at the port number, compares that to its record of ones that it has changed and then replaces the IP address and port with that of the computer that originally made the request and sends the reply back to that computer on the local network.
OK, there is more information there than most people would like to know, but it demonstrates that the
source port can be almost any, only the
destination port is fixed (110 for POP3, 25 for SMTP, 80 or 8080 for HTTP and 21 for FTP are just some examples).
[*] This address is one of a series of addresses that are reserved for use on private networks and as a result will never appear on the intenet. They are:
10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255
Eric wrote:Too late, Robin beat me again.
