Computer Networks

Chapter 7
Transport Layer and End-to-End Communication

Post Graduate Diploma in Data Science
Computer Networks   •   Post Graduate

7. Transport Layer and End-to-End Communication

Introduction and Context

The transport layer is responsible for communication between application processes running on different hosts. Earlier networking layers deliver packets across interconnected networks, but they do not, by themselves, identify the specific application that should receive data, recover from loss, regulate transmission speed, or preserve the order of a data stream. These responsibilities belong primarily to the transport layer.

For data-science professionals, transport-layer behaviour is not merely a networking detail. Distributed data-processing systems, database clients, model-serving APIs, cloud storage, streaming platforms, notebooks, and machine-learning pipelines all depend on transport protocols. A poorly chosen protocol can produce unnecessary latency, excessive retransmission, unstable throughput, or difficult operational failures. Conversely, a suitable transport design can improve reliability, scalability, and resource utilisation.

The central design question is whether an application needs a reliable ordered byte stream, a lightweight datagram service, or a more modern transport that combines stream-oriented communication with reduced connection-establishment latency and improved behaviour over changing networks. TCP, UDP, and QUIC represent important answers to this question.

Learning Objectives

After studying this chapter, students should be able to:

1. Explain the role of the transport layer in end-to-end communication.

2. Distinguish ports, sockets, connections, and flows.

3. Describe multiplexing, demultiplexing, segmentation, and reassembly.

4. Explain how TCP provides reliability, flow control, congestion control, and connection management.

5. Compare TCP, UDP, and QUIC in terms of semantics, performance, security, and use cases.

6. Select an appropriate transport mechanism for data-intensive applications.

7. Analyse common transport-layer failures and design suitable diagnostic and mitigation strategies.

From Host-to-Host Delivery to Process-to-Process Communication

The network layer generally identifies destination hosts through IP addresses. A host, however, may run hundreds or thousands of networked applications at the same time. A packet addressed only to a machine is therefore insufficient. The transport layer adds a process-level addressing mechanism called a port number.

A port is a logical endpoint associated with a transport service. Port numbers are 16-bit values, ranging from 0 to 65,535. Ports from 0 to 1,023 are commonly called well-known ports and are traditionally associated with standard services, although actual use depends on operating-system privileges and deployment practices. Registered and dynamic ranges are used for application assignments and temporary client ports.

A client normally receives an ephemeral source port chosen by the operating system. The server listens on a known destination port. The combination of an IP address and a port is an endpoint. In programming, this endpoint is commonly represented through a socket. A socket is an operating-system abstraction that allows an application to send and receive data through a transport protocol.

For a TCP connection, the connection is identified by a four-tuple:

`(source IP address, source port, destination IP address, destination port)`

The protocol is also relevant in a complete identification. Multiple clients can connect to the same server port because their source addresses or source ports differ. A web server, for example, can accept many simultaneous connections on one service port while the operating system maintains separate socket state for each connection.

UDP demultiplexing is usually based primarily on the destination IP address and destination port, though operating systems may apply additional rules. UDP does not create a connection in the TCP sense. It sends independent datagrams, and each datagram retains message boundaries.

Multiplexing and Demultiplexing

Multiplexing occurs when data from several application processes is collected by the transport layer and transmitted through the network. The transport layer adds a header containing, among other information, source and destination ports. Demultiplexing occurs at the destination: the transport layer examines the header and delivers the payload to the correct socket.

This arrangement enables a single host to operate a web service, database service, secure shell service, monitoring agent, and many client applications simultaneously. It also explains why an incorrect port configuration can make a perfectly reachable server appear unavailable.

Segmentation and Reassembly

Applications often produce messages larger than the maximum payload that can be carried efficiently in one network packet. The transport layer divides application data into segments or datagrams. At the receiver, the data is reassembled according to the protocol’s rules.

TCP presents an ordered byte stream to the application. It does not preserve application message boundaries: two writes may be combined, or one write may be divided across several reads. Applications using TCP must therefore implement framing, such as length-prefix framing, delimiter-based framing, or a self-describing serialization format.

