When transmitting data, the Transport layer gets data from the Application layer and divides them into several data packets. TCP (Transmission Control Protocol) is the most used protocol on the Transport layer. When receiving data, TCP protocol gets the packets sent by the Internet layer and put them in order, because packets can arrive at the destination out-of-order, and also checks if the contents of the received packet are intact and sends an acknowledge signal to the transmitter, allowing it to know that the packet arrived intact at destination. If no acknowledge signal is received (either because it didn’t arrive the destination or because TCP found out that data was corrupted), the transmitter will re-send the lost packet.
While TCP re-orders packets and also uses this acknowledge system we mention, which is desirable when transmitting data, there is another protocol that works on this layer that does not have these two features. This protocol is called UDP (User Datagram Protocol).
Thus TCP is considered a reliable protocol, while UDP is considered an unreliable protocol. UDP is typically used when no important data is being transmitted, typically on DNS (Domain Name System) requests. Because it does not implement reordering nor an acknowledge system, UDP is faster than TCP.
When UDP is used, the application that requested the transmission will be in charge of checking whether data arrived and if it is intact or not and also reordering the received packets, i.e., the application will do the task of TCP.
Both UDP and TCP will get the data from the Application layer and add a header to it when transmitting data. When receiving data, the header will be removed before sending data to the proper port. On this header there are several control information, in particular the source port number, the target port number, a sequence number (for the acknowledge and reordering systems used on TCP) and a checksum (which is a calculation used to check whether data arrived intact at destination or not). UDP header has 8 bytes while TCP header has 20 or 24 bytes (whether the options field isn’t or is used, respectively).
In Figure 3 we illustrate the data packet generated on the transport layer. This data packet will be sent to the Internet layer (if we are transmitting data) or was sent from the Internet layer (if we are receiving data).