• Port number from listen address

    From Roy Hann@21:1/5 to All on Mon Mar 13 17:14:10 2023
    Now that a listen address can have a "subport" number up to 15
    (formerly only up to 7), how is it hashed to an IP port number?

    I could just set one up to see where the extra bit pops up, but if
    someone knows off the top of their head...

    Roy

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Roy Hann@21:1/5 to Roy Hann on Mon Mar 13 21:11:08 2023
    Roy Hann wrote:

    Now that a listen address can have a "subport" number up to 15
    (formerly only up to 7), how is it hashed to an IP port number?

    I could just set one up to see where the extra bit pops up, but if
    someone knows off the top of their head...

    I went ahead and set one up. It turns out to be about as complicated as
    you might guess.

    Before I describe the change, there is a weird presentation of the
    old port number hash at https://communities.actian.com/s/article/Manual-Calculation-of-the-tcp-ip-Port-Number-from-Listen-Address.
    There is a better presentation including C code at https://ariel.its.unimelb.edu.au/~yuan/ingres/ingres_net_port.html. The
    latter explanation makes it clear the hash starts by setting bit 14,
    then additional bits are turned on depending on the listen address.

    In the new method, if the subport is less than or equal to 7 then bit 14
    is still set to 1. But if the subport is greater than 7 then
    bit 15 is set to 1 instead. The low-order three bits are set to
    whatever the subport is, masked with 0x07. (So if it's 8 the low order
    three bits are 000; if it is 10 the low order three bits are 010,
    etc.)

    Roy

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)