Hi, Danny (et al.), On 2/20/2017 4:46 AM, Danny Niu wrote:
+1ell UDP source port 0 means don't reply (RFC 768). It's for uni directional streams. As for 0 to select a ephemeral port that is a BSD sockets convention. That isn't something the IETF should specify. The IANA port registries indicate default service interpretation for ports used as a destination for first-contact (TCP SYN, UDP 'request' messages intending a reply).It seems to me that this is rather more an IANA registry matter than a standardization one and that, given practices today, it would be reasonable to annotate the registry by adding "used for" or "known to be used for" to "reserved". There is no IANA registry for source ports, nor should there be. Ports in the incoming first-contact are swapped, as indicated in RFCs 768 and 793. Source ports indicate "who to call back", and "0" is indicated in UDP (RFC768) as "nobody" and TCP (RFC793) As to the Berkeley socket convention, "0" has special meaning when used in that API which follows mostly that already documented in RFC793. The special meaning is for passive OPEN when indicating the foreign socket. The other Berkeley conventions are specific to its API - if/when IANA decided to assign 0 for active OPEN foreign sockets or other uses, then presumably any API that could support that use would need a different way to indicate "don't care" or "to be selected by the OS". There's no *protocol* reason to exclude it, though, except that 793 makes it difficult to do a passive OPEN to that port. Finally, nearly all assigned ranges have RESERVED first and last values, to allow for future changes. RFC820 (Jan 1983) is the first to list 0 as RESERVED. The lists in RFC739 (Nov 1971) and 758 (Aug 1979) starts at 1, though 0 not yet flagged as RESERVED, it is not assigned as early as that. So, IMO, I would infer that the "not assignable" convention seems to predate the Berkeley socket convention. Joe |