NivaarExam PrepOfficial exam papers ↗

22-Elec-B4 Information Technology Networks · May 2017

Question 5 of 5: IP Packet Routing

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

Notes on this paper

Paper format. Engineers Canada / Professional Engineers of Ontario, National Examinations — May 2017, 16-Elec-B4 Information Technology Networks. Three hours, closed book, one approved Casio or Sharp calculator permitted. Five questions of 25 marks each; any four constitute a complete paper worth 100 marks, and the marks are printed in the left margin against every sub-part. All five questions are solved here, because this set is a study resource rather than an exam attempt.

Reference texts.

Canadian context. The spectrum, licensing and equipment-certification framework assumed throughout is the Canadian one: Innovation, Science and Economic Development Canada (ISED) licenses the cellular bands under the Radiocommunication Act and publishes the Standard Radio System Plans (SRSP) that fix the duplex spacing referred to in Question 1(e), and Canadian carriers deploy the same 3GPP LTE numerology used in Question 1(b).

Question 5: IP Packet 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.

Part (a) — the size of the two address spaces.

Given. An IPv4 address is a 32-bit binary number; an IPv6 address is a 128-bit binary number. Reserved and special-purpose ranges are to be ignored.

Find. The total number of IPv4 addresses, and whether IPv6 offers more, fewer or the same.

Approach. An $n$-bit field takes $2^{n}$ distinct values; evaluate for both address lengths and take the ratio.

  1. Count the IPv4 addresses. The address is four octets, so 32 bits, giving $$N_{4} = 2^{32} = \boxed{4\,294\,967\,296 \approx 4.29 \times 10^{9} \text{ addresses}}$$ which is fewer than the world's population, and the reason the usable total is smaller still once the loopback block of part (d), the private ranges and the multicast space are removed.
  2. Count the IPv6 addresses. The address is 128 bits, so $$N_{6} = 2^{128} = 3.40 \times 10^{38} \text{ addresses,}$$ which is very much more.
  3. Express the increase as a ratio. Quadrupling the address length multiplies the address space exponentially: $$\frac{N_{6}}{N_{4}} = \frac{2^{128}}{2^{32}} = 2^{96} = 7.92 \times 10^{28},$$ so IPv6 provides about $7.9 \times 10^{28}$ addresses for every IPv4 address in existence.

