← all topics

Mock midterm 2 (do it in 50 minutes, then open the answers)

Same layout as the official sample: short answers, TCP seq/ACK, distance vector, then homework-style problems · All numbers are new · Closed book, no calculator needed

Set a 50-minute timer. Write every answer on paper before opening any details block. Suggested split: P1 8 min · P2 5 · P3 5 · P4 12 · P5 7 · P6 7 · P7 6.

Problem 1 (short answers)

  1. Host A (TCP Reno) has five 500-byte segments in flight, starting at bytes 1000, 1500, 2000, 2500 and 3000. The next four ACKs to arrive all carry ACK number 1500. What does A conclude, and what does it do?
  2. A router's 10 Gbps output link carries 10,000 long-lived TCP flows with a typical RTT of 200 ms. How much buffer does the RFC 3439 rule give, and how much does the newer N-flow rule give?
  3. A router receives an IPv4 datagram whose TTL field is 1. What does the router do with it, and why does the TTL field exist?
  4. At a coffee shop your laptop is given the address 192.168.5.23. A web server you visit logs the source address of your requests. What address does it see, and why not 192.168.5.23?
  5. A network operator wants traffic from H1 to H3 to leave router A on interface 3, and traffic from H2 to H3 to leave on interface 4. Can a traditional destination-based forwarding table do this? What can?
Answers to Problem 1
  1. The first ACK 1500 acknowledges the segment at 1000. The other three are duplicate ACKs for 1500 → triple duplicate ACK → the segment starting at byte 1500 was probably lost while later ones arrived. A does a fast retransmit of the segment with seq 1500 without waiting for the timer, and Reno sets ssthresh = cwnd/2, cwnd = ssthresh + 3, then grows linearly (3-56, 3-81).
  2. RFC 3439: RTT · C = 0.2 s × 10×10⁹ b/s = 2×10⁹ bits = 2 Gbit. N-flow rule: RTT·C/√N = 2 Gbit / √10,000 = 2 Gbit / 100 = 20 Mbit (4-25).
  3. It decrements TTL to 0 and drops the datagram (ICMP can report the error to the source). TTL = remaining max hops; it stops a datagram from circling forever in a routing loop, for example while distance vector counts to infinity (4-34).
  4. It sees the NAT router's public IP (with a new source port chosen by NAT). 192.168.5.23 is in the private block 192.168/16, usable only inside the local network; the laptop got it from the shop's router by DHCP, and NAT rewrites (src IP, port) on every outgoing datagram (4-57, 4-58).
  5. No. Destination-based forwarding looks only at the destination address, so all H3 traffic goes out one interface (HW5 P1b). Generalized forwarding (OpenFlow match plus action) can: match on IP src = H1 or H2 plus IP dst = H3, action forward(3) or forward(4) (4-70 → 4-72).

Problem 2 (TCP sequence and ACK numbers)

Host B has received all bytes from Host A up through byte 349. A now sends two segments back to back: the first carries 60 bytes, the second 90 bytes. The first has sequence number 350, source port 5123, destination port 443. B sends an ACK for every segment it receives.

  1. In the second segment, what are the sequence number, source port, and destination port?
  2. If the first segment arrives first, what are the ACK number, source port, and destination port of the ACK for it?
  3. If the second segment arrives first, what is the ACK number in the ACK for that first-arriving segment?
  4. Both segments arrive in order. The first ACK is lost, and the second ACK arrives after A's timeout. Draw the timeline: every segment (seq, bytes) and every ACK (number).
  5. Same as (d), but the second ACK arrives before the timeout. Does A retransmit anything?
  6. Sample-style: a telnet client sends (seq = 73, ACK = 210, data = 'q'). Fill in the server's echo (seq = __, ACK = __, data = 'q') and then the client's ACK of the echo.
