11  Routing Labs and Quiz

In 60 Seconds

A lab series covering routing table examination, static route configuration, route selection analysis with longest-prefix matching, traceroute troubleshooting, and multi-subnet IoT deployment planning. Includes hands-on exercises for Windows, Linux, macOS, and ESP32 platforms.

11.1 Learning Objectives

By the end of this lab series, you will be able to:

  • Examine routing tables using system commands to view and interpret entries on Windows, Linux, and macOS
  • Configure static routes to add, modify, and delete routes for network segmentation
  • Analyze route selection by tracing how routing decisions are made based on metrics and longest-prefix matching
  • Diagnose connectivity failures using traceroute and ping to isolate routing issues in IoT networks
  • Implement default gateways to configure gateway addresses for proper internet connectivity
  • Design subnet routing to plan routing tables for multi-subnet IoT deployments

Deep Dives:

IoT Routing:

Topologies:

Related Protocols:

Learning:

“These labs are where routing theory meets practice,” said Max the Microcontroller. “You will examine real routing tables, configure static routes, use traceroute to map network paths, and even program an ESP32 to forward packets.”

“The series builds progressively,” explained Sammy the Sensor. “Start with fundamentals – looking at routing tables on your own computer. Then move to algorithm implementation in Python. Finally, tackle advanced labs with ESP32 packet forwarding and convergence simulation.”

“I love the troubleshooting exercises,” added Lila the LED. “You get broken network scenarios and have to use ping and traceroute to figure out what is wrong. Is it a missing route? A wrong next hop? A TTL that is too low? These are real-world skills.”

“The quiz at the end tests your practical understanding,” said Bella the Battery. “It covers route selection, longest prefix matching, and multi-subnet design for IoT deployments. If you can pass the quiz, you are ready to configure routing for real IoT networks!”

11.2 Lab Series Overview

This routing lab series is organized into three focused chapters:

Chapter Focus Difficulty Time
Routing Labs: Fundamentals View tables, traceroute, ESP32 basics Intermediate 30 min
Routing Labs: Advanced Packet forwarding, convergence simulation Advanced 45 min
Routing Labs: Algorithms Dijkstra, Bellman-Ford, longest prefix Advanced 40 min

11.3 Prerequisites

These labs build on the core routing theory. You will find them easier if you have already studied:

You should also be comfortable running simple commands in a terminal (PowerShell, Command Prompt, or a Linux shell).

Key Concepts
  • Lab Environment: The simulated or physical network setup used for hands-on routing exercises, including routers, hosts, configured subnets, and connectivity.
  • Knowledge Check: A formative assessment question verifying understanding of a specific routing concept before proceeding to more complex topics.
  • OSPF Configuration: The process of enabling OSPF routing protocol on a router, defining OSPF area, advertising networks, and verifying neighbor relationships and routing table population.
  • RIP Configuration: The simpler distance-vector routing protocol configuration; enables route sharing between directly connected neighbors using UDP port 520.
  • Convergence Testing: Lab exercises verifying that the routing protocol correctly updates routing tables after topology changes (link failure, node addition/removal).

11.4 Cross-Hub Connections

These labs connect to multiple learning resources:

Simulations Hub:

Videos Hub:

Knowledge Gaps Hub:

Quizzes Hub:

These labs work best when combined with simulations (see routing behavior visually) and videos (understand WHY routes are selected before practicing HOW to configure them).

11.5 Getting Started (For Beginners)

Routing can feel abstract until you see packets actually taking different paths. These labs are designed to connect the theory to real tools.

  • If you are on a laptop where you can run route, ip route, ping, and traceroute:
    • Work through the labs in order and copy the commands exactly.
    • Compare your output with the examples and note any differences (different gateways, subnets, or hop counts).
  • If you cannot run privileged commands (e.g., on a managed corporate machine):
    • Focus on reading the command examples and explanations.
    • Sketch routing tables on paper and answer the quiz questions to check your understanding.

Key ideas to keep in mind:

Idea Plain-language explanation
Default route “Send everything I don’t recognise to this next hop.”
Connected route Automatically added when an interface gets an IP address
Metric Cost value; lower metric = more preferred route
Hop Each router a packet passes on its way to the destination

When the questions talk about “floating static routes” or “failover”, picture two default routes with different metrics, where the backup only becomes active when the primary path disappears. If that feels fuzzy, revisit Routing Fundamentals first, then come back to these labs.


11.6 Lab Network Topology Overview