Explanation. IPv6 gives more — overwhelmingly more — because the address field was widened from 32 to 128 bits, and each added bit doubles the space. The size is deliberately extravagant rather than merely sufficient: it permits a fixed 64-bit interface identifier so that hosts can autoconfigure from the link-layer address, and a 64-bit hierarchical routing prefix, which keeps allocation sparse and global routing tables aggregated. That is the real motive. Exhaustion of IPv4 (IANA's free pool ran out in 2011) had until then been deferred by classless inter-domain routing, private addressing and network address translation, all of which preserve addresses at the cost of breaking the end-to-end model.

Part (b) — the routing tables at both routers.

Given. Three LANs, drawn as buses, with class-B-derived network numbers 128.100.11.0, 128.100.12.0 and 128.100.13.0; the third octet distinguishes the subnets, so the subnet mask throughout is 255.255.255.0, that is a /24 prefix. Router R1 has interfaces 128.100.11.3 on the upper LAN and 128.100.12.3 on the middle LAN. Router R2 has interfaces 128.100.12.254 on the middle LAN and 128.100.13.3 on the lower LAN, and also holds the link to the Internet.

Find. A forwarding table at each router giving, for every destination network, the netmask, the outgoing interface and the next-hop gateway.

Approach. Enter the directly-attached networks first (no gateway needed), then one entry for each remote network reached through the other router, and finally a default route for everything else.

128.100.11.0/24128.100.11.1128.100.11.2128.100.12.0/24128.100.12.1128.100.12.2128.100.13.0/24128.100.13.1128.100.13.2R1128.100.11.3128.100.12.3R2128.100.12.254128.100.13.3Internet
Figure 5(b). The three LANs of the question. Light boxes are hosts, dark boxes are routers; each router's interface address on the bus above and below it is labelled to its left. R2 also carries the link to the Internet, and therefore holds the network's default route.
  1. Determine the mask. Every host address on a given bus shares its first three octets, and 128.100.x.0 is written as the network number, so each LAN is a /24 subnet: $$\text{mask} = 255.255.255.0 \;\equiv\; \text{/24},$$ giving $2^{8} - 2 = 254$ usable host addresses per LAN. (The parent 128.100.0.0/16 is a class-B network subnetted on the third octet.)
  2. Enter the directly-attached networks. A router reaches a network to which it has an interface without any intermediate hop, so those entries carry the interface address and no gateway: R1 is directly on 128.100.11.0/24 and 128.100.12.0/24, and R2 is directly on 128.100.12.0/24 and 128.100.13.0/24. These entries are what let the routers deliver by ARP on the local bus.
  3. Enter the remote networks. R1 has no interface on 128.100.13.0/24; the only way there is across the middle LAN to R2, so the entry sends the packet out interface 128.100.12.3 with gateway 128.100.12.254. Symmetrically, R2 reaches 128.100.11.0/24 out interface 128.100.12.254 with gateway 128.100.12.3. Note that in each case the gateway lies on the same subnet as the exit interface — a next hop that does not is an invalid entry.
  4. Add the default routes. Everything not matching a specific entry must leave via the Internet link, which is attached to R2. So R2 carries $$\text{0.0.0.0/0} \rightarrow \text{Internet interface},$$ and R1 carries 0.0.0.0/0 pointing at gateway 128.100.12.254, since R2 is R1's route to the outside world. Forwarding is by longest prefix match, so the /24 entries always win over the /0 default.
Routing table at R1 (interfaces 128.100.11.3 and 128.100.12.3)
Destination networkNetmaskGateway (next hop)InterfaceMetric
128.100.11.0255.255.255.0— (direct)128.100.11.30
128.100.12.0255.255.255.0— (direct)128.100.12.30
128.100.13.0255.255.255.0128.100.12.254128.100.12.31
0.0.0.0 (default)0.0.0.0128.100.12.254128.100.12.31
Routing table at R2 (interfaces 128.100.12.254 and 128.100.13.3, plus the Internet link)
Destination networkNetmaskGateway (next hop)InterfaceMetric
128.100.12.0255.255.255.0— (direct)128.100.12.2540
128.100.13.0255.255.255.0— (direct)128.100.13.30
128.100.11.0255.255.255.0128.100.12.3128.100.12.2541
0.0.0.0 (default)0.0.0.0— (ISP link)Internet1

For completeness, each host carries a two-line table of the same form: its own /24 as directly attached, and a default route to the router on its bus — 128.100.11.3 for the upper LAN, 128.100.12.254 (or 128.100.12.3) for the middle, and 128.100.13.3 for the lower.

Part (c) — the path taken by a packet from 128.100.11.2 to 128.100.13.1.

Given. Source 128.100.11.2 on the upper LAN; destination 128.100.13.1 on the lower LAN; the tables of part (b).

Find. The sequence of hops, with the decision made at each.

Approach. Apply, at each node in turn, the same two-step test: mask the destination with the local prefix to see whether it is on-link, and otherwise look it up by longest prefix match.

  1. The source host decides the destination is remote. Host 128.100.11.2 masks the destination with its own /24: $$128.100.13.1 \wedge 255.255.255.0 = 128.100.13.0 \neq 128.100.11.0,$$ so the destination is not on its LAN. It therefore sends the packet to its default gateway, ARPs for 128.100.11.3, and puts R1's MAC address in the frame while leaving the IP destination as 128.100.13.1.
  2. R1 forwards across the middle LAN. R1 looks up 128.100.13.1 and matches its 128.100.13.0/24 entry, which names gateway 128.100.12.254 out interface 128.100.12.3. It decrements the TTL, recomputes the header checksum, and re-frames the packet with R2's MAC address for the hop across the 128.100.12.0 bus. The IP addresses are unchanged: $$\text{IP src/dst fixed} = (128.100.11.2,\ 128.100.13.1),\quad \text{MAC rewritten each hop.}$$
  3. R2 delivers on the lower LAN. R2 matches 128.100.13.0/24 as directly attached through interface 128.100.13.3, so there is no further gateway. It ARPs for 128.100.13.1, frames the packet to that host's MAC address and transmits: $$\boxed{128.100.11.2 \rightarrow \text{R1} \rightarrow \text{R2} \rightarrow 128.100.13.1 \quad (2 \text{ router hops})}$$ A packet leaving with TTL 64 arrives with TTL 62, which is how traceroute would confirm the path.

Two points earn the explanation marks. First, the packet never touches the Internet link: R1's specific /24 entry is a longer prefix match than its default route, so the default is not consulted. Second, the destination IP address is constant end to end while the layer-2 destination changes at every hop — this is the practical expression of the layering of Question 3, with the network layer providing the global address and the data link layer providing delivery across each individual bus.

Part (d) — where a packet addressed to 127.0.0.1 goes. Nowhere: it goes straight back up the sending host's own protocol stack and never reaches the wire. 127.0.0.0/8 is reserved by RFC 1122 as the loopback block — over sixteen million addresses, of which 127.0.0.1 is the conventional one, named localhost. Every compliant IP implementation carries a loopback interface with a route for that prefix, and a datagram matching it is looped back inside the kernel: it is passed from the IP output routine directly to the IP input routine on the same machine, delivered to whatever process is listening on the destination port, and no frame is ever handed to a network adapter.

Three consequences follow, and they are what the five marks are testing. A router must never forward a packet whose source or destination lies in 127.0.0.0/8, and must discard any such packet arriving on a real interface (a rule enforced by martian filtering, since spoofed loopback addresses would otherwise defeat host-based access control). The address is host-relative rather than global, so 127.0.0.1 means a different machine on every machine — it cannot be used to reach a peer. And its practical uses follow directly: testing that a local stack is installed and working, letting a client and a server on one machine communicate over ordinary sockets, and binding a service so that it is reachable only from the machine itself. The IPv6 equivalent is the single address ::1.

Final results — Question 5
QuantitySymbol / whereValue
Total IPv4 addresses$N_{4} = 2^{32}$, Q5(a)4 294 967 296 (4.29 × 109)
Total IPv6 addresses$N_{6} = 2^{128}$, Q5(a)3.40 × 1038 (more)
Ratio IPv6 : IPv4$2^{96}$, Q5(a)7.92 × 1028
Subnet mask on every LANQ5(b)255.255.255.0 (/24), 254 usable hosts
Entries in each router tableQ5(b)4 (two direct, one remote, one default)
Router holding the default routeQ5(b)R2 (128.100.12.254 / 128.100.13.3)
Path 128.100.11.2 → 128.100.13.1Q5(c)host → R1 → R2 → host, 2 router hops
TTL on arrival (from 64)Q5(c)62
Destination of a packet to 127.0.0.1Q5(d)The sending host itself (127.0.0.0/8 loopback)
Back to the paper →