NivaarExam PrepOfficial exam papers ↗

22-Elec-B4 Information Technology Networks · May 2014

Question 5 of 5: Shortest-path routing

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

Paper format. Professional Engineers of Ontario annual examination, 07-Elec-B4 Information Technology Networks, May 2014. Three hours, closed book, one PEO-approved non-programmable calculator permitted. Marks are printed in the left margin; the cover page states that there are five questions and that any four constitute a complete paper worth 100 marks. All five questions and every sub-part are answered below, because this set is intended as a study resource rather than as a sat examination.

Reference texts. A. Leon-Garcia and I. Widjaja, Communication Networks: Fundamental Concepts and Key Architectures, 2nd ed. — the text listed by the Engineers Canada syllabus for this examination code; J. F. Kurose and K. W. Ross, Computer Networking: A Top-Down Approach, 8th ed.; A. S. Tanenbaum and D. J. Wetherall, Computer Networks, 5th ed.; W. Stallings, Wireless Communications and Networking, 2nd ed.; T. S. Rappaport, Wireless Communications: Principles and Practice, 2nd ed. Normative documents cited: ISO/IEC 7498-1 (the OSI reference model), IEEE 802.3 (CSMA/CD), IEEE 802.11 (wireless LAN), 3GPP TS 23.401 (the LTE Evolved Packet Core), RFC 768 (UDP) and RFC 959 (FTP).

Question 5: Shortest-path routing (25 marks)

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

Given. The undirected network printed with the question, whose ten nodes and fourteen weighted edges are transcribed from the figure below; all costs are positive.

[Figure not reproduced: Figure 5.1 — The network as printed, with the edge costs read from the examination figure: A–B 1, A–C 5, B–D 5, B–E 2, C–E 1, D–E 1, D–F 3, E–G 1, F–G 1, F–H 4, F–I 2, G–I 2, H–J 3, I–J 2. See the official exam paper.]

Find. (a) the least-cost path and its cost from A to each of the other nine nodes, obtained by a correctly executed Dijkstra iteration; and (b) the smallest increase in the cost of link C–E that alters that answer, together with the alteration it produces.

Approach. Run Dijkstra's algorithm: maintain a set $S$ of nodes whose least cost is settled and a tentative label $d(v)$ for every other node; at each iteration move the unsettled node of least label into $S$ and relax the edges leaving it. Then, for part (b), treat $d(\mathrm{C})$ as a function of the C–E cost and find where the two candidate routes to C cross over.

(a) Dijkstra's algorithm from node A

The algorithm is stated once and then applied. At every iteration the node $u \notin S$ with the smallest label is made permanent, and each neighbour $v$ of $u$ is relaxed:

$$ d(v) \leftarrow \min\bigl(d(v),\; d(u) + w(u,v)\bigr) $$

with the predecessor of $v$ set to $u$ whenever the second term wins. Initially $d(\mathrm{A}) = 0$ and every other label is $\infty$.

  1. Part (a), iteration 1 — make A permanent and relax its edges. $S = \{\mathrm{A}\}$. A's neighbours are B and C, so $d(\mathrm{B}) = 0 + 1 = 1$ (via A) and $d(\mathrm{C}) = 0 + 5 = 5$ (via A). All other labels remain $\infty$.
  2. Iteration 2 — B is the smallest label, at 1. $S = \{\mathrm{A,B}\}$. Relaxing B's edges: $d(\mathrm{D}) = 1 + 5 = 6$ (via B) and $d(\mathrm{E}) = 1 + 2 = 3$ (via B). C stays at 5.
  3. Iteration 3 — E is the smallest label, at 3, and it improves three neighbours. $S = \{\mathrm{A,B,E}\}$. Now $d(\mathrm{C}) = \min(5,\ 3+1) = 4$ (via E, which displaces the direct A–C link), $d(\mathrm{D}) = \min(6,\ 3+1) = 4$ (via E, displacing B) and $d(\mathrm{G}) = 3 + 1 = 4$ (via E). This is the iteration that does most of the work, and it is where a hand solution most often goes wrong by forgetting to re-examine C and D.
  4. Iterations 4–6 — C, D and G are tied at 4, so any order is valid. Taking C first: C's only other neighbour is A, already permanent, so nothing changes. Taking D next relaxes D–F to give $d(\mathrm{F}) = 4+3 = 7$ (via D). Taking G then gives $d(\mathrm{F}) = \min(7,\ 4+1) = 5$ (via G, displacing D) and $d(\mathrm{I}) = 4 + 2 = 6$ (via G). The tie is real and harmless: Dijkstra guarantees the same final labels whichever tied node is chosen, because no negative edges exist and a settled label can never later be improved.
  5. Iteration 7 — F, at 5. $d(\mathrm{H}) = 5 + 4 = 9$ (via F), and F–I offers $5 + 2 = 7$, which does not beat I's existing label of 6, so I keeps its route through G.
  6. Iteration 8 — I, at 6. $d(\mathrm{J}) = 6 + 2 = 8$ (via I).
  7. Iterations 9 and 10 — J at 8, then H at 9. From J, $8 + 3 = 11$ does not improve H's label of 9, so H keeps its route through F. H is the last node to settle and the whole set is now permanent: $$ \boxed{d = \{\mathrm{A}\,0,\ \mathrm{B}\,1,\ \mathrm{E}\,3,\ \mathrm{C}\,4,\ \mathrm{D}\,4,\ \mathrm{G}\,4,\ \mathrm{F}\,5,\ \mathrm{I}\,6,\ \mathrm{J}\,8,\ \mathrm{H}\,9\}} $$

