ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Computer Networks
    CSI-417
    Progress0 / 18 topics
    Topics
    1. Analogue and Digital Transmission2. Noise3. Media4. Encoding5. Asynchronous and Synchronous Transmission6. Protocol Design Issues7. Network System Architectures (OSI, TCP/IP)8. Error Control9. Flow Control10. Data Link Protocols (HDLC, PPP)11. Local Area Networks and MAC Layer Protocols (Ethernet, Token Ring)12. Multiplexing13. Switched and IP Networks14. Inter-networking15. Routing16. Bridging17. Transport Layer Protocols (TCP/IP, UDP)18. Network Security Issues
    CSI-417›Transport Layer Protocols (TCP/IP, UDP)
    Computer NetworksTopic 17 of 18

    Transport Layer Protocols (TCP/IP, UDP)

    6 minread
    983words
    Intermediatelevel

    Transport Layer Protocols (TCP/IP, UDP)

    The Transport Layer is the fourth layer in the OSI model and is responsible for end-to-end communication, error handling, flow control, and ensuring reliable data delivery between devices on a network. The two most important transport layer protocols are Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). Both protocols are used to send data over networks like the internet but differ significantly in terms of reliability, control, and usage scenarios.


    1. Transmission Control Protocol (TCP)

    Transmission Control Protocol (TCP) is a connection-oriented, reliable transport layer protocol. It ensures that data is transmitted reliably between devices over a network by establishing a connection before transmission (using a three-way handshake) and providing mechanisms for error checking, flow control, and retransmission of lost packets.

    Key Characteristics of TCP:

    1. Connection-Oriented:

      • TCP establishes a connection before any data is transmitted. This involves a three-way handshake between the sender and receiver to synchronize the connection and ensure that both sides are ready to communicate.
    2. Reliability:

      • TCP guarantees the delivery of data. If packets are lost during transmission, TCP retransmits them. This is done using acknowledgements (ACKs) and sequence numbers to ensure all packets are received correctly and in order.
    3. Flow Control:

      • TCP uses flow control to prevent the sender from overwhelming the receiver. This is achieved using a mechanism called sliding window, where the sender is allowed to send a specific number of unacknowledged packets before waiting for an ACK from the receiver.
    4. Error Detection and Correction:

      • TCP uses a checksum to detect errors in the transmitted data. If errors are detected, TCP requests retransmission of the affected data.
    5. Sequencing:

      • Each TCP segment contains a sequence number that allows the receiver to reorder the segments in the correct order if they are received out of sequence.
    6. Congestion Control:

      • TCP includes mechanisms to detect network congestion and adjust its data transmission rate accordingly. Algorithms like slow start, congestion avoidance, and fast retransmit help manage congestion and ensure efficient use of network resources.
    7. Full-Duplex Communication:

      • TCP supports bidirectional data flow, meaning that data can be sent and received simultaneously between devices.

    TCP Three-Way Handshake:

    The three-way handshake is used to establish a TCP connection between the sender and receiver:

    1. SYN: The sender sends a synchronization (SYN) packet to initiate the connection.
    2. SYN-ACK: The receiver responds with a synchronization acknowledgment (SYN-ACK) packet.
    3. ACK: The sender sends an acknowledgment (ACK) packet to confirm the connection, and the data transfer begins.

    TCP Packet Structure:

    • The TCP header contains information like:
      • Source and destination port numbers
      • Sequence numbers
      • Acknowledgment numbers
      • Window size (for flow control)
      • Flags (SYN, ACK, FIN, etc.)
      • Checksum (for error detection)

    When to Use TCP:

    • Applications that require reliable data transmission, such as:
      • Web browsing (HTTP/HTTPS)
      • File transfers (FTP)
      • Email (SMTP, IMAP)
      • Remote logins (SSH, Telnet)

    2. User Datagram Protocol (UDP)

    User Datagram Protocol (UDP) is a connectionless, lightweight transport layer protocol. Unlike TCP, UDP does not establish a connection before data transmission and does not guarantee the reliable delivery of data. It is often used in applications where speed is more critical than reliability.

    Key Characteristics of UDP:

    1. Connectionless:

      • UDP does not establish a connection before sending data. There is no handshake process, and the sender simply sends data to the receiver without any prior negotiation.
    2. Unreliable:

      • UDP does not guarantee that data will be delivered or that it will be delivered in the correct order. There is no retransmission of lost or out-of-order packets, and no acknowledgment from the receiver.
    3. Low Overhead:

      • UDP has a smaller header size compared to TCP, making it more efficient in terms of transmission. This low overhead allows for faster data transfer.
    4. No Flow Control or Congestion Control:

      • UDP does not include mechanisms for flow control or congestion control. It sends data as fast as possible, which can sometimes lead to congestion or packet loss.
    5. Error Detection:

      • Like TCP, UDP uses a checksum for error detection. However, unlike TCP, if errors are detected, UDP does not request retransmission. The application layer is responsible for handling any errors if needed.
    6. Full-Duplex Communication:

      • UDP also supports bidirectional communication, allowing both sender and receiver to send and receive data simultaneously.

    UDP Packet Structure:

    • The UDP header is much simpler than the TCP header and contains:
      • Source and destination port numbers
      • Length (of the UDP header and data)
      • Checksum (for error detection)

    When to Use UDP:

    • Applications that prioritize speed over reliability, such as:
      • Streaming media (audio, video)
      • Voice over IP (VoIP)
      • Online gaming
      • DNS (Domain Name System) lookups
      • TFTP (Trivial File Transfer Protocol)

    UDP vs. TCP: A Comparison

    Feature TCP UDP
    Connection Type Connection-oriented Connectionless
    Reliability Guarantees delivery, retransmits lost packets No guarantees; packets may be lost
    Flow Control Yes (sliding window) No
    Congestion Control Yes No
    Error Detection Yes (checksum and retransmission) Yes (checksum, no retransmission)
    Packet Ordering Guarantees ordered delivery No ordering; packets may arrive out of order
    Overhead High (due to error handling, flow control) Low (minimal header)
    Speed Slower due to reliability mechanisms Faster due to minimal overhead
    Applications Web browsing, file transfer, email Streaming, gaming, VoIP, DNS

    Conclusion

    • TCP is ideal for applications that require reliable, ordered, and error-checked delivery of data. It is used in scenarios where data integrity and correctness are critical, such as file transfers, web browsing, and email.

    • UDP, on the other hand, is best for real-time applications that require fast transmission with lower overhead, and where occasional packet loss is acceptable, such as video streaming, VoIP, and online gaming.

    Both protocols serve different purposes depending on the needs of the application, with TCP focusing on reliability and UDP on speed and efficiency. Understanding when to use each protocol is key to building optimal network communication systems.

    Previous topic 16
    Bridging
    Next topic 18
    Network Security Issues

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time6 min
      Word count983
      Code examples0
      DifficultyIntermediate