What are: Network Ports, TCP & UDP

Network Ports:

When one computing device wants to communicate with a remote computing device, it needs two important parameters to reach and communicate with it. First, it needs the IP address of the remote computing device so that it can locate it over WAN / Internet, and it also needs to know the specific network port it wants to communicate with, on the remote machine.

Well, there is only one physical port – The Ethernet port that connects to the computer via an RJ-45 connection. But Network Ports refer to virtual ports that are used by software applications to communicate and interface with the hardware. Each application uses a different (virtual) network port to communicate with a Computer.

Common applications use certain pre-defined ports (defined by IANA) that are same for all the computers in the world. But applications can also be programed to communicate using specific/ uncommon ports.

Port numbers range from 0 – 65535 and most of the ports used by common applications use port numbers less than 1024. Applications can be sent by using TCP or UDP and both of them specify the source and destination port numbers in their headers.

For example, http/ https (web applications) communicate using port 80/ port 443, SMTP (email applications) communicate using port 25, SNMP (Network management applications) communicate using port 161, SSH/ Telnet (remote log-in applications) communicate via port 22/ port 23 , etc.

One of the important functions of a Network Firewall is to deny access to certain potentially harmful applications by blocking the ports used by them. For example, all FTP communications with a server can be denied by blocking port number 21 in the Firewall. But these days Firewalls have become much more advanced and can do more than just port blocking. Port scanning is a method by which hackers try to identify open ports in a computing device in order to hack-in and access resources using specific vulnerabilities applicable to those ports.

TCP (Transmission Control Protocol):

While the Internet Protocol is a Network Layer protocol that handles IP addresses and routing of messages to the right network destination, the TCP (Transmission Control Protocol) ensures that the messages are broken into small blocks (packets), wrapped using a header (at the senders end) and sent out using IP (Internet Protocol). TCP is also responsible for receiving individual packets (at the destination), arranging them in the right order and recreating the original message.

TCP is a connection-oriented protocol. Once a TCP session is established between two computing devices, the session continues till both the devices have exchanged all messages (for that session) completely. Multiple computing devices can open individual TCP sessions with remote computers simultaneously, using the same network port.

TCP is responsible for rearranging all the packets at the receiver end in the right order. So, if certain packets are lost during transit it will request for re-transmission and wait until all the packets have fully arrived, before presenting it to the application.

As you can see, TCP is very reliable but it takes up more computing resources at both endsΒ  because TCP sessions have to be individually opened and monitored. Any application that requires reliable transmission of all the data could use TCP. For example, TCP is used for delivery of web pages, file transfer, etc.

UDP (User Datagram Protocol):

The UDP (User Datagram Protocol) is very similar to TCP and works along with IP (Internet Protocol), like the TCP. While messages sent with UDP are packaged into small packets at the source and sent across to their destination location using IP, its job ends there.

UDP does not maintain a session with the remote computer till an entire message is completely delivered. They just send the packets out on the network and hope that most of the packets would reach their network destination.

UDP does not check if the packets have reached their destination, or if the packets have reached in order. These functions maybe done by the application at the receiving end. With UDP, there is no re-transmission of lost packets. For this reason, UDP is referred to as connection-less protocol.

Even though UDP does not offer a reliable service in sending all the packets to its destination, it is still popular for certain applications where timely delivery of majority of the packets with a low computing overhead, is very critical.

Think about real time applications like voice and video transported over the IP Network. These applications cannot wait until all the packets are delivered. In many cases, they can recreate the overall message using (most of) the available packets or using software correction algorithms.

You could stay up to date on the various computer networking / enterprise IT technologies by subscribing to this blog with your email address in the sidebar box that says, ‘Get email updates when new articles are published’