UDP preserves datagram boundaries. A single UDP send corresponds conceptually to one datagram, although the datagram may be lost, duplicated, reordered, or rejected if it exceeds path limitations. This distinction is fundamental when selecting a protocol.

Reliability as a Protocol Function

IP provides best-effort delivery. Packets may be lost because of congestion, corrupted, filtered, or delivered out of order. A transport protocol may address these problems using sequence numbers, acknowledgements, checksums, retransmission timers, and duplicate detection.

TCP numbers bytes in the stream. The acknowledgement number indicates the next byte expected by the receiver, thereby implementing cumulative acknowledgement. If a segment is lost, later segments may arrive but cannot be delivered in order to the application. TCP retransmits the missing data after a timeout or after sufficient evidence of loss, such as duplicate acknowledgements.

Reliability does not mean that the network becomes error-free. It means that the transport protocol detects specified failures and attempts recovery. Reliability also has a cost: acknowledgement traffic, buffering, state maintenance, retransmission delay, and possible head-of-line blocking.

UDP includes a checksum for detecting corruption, but it does not ordinarily retransmit lost data, reorder packets, or suppress duplicates. If an application requires such features, it must implement them itself or use a protocol built above UDP. This can be advantageous when the application can tolerate loss, has its own recovery strategy, or needs to make deadline-sensitive decisions.

TCP: A Reliable Byte-Stream Service

TCP is connection-oriented. Before application data is exchanged, the endpoints establish shared state through the three-way handshake. The initiating host sends a SYN segment, the receiver responds with SYN-ACK, and the initiator returns an ACK. The handshake synchronises sequence numbers and confirms bidirectional reachability sufficiently for connection establishment.

TCP uses sequence numbers to order data and acknowledgements to confirm receipt. Its receiver advertises a receive window, which limits the amount of unacknowledged data that the sender may transmit. This is the mechanism of flow control. The receive window protects a slow receiver from buffer exhaustion.

TCP also performs congestion control, which protects the network rather than an individual receiver. A sender maintains a congestion window based on its estimate of available network capacity. Important mechanisms include slow start, congestion avoidance, fast retransmit, and fast recovery. The effective sending window is constrained by both the receiver’s advertised window and the congestion window.

A simplified relationship is:

`in-flight data ≤ min(receive window, congestion window)`

TCP’s congestion-control algorithms respond to loss, delay, or explicit signals depending on the implementation. They attempt to share network capacity fairly, although fairness varies across algorithms, traffic patterns, and network conditions.

TCP connections are full duplex: both endpoints can send independently. They may be terminated gracefully using FIN and ACK exchanges or aborted using a reset. An endpoint may also enter states such as TIME-WAIT to prevent delayed segments from being confused with a later connection using the same addressing information.

TCP’s strengths include dependable ordered delivery, broad operating-system support, mature congestion control, and compatibility with many application protocols. Its limitations include connection setup overhead, head-of-line blocking, kernel and state-management costs, and limited visibility for applications into message boundaries.

UDP: Minimal Datagram Transport

UDP provides a connectionless datagram service. Its header is small and contains source port, destination port, length, and checksum fields. There is no handshake, built-in retransmission, ordering, receiver flow control, or general congestion-control algorithm comparable to TCP.

UDP is appropriate when low protocol overhead, message boundaries, or application-controlled timing is more important than automatic reliability. Examples include real-time media, discovery protocols, telemetry, online gaming, DNS queries, and some high-performance systems. It is also a foundation for newer protocols such as QUIC.

The absence of built-in reliability is not automatically a performance advantage. An application that adds acknowledgements, retransmissions, sequencing, rate control, and security may recreate much of TCP’s complexity. UDP is therefore best understood as a flexible building block, not as an inherently faster replacement for TCP.

UDP introduces operational responsibilities. Applications must consider packet loss, duplication, reordering, amplification risks, source-address validation, and congestion effects. A UDP sender that transmits aggressively without congestion control can harm other traffic and may be restricted by firewalls or network policy.

