0
5.1kviews
Distinguish between UDP and TCP. Discuss their header formats also.
1 Answer
0
69views
Characteristics Description UDP TCP
Acronym for User Datagram Protocol or Universal Datagram Transmission Control Protocol
General Description Simple High speed low functionality "wrapper" that interface applications to the network layer and does little else Full-featured protocol that allows applications to send data reliably without worrying about network layer issues.
Protocol connection Setup Connection less; data is sent without setup Connection-oriented; Connection must be Established prior to transmission.
Data interface to application Message base-based is sent in discrete packages by the application. Stream-based; data is sent by the application with no particular structure
Reliability and Acknowledgements Unreliable best-effort delivery without acknowledgements Reliable delivery of message all data is acknowledged.
Retransmissions Not performed. Application must detect lost data and retransmit if needed. Delivery of all data is managed, and lost data is retransmitted automatically.
Features Provided to Manage flow of Data None Flow control using sliding windows; window size adjustment heuristics; congestion avoidance algorithms
Overhead Very Low Low, but higher than UDP
Transmission speed Very High High but not as high as UDP
Data. Quantity Suitability Small to moderate amounts of data. Small to very large amounts of data.

UDP Header Format: UDP packets, called user datagrams, have a fixed-size header of 8 bytes. Figure2shows the format of a user datagram. The fields are as follows:

enter image description here

1) Source port number :

i. This is the port number used by the process running on the source host.

ii. It is 16 bits long, which means that the port number can range from 0 to 65,535.

iii. If the source host is the client, the port number, in most cases, is an ephemeral port number requested by the process and chosen by the UDP software running on the source host.

iv. If the source host is the server, the port number, in most cases, is a well-known port number.

2) Destination port number :

i. This is the port number used by the process running on the destination host. It is also 16 bits long.

ii. If the destination host is the server, the port number, in most cases, is a well-known port number.

iii. If the destination host is the client, the port number, in most cases, is an ephemeral port number.

3) Length :

i. This is a 16-bit field that defines the total length of the user datagram, header plus data.

ii. The 16 bits can define a total length of 0 to 65,535 bytes. The length field in a UDP user datagram is actually not necessary.

4) Checksum :

This field is used to detect errors over the entire user datagram (headerplus data).

TCP header

The format of a segment is shown in Fig6. The segment consists of a header of20 to 60 bytes, followed by data from the application program.

The header is 20 bytes.

enter image description here

Fig6: TCP segment format

i. Source port address: This is a 16-bit field that defines the port number of the application program in the host that is sending the segment. This serves the same purpose as the source port address in the UDP header.

ii. Destination port address: This is a 16-bit field that defines the port number of the application program in the host that is receiving the segment. This serves the same purpose as the destination port address in the UDP header.

iii. Sequence number: This 32-bit field defines the number assigned to the first byte of data contained in this segment. TCP is a stream transport protocol. To ensure connectivity, each byte to be transmitted is numbered. The sequence number tells the destination which byte in this sequence is the first byte in the segment. During connection establishment each party uses a random number generator to create an initial sequence number (ISN), which is usually different in each direction.

iv. Acknowledgment number: This 32-bit field defines the byte number that the receiver of the segment is expecting to receive from the other party. If the receiver of the segment has successfully received byte number x from the other party, it returns x+ 1 as the acknowledgment number. Acknowledgment and data can be piggy backed together.

v. Header length: This 4-bit field indicates the number of 4-byte words in the TCP header. The length of the header can be between 20 and 60 bytes. Therefore, the value of this field is always between 5 and 15.

vi. Reserved: This is a 6-bit field reserved for future use.

vii. Control: This field defines 6 different control bits or flags as shown in Figure7.One or more of these bits can be set at a time. These bits enable flow control, connection establishment and termination, connection abortion, and the mode of data transfer in TCP.

enter image description here

Fig7: Control Field

viii. Window size: This field defines the window size of the sending TCP in bytes. Length of this field is 16 bits, which means that the maximum size of the window is 65,535 bytes. This value is normally referred to as the receiving window and is determined by the receiver.

ix. Checksum: This 16-bit field contains the checksum. However, the use of the checksum in the UDP datagram is optional, whereas the use of the checksum for TCP is mandatory. The same pseudo header, serving the same purpose, is added to the segment. For the TCP pseudo header, the value for the protocol field is 6.

x. Urgent pointer: This 16-bit field, which is valid only if the urgent flag is set, issued when the segment contains urgent data. It defines a value that must be added to the sequence number to obtain the number of the last urgent byte in the data section of the segment.

xi. Options: There can be up to 40 bytes of optional information in the TCP header.

Please log in to add an answer.