Chapter recap
Chapter 4.1 bridged the gap from a computer's network card (IP address) to the exact running program (16-bit port number). Make sure you have the 4-tuple TCP demultiplexing rule and the 3 port ranges locked in before we start reliable delivery and flow control in Chapter 4.2.
Practice questions
- NAT · 1 mark
How many port numbers belong to the Well-Known port range (0 to 1023 inclusive)?
Write your answer before opening the key.
- MCQ · 2 marks
Host C1 (10.1.1.1) opens 3 concurrent TCP connections to Server S (20.1.1.1) on port 80, and Host C2 (10.1.1.2) opens 2 concurrent TCP connections to the same Server S on port 80. How many distinct connected TCP sockets exist at Server S for these connections, and what is the minimum number of distinct source port numbers used across C1 and C2 combined?
- 5 sockets at S; minimum 5 distinct source ports
- 5 sockets at S; minimum 3 distinct source ports
- 1 socket at S; minimum 5 distinct source ports
- 2 sockets at S; minimum 3 distinct source ports
- MCQ · 1 mark
If Client C1 (10.1.1.1:5001) and Client C2 (10.1.1.2:5002) both send UDP datagrams to Server S (20.1.1.1:53), how many UDP sockets at Server S receive these datagrams?
- 1 socket (identified by 20.1.1.1:53)
- 2 sockets (one per client IP)
- 2 sockets (one per source port)
- 3 sockets
- NAT · 1 mark
A UDP datagram has a UDP Length field value of 52. How many bytes of application payload does it carry?
Write your answer before opening the key.
- MSQ · 2 marks
Which of the following services are provided by TCP but NOT by UDP?
- Process-to-process demultiplexing using port numbers
- Reliable in-order byte-stream delivery
- Flow control and congestion control
- Connection setup before data transfer
- MCQ · 1 mark
Which field in the 20-byte IPv4 header tells the receiving host’s network layer whether to hand the payload up to TCP (6) or UDP (17)?
- Type of Service
- Protocol (8 bits)
- Identification (16 bits)
- Flags (3 bits)
- NAT · 2 marks
How many usable hosts are in a /27 IPv4 subnet?
Write your answer before opening the key.
- NAT · 2 marks
In a 3-node triangle graph with edge costs (A,B)=2, (B,C)=3, and (A,C)=7, what is the shortest-path cost from A to C?
Write your answer before opening the key.
Answer key
Try the questions first. Open when you are ready to check.
- 1024 — 0 through 1023 inclusive contains 1023 − 0 + 1 = 1024 port numbers.
- B — Each of the 3 + 2 = 5 TCP connections has its own 4-tuple socket at S. C1 needs 3 distinct source ports (say p1, p2, p3) for its 3 connections, while C2 (which has a different Source IP!) can reuse p1 and p2 for its 2 connections → minimum 3 distinct source port numbers!
- A: C2 can reuse two of C1’s source port numbers because C2 has a different Source IP.
- C: TCP creates a separate connected socket per 4-tuple.
- D: There are 5 active connections, so 5 connected sockets.
- A — UDP demultiplexes using only the 2-tuple (Destination IP, Destination Port) = (20.1.1.1, 53), so both datagrams go to the same server socket.
- B: UDP does not split sockets by client IP.
- C: UDP does not split sockets by client port.
- D: Only 1 socket is bound to 20.1.1.1:53.
- 44 — UDP Length includes the 8-byte UDP header, so application payload = 52 − 8 = 44 bytes.
- BCD — Both TCP and UDP provide process-to-process demultiplexing via 16-bit port numbers; reliability, flow/congestion control, and connection setup are TCP-only.
- A: Both UDP and TCP provide port-based process-to-process demultiplexing.
- B — The 8-bit Protocol field in the IPv4 header identifies the upper-layer protocol (6 = TCP, 17 = UDP).
- A: TOS is for traffic priority/QoS.
- C: Identification is for fragment reassembly.
- D: Flags control fragmentation (DF, MF).
- 30 — h = 32 − 27 = 5 host bits → 2⁵ − 2 = 30 usable hosts.
- 5 — Path A → B → C costs 2 + 3 = 5, which is less than the direct edge cost 7.