Options

Question about ports

Bl8ckr0uterBl8ckr0uter Inactive Imported Users Posts: 5,031 ■■■■■■■■□□
Greetings:


I have a quick question about ports. I know that 0-1023 are commonly known ports and I know that the host will make up ports to identify what program the data stream is from. I just have a few questions about the process (please be as blunt as possible as I am trying to learn):

Is there a process or procedure in which the host will choose the port?
For an example if 1 web server has many host hitting it using port 80, what is the process in which it will choose the next port? Does it just start counting from 1024 and continue forward?

I know that you can redirect common ports to high level lesser known ports. In the case above if the webserver redirected all port 80 traffic to port 1024 and another port 80 connection was made, would it begin counting from there?

If someone could point in the right direction i would be pleased.

Comments

  • Options
    tierstentiersten Member Posts: 4,505
    knwminus wrote: »
    I know that 0-1023 are commonly known ports
    They're called Well Known ports.
    knwminus wrote: »
    Is there a process or procedure in which the host will choose the port?
    Depends on the OS. Read this.
  • Options
    Bl8ckr0uterBl8ckr0uter Inactive Imported Users Posts: 5,031 ■■■■■■■■□□
    tiersten wrote: »
    They're called Well Known ports.

    This I knew. It has been a LONG day.
    tiersten wrote: »
    Depends on the OS. Read this.

    This I did not. Interesting.
  • Options
    Bl8ckr0uterBl8ckr0uter Inactive Imported Users Posts: 5,031 ■■■■■■■■□□
    that was very interesting. I noticed that windows only uses a little more than 3000 ports. Kind of makes you wonder why did they choose such a small port range and what happens to all of those wasted ports on a windows box.
  • Options
    gravyjoegravyjoe Member Posts: 260
    knwminus wrote: »
    that was very interesting. I noticed that windows only uses a little more than 3000 ports. Kind of makes you wonder why did they choose such a small port range and what happens to all of those wasted ports on a windows box.

    That is strange. I didn't know that. I always knew about the high dynamic ports, but I didn't know that Windows only used a few thousand ports for outbound connections (not only that, but that they're not in the high, dynamic port range).

    Normally, ports between 1024 - 49151 are used for inbound connections for vendor specific applications, while ports above 49151 are used for outbound connections.
    The biggest risk in life is not taking one.
  • Options
    Bl8ckr0uterBl8ckr0uter Inactive Imported Users Posts: 5,031 ■■■■■■■■□□
    gravyjoe wrote: »
    That is strange. I didn't know that. I always knew about the high dynamic ports, but I didn't know that Windows only used a few thousand ports for outbound connections (not only that, but that they're not in the high, dynamic port range).

    Normally, ports between 1024 - 49151 are used for inbound connections for vendor specific applications, while ports above 49151 are used for outbound connections.

    Well apparently only BSD follows the IANA's suggested port range. I thought it was odd as well. I also think that the actual port numbers are strange. I wonder if there is any thing to the fact that the amount of ports it 2 to the 16th. I wonder if it had to do with OS technology at the time....
  • Options
    UnixGeekUnixGeek Member Posts: 151
    knwminus wrote: »
    Well apparently only BSD follows the IANA's suggested port range. I thought it was odd as well. I also think that the actual port numbers are strange. I wonder if there is any thing to the fact that the amount of ports it 2 to the 16th. I wonder if it had to do with OS technology at the time....

    You're thinking along the right lines. Both TCP and UDP headers include 16-bit source and destination port numbers, so that's where the upper limit comes in.
  • Options
    tech-airmantech-airman Member Posts: 953
    knwminus wrote: »
    Greetings:


    I have a quick question about ports. I know that 0-1023 are commonly known ports and I know that the host will make up ports to identify what program the data stream is from. I just have a few questions about the process (please be as blunt as possible as I am trying to learn):

    Is there a process or procedure in which the host will choose the port?
    For an example if 1 web server has many host hitting it using port 80, what is the process in which it will choose the next port? Does it just start counting from 1024 and continue forward?

    I know that you can redirect common ports to high level lesser known ports. In the case above if the webserver redirected all port 80 traffic to port 1024 and another port 80 connection was made, would it begin counting from there?

    If someone could point in the right direction i would be pleased.

    knwminus,

    In order to help understand port numbers, it helps to understand how TCP or UDP works with those port numbers. Imagine a simple system of client and web server. So when the client requests a webpage, the TCP segment would carry a destination port of 80 but a source port of some random number. Then that TCP segment is sent towards the web server.

    The web server receives the TCP segment with a destination port of 80 and some random number for a source port, let's say 8000. So just like receiving an envelope in the mail, in order for the recipient of the mail to send a letter back to sender is to change the destination address from the recipient to the sender's address and change the sender's address from the sender's address to the recipient's address. Similarly, the same thing happens with the web server's reply to the client. The web server's reply back to the client is sent by another TCP segment, with destination port of 8000 and source port of 80.

    Eventually, the client receives the TCP segment and since it recognizes the destination port of 8000 which originally referred to the outbound web request's source port, the operating system forwards that traffic to the web browser application.

    Did this quick explanation help you understand port numbers better?
  • Options
    cerberoscerberos Member Posts: 168
    The point is that Microsoft is violating the Standard with reason and without. IANA stated that for outbound connection u should go after port 49151 and above but still there is no obligation or restriction on this rule, I don't know what's the real reason for Microsoft breaking this rule.
  • Options
    Bl8ckr0uterBl8ckr0uter Inactive Imported Users Posts: 5,031 ■■■■■■■■□□
    knwminus,

    In order to help understand port numbers, it helps to understand how TCP or UDP works with those port numbers. Imagine a simple system of client and web server. So when the client requests a webpage, the TCP segment would carry a destination port of 80 but a source port of some random number. Then that TCP segment is sent towards the web server.

    The web server receives the TCP segment with a destination port of 80 and some random number for a source port, let's say 8000. So just like receiving an envelope in the mail, in order for the recipient of the mail to send a letter back to sender is to change the destination address from the recipient to the sender's address and change the sender's address from the sender's address to the recipient's address. Similarly, the same thing happens with the web server's reply to the client. The web server's reply back to the client is sent by another TCP segment, with destination port of 8000 and source port of 80.

    Eventually, the client receives the TCP segment and since it recognizes the destination port of 8000 which originally referred to the outbound web request's source port, the operating system forwards that traffic to the web browser application.

    Did this quick explanation help you understand port numbers better?


    Yes and no. I understand ports and all it is just the numbers. The wiki article answered some questions but caused some more. But i'll manage.
Sign In or Register to comment.