TRANSPORT LAYER PROTOCOLS
TCP/IP defines two protocols for the transport layer, TCP and UDP. TCP is a connection-based protocol. Being connection based, the sender and receiver send each other a request and an acknowledgment to communicate before the data communication starts. UDP is a simple connectionless protocol. In this protocol, there is no packet exchange between the sender and receiver before communication begins.
TRANSMISSION CONTROL PROTOCOL (TCP-TRANSMISSION CONTROL PROTOCOL)
BASIC FUNCTIONS OF TCP:
- Multiplexing
- Troubleshooting (Reliability)
- Flow control using windowing
- Establishing and terminating a connection
- Data transfer
A gateway, called a port, is defined between the application layer and transport layer protocols. Each port has a 16-bit number and 216 ports are defined at each end. The 16-bit port number, a transmission control protocol and a 32-bit IP address form a socket. Port numbers are expressed as a number between 1 and 65536. Devices dynamically allocate port numbers starting from 1024. Commonly known port numbers (1-1024) are used by servers. Applications that provide a service, such as FTP or Telnet servers, open a socket using a commonly known port and listen for connection requests. These connection requests from clients must include both source and destination port numbers, and the port numbers used by servers must be commonly known port numbers. Port numbers between 0 and 255 are reserved for access to standard application layer services. Because port numbers can be used for multiple endpoint connections, users can share a port resource simultaneously.
TCP PACKET FORMAT :
tcp_packet
INITIATING TCP CONNECTION:
tcp-handshaking
INITIATING TCP CONNECTION:
UDP is one of the two transport layer protocols of the TCP/IP protocol group. The UDP protocol was written to create a datagram mode for packet-switched computer communication in advanced computer networks. This protocol includes a method for sending messages from one application program to another with a minimum protocol mechanism.
This protocol is transaction-oriented. Applications that require a guarantee of packet delivery use the TCP protocol. UDP is used for real-time data transfers such as voice and video transmission in wide area networks (WAN). UDP minimizes data transmission time by eliminating connection setup, flow control and retransmission. When UDP and TCP use the same communication path, the quality of service of real-time data transfer with UDP is reduced due to the high data traffic generated by TCP.
UDP is an unreliable transport protocol. The UDP protocol sends a packet over the network and does not keep track of whether or not it has arrived, and has no authority to confirm whether or not the packet has arrived. An example of a program that uses the UDP protocol is the SNMP service that uses port 161.
UDP is designed to be used in applications where it is not necessary to put datagrams in a specific order. Like TCP, UDP also has a header. The network software puts this UDP header at the beginning of the information to be transmitted. UDP then sends this information to the IP layer. The IP layer inserts its own header information and protocol number, this time the value of UDP is written in the number field. But UDP does not do everything that TCP does. The information is not divided into datagrams here and there is no record of the packets sent. All UDP provides is the port number. So many programs can use UDP. The UDP header is shorter than the TCP header because it contains less information. The header is all the information, including the source and destination port numbers and the checksum.
UDP PACKAGE FORMAT:
dataudp_package2
DIFFERENCES BETWEEN UDP AND TCP
UDP is not a reliable protocol because it does not check that the sent packet has arrived. User Datagram Protocol differs from TCP in that it is for the transmission of small data for query and test purposes; since the data is small, it does not need to be fragmented.
The UDP protocol does not take up much bandwidth on the network. The UDP header is shorter than the TCP header.
At the transport layer, the data whole formed by UDP is called a “datagram” and the data whole formed by TCP is called a “segment”. The main difference between the two is that the data group that makes up the segment has a sequence number at the beginning. Each datagram or segment is converted into an IP packet by IP by adding its own header and each IP packet is sent independently to the target device. The table compares the differences between TCP and UDP.
DIFFERENCES BETWEEN TCP AND UDP
tcp-udp
The most important reason for using UDP is low protocol overhead. For an application that requires real-time data flow, such as a video server, TCP is overloaded and the image will not play in real time. This is why datagram sockets are used in multicast applications. Also, for video and audio images, a small loss of data usually does not distort the sound or image. There is therefore no need for strict packet control. If you have a good physical connection, the error rate will be low and therefore TCP’s error packet checking will be overhead.