What are network ports internally?

0

I know there will be multiple ports in the host/computing machine for each of the services that i hosts on the network.

But i want to understand what are these ports internally?

Below is my understanding of network ports. Correct me if i am wrong. Add details to make it more clear.

They might be a software construct, mostly a queue/buffer inside the networking component of OS, created dynamically whenever a network service (Web service, file transfer service, etc.) is hosted on the machine. And each of the network service would be listening to their respectively port (to receive the data) and also has access to write it that port (to send the data). [Just like a bounded buffer problem]

When data needs to be sent-
The network service (Application) would make a system call to OS (say, send()) to write the data onto the buffer and inform the transport protocol. So that the TCP/UDP protocol would take the data from the buffer and segment it and pass it down the network stack.

When data needs to be received-
As the data arrives to the host through the NIC, data would be read from some low level network component in the OS and passed up the network stack. And when the transport layer component of OS reads it, it puts the data on the queue associated with that particular port no. so that the application (network service) listening to that port can read the data.

Darshan L

Posted 2018-03-28T10:54:29.733

Reputation: 555

Question was closed 2018-04-02T06:50:59.820

Feel free to have a look here : https://en.wikipedia.org/wiki/Port_(computer_networking)

– pim – 2018-03-28T11:08:44.377

Related:  What is a socket? (on U&L)

– Scott – 2018-04-02T18:31:53.263

Answers

1

Almost, but not entirely correct.

  • Sockets are the software construct with buffers (each socket has separate send & receive queues). For TCP, each connection uses a separate socket.

  • Ports are only numeric labels used for demultiplexing – helping the OS choose which socket (or which receive buffer) should receive an incoming packet.

Each socket is associated with multiple parameters – protocol, local & remote addresses, and local & remote ports – and all of them are used when looking up a received packet. (When the addresses are identical, at least one of the ports must be different. But if the addresses are different, then multiple sockets can use identical ports.)

user1686

Posted 2018-03-28T10:54:29.733

Reputation: 283 655