QUIC: Transport Functions over UDP

QUIC is a modern encrypted transport protocol implemented in user space and carried over UDP. It provides reliable delivery for streams, congestion control, connection identifiers, and integrated cryptographic handshaking. HTTP/3 uses QUIC as its transport.

QUIC typically combines transport establishment and cryptographic negotiation more efficiently than the traditional TCP-plus-TLS stack. It supports multiple independent streams within one connection. Loss affecting one stream does not require unrelated streams to wait for the missing data, reducing transport-level head-of-line blocking.

A QUIC connection is identified using connection identifiers rather than only the traditional four-tuple. This supports connection migration when a device changes network paths, such as moving from Wi-Fi to cellular access. QUIC encrypts most transport metadata and evolves through authenticated version negotiation and extensible frames.

QUIC does not eliminate congestion, propagation delay, or packet loss. It still requires retransmission and congestion-control mechanisms. Its advantages are especially significant for web applications, mobile clients, geographically distributed services, and systems with many logically independent streams.

QUIC can create deployment challenges. Middleboxes may treat unfamiliar UDP traffic differently from TCP, and monitoring tools must be adapted because transport information is encrypted. Server and client implementations also require careful tuning of cryptographic, memory, and connection-state resources.

Comparing TCP, UDP, and QUIC

TCP is the conventional choice when an application requires a reliable, ordered byte stream and broad compatibility. It is suitable for database sessions, file transfer, secure shell, many APIs, and transactional services.

UDP is suitable when the application values datagram boundaries, minimal setup, custom reliability, or time-sensitive delivery. It is useful for media, discovery, gaming, and specialised telemetry, provided the application manages loss and congestion responsibly.

QUIC is suitable when reliable streams are required but rapid setup, stream independence, connection migration, or user-space evolution are valuable. It is increasingly relevant to HTTP/3, mobile applications, and high-latency or variable-access networks.

Protocol selection should consider more than raw throughput. Relevant dimensions include:

  • delivery semantics: reliable, partially reliable, or best effort;
  • data model: byte stream or message-oriented datagrams;
  • latency: setup delay and recovery delay;
  • loss sensitivity and tolerance;
  • congestion-control requirements;
  • network compatibility and firewall traversal;
  • security and certificate integration;
  • observability and operational tooling;
  • connection scale and memory consumption; and
  • requirements for mobility or connection migration.

Flow Control, Congestion Control, and Performance Reasoning

Flow control is local to the sender and receiver. It prevents a sender from overwhelming the receiver’s buffer. Congestion control is broader: it regulates traffic according to estimated conditions in the shared network. Confusing the two leads to poor diagnosis. A receiver-window limitation suggests receiver processing or buffering constraints; a congestion-window limitation may indicate loss, delay, or a congested path.

Throughput is influenced by bandwidth, round-trip time, packet loss, window size, processing capacity, and application behaviour. In a long-distance high-bandwidth path, a small window can prevent the sender from keeping the path full. The bandwidth-delay product provides a useful conceptual estimate of the amount of data that must be in flight to utilise a path fully:

`bandwidth-delay product = bandwidth × round-trip time`

A data-intensive application should therefore be evaluated under realistic network conditions rather than only on a local network. Measurements should include throughput, goodput, round-trip time, retransmission rate, connection-establishment time, tail latency, loss, and resource consumption.

Practical Design and Diagnostic Considerations

An application should define its data semantics before selecting a transport. If every record is independently meaningful and late records have little value, datagrams may be suitable. If a missing byte invalidates all subsequent content, a reliable stream is more appropriate. If independent requests share a connection and blocking between them is costly, QUIC streams may offer an advantage.

TCP applications need explicit framing and sensible timeout policies. A read operation may return fewer bytes than requested, and an apparent idle connection may actually be broken. Applications should handle partial reads, orderly closure, resets, retries, and duplicate application requests. Retries must be designed with idempotency in mind; blindly retrying a non-idempotent transaction can create duplicate effects.

