Transport Layer Principles and Protocols
Chapter 1: Introduction to Transport Layer
- Overview of the transport layer, specifically focusing on TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).
- Learning objectives:
- Understand and describe transport layer principles.
- Perform calculations related to transport layer concepts (examples provided).
- High-level aspects of transport layer services.
Principles of Transport Layer Services
- The transport layer operates between the application layer and the network layer, enabling process-to-process communication (e.g. web browser to web server).
- Key functions of the transport layer:
- Provides reliability and error detection, essential for applications.
- Uses multiplexing/demultiplexing to allow multiple applications to share a single transport connection.
- Flow control to manage data transmission speed between sender and receiver.
Types of Transport Services
- Connection-oriented: Establish a reliable connection first (e.g. TCP).
- Connectionless: Send messages without establishing a connection (e.g. UDP).
- Each service offers different reliability guarantees, with TCP ensuring reliable delivery while UDP does not.
Addressing in Transport Layer
- Addresses in transport layer consist of:
- IP address for locating the host.
- Port number for identifying the specific application on the host (e.g. port 80 for HTTP, port 22 for SSH).
Multiplexing and Demultiplexing
- Multiplexing: Combining multiple data streams into one during transmission.
- Demultiplexing: Extracting the original streams from combined data at the receiving end, using port numbers to distinguish between applications.
Flow Control Mechanism
- Flow control prevents the receiver from being overwhelmed with data, allowing it to signal the sender to slow down if necessary.
- Involves managing buffer sizes to ensure data is processed efficiently without data loss.
Chapter 2: UDP Protocol Overview
- UDP is a connectionless protocol used for applications where speed is preferred over reliability (e.g. live video streaming).
- UDP benefits:
- No need for connection establishment or maintenance (lower overhead).
- Smaller header size (8 bytes) compared to TCP (20 bytes), advantageous for lightweight devices.
- Real-time applications can tolerate some data loss rather than delays caused by retransmissions.
- Composed of four fields, each 2 bytes in length:
- Source Port and Destination Port (16-bit each).
- Length of the UDP packet (header + data).
- Checksum for error detection (optional).
- Checksum calculated over the entire UDP datagram and selected IP header fields to detect corruption during transmission.
Chapter 3: TCP Protocol Overview
- TCP is a connection-oriented protocol ensuring reliable byte-stream communication, preserving message order and retransmitting lost packets.
- Key TCP features:
- Connection establishment (three-way handshake): SYN, SYN-ACK, ACK.
- Reliable delivery through sequence numbers, acknowledgments, and retransmissions.
- Flow control to avoid overwhelming the receiver.
- Congestion control to adapt to network traffic conditions.
- TCP header includes:
- Source and destination port numbers (16 bits each).
- Sequence and acknowledgment numbers (32 bits each).
- Flags for controlling packet handling (e.g., SYN, ACK).
- Window size to manage flow control.
- Checksum for error detection (similar to UDP).
- Optional fields for additional functionalities.
Chapter 4: TCP Connection State Machine
- TCP uses a state machine to manage the connection lifecycle:
- Common states include LISTEN, SYNSENT, ESTABLISHED, FINWAIT, TIME_WAIT, and CLOSED.
- The client and server states progress through various events (e.g., SYN, ACK) during connection establishment and termination.
- Important states include:
- SYN_SENT: Initiated by the client to establish connection.
- ESTABLISHED: Both ends have successfully communicated and can exchange data.
- FINWAIT and TIMEWAIT: Manage graceful connection closure, ensuring all packets are accounted before fully terminating.
Chapter 5: Reliable Data Transfer Concepts
- Reliable data transfer protocols must handle various error scenarios in network communication:
- Bit errors: use checksums to detect and request retransmissions.
- Packet loss, requiring mechanisms like acknowledgments and sequence numbers to ensure the sender knows which packets have been received.
- The protocol design involves balanced trade-offs between complexity and performance depending on the application's requirements.
- Stop-and-Wait Protocol: A simple approach where the sender waits for an acknowledgment before sending the next packet. It can be inefficient but is easy to understand.
Sequence Numbers in Reliable Communication
- Adding sequence numbers helps in identifying which packets have been received or acknowledged, providing an efficient way to deal with retransmissions and duplicate packets.
- Using sequence numbers avoids confusion between acknowledging a new packet or resending the previous packet.
Conclusion
- Understanding the principles and mechanisms of TCP and UDP is essential for developing systems that rely on data transmission across networks.
- These protocols define how applications communicate over networks today, affecting everything from web browsing to video streaming. It’s crucial to grasp their operational details for effective networking in real-world applications.