Answers to Problem 2
  1. seq = 350 + 60 = 410, source port 5123, destination port 443 (same direction, same ports).
  2. Bytes 350–409 received → ACK 410. Ports reverse: source 443, destination 5123.
  3. Bytes 410–499 arrive but 350–409 are missing → B re-ACKs the next byte it expects: ACK 350 (a duplicate ACK).
  4. Host A                                   Host B
      seq=350, 60 bytes   ----------------->
      seq=410, 90 bytes   ----------------->
                            X<--------------  ACK=410   (lost)
      (timer for 350 expires)
      seq=350, 60 bytes   ----------------->  (retransmit)
                          <-----------------  ACK=500   (2nd ACK, arrives late)
                          <-----------------  ACK=500   (reply to the duplicate)
    The timer runs for the oldest unACKed segment (350), so A retransmits only seq 350 with 60 bytes. B already has bytes up to 499, so it answers the duplicate with ACK 500 again. No other retransmission: the cumulative ACK 500 covers both segments.
  5. No. ACK 500 is cumulative and covers bytes 350–499, so SendBase moves to 500 and the timer stops (or restarts for newer data). The next new segment starts at seq 500 (3-54).
  6. Echo: seq = client's ACK = 210, ACK = 73 + 1 = 74. Client's ACK of the echo: seq = 74, ACK = 211 (3-47).

Problem 3 (distance vector)

Node A runs the distance-vector algorithm. It has three neighbours, B, C, and D, with link costs c(A,B) = 3, c(A,C) = 6, c(A,D) = 2.

DestinationCostNext node
A0–
B3B
C6C
D2D
E8D
F10B

A then receives these updates:

  1. After one round, what is A's cost to F, and which next node?
  2. What is A's cost to E, and which next node?
  3. Does A send its distance vector to its neighbours after this update? Why?
  4. Later the cost of link A–B rises to 10. Nothing else changes. What are A's new cost and next node for F?
  5. With poisoned reverse, what cost to F does A advertise to C after (d)? To B and D?
Answers to Problem 3
(a) D_A(F) = min{ c(A,B)+D_B(F), c(A,C)+D_C(F), c(A,D)+D_D(F) }
           = min{ 3+5, 6+3, 2+9 } = min{ 8, 9, 11 } = 8    next node B

(b) D_A(E) = min{ 3+7, 6+4, 2+5 } = min{ 10, 10, 7 } = 7    next node D

