UDP Sessions and Ephemeral Port Selection
I would like to ask community to help me finding answers to the following questions:
- According to RFC 6056 an operating system should pseudo-randomly select ephemeral ports for each transport layer connection. For TCP, which is stateful protocol, the situation is clear: the ephemeral port is assigned to 5 tuple {protocol, source_ip, source_port, destination_ip, destination_port} until the connection is dropped. However, UDP is a stateless protocol, there is no UDP connection. Therefore, for me it is not clear how an ephemeral port is assigned in case of UDP. Is it different for every request? Is it randomly assigned to 5 tuple and preserved until no packets received during a TIMEOUT?
- Are the differences in the implementations of various operating systems, e.g., Windows, Unix, Linux?
According to https://www.cymru.com/jtk/misc/ephemeralports.html the selection strategy varies between random and sequential depending on OS. Based on my observations, it the source port for UDP is different for each request.