TCP/UDP Ports – Is a Unique TCP/UDP Port Assigned to a User?

ipv4tcpudp

I know that a user is assigned a routable IP to access internet so I was wondering if user is also assigned with TCP/UDP port too? I mean just like there is a specific IP of the destination server with whom we are connecting to and there is also a TCP/UDP port on that server on which we are connected. On client side we have external IP of the client. Does that client also have a port number? How to check it?

Best Answer

Many ISP's assign you an IP Address for Some Period. Most of the time they have one or more DHCP servers, so that every time you connect your modem or corresponding networking device you get a different IP and if they are not using NAT then most probably you will get a Temporary Public IP Address.

OK, now you have an working IP address and you can start communicating with some Internet Services whether it is a Network Layer Service, Transport Layer Service or Application Layer Service.

For Network layer Service you do not need to open a port on your computer. For example when you are pinging a machine from your computer by using ping command then you are actually using the ICMP protocol and more specifically you are using the ICMP Echo Request and In response you will get an ICMP echo Response. The Network layer can be also used for some other purposes for example IGMP or other Layer 3 protocols. The most interesting fact about this is that you do not need to have any Port open to work with this protocol. You need only an IP address for this.

But in terms of Transport Layer Service whether it is TCP or UDP you need to open a port to communicate with the service. And in terms of Application layer service that port will work with the socket API that will work with the particular Application. Most of the time it will open a higher value port (>1000) that is called an Ephemeral Port aka short lived port because the port will be closed as long as the transport layer is done.

Note that the Ephemeral port number varies from machine to machine.

Now the best Part is that ISP does not restrict you using any port number so you can use any short lived port with you connection.