Transport tuning should not be used to conceal architectural problems. Increasing buffers may improve throughput in one environment but increase memory use and queueing delay in another. Disabling congestion safeguards is unsafe. Similarly, opening excessive parallel connections may increase load on servers, proxies, and operating systems.

Tools such as packet captures, socket statistics, flow logs, application metrics, and distributed tracing help distinguish DNS, routing, transport, and application failures. In encrypted QUIC traffic, packet-level analysis may reveal timing and loss patterns but cannot inspect application payloads without endpoint instrumentation.

Applied Case: A Distributed Feature-Processing Pipeline

Background

Consider an illustrative case involving a company that calculates customer features for real-time fraud detection. Events arrive from payment systems, are enriched by several services, and are stored in a distributed data platform. The system must process high volumes while keeping decision latency low.

Situation and Problem

The first implementation used one long-lived TCP connection between each processing worker and an enrichment service. The connection carried several logical request types. Under packet loss, a delayed response for one request caused later responses to wait in the application’s stream-processing logic. During mobile-network failover at some edge sites, connections also failed and required complete re-establishment. Operators observed high tail latency even though average bandwidth was adequate.

Analysis

The workload required reliable responses, so simply replacing TCP with raw UDP would have transferred substantial reliability and security responsibilities to the application. However, the workload contained independent logical streams, and some clients changed network paths. The main issues were application framing, stream interference, connection recovery, and insufficient instrumentation.

Approach and Solution

The engineering team adopted a QUIC-based protocol for suitable client-to-service traffic. Each request class used a separate logical stream, while message lengths were explicitly framed. The protocol used authenticated encryption, bounded request sizes, deadlines, and application-level correlation identifiers. Congestion control was retained, and the service imposed limits on concurrent streams and connection memory.

For internal batch transfers, where compatibility with existing infrastructure was more important than migration support, TCP remained in use. UDP was retained only for a lightweight discovery mechanism whose messages were small, repeatable, and safe to lose.

The team also added metrics for connection setup time, retransmissions, stream completion latency, abandoned requests, and retry counts. Idempotency keys prevented a retry from creating duplicate feature updates.

Outcome

The redesign reduced interference among independent requests and made path changes less disruptive. It did not remove all latency variability: congestion and remote-service delays remained observable. The major improvement came from matching transport semantics to workload structure and from measuring behaviour at both transport and application levels.

Learning Points

The case demonstrates that protocol choice is an architectural decision. Reliability, latency, mobility, observability, and operational compatibility must be considered together. A modern protocol is not automatically superior; TCP remained the rational choice where established infrastructure and stream semantics dominated.

Risks, Limitations, and Professional Considerations

Transport protocols can be abused through scanning, connection exhaustion, reflection or amplification attacks, spoofing, and denial-of-service traffic. Services should validate input sizes, limit concurrency, use authentication where appropriate, and monitor abnormal connection patterns. UDP services require particular attention to amplification: a small unauthenticated request must not cause a large response to an unsuspecting address.

Encryption protects confidentiality and integrity but does not guarantee trustworthy application behaviour. Certificates, key rotation, access control, logging, and data-retention policies remain necessary. Organisations should avoid collecting more network metadata than required and should protect flow records because they can reveal user behaviour, business relationships, or sensitive operational patterns.

Reliability mechanisms also create ethical and operational trade-offs. Aggressive retries can overload a failing service and amplify an incident. A data-science platform should use bounded retries, exponential backoff with jitter, circuit breakers, and clear failure semantics. Performance optimisation must not undermine availability for other users or violate organisational network policies.

Emerging Directions

Transport development is increasingly shaped by encrypted protocols, user-space implementations, programmable networking, and edge computing. QUIC’s extensibility permits new transport features without requiring every operating system kernel and middlebox to change simultaneously. Multipath transport research and deployment aim to use multiple network paths for resilience or performance. Datacenter applications also explore specialised congestion-control algorithms and kernel-bypass techniques, though these require careful testing and operational expertise.