Before diving into individual labs, let’s visualize a typical multi-router lab network topology that demonstrates routing concepts:

Network topology diagram showing multi-router lab environment with three networks. Network 1 (192.168.1.0/24) contains PC1 and ESP32 connected to Router R1 (gateway at 192.168.1.1). Network 2 (10.0.0.0/8) contains IoT Sensor 1 and Sensor 2 connected to Router R2 (10.0.0.1). Network 3 (172.16.0.0/16) contains Web Server and Database connected to Router R3 (172.16.0.1). Routers are interconnected: R1 connects to R2 with metric 1, R1 to R3 with metric 5, R2 to R3 with metric 10, and R1 has default route to ISP router for internet access. Multiple paths exist between networks with different metrics for route selection testing.
Figure 11.1: Lab Network Topology Setup: Multi-router lab environment demonstrating key routing concepts. Network 1 (192.168.1.0/24) represents your local network with a computer and ESP32, connected via gateway router R1. Network 2 (10.0.0.0/8) simulates an IoT sensor network behind router R2. Network 3 (172.16.0.0/16) represents backend servers behind router R3. Multiple paths exist between networks with different metrics, enabling testing of route selection, TTL decrement, longest-prefix matching, and multi-hop forwarding scenarios.
Router decision flowchart for packet with destination 172.16.0.100. First decision: Is destination on local subnet? If Yes (Same /24), direct delivery via ARP to MAC address. If No (Different network), check routing table using longest prefix match. Found matching route? If 172.16.0.0/16 via R3 metric 5, forward to R3 with TTL-1. If 10.0.0.0/8 via R2 metric 1, forward to R2 with TTL-1. If 0.0.0.0/0 default route, forward to ISP as gateway of last resort. If no match found, drop packet and send ICMP unreachable.
Figure 11.2: Alternative View: Router Decision Process - While the topology shows network layout, this flowchart shows HOW a router decides where to send each packet. First check: is destination local? If yes, deliver directly via ARP. If no, consult routing table using longest-prefix matching. The most specific matching route wins (172.16.0.0/16 beats 0.0.0.0/0 default). If no route matches, drop the packet and send ICMP unreachable. Understanding this decision process helps debug “destination unreachable” errors.

Longest-prefix matching determines which route wins when multiple overlap. For destination 192.168.10.50:

\[ \text{Prefix Length} = N \text{ (bits matched from left)} \]

where a /24 prefix matches the first 24 bits, /16 matches the first 16 bits, and /0 (default) matches zero bits (always matches).

Worked example: Routing table has three entries: - Route A: 192.168.0.0/16 (16-bit prefix, 65,536 hosts) - Route B: 192.168.10.0/24 (24-bit prefix, 256 hosts) - Route C: 0.0.0.0/0 (0-bit prefix, all destinations)

For 192.168.10.50: Route B matches with /24 (24 bits match), Route A with /16 (16 bits match), Route C with /0 (0 bits required). Route B wins (longest prefix = most specific). The router forwards to Route B’s next-hop, not the default route.

Lab Scenarios You Can Test

This topology enables hands-on practice with:

  1. Direct Delivery (PC1 to ESP1): Both on 192.168.1.0/24, packets delivered locally without routing
  2. Single Hop Routing (PC1 to IoT1): R1 forwards to R2 (one hop between networks)
  3. Multi-Hop Routing (PC1 to Server): Packets traverse R1 to R2 to R3 or R1 to R3 (metric decides)
  4. Default Route Testing (PC1 to Internet): All unknown destinations forward via R1 to ISP
  5. Path Selection (R1 to R3): Direct link (metric 5) vs via R2 (metric 11), demonstrates lowest-cost path selection
  6. TTL Tracking: traceroute from PC1 to DB shows TTL decrement at each hop

The labs below use this topology conceptually, even if you’re working on a simpler single-router setup.

11.6.1 Route Path Selection Calculator

Use this calculator to explore how metric values determine which path a router selects:


11.7 Quick Lab Navigation

Start with the fundamentals and progress to advanced topics:

11.7.1 1. Routing Labs: Fundamentals

  • Lab 1: View routing tables with route print / ip route show
  • Lab 2: Trace packet paths with traceroute
  • Lab 3: ESP32 gateway configuration
  • Common misconception: “More routes = better connectivity”

11.7.2 2. Routing Labs: Advanced

  • Lab 4: ESP32 packet forwarding simulator (TTL decrement, route lookup)
  • Lab 5: Python network convergence simulator
  • Routing metrics comparison (hop count, ETX, latency)

