0

Not sure how else to phrase the question so that's why it's phrased the way it is. I have these two questions:

  1. Is it possible for two TCP segments with source port 80 to be sent by different processes at the sending host
  2. Is it possible for two UDP segments with source port 5723 to be sent by different processes at the same host?

I was unsure of the answer at first, but I believe the answer for both of these to be no, it isn't possible. The reason for this is in the case of TCP, there is no way to uniquely identify the segment because the 4 tuple (source port, dest port, source ip, and dest ip) will be the same across both processes which means no way to distinguish between the segments. Similarly, for UDP, the IP datagram will carry the source/dest IP, however, these will be the same. The UDP segment will carry the source port/dest port, but again, these will be the same. This means no ability to distinguish between segments for either protocol.

Possible solutions are to use the processes on two separate clients (would mean separate IP, solving the problem in both scenarios), or using the processes from the same host with different ports.

Please inform me if this is correct or if I'm way off, please tell me why. Thank you for your time!

wiregh0st
  • 57
  • 10
  • First, neither TCP nor UDP have clients or servers. Client/server is an application concept. Next, port numbers for TCP and UDP are really addresses for the process attached to the transport protocol. The port numbers are per protocol, so TCP 12345 is not TCP 12345. A process attached to a port number of either protocol exclusively uses that port number for that protocol. – Ron Maupin Oct 05 '20 at 01:33

1 Answers1

0

There's a related question: TCP: can two different sockets share a port? This piece is relevant there:

a given socket connection is uniquely identified by a combination of transport protocol, client IP+port, and server IP+port. Multiple clients can connect to the same server IP+port only if their client IP+port are different from each other

So I think you're mostly right but there can be special circumstances caused by SO_REUSEADDR or SO_REUSEPORT which might allow multiple different processes to reuse the same port: TCP - possible for same client-side port to be used for different connections by different applications simlutaneously?

Juraj Martinka
  • 3,991
  • 2
  • 23
  • 25