Back to the 2021 paper

Module 4: Transport Layer & Congestion Control

202114m

Draw and describe the TCP header. Assume that a host receives a UDP segment with 01011101 11110010 (we separated the values of each byte with a space for clarity) as the checksum. The host adds the 16-bit words over all necessary fields excluding the checksum and obtains the value 00110010 00001101. Is the segment considered correctly received or not? What does the receiver do?

Worked SolutionAI Assisted

TCP Header and UDP Checksum Verification

Part A — TCP header

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Acknowledgment Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data Offset | Reserved  |C|E|U|A|P|R|S|F|      Window         |
|     (4)      |    (4)    |W|C|R|C|S|Y|I|N|N|    (16 bits)      |
|              |           |R|E|G|K|H|T|N|N|                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |       Urgent Pointer          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              Options (variable, 0–40 bytes)     |    Padding   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Field description

Field Bits Purpose
Source / Destination Port 16 + 16 Identify the sending and receiving processes (sockets) for demultiplexing
Sequence Number 32 Number of the first data byte of this segment (SYN/FIN each consume one number)
Acknowledgment Number 32 Next byte the receiver expects — valid only when ACK = 1
Data Offset 4 Header length in 32-bit words: 5 words = 20 bytes min., 15 words = 60 bytes max.
Reserved 4 Must be zero (future use)
Flags 8 CWR, ECE (ECN), URG (urgent pointer valid), ACK (ack # valid), PSH (push to app now), RST (reset), SYN (open connection), FIN (close connection)
Window 16 Flow control — number of bytes the receiver can still accept (rwnd); sender may transmit min(cwnd, rwnd)
Checksum 16 One's-complement sum of a pseudo-header (src IP, dst IP, zero, protocol = 6, TCP length) + TCP header + data — detects corruption on any link
Urgent Pointer 16 Offset from the sequence number to the end of urgent data (valid if URG = 1)
Options 0–40 MSS, Window Scale, SACK permitted / selective ACK blocks, timestamps, NOP, End-of-Option

Fixed part = 20 bytes; with options up to 60 bytes. Ports give process-to-process delivery, sequence/ack numbers give byte-stream reliability, the window gives flow control, and the checksum (with pseudo-header) guarantees end-to-end integrity across IP.


Part B — UDP checksum verification

Given

  • Sum of all 16-bit words excluding the checksum = 00110010 00001101 = 0x320D
  • Received checksum field = 01011101 11110010 = 0x5DF2

Test: the receiver adds all 16-bit words including the checksum field (folding any end-around carry). The segment is correct only if the result is 11111111 11111111 = 0xFFFF.

Computation

      00110010 00001101   (sum of all other fields)   0x320D
    + 01011101 11110010   (checksum field)            0x5DF2
    ------------------------------------------
      10001111 11111111                              0x8FFF

There is no carry out of bit 15, so no end-around carry is added, and

0x320D+0x5DF2=0x8FFFeq0xFFFF0x320D + 0x5DF2 = 0x8FFF eq 0xFFFF

Cross-check: the expected checksum is the one's complement of the sum of the other fields:
~00110010 00001101 = 11001101 11110010 = 0xCDF2, which is not the received value 0x5DF2.

Conclusion: the sum is not 0xFFFF ⇒ the segment is NOT correctly received (at least one bit has been corrupted).

What the receiver does

  1. Silently discards the UDP segment. UDP is connectionless and unreliable: it sends no NAK, no error ICMP and no request for retransmission — recovery, if any, is left to the application.
  2. The missing data must be re-sent by the application after its own timeout (or the transfer simply fails).
  3. Had this been a TCP segment, the receiver would likewise discard it but would send no ACK; TCP's retransmission timer would then retransmit the segment, so the error would be repaired end-to-end.
  4. (Note: in IPv4 the UDP checksum is optional and may be sent as 0 = "not computed"; in IPv6 it is mandatory. If the calculated checksum is 0 it is transmitted as all 1s.)

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.