Back to the 2021 paper

Module 4: Transport Layer & Congestion Control

20217m

Compare and contrast the protocol field at the network layer with the port numbers at the transport layer. What is their common purpose? Why do we need two port-number fields but only one protocol field? Why is the size of the protocol field only half the size of each port number?

Worked SolutionAI Assisted

Protocol Field (Network Layer) vs Port Numbers (Transport Layer)

Common purpose

Both fields are demultiplexing identifiers. Many protocols / many applications share the same physical network and the same IP address, so at the receiver something must say which upper-layer entity should get the payload. Both fields answer exactly that question — they let several users of a channel coexist (multiplexing at the sender, demultiplexing at the receiver).

Comparison

Feature Protocol field (IP header) Port numbers (TCP/UDP header)
Layer Network layer (Layer 3) Transport layer (Layer 4)
Size 8 bits 16 bits each
Number of fields One Two (source + destination)
Identifies The next-layer protocol to which the payload is handed (TCP = 6, UDP = 17, ICMP = 1, IPv6 = 41) The sending/receiving process (application socket)
Value assigned by The sending host's IP layer The OS/application — well-known ports 0–1023, ephemeral 49152–65535
Demultiplexing done by Receiver's IP layer → protocol module Receiver's transport layer → process
Namespace Small, closed set of registered protocols Very large, dynamic set of concurrent applications

Why two port fields but only one protocol field?

A received IP datagram contains the payload of exactly one protocol — IP delivers it to one and only one next layer — so a single "next protocol" field completely identifies the destination; there is no "sender protocol" to represent, since IP itself is always the sender at that layer. A transport segment, however, is part of a two-way conversation: the receiver must know which remote process it came from (so it can reply) and which local process it is for. Without a source port the reply could not be routed back to the right socket at the original host — hence, exactly as with source and destination IP addresses, two port fields (source and destination) are required.

Why is the protocol field only half the size of a port number?

  • The protocol field is 8 bits = 256 values, which is ample because only a few dozen protocols are registered at the network layer; it merely has to point to a subsystem (TCP, UDP, ICMP, …) inside the host — a small, essentially fixed, closed set.
  • A port number is 16 bits = 65 536 values because it must name individual processes/sockets on one machine: every concurrent web, mail, DNS, SSH, streaming … connection needs its own port, and both well-known and dynamically assigned (ephemeral) ports share that range. Two 16-bit fields also yield 2³² distinct (source, destination) socket pairs per IP address pair, which is necessary for many simultaneous connections between the same two hosts.
  • So the difference in size simply reflects the difference in the size of the two namespaces: protocol identification is coarse-grained, process identification is fine-grained.

Similar questions

AI LearningWeb Platform

Coursify — Personal AI Course Generator

Struggling with a difficult subject or concept? Turn any engineering topic into a structured course with interactive lessons, quizzes, and research-backed explanations.