(d) D_A(F) = min{ 10+5, 6+3, 2+9 } = min{ 15, 9, 11 } = 9   next node C
  1. 8 via B. The old entry (10 via B) plays no part; only link cost + each neighbour's new report counts.
  2. 7 via D.
  3. Yes. Its vector changed (F: 10 → 8, E: 8 → 7), and a DV node notifies its neighbours whenever its own vector changes (5-18).
  4. 9 via C. The cost went up, which is allowed: DV follows the new numbers, not the old table.
  5. A routes to F through C, so it tells C: ∞ (so C won't route to F through A). It tells B and D: 9 (5-22).

Problem 4 (TCP Reno congestion window)

A TCP Reno connection has this congestion window (in segments) in transmission rounds 1–20. Exactly one triple-duplicate-ACK event and one timeout happen.

Round12345678910
cwnd1248161718192021
Round11121314151617181920
cwnd2214151617181248
round  cwnd
  1  # 1
  2  ## 2
  3  #### 4
  4  ######## 8
  5  ################ 16
  6  ################# 17
  7  ################## 18
  8  ################### 19
  9  #################### 20
 10  ##################### 21
 11  ###################### 22
 12  ############## 14
 13  ############### 15
 14  ################ 16
 15  ################# 17
 16  ################## 18
 17  # 1
 18  ## 2
 19  #### 4
 20  ######## 8
  1. Identify the intervals of time when TCP slow start is operating.
  2. Identify the intervals of time when TCP congestion avoidance is operating.
  3. After the 11th transmission round, is segment loss detected by a triple duplicate ACK or by a timeout?
  4. After the 16th transmission round, is segment loss detected by a triple duplicate ACK or by a timeout?
  5. What is the initial value of ssthresh at the first transmission round?
  6. What is the value of ssthresh at the 13th transmission round?
  7. What is the value of ssthresh at the 19th transmission round?
  8. During what transmission round is the 100th segment sent?

Bonus: (i) What is cwnd in round 21? (j) If the connection used TCP Tahoe and the triple duplicate ACK after round 11 were the same, what are ssthresh and cwnd in round 14?

Answers to Problem 4
  1. Slow start: [1, 5] and [17, 20] (cwnd doubles each round: 1, 2, 4, 8, 16 and 1, 2, 4, 8).
  2. Congestion avoidance: [5, 11] and [12, 16] (+1 per round: 16 → 22 and 14 → 18).
  3. Triple duplicate ACK. cwnd went 22 → 14 = 22/2 + 3, then kept growing linearly. A timeout would have dropped it to 1.
  4. Timeout. cwnd dropped to 1 and slow start restarted.
  5. 16: doubling stops at 16 and growth turns linear in round 6.
  6. Loss after round 11 with cwnd = 22 → ssthresh = 22/2 = 11 (in force from round 12 through 16).
  7. Timeout after round 16 with cwnd = 18 → ssthresh = 18/2 = 9.
  8. Count segments cumulatively:
    round 1:  1 segment   →  1
    round 2:  2           →  2–3
    round 3:  4           →  4–7
    round 4:  8           →  8–15
    round 5: 16           → 16–31
    round 6: 17           → 32–48
    round 7: 18           → 49–66
    round 8: 19           → 67–85
    round 9: 20           → 86–105   ← segment 100
    The 100th segment is sent in round 9.

(i) Slow start would double 8 → 16 but stops at ssthresh = 9, so cwnd = 9 in round 21 (then 10, 11, … linearly).
(j) Tahoe: ssthresh = 22/2 = 11, cwnd = 1 in round 12, 2 in round 13, 4 in round 14.

Problem 5 (longest prefix match and subnets)

A router has this forwarding table:

PrefixInterface
135.46.56.0/220
135.46.60.0/221
135.46.57.0/242
192.53.40.0/233
otherwise4
  1. Which interface does each destination use: 135.46.57.14, 135.46.63.10, 192.53.42.7?
  2. How many addresses does each of the four prefixes cover? How many addresses actually leave on interface 0?
  3. An organization owns 154.20.96.0/23 and needs four subnets with at least 200, 100, 50, and 20 interfaces. Give four a.b.c.d/x subnet addresses.
Answers to Problem 5

Only the third octet matters for the 135.46 and 192.53 entries:

56 = 00111000   /22 keeps 6 bits: 001110  → 56–59
60 = 00111100   /22 keeps 6 bits: 001111  → 60–63
57 = 00111001   /24: exactly 57
40 = 00101000   /23 keeps 7 bits: 0010100 → 40–41
  1. 135.46.57.14: 57 = 00111001 matches 001110 (entry 0, /22) and 57 (entry 2, /24). Longest wins → interface 2.
    135.46.63.10: 63 = 00111111 → 001111 matches entry 1 only → interface 1.
    192.53.42.7: 42 = 00101010 → first 7 bits 0010101 ≠ 0010100 → no match → interface 4 (otherwise).
  2. /22 → 210 = 1024 each (entries 0 and 1); /24 → 256; /23 → 512. Interface 0 gets 135.46.56.x, 58.x, 59.x: 1024 − 256 = 768, because 135.46.57.x goes to interface 2.
  3. The /23 covers 154.20.96.0 – 154.20.97.255 (512 addresses). Round each need up to a power of two and place the largest first:
    ≥ 200 → 256 = /24 : 154.20.96.0/24    (96.0   – 96.255)
    ≥ 100 → 128 = /25 : 154.20.97.0/25    (97.0   – 97.127)
    ≥  50 →  64 = /26 : 154.20.97.128/26  (97.128 – 97.191)
    ≥  20 →  32 = /27 : 154.20.97.192/27  (97.192 – 97.223)
    spare            : 154.20.97.224/27
    These still fit after subtracting the network and broadcast addresses (254, 126, 62, 30 usable). Other aligned layouts are also correct.

Problem 6 (Dijkstra)

Six routers u, v, w, x, y, z. Link costs (all links bidirectional, any pair not listed has no link):

u–v 3    u–w 2    u–x 7    v–w 2    v–y 5
w–x 3    w–y 8    x–y 2    x–z 6    y–z 1

Run Dijkstra's algorithm from u. Show the table (N', D(·), p(·) for each step), the shortest-path tree, and u's forwarding table.

