What are the differences between TCP and UDP? Also discuss various fields in TCP and UDP headers?

The TCP/IP protocol model at Layer 4 (transport layer) has two protocols - TCP and UDP.Both TCP and UDP use port (or socket) numbers to pass information to the upper layers:

 

        TCP supplies a virtual circuit between end-user applications.
        These are main characteristics of the TCP:
        Connection-oriented.
        Reliable.
        Divides outgoing messages into segments.
        Reassembles messages at the destination station.
        Re-sends anything not received.
        Reassembles messages from incoming segments.

 In brief TCP is transport layer protocol that provides reliable full-duplex data transmission.
 

TCP-Header:-   

Following are the fields in TCP-header.

TCP headers



  • Source Port 16 bits-This is the port through which was packet was generated at source machine.
  •  Destination Port 16 bits- This is the port through which the packet is supposed to be received by destination machine.
  • Sequence Number: 32 bits – Each TCP packet is assigned an identification number by transport layer. The sequence number field represents the sequence number of the first data octet in this segment (except when SYN is present).This field is used to ensure correct sequencing of the arriving data
  • Acknowledgment Number: 32 bits- This field contains the value of the next sequence number the sender of the segment is expecting to receive.
  • HLEN:-Number of 32-bit words in the header.
  •  Checksum:-Ensure that the data has not been damaged during transmission
  •  Urgent Pointer: Indicates the end of the urgent data
  •   Control or Flag Bits:  8 bits
=>  ACK:  Acknowledgment field significant
=>  RST:   Reset the connection
=> SYN:  Synchronize sequence numbers
=>  FIN:    No more data from sender
  •  Window:  16 bits
=> The number of data octets beginning with the one indicated in the acknowledgment field which the sender of this segment is willing to accept. Number of octets sender is willing to accept

      UDP-Protocol: UDP transports data unreliably between hosts.
Following are the characteristics:
  • }  Connectionless.
  • }  Unreliable.
  • }  Transmit messages (called user datagrams).
  • }  Provides no software checking for message delivery (unreliable).
  • }  Does not reassemble incoming messages.
  • }  Uses no acknowledgements.
Thus UDP is a simple protocol that exchanges datagrams, without acknowledgments or guaranteed delivery. Applications that do not need to guarantee data delivery use the faster UDP. UDP has no windowing or acknowledgments, so error detection is provided by application layer protocols.  UDP is encapsulated within the IP packet. UDP is the transport layer protocol used by DNS, TFTP, SNMP, and DHCP.

UDP-Header:- Following are the fields of UDP-Header:-

UDP headers

Source Port: - Optional - used only if reply is expected
Destination Port:-Specifies the application/protocol to which UDP needs to pass the data
Length:-Number of octets in the UDP segment
Checksum:-Ensure that the data has not been damaged during transmission

 
 

0 comments:

Feel free to contact the admin for any suggestions and help.