1

Researching about ports online, I have found it being described in many different ways. The main way is that a port is a like a door on your computer used by a specific process. A second way it is commonly explained is that it is just a tag, an extra identifier on top of the IP address for a specific process.

What I'm having trouble understanding is that if ports are actually "physical" in some way like a door. Does data actually go through a port? If so, then can data both be sent and received through the same port simultaneously?

If a port is more like just a tag, then what does it mean to "open" ports through a firewall?

Last question is, are ports needed to send data from the sending process? I understand that it has to send data to a specific port on the receiving end, and that it has to specify its local port used to receive data back, but when it does the actual sending, does it need to use a port (and is it the same as the port it already uses to receive)?

Any help is greatly appreciated!

1 Answer 1

0

Researching about ports online, I have found it being described in many different ways. The main way is that a port is a like a door on your computer used by a specific process. A second way it is commonly explained is that it is just a tag, an extra identifier on top of the IP address for a specific process.

The "door" explanation is just a metaphor. The tag example is more accurate. The destination and source ports are simply fields in the TCP and UDP headers that differentiate one TCP/UDP connection (combination of IP address and port) from another.

What I'm having trouble understanding is that if ports are actually "physical" in some way like a door. Does data actually go through a port? If so, then can data both be sent and received through the same port simultaneously?

Ports are not literally physical, but it's a useful methaphor to help understand.

If a port is more like just a tag, then what does it mean to "open" ports through a firewall?

A firewall that blocks specific ports simply inspects all traffic passing through it and checks the destination and/or source ports of TCP/UDP traffic. If there is a rule to block all incoming connections on port 80, then it will drop that traffic, otherwise it will forward it to the destination.

Last question is, are ports needed to send data from the sending process? I understand that it has to send data to a specific port on the receiving end, and that it has to specify its local port used to receive data back, but when it does the actual sending, does it need to use a port (and is it the same as the port it already uses to receive)?

Ports are only needed if you want to send data over TCP or UDP. For instance, a web server binds a socket to an IP address and port (usually 80 for HTTP). It listens for incoming connections with a destination port of 80. Once it establishes a connection (usually through the TCP handshake) it will open a new connection listening on a different port and tell the client which port to now connect to. To answer your question, the port is needed from the sending process so the receiver's kernel knows where to send the incoming traffic. It associates the (address, port) pair with a process.

2
  • Thanks for your answers. So for final clarification, when a computer sends data over TCP, there is no such thing as sending data through a port. It just specifies the destination port and includes a source port so the other end knows which port to send its replies. Correct? When I think of the word port, I think of portals that things go in and out of. But like you said, I guess it is more like just a tag or label.
    – johng2
    Jun 3, 2015 at 19:58
  • Correct. A port is nothing more than a label and has no more significance than if we started calling them weasels.
    – chemdt
    Jun 3, 2015 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.