Reading the predecessors back from each node gives the shortest-path tree, drawn in Figure 5.2. Note how the tree tells the story of the network: almost everything leaves A through the cheap A–B–E corridor, so the expensive direct A–C link and the B–D link are never used at all.

15521131142232Ad = 0Bd = 1Dd = 4Fd = 5Hd = 9Cd = 4Ed = 3Gd = 4Id = 6Jd = 8
Figure 5.2 — The shortest-path tree rooted at A (heavy lines), with each node's least cost from A. Unused links are shown dashed: A–C (5), B–D (5), D–F (3), F–I (2) and H–J (3) are all more expensive than the route the tree already provides.
Table 5.1 — Dijkstra iteration table: the label of each node after each node is made permanent (a dash means the node is already settled)
IterationMade permanentBCDEFGHIJ
1A (0)15$\infty$$\infty$$\infty$$\infty$$\infty$$\infty$$\infty$
2B (1)—563$\infty$$\infty$$\infty$$\infty$$\infty$
3E (3)—44—$\infty$4$\infty$$\infty$$\infty$
4C (4)——4—$\infty$4$\infty$$\infty$$\infty$
5D (4)————74$\infty$$\infty$$\infty$
6G (4)————5—$\infty$6$\infty$
7F (5)——————96$\infty$
8I (6)——————9—8
9J (8)——————9——
10H (9)—————————
Table 5.2 — Final results, Question 5(a): shortest path from A to every node
DestinationLeast-cost pathCostCost re-added from its own links
BA–B11
CA–B–E–C4$1+2+1$
DA–B–E–D4$1+2+1$
EA–B–E3$1+2$
FA–B–E–G–F5$1+2+1+1$
GA–B–E–G4$1+2+1$
HA–B–E–G–F–H9$1+2+1+1+4$
IA–B–E–G–I6$1+2+1+2$
JA–B–E–G–I–J8$1+2+1+2+2$

(b) Sensitivity of the solution to the cost of link C–E

The question is a sensitivity analysis, and it is answered by asking which entries of the part (a) solution can depend on $w_{\mathrm{CE}}$ at all. Only two paths in the whole tree touch C: the path to C itself, and any path that passes through C on the way somewhere else. Inspecting Table 5.2, no path routes through C — C is a leaf of the tree, which makes sense because C's only other neighbour is A, the source. So the entire question reduces to $d(\mathrm{C})$, and every other row of Table 5.2 is unaffected no matter how large $w_{\mathrm{CE}}$ becomes.

  1. Part (b) — write $d(\mathrm{C})$ as a function of the link cost. C has exactly two neighbours, A and E. Since $d(\mathrm{E}) = 3$ does not itself depend on the C–E link (E is reached from B), the least cost to C is the better of the two candidate routes: $$ d(\mathrm{C}) = \min\bigl(\underbrace{5}_{\text{direct A--C}},\ \underbrace{3 + w_{\mathrm{CE}}}_{\text{via E}}\bigr) $$ At the printed value $w_{\mathrm{CE}} = 1$ this is $\min(5, 4) = 4$, the answer from part (a).
  2. Find the crossover. The route through E stops being strictly better when $3 + w_{\mathrm{CE}} \ge 5$, that is when $$ w_{\mathrm{CE}} \ge 5 - 3 = 2 $$ so the critical link cost is 2, reached from the printed value of 1 by an $$ \boxed{\text{increase of } 1 \text{ unit}} $$ At exactly $w_{\mathrm{CE}} = 2$ the two routes tie at cost 5 and the solution is no longer unique; for any $w_{\mathrm{CE}} > 2$ the direct link is strictly better and the tree definitely changes.
  3. State the change that is made. C's parent in the shortest-path tree moves from E to A: the path becomes the direct A–C link, the cost to C rises from 4 to 5, and the edge C–E leaves the tree while A–C joins it. Because C carries no transit traffic, $d(\mathrm{C})$ is then capped at 5 and cannot rise further however expensive C–E becomes — raising it to 100 or to infinity produces exactly the same tree. No other entry of Table 5.2 changes at any value.

It is worth saying what this means operationally, since that is the point of asking. Link costs in a real link-state protocol such as OSPF are set by the network administrator, usually as a decreasing function of link bandwidth, and are re-advertised whenever they change. The calculation above is exactly what an OSPF router does when it receives a new link-state advertisement: it re-runs Dijkstra over the whole topology database. This example shows why that is usually cheap in its effect — a cost change on one leaf edge moved one entry of the forwarding table, and only past a definite threshold. It also shows the flip side: a change of a single unit on the wrong edge, one that carries transit traffic, would have re-parented every node downstream of it.

Table 5.3 — Final results, Question 5(b)
QuantityValue
Printed cost of link C–E1
Critical cost at which the two routes to C tie2
Minimum increase that changes the solution1 unit (strictly, any increase beyond 1)
Change madeC is reached by the direct link A–C instead of A–B–E–C
Cost to C after the change5 (up from 4), and capped there for any larger cost
Other entries of the solution affectednone — C carries no transit traffic
Back to the paper →