Answer to Problem 6
StepN'D(v),p(v)D(w),p(w)D(x),p(x)D(y),p(y)D(z),p(z)
0u3,u2,u7,u∞∞
1uw3,u5,w10,w∞
2uwv5,w8,v∞
3uwvx7,x11,x
4uwvxy8,y
5uwvxyz
Step 1: add w (D=2, smallest of 3, 2, 7)
  v: min(3, 2+2=4) = 3   keep p=u
  x: min(7, 2+3=5) = 5   p=w
  y: min(∞, 2+8=10) = 10 p=w
Step 2: add v (D=3, smallest of 3, 5, 10)
  y: min(10, 3+5=8) = 8  p=v
Step 3: add x (D=5, smallest of 5, 8, ∞)
  y: min(8, 5+2=7) = 7   p=x
  z: min(∞, 5+6=11) = 11 p=x
Step 4: add y (D=7, smallest of 7, 11)
  z: min(11, 7+1=8) = 8  p=y
Step 5: add z (D=8). Done.

Final: v = 3 (u–v), w = 2 (u–w), x = 5 (u–w–x), y = 7 (u–w–x–y), z = 8 (u–w–x–y–z). Check z: direct alternatives u–x–z = 13, u–w–x–z = 11, u–v–y–z = 9, so 8 is the minimum.

DestinationLink from u
v(u,v)
w(u,w)
x(u,w)
y(u,w)
z(u,w)

Shortest-path tree edges: u–v, u–w, w–x, x–y, y–z.

Problem 7 (fragmentation and NAT)

  1. A 5000-byte IPv4 datagram (20-byte header, no options, ID = 777) must cross a link with MTU = 1400 bytes. How many fragments are created? Give total length, ID, fragflag, and offset for each.
  2. A home network uses 192.168.0/24 behind a NAT router whose ISP address is 71.12.5.9. Host 192.168.0.11 opens two TCP connections from ports 4100 and 4101, and host 192.168.0.12 opens one from port 4100, all to 151.101.1.69 port 443. Give the NAT translation table (NAT picks WAN ports starting at 6000). Then give the source and destination (IP, port) of a reply on the third connection, as it arrives at the NAT router and after the NAT rewrites it.
Answers to Problem 7

(a)

data in the original   = 5000 − 20 = 4980 bytes
max data per fragment  = 1400 − 20 = 1380 → round down to a multiple of 8
                         1380 / 8 = 172.5 → 172 × 8 = 1376 bytes
fragments              = ⌈4980 / 1376⌉ = ⌈3.62⌉ = 4
last fragment's data   = 4980 − 3 × 1376 = 4980 − 4128 = 852 bytes
FragmentData bytesTotal lengthIDfragflagOffset
11376139677710
21376139677711376/8 = 172
31376139677712752/8 = 344
485287277704128/8 = 516

Check: 1376 + 1376 + 1376 + 852 = 4980. Using 1380 per fragment is the trap: 1380/8 is not a whole number.

(b)

WAN sideLAN side
71.12.5.9, 6000192.168.0.11, 4100
71.12.5.9, 6001192.168.0.11, 4101
71.12.5.9, 6002192.168.0.12, 4100

Both hosts used source port 4100, but their WAN ports differ (6000 vs 6002), which is how NAT tells the replies apart.

reply arriving at NAT:  S = 151.101.1.69, 443   D = 71.12.5.9, 6002
after NAT rewrite:      S = 151.101.1.69, 443   D = 192.168.0.12, 4100

← review sheet · all topics →