Topic3-Transport_layer_protocols
UDP Communication
UDP Datagram Reassembly
UDP (User Datagram Protocol) fundamentally differs from TCP in its approach to data transfer reliability and ordering.
No Sequence Numbers: Unlike TCP, UDP does not employ sequence numbers in its datagram headers. This means it lacks the inherent mechanism to track the order in which datagrams are sent.
No Reordering: Consequently, UDP has no built-in method to reorder incoming datagrams if they arrive out of their original transmission sequence.
"Best Effort" Delivery: UDP simply reassembles the data in the exact order it arrives at the destination. This reassembled data is then immediately forwarded to the higher-layer application without any waiting for missing segments or reordering.
UDP Server Processes and Requests
Assigned Port Numbers: UDP-based server applications are typically configured to listen on specific, pre-defined port numbers. These can be either "well-known" ports (e.g., DNS on port 53, DHCP on port 67/68) or "registered" ports (for specific applications).
Demultiplexing: When a UDP datagram arrives at a server, the transport layer examines the destination port number in the datagram header. It then uses this port number to identify the specific application process that the data is intended for.
Data Forwarding: Once the appropriate application is identified, the application data payload from the UDP datagram is forwarded directly to that application.
UDP Client Processes
Dynamic Source Port Selection: When a UDP client application initiates a communication, it dynamically selects a temporary port number from a range of available numbers (often within the ephemeral port range, e.g., 49152 to 65535).
Destination Port: The destination port for the client's communication is typically the well-known or registered port number assigned to the server process it wishes to communicate with.
Consistent Port Pair: For the duration of a single transaction or conversation, the same pair of source and destination port numbers is used consistently in the header of all UDP datagrams exchanged between that client and server.
Module Summary: Transport Layer
Key Learnings
The transport layer (Layer 4 of the OSI model) serves as a critical bridge, linking the application layer (Layer 7) with the lower layers responsible for actual network transmission (network, data link, and physical layers).
Its primary function is to provide end-to-end communication services for applications, handling multiplexing and demultiplexing of application data.
The two fundamental protocols operating at this layer are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).
TCP Characteristics
Connection-Oriented: TCP establishes a formal connection, known as a "session," between the sender and receiver before data transfer begins. This involves a three-way handshake process.
Reliability: TCP ensures the reliable delivery of data. If segments are lost, corrupted, or duplicated, TCP detects these issues and initiates retransmissions.
Same-Order Delivery: TCP guarantees that data segments are delivered to the application layer in the exact order they were sent, even if they arrive out of sequence at the transport layer due to network conditions.
Flow Control: TCP implements flow control mechanisms to prevent a fast sender from overwhelming a slow receiver. It uses a "sliding windows" mechanism, where the receiver advertises its available buffer space, and the sender adjusts its transmission rate accordingly.
Sequence Numbers: Each segment in a TCP communication is assigned a sequence number in its header. This number is crucial for reordering segments and for acknowledging received data.
Acknowledgements (ACKs): The destination sends acknowledgments (ACKs) for received data, informing the source that specific bytes have been successfully received. This is integral to reliability and flow control.
Congestion Control: TCP incorporates sophisticated algorithms to detect and react to network congestion. These mechanisms, such as slow start, congestion avoidance, fast retransmit, and fast recovery, aim to reduce transmission rates when congestion is detected to prevent network collapse.
Typical MSS: A common Maximum Segment Size (MSS) for data within a TCP segment is 1,460 bytes. This refers to the largest amount of data (excluding TCP/IP headers) that a destination device can receive in a single segment.
UDP Characteristics
Connectionless: UDP does not establish a session prior to data transmission. Data is sent as simple datagrams without any pre-negotiation.
Unreliable: UDP offers no guarantees of delivery. Lost segments are not detected or retransmitted. It also does not ensure in-order delivery.
No Flow Control: UDP lacks mechanisms to manage the data flow rate between sender and receiver. It does not inform the sender about the receiver's resource availability, potentially leading to segment drops if the receiver is overwhelmed.
Simplicity and Speed: Due to its minimalist nature, UDP has lower overhead than TCP, making it faster and more suitable for applications where speed is paramount and occasional data loss is acceptable (e.g., streaming video/audio, DNS queries, online gaming).
Port Numbers
Multiplexing and Demultiplexing: Both TCP and UDP utilize port numbers to enable multiple applications on a single host to share the same network connection simultaneously. This process is called "multiplexing" at the sender and "demultiplexing" at the receiver.
Application Identification: Each application process running on a server or client is uniquely identified by a port number. This allows the transport layer to direct incoming data to the correct application and to identify the source application for outgoing data.
Assignment: Port numbers can be either:
Well-Known Ports (0-1023): Assigned to common network services (e.g., HTTP: 80, FTP: 21, SMTP: 25).
Registered Ports (1024-49151): Assigned to user processes or applications at the request of the developer.
Dynamic/Private (Ephemeral) Ports (49152-65535): Dynamically assigned by a client's operating system when a connection is initiated.
Data Reassembly: For the original message to be properly understood by the recipient application, all expected data segments must be received, and the data within these segments must be correctly reassembled into their original order (though for UDP, this is only in the order of arrival).