Transport layer is one of the most exam-important networking topics because it connects abstract network delivery with real application communication. For PSC Computer Engineer, you should be able to explain ports, sockets, UDP, TCP reliability, flow control, congestion control, handshake, timeout and window-based transmission with engineering clarity.
Engineering Definitions
Transport layer
Standard definition: The layer that provides process-to-process communication between applications running on different hosts.
Exam meaning: IP ले host-to-host delivery गर्छ; transport layer ले application process-to-process delivery गर्छ।
Port number
Standard definition: A 16-bit logical identifier used by the transport layer to identify an application process or service endpoint.
Exam meaning: एउटै IP भएको computer मा कुन application/service लाई data दिनुपर्ने हो छुट्याउने number।
TCP
Standard definition: Transmission Control Protocol is a connection-oriented, reliable, ordered byte-stream transport protocol.
Exam meaning: Reliable, ordered र congestion-aware communication चाहिँदा प्रयोग हुने transport protocol।
UDP
Standard definition: User Datagram Protocol is a connectionless, message-oriented transport protocol with minimal overhead and no built-in reliability.
Exam meaning: कम overhead, low latency र application-controlled reliability चाहिँदा प्रयोग हुने protocol।
Flow control
Standard definition: A mechanism that prevents a fast sender from overwhelming a slow receiver.
Exam meaning: Receiver को buffer capacity अनुसार sender लाई नियन्त्रण गर्ने mechanism।
Congestion control
Standard definition: A mechanism that prevents too much traffic from overloading the network path.
Exam meaning: Network भित्र queue overflow, packet loss र delay बढ्न नदिन sender rate adjust गर्ने mechanism।
Concept Teaching
Think of transport layer as the operating system service that takes data from one program and delivers it to the correct program on another machine. IP only knows source and destination host addresses. TCP/UDP add source and destination ports, so web browser, DNS resolver, SSH client, database client and mail client can all share the same network interface at the same time.
Transport Layer Service Model
Transport layer sits above IP. It cannot magically make the network perfect, but it can add useful end-to-end services such as multiplexing, reliability, ordering and rate control.
- Multiplexing: sender collects data from many application processes and marks each with a port number.
- Demultiplexing: receiver uses destination port and socket information to deliver data to the correct process.
- Connection management: TCP establishes and terminates logical connection state; UDP does not.
- Reliability: TCP detects lost segments and retransmits; UDP leaves reliability to the application if needed.
- Ordering: TCP delivers bytes in order; UDP preserves datagram boundaries but does not reorder for the application.
Sockets and Connection Identification
A socket is the endpoint abstraction used by applications for network communication. For TCP, a connection is uniquely identified by a four-tuple.
| Identifier | Meaning | Example |
|---|---|---|
| Source IP | Client host address | 10.0.0.12 |
| Source port | Temporary client-side port | 51544 |
| Destination IP | Server host address | 142.250.190.14 |
| Destination port | Server application service port | 443 |
UDP: Small Header, Low Latency, Application Responsibility
UDP is not “bad TCP”. It is a deliberate design for applications that prefer low overhead, quick exchange or their own reliability rules.
- UDP header has source port, destination port, length and checksum.
- UDP is message-oriented: each send operation creates a datagram boundary visible to the receiver.
- No handshake, no retransmission, no ordering guarantee, no congestion window at UDP layer.
- Common uses: DNS, DHCP, VoIP, video streaming, online games, SNMP and QUIC underneath HTTP/3.
- Engineering answer: mention that application can implement reliability, sequencing or congestion behavior above UDP if required.
TCP: Reliable Ordered Byte Stream
TCP converts unreliable IP datagram service into a reliable byte-stream service using sequence numbers, acknowledgements, retransmission, sliding windows and control algorithms.
- Byte stream means TCP does not preserve application message boundaries; application protocols must frame their own messages.
- Sequence number identifies byte position in the stream, not just segment count.
- Acknowledgement number is cumulative: it indicates the next byte expected.
- Checksum detects corruption; lost or damaged segments are retransmitted.
- Receiver buffers out-of-order segments and delivers ordered bytes to the application.
TCP Three-Way Handshake
The handshake establishes initial sequence numbers and proves that both sides can send and receive.
- Step 1: client sends SYN with initial sequence number x.
- Step 2: server replies SYN+ACK with its own initial sequence number y and ACK x+1.
- Step 3: client sends ACK y+1; connection enters established state.
- SYN consumes one sequence number even though it carries no application data.
- Exam trap: handshake is not only “permission”; it synchronizes sequence spaces and creates connection state.
Sliding Window and Pipelining
A stop-and-wait sender wastes capacity on high-delay links. TCP uses sliding window so multiple bytes/segments can be in flight before acknowledgements return.
- Sender window = bytes allowed to be sent but not yet acknowledged.
- As ACKs arrive, the window slides forward and new data can be transmitted.
- Receiver advertised window limits sending based on receiver buffer.
- Congestion window limits sending based on estimated network capacity.
- Effective send window is approximately min(receiver window, congestion window).
Flow Control vs Congestion Control
These two controls are frequently confused in exams. Flow control protects the receiver; congestion control protects the network.
| Aspect | Flow control | Congestion control |
|---|---|---|
| Problem | Receiver buffer overflow | Network overload and packet loss |
| Signal | Receiver advertised window | Loss, duplicate ACKs, RTT changes, ECN if used |
| Main variable | rwnd | cwnd |
| Controlled by | Receiver capacity | Sender algorithm reacting to network |
| Typical answer phrase | Do not overwhelm receiver | Do not overload routers/path |
TCP Congestion Control
TCP congestion control probes available bandwidth and backs off when the network shows signs of congestion.
- Slow start: cwnd grows exponentially each RTT until threshold or loss.
- Congestion avoidance: cwnd grows roughly linearly using additive increase.
- Packet loss by timeout: strong congestion signal; cwnd is reduced sharply and slow start restarts.
- Triple duplicate ACK: likely one segment loss; fast retransmit sends missing segment before timeout.
- Fast recovery: reduces cwnd but avoids returning fully to the beginning when possible.
- AIMD principle: additive increase, multiplicative decrease gives fairness and stability.
TCP Connection Termination
TCP is full-duplex, so each direction is closed separately. That is why termination commonly uses four segments.
- One side sends FIN when it has no more data to send.
- Other side ACKs the FIN but may still send remaining data.
- Other side later sends its own FIN.
- First side ACKs and enters TIME_WAIT to handle delayed segments.
- Exam point: TCP close is graceful; RST is abrupt termination/reset.
Engineering Mechanism
- Application writes data into a socket.
- Transport layer adds source and destination port numbers.
- UDP sends independent datagrams with minimal processing.
- TCP establishes connection state, splits data into segments and assigns sequence numbers.
- Receiver acknowledges bytes received; sender retransmits when timeout or duplicate ACK indicates loss.
- Flow control uses receiver window; congestion control uses congestion window and loss/RTT signals.
- Connection is terminated using FIN/ACK exchange or reset using RST.
Diagrams / Models To Draw
- Draw TCP/UDP position above IP and below applications.
- Draw TCP three-way handshake: SYN, SYN+ACK, ACK with sequence and acknowledgement numbers.
- Draw sliding window with sent-and-ACKed, sent-not-ACKed and allowed-to-send ranges.
- Draw congestion window growth: slow start exponential, congestion avoidance linear, drop after loss.
- Draw four-tuple socket identification for a TCP connection.
Formulas, Fields and Algorithms
- Port number size = 16 bits; range = 0 to 65535.
- Common ports: HTTP 80, HTTPS 443, DNS 53, FTP control 21, SSH 22, SMTP 25.
- TCP connection identifier = source IP + source port + destination IP + destination port.
- Effective TCP sending capacity is constrained by min(rwnd, cwnd).
- Approximate window-limited throughput = window size / RTT.
- Stop-and-wait utilization becomes poor when RTT is large compared with transmission time.
| Feature | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented with handshake | Connectionless, no handshake |
| Reliability | ACK, sequence number and retransmission | No built-in retransmission |
| Ordering | Ordered byte stream | No ordering guarantee |
| Message boundary | Not preserved | Preserved per datagram |
| Header size | Minimum 20 bytes | 8 bytes |
| Typical use | Web, file transfer, email, SSH | DNS, streaming, VoIP, DHCP |
Exam Point
- Always separate host-to-host IP delivery from process-to-process transport delivery.
- For TCP reliability, write sequence number + ACK + timeout/retransmission + checksum + ordered delivery.
- For flow vs congestion control, identify who is protected: receiver versus network.
- Do not call UDP unreliable in a careless way; say UDP has no built-in reliability and applications may add it.
- For long answers, include handshake diagram and congestion control phases.
Worked Example
Suppose a browser at 10.0.0.5:52000 connects to a web server at 203.0.113.10:443. TCP first exchanges SYN, SYN+ACK and ACK. Browser data is then divided into segments. If bytes 1001-1500 are lost, the receiver continues acknowledging the next expected byte or sends duplicate ACKs. The sender retransmits the missing segment and adjusts its congestion window based on the loss signal.
Subjective Answer Pattern
- Define transport layer and process-to-process communication.
- Explain port numbers, sockets, multiplexing and demultiplexing.
- Compare TCP and UDP with services and use cases.
- Explain TCP reliability using sequence number, ACK, timer, retransmission and sliding window.
- Differentiate flow control and congestion control with rwnd and cwnd.
- Add handshake/teardown diagram if marks are high.
Common Engineering Mistakes
- Confusing IP address with port number.
- Saying TCP sends messages; TCP actually provides a byte stream.
- Writing flow control and congestion control as the same concept.
- Forgetting that UDP checksum detects corruption but UDP does not retransmit.
- Assuming a TCP ACK acknowledges a segment number rather than the next expected byte.
- Ignoring TIME_WAIT in TCP connection termination questions.
MCQ Revision
- Which transport protocol is connection-oriented?
- Which field identifies application process at transport layer?
- TCP header minimum size?
- UDP header size?
- What does ACK number represent in TCP?
- Flow control protects receiver or network?
- Congestion window is controlled by sender or receiver?
- Does TCP preserve message boundaries?
Final Summary
- Transport layer provides process-to-process delivery using ports.
- UDP is lightweight and message-oriented; TCP is reliable, ordered and byte-stream based.
- TCP reliability comes from sequence numbers, ACKs, retransmission and windows.
- Flow control depends on receiver capacity; congestion control depends on network condition.
- PSC answers should include mechanisms, not only definitions.