Observability is evolving alongside encryption. Endpoint telemetry, structured events, eBPF-based measurements, connection identifiers, and distributed tracing can provide useful information without exposing application content. In data-intensive systems, transport metrics are increasingly integrated with workload metrics so that a fall in model-serving throughput can be related to retransmission, queueing, or path changes.

Best-Practice Guidelines

1. Select transport semantics from application requirements rather than protocol popularity.

2. Define message framing explicitly when using a byte-stream protocol.

3. Distinguish receiver flow control from network congestion control during diagnosis.

4. Use deadlines, bounded retries, exponential backoff, and idempotency controls.

5. Measure tail latency, loss, retransmission, setup time, and resource usage—not throughput alone.

6. Treat UDP as an engineering responsibility: add only the reliability and control mechanisms the application genuinely needs.

7. Consider QUIC when stream independence, rapid setup, encryption integration, or path migration is valuable.

8. Preserve TCP when compatibility, mature tooling, and dependable ordered streams are the dominant requirements.

9. Protect services against connection exhaustion, amplification, spoofing, and malformed input.

10. Test transport decisions under realistic bandwidth, delay, loss, mobility, and failure conditions.

Chapter Summary

The transport layer provides process-to-process communication above host addressing. Ports and sockets support multiplexing and demultiplexing, while segmentation and reassembly adapt application data to network transmission. TCP offers a reliable, ordered byte stream through sequence numbers, acknowledgements, retransmission, flow control, and congestion control. UDP offers a lightweight datagram service but leaves reliability and rate control largely to the application. QUIC uses UDP to provide encrypted, reliable streams, stream independence, connection identifiers, and support for connection migration.

Transport selection should be based on workload semantics, latency, loss tolerance, message boundaries, mobility, security, observability, and operational constraints. Data-intensive systems require measurement under realistic conditions and must treat retries, buffering, congestion, and connection scale as architectural concerns. Appropriate transport design improves not only network performance but also the reliability, security, and maintainability of distributed applications.

Key Terms

Port: A logical 16-bit identifier used to deliver transport-layer data to an application process.

Socket: An operating-system abstraction representing an application’s communication endpoint.

Endpoint: An addressable combination of a host address and transport port.

Multiplexing: Combining data from multiple application processes for transport across a network.

Demultiplexing: Delivering received transport data to the appropriate application socket.

Segmentation: Dividing application data into transport-layer units.

Reassembly: Reconstructing application data from received transport units.

Byte stream: An ordered sequence of bytes without preserved application message boundaries.

Datagram: An independent, message-oriented transport unit.

Reliability: The ability to detect specified delivery failures and attempt recovery.

Acknowledgement: Feedback indicating that data has been received or what data is expected next.

Flow control: Regulation that prevents a sender from overwhelming a receiver.

Congestion control: Regulation intended to prevent excessive load on the shared network.

Receive window: The amount of data a receiver is currently prepared to accept.

Congestion window: A sender’s estimate of the amount of data safely allowed in the network.

Head-of-line blocking: Delay to later data caused by missing earlier data.

Connection migration: Continuation of a transport connection while the network path changes.

Ephemeral port: A temporary port generally selected by an operating system for a client connection.

Bandwidth-delay product: The amount of data that can occupy a path based on bandwidth multiplied by round-trip time.

Idempotency: A property whereby repeating an operation does not produce additional unintended effects.

Review Questions

Short Answer Questions

1. Why are IP addresses alone insufficient for process-to-process communication?

2. What is the difference between a TCP byte stream and a UDP datagram service?

3. Distinguish flow control from congestion control.

4. What information is represented by a TCP four-tuple?

5. Why must TCP applications implement message framing?

Long Answer Questions

1. Explain TCP connection establishment, reliable delivery, flow control, and congestion control as an integrated system.

2. Compare TCP, UDP, and QUIC with respect to semantics, setup, reliability, security, and application suitability.