11.7.3 3. Routing Labs: Algorithms

  • Implementation 1: Routing table with longest prefix matching
  • Implementation 2: Dijkstra’s shortest path (link-state routing)
  • Implementation 3: Distance vector protocol (RIP simulation)
  • Algorithm comparison: OSPF vs RIP

11.8 Quiz: Test Your Understanding

Scenario: You’re deploying 500 environmental sensors in a remote warehouse. Internet connectivity is critical for real-time alerts, but the site has unreliable internet:

  • Primary connection: Fiber (99.9% uptime, 500 Mbps)
  • Backup connection: 4G LTE (95% uptime when fiber fails, 25 Mbps, $50/GB overage)

Current Setup (Single Default Route):

ip route 0.0.0.0/0 via 192.168.1.1  # Fiber gateway only

Problem: When fiber fails (0.1% of time = 8.8 hours/year), sensors can’t send alerts. Fire detected at 2 AM? No alert until fiber restored 6 hours later.

Solution Options:

Option A: Manual failover (call IT, add LTE route, wait 30 min response time) Option B: Dual default routes with equal metrics (load balancing) Option C: Floating static route (primary metric 10, backup metric 100)

Floating Static Route Config:

ip route 0.0.0.0/0 via 192.168.1.1 metric 10   # Fiber - preferred
ip route 0.0.0.0/0 via 10.0.0.1 metric 100     # LTE - standby

How It Works:

  • Normal: Fiber installed (metric 10 < 100), all traffic to fiber, LTE route ignored
  • Fiber fails: Fiber route removed (link down), LTE route activates (only remaining default)
  • Fiber returns: Fiber route reinstalled (metric 10 < 100), LTE route deactivated, failback automatic

The Math:

  • Fiber downtime: 8.8 hours/year
  • During downtime: 500 sensors x 12 readings/hour x 8.8 hours = 52,800 packets
  • Average packet: 200 bytes
  • LTE usage: 52,800 x 200 bytes = 10.56 MB/year
  • LTE cost: 10.56 MB x $50/GB = $0.52/year (negligible)
  • Benefit: Zero downtime for critical fire/safety alerts

Key Insight: The metric difference (10 vs 100) creates a clear preference hierarchy. When fiber is up, LTE costs $0. When fiber fails, LTE costs cents but maintains system availability.


11.9 RPL DODAG Formation

Three-phase RPL DODAG formation process diagram. Phase 1: Root node (RANK 0) broadcasts DIO messages. Phase 2: Tier-1 nodes (Node 1 and Node 2) receive DIOs from root, calculate RANK 256, and select root as parent. Phase 3: Multi-level hierarchy forms as Node 3 and Node 4 join at RANK 512 by selecting Tier-1 nodes as parents. Dotted arrows indicate DIO message flow, solid arrows show parent-child relationships. Lower RANK values indicate proximity to root, demonstrating how RPL builds hierarchical routing topology in IoT networks.
Figure 11.3: RPL DODAG Formation Process: Shows how RPL builds a Destination-Oriented Directed Acyclic Graph in three phases. Phase 1: Root node broadcasts DIO (DODAG Information Object) messages. Phase 2: Neighboring nodes receive DIOs, calculate their rank, and select the root as parent. Phase 3: Multi-level hierarchy forms as nodes propagate DIOs and deeper nodes select intermediate parents. Lower rank values indicate proximity to root, and routing follows parent relationships toward the root node.

This sequence diagram shows the temporal flow of RPL control messages during DODAG formation and data transmission, emphasizing the message types and their purposes.

Diagram illustrating Rpl Message Timeline
Figure 11.4: RPL message exchange timeline showing three phases: DIO messages propagate downward from root to build DODAG hierarchy with each node calculating its rank. DAO messages flow upward to register routes and aggregate reachability information. Finally, sensor data follows the established parent chain upward to the border router. This temporal view complements the static topology diagram by showing HOW the routing structure is established through message exchanges.
Understanding RPL DODAG Formation

The diagram above illustrates how RPL creates routing hierarchies in IoT networks:

  • Rank: Numerical value indicating distance from root (lower = closer)
  • Parent Selection: Nodes choose best parent based on metrics (ETX, latency, hop count)
  • Self-Healing: If a parent fails, nodes automatically select alternate parents
  • Upward Routes: Established via DIO messages (toward root)
  • Downward Routes: Established via DAO messages (toward leaf nodes)

