About IP Packet Communications – TCP and UDP

Devices communicate data to other devices on the Internet using certain recognised protocols that involve routing and transmission of packets of data to a remote device identified by an IP addresses. The most widely used protocols on the Internet are TCP and UDP. The differences between these two protocols are of a highly technical nature which we do not attempt to explain in detail here. However, there are some important common factors about the way they use IP addresses and Port Numbers for addressing and some important differences about reliability of transmission that it is useful to understand. Both connection methods can be used to send data between two computers over very short or very long distances. The Internet and World Wide Web relies heavily on TCP/IP as the means for communicating between end points – it is the transport mechanism for e-mail, web, FTP and many other core applications that run over the Internet.

Packets, Addresses and Port Numbers
For devices to establish a connection for communication of data over the Internet (or even across a Local Area Network), they must be able to send data packets to each other. They do this by setting the destination IP address within every data packet. To allow multiple services to run on each device and multiple separate conversations to exist at any given time, the destination address embedded in each packet also includes a Port Number. The IP address is used to route packets and send them along until they reach their destination. Once the packet arrives at the destination device, then the Port Number is inspected and used to determine which service is required (Web, FTP or whatever) and to establish if the packet belongs to a previously established connection.

Also embedded within each data packet is the IP address and Port Number of the sending device. We could therefore describe a data packet, in a simplified way, as a block of digital information comprising the Source address (IP address and Port Number), the destination address (IP and Port Number) and the actual data.

In TCP/IP, there is an initial dialogue between the two end points that involves an exchange of messages in a pre-defined conversation referred to as the handshake. TCP uses SYN messages in a three way handshake and thereby establishes a reliable confirmed connection. The initial dialogue used to establish the connection only needs to happen once – from then on the devices can send data messages to each using the existing connection in an ad-hoc manner until one of the participants closes the connection. However, each time a message is sent within an established connection, the TCP protocol requires that confirmation of receipt is sent back to the sending device thereby ensuring reliable transmission.

In UDP, messages are sent to the target destination without any inherent expectation of a response. There is no guarantee that the packet or packets sent to the destination will ever arrive. However, many of the applications that use UDP, including SIP, therefore include their own handshake protocols to confirm that two-way communication of messages is actually happening. The handshake is part of the higher level application protocol and is not built into the raw UDP mechanism in the way it is for TCP. UDP is therefore considered to be a lighter weight protocol than TCP – it involves less overhead at the lower levels than TCP.

1 thought on “About IP Packet Communications – TCP and UDP”

Comments are closed.