3. Discuss how sequence numbers, acknowledgements, retransmissions, and windows contribute to reliable communication.

4. Explain the design factors that should guide transport selection for a distributed data-processing platform.

5. Analyse the benefits and operational challenges of using QUIC for mobile and geographically distributed applications.

Analytical / Application Questions

1. A data pipeline sends independent requests over a single TCP connection. Packet loss causes severe tail-latency increases. Diagnose the likely mechanism and recommend two architectural responses.

2. A telemetry application sends frequent measurements where stale data has little value. Compare a carefully designed UDP solution with TCP and justify a choice.

3. A service experiences repeated duplicate database updates after network timeouts. Explain how transport behaviour and application retries can interact, and design safeguards to prevent the problem.

22. Multiple Choice Questions with Answers

Question 1

Which combination most directly identifies a TCP connection?

A. Destination IP address and protocol only

B. Source and destination IP addresses with source and destination ports

C. Source port and packet checksum only

D. MAC addresses and destination port

Correct Answer: B. Source and destination IP addresses with source and destination ports

Question 2

Why does a TCP application commonly require explicit message framing?

A. TCP encrypts all application messages

B. TCP preserves datagram boundaries incorrectly

C. TCP provides an ordered byte stream rather than application message boundaries

D. TCP cannot deliver data in sequence

Correct Answer: C. TCP provides an ordered byte stream rather than application message boundaries

Question 3

A receive window primarily protects which component?

A. The receiver from being overwhelmed

B. The network from all congestion

C. The sender from address spoofing

D. The application from encryption overhead

Correct Answer: A. The receiver from being overwhelmed

Question 4

Which feature distinguishes QUIC from a conventional TCP connection carrying several application requests?

A. QUIC eliminates congestion control

B. QUIC guarantees delivery without retransmission

C. QUIC supports independent streams that can reduce cross-stream head-of-line blocking

D. QUIC cannot operate over UDP

Correct Answer: C. QUIC supports independent streams that can reduce cross-stream head-of-line blocking

Question 5

Which application is the strongest candidate for UDP rather than TCP?

A. A file transfer requiring every byte in order

B. A transactional database update requiring reliable completion

C. A time-sensitive telemetry stream where late data is less useful than current data

D. A remote login session requiring an ordered character stream

Correct Answer: C. A time-sensitive telemetry stream where late data is less useful than current data

Question 6

If a sender is limited by its congestion window, what is the most relevant interpretation?

A. The receiver has definitely closed its socket

B. The sender is regulating in-flight data in response to estimated network conditions

C. The application has lost its port number

D. The transport protocol has disabled acknowledgements

Correct Answer: B. The sender is regulating in-flight data in response to estimated network conditions

Question 7

What is a major operational risk of implementing a high-volume UDP service without suitable controls?

A. It cannot use port numbers

B. It may contribute to congestion or amplification attacks

C. It automatically creates head-of-line blocking

D. It cannot transmit checksums

Correct Answer: B. It may contribute to congestion or amplification attacks

Question 8

A mobile client changes from Wi-Fi to cellular access during an active session. Which QUIC capability is particularly relevant?

A. Connection migration using connection identifiers

B. Removal of all encryption

C. Permanent elimination of packet loss

D. Conversion of datagrams into IP addresses

Correct Answer: A. Connection migration using connection identifiers

Question 9

What does the bandwidth-delay product help an engineer estimate?

A. The number of available port numbers

B. The amount of data that may need to be in flight to utilise a path

C. The probability that a checksum is correct

D. The number of application processes on a host

Correct Answer: B. The amount of data that may need to be in flight to utilise a path

Question 10

A service retries a timed-out non-idempotent request and creates duplicate effects. Which design principle best addresses this problem?

A. Increase the destination port number after every retry

B. Disable all acknowledgements

C. Use idempotency keys or equivalent duplicate-detection logic

D. Replace every TCP connection with an unregulated UDP flow

Correct Answer: C. Use idempotency keys or equivalent duplicate-detection logic

Computer Networks
Chapter 7 of 14