This hierarchical structure is ideal for sensor networks where most traffic flows to/from a central gateway or border router.


Common Pitfalls

Lab completion is not the goal — understanding why the protocol behaves as it does is. For every lab exercise, explain the routing protocol behavior observed before moving to the next exercise.

Labs that only verify successful routing miss the most important behavior — recovery from failures. Always include at least one failure injection test in every routing lab.

The quiz questions target conceptual gaps that hands-on labs may not reveal. Routing misconceptions at the conceptual level lead to hard-to-debug production issues. Complete both labs and quiz.

11.11 Summary

  • Routing tables can be examined using route print (Windows) or ip route show (Linux/macOS) to view how packets are forwarded
  • Traceroute commands map the complete path packets take across multiple routers, revealing network topology and performance bottlenecks
  • Static routes can be manually configured on IoT devices and routers to direct traffic through specific gateways or interfaces
  • TTL (Time-To-Live) decrements at each router hop and prevents routing loops by dropping packets when TTL reaches zero
  • Routing protocols like RPL are specifically designed for low-power IoT networks, providing automatic route discovery and self-healing capabilities
  • Longest prefix matching ensures routers select the most specific route available, with default routes serving as catch-all when no specific match exists
  • Hands-on labs with ESP32 and Python demonstrate packet forwarding, route lookup algorithms, and convergence behavior in real networks

Scenario: A manufacturing plant needs to deploy 300 IoT devices across 4 production lines plus an office network. Each area requires network isolation for security, but devices must reach a central SCADA server and cloud analytics platform.

Network Requirements:

  • Line 1 (Welding): 80 devices, 192.168.10.0/24
  • Line 2 (Assembly): 100 devices, 192.168.20.0/24
  • Line 3 (Packaging): 70 devices, 192.168.30.0/24
  • Line 4 (QA/Testing): 50 devices, 192.168.40.0/24
  • Office Network: 30 devices, 192.168.100.0/24
  • SCADA Server: 10.50.50.10 (in DMZ 10.50.50.0/24)
  • Cloud Gateway: Internet via 203.0.113.1

Design Challenge: Configure routing on the central gateway router to enable: 1. All production lines can reach SCADA server 2. All production lines can reach cloud (internet) 3. Office network can reach production lines (for diagnostics) 4. Production lines CANNOT reach each other directly (security isolation)

Gateway Router Configuration:

Interface Assignments:

eth0: 192.168.10.1/24   # Line 1 gateway
eth1: 192.168.20.1/24   # Line 2 gateway
eth2: 192.168.30.1/24   # Line 3 gateway
eth3: 192.168.40.1/24   # Line 4 gateway
eth4: 192.168.100.1/24  # Office gateway
eth5: 10.50.50.1/24     # SCADA DMZ gateway
eth6: 203.0.113.10/30   # Internet uplink

Step 1: Connected Routes (Automatic)

# These routes are automatically created when interfaces configured
ip addr show
# Output shows connected routes:
# 192.168.10.0/24 dev eth0
# 192.168.20.0/24 dev eth1
# 192.168.30.0/24 dev eth2
# 192.168.40.0/24 dev eth3
# 192.168.100.0/24 dev eth4
# 10.50.50.0/24 dev eth5
# 203.0.113.8/30 dev eth6

Step 2: Default Route for Internet Access

# All production lines need internet connectivity for cloud analytics
ip route add 0.0.0.0/0 via 203.0.113.9 dev eth6 metric 10

Step 3: Firewall Rules for Security Isolation

# ALLOW: Production lines → SCADA server
iptables -A FORWARD -s 192.168.10.0/24 -d 10.50.50.10 -j ACCEPT
iptables -A FORWARD -s 192.168.20.0/24 -d 10.50.50.10 -j ACCEPT
iptables -A FORWARD -s 192.168.30.0/24 -d 10.50.50.10 -j ACCEPT
iptables -A FORWARD -s 192.168.40.0/24 -d 10.50.50.10 -j ACCEPT

# ALLOW: Production lines → Internet (cloud)
iptables -A FORWARD -s 192.168.10.0/24 -o eth6 -j ACCEPT
iptables -A FORWARD -s 192.168.20.0/24 -o eth6 -j ACCEPT
iptables -A FORWARD -s 192.168.30.0/24 -o eth6 -j ACCEPT
iptables -A FORWARD -s 192.168.40.0/24 -o eth6 -j ACCEPT

