Transport Layer Services, Sockets, UDP Notes
Key Concepts of Transport Layer Services
Transport Layer Overview
- Acts as an interface between the application layer and the network layer.
- Responsible for process-to-process communication.
Segmentation and Reassembly
- Data is divided into segments before sending (sender side).
- Segments are reassembled back into messages upon receiving (receiver side).
- Segments may arrive out of order.
- Encapsulation: Adding headers as the packet moves down the layers.
- Decapsulation: Removing headers as the packet moves up the layers.
Transport Layer Services
Logical Communication
- Facilitates logical communication between application layer processes on different hosts.
- Sender side: choses segments and sends it down to the network layer.
- Receiver side: reconstructs the messages from segments.
Protocols in Transport Layer
- TCP (Transmission Control Protocol):
- Connection-oriented protocol.
- Guarantees reliable, ordered delivery of segments.
- Implements features like flow control, sequence numbers, and acknowledgments.
- UDP (User Datagram Protocol):
- Connectionless protocol.
- Provides no guarantees on delivery, order, or data integrity.
- Minimal services offered are process-to-process delivery and error checking.
Transport Protocol Functions
- Extends the network-layer service into a process-to-process delivery service.
- Implement multiplexing (sending) and demultiplexing (receiving) services.
Socket Programming
- Definitions
- Socket: Communication endpoints used by applications to communicate over the network.
- Identified by IP address and port number.
- Client-side: distinguishes between apps on the same machine.
- Server-side: distinguishes between different protocols (e.g., HTTP on port 80).
- Port Numbers:
- Well-known ports: 0 to 1023 for standard application protocols.
- Registered ports: 1024 to 49151 can be registered by vendors.
- Dynamic ports: 49152 to 65535 for temporary or private uses.
Multiplexing & Demultiplexing
Transport-layer Multiplexing
- Multiple segments distinguished using port numbers.
- At sender end, data from multiple sockets handled and port numbers added.
Demultiplexing
- At receiver end, tracks which segment belongs to which socket through its port number.
User Datagram Protocol (UDP)
Characteristics
- Connectionless with best-effort service.
- Susceptible to data loss and out-of-order delivery.
- Favored for real-time applications like DNS, streaming, or those that require minimal overhead.
UDP Header Format
- Contains source and destination ports, data length, checksum, and application data.
- Simple structure leads to reduced latency.
Checksum Mechanism
- A method to check for errors with sender performing one’s complement of the sum of segment words, and the receiver checks against the checksum value.
Application Contexts
- Used when applications can tolerate some data loss or require fast transmission without the overhead of connection management.