# ALLOW: Office → Production lines (diagnostics)
iptables -A FORWARD -s 192.168.100.0/24 -d 192.168.10.0/24 -j ACCEPT
iptables -A FORWARD -s 192.168.100.0/24 -d 192.168.20.0/24 -j ACCEPT
iptables -A FORWARD -s 192.168.100.0/24 -d 192.168.30.0/24 -j ACCEPT
iptables -A FORWARD -s 192.168.100.0/24 -d 192.168.40.0/24 -j ACCEPT

# DENY: Production lines → Other production lines (security)
iptables -A FORWARD -s 192.168.10.0/24 -d 192.168.20.0/24 -j DROP
iptables -A FORWARD -s 192.168.10.0/24 -d 192.168.30.0/24 -j DROP
# ... (repeat for all cross-line combinations)

# Default DENY
iptables -P FORWARD DROP

Step 4: NAT for Internet-Bound Traffic

# Production devices use private IPs - need NAT for internet access
iptables -t nat -A POSTROUTING -o eth6 -j MASQUERADE

Verification Tests:

Test Source Destination Expected Result Actual Result
SCADA reachability 192.168.10.50 (Line 1) 10.50.50.10 Success ping 10.50.50.10 - 0% loss ✓
Cloud connectivity 192.168.20.75 (Line 2) 8.8.8.8 (Google DNS) Success ping 8.8.8.8 - 0% loss ✓
Cross-line isolation 192.168.10.50 (Line 1) 192.168.20.75 (Line 2) Blocked ping 192.168.20.75 - 100% loss (filtered) ✓
Office diagnostics 192.168.100.10 (Office) 192.168.10.50 (Line 1) Success ping 192.168.10.50 - 0% loss ✓

Routing Table on Gateway:

ip route show
# Output:
# default via 203.0.113.9 dev eth6 metric 10
# 192.168.10.0/24 dev eth0 scope link
# 192.168.20.0/24 dev eth1 scope link
# 192.168.30.0/24 dev eth2 scope link
# 192.168.40.0/24 dev eth3 scope link
# 192.168.100.0/24 dev eth4 scope link
# 10.50.50.0/24 dev eth5 scope link
# 203.0.113.8/30 dev eth6 scope link

Key Design Decisions:

Decision Rationale Alternative Considered
Use single gateway router Centralized control, easier firewall management Per-line routers (more complex, higher cost)
Connected routes only Simple, no dynamic routing overhead OSPF (unnecessary for static topology)
Firewall for isolation Layer 4 security without routing complexity VLANs + inter-VLAN routing (requires Layer 3 switches)
NAT on internet egress Conserve public IPs, hide internal topology Public IPs for each device (expensive, security risk)

Lessons Learned:

  1. Connected routes sufficient for star topologies – static routing works when all traffic funnels through central gateway
  2. Firewall rules enforce security policies that routing alone cannot provide
  3. Default route handles internet without needing specific routes for every cloud service
  4. Proper testing verifies both positive cases (should work) and negative cases (should be blocked)

Scalability Considerations:

  • Current: 300 devices across 5 subnets - single gateway handles easily
  • Growth: If expanding to 10+ production lines, consider:
    • Route summarization (e.g., 192.168.0.0/20 for all lines)
    • Dynamic routing (OSPF) if topology becomes mesh
    • Load balancing across multiple gateways

This lab series builds upon:

This lab series connects to:

Real-world applications:

  • Configuring IoT gateways for multi-subnet deployments
  • Designing redundant connectivity for critical systems
  • Troubleshooting sensor-to-cloud communication paths
  • Implementing failover routing for high-availability

Network Simulators:

Video Tutorials:

Documentation:

Hands-On Resources:

11.12 What’s Next

Previous Up Next
Routing Review: Advanced Routing Fundamentals Routing Labs: Fundamentals

After mastering routing fundamentals through hands-on practice, you’re ready to explore:

Network Topologies - Understanding how devices are physically and logically arranged in star, mesh, tree, and hybrid configurations

Wired Communication Protocols - Diving into RS-232, I2C, SPI, and other protocols for direct device-to-device connections

Wireless IoT Protocols - Exploring Wi-Fi, BLE, LoRaWAN, Zigbee, and their routing characteristics in mesh and star topologies

The routing concepts you’ve practiced - longest prefix matching, TTL management, and route convergence - directly apply when designing IoT networks. Many wireless protocols like Zigbee and Thread implement RPL routing internally, making your understanding of routing mechanics essential for troubleshooting and optimizing real deployments.