Chapter 61: Interactive Lab Exercises and Simulations
Learning Objectives
By the end of this chapter, you will be able to: - Access and use interactive ContainerLab simulations - Complete guided lab exercises with real-time feedback - Use web-based network topology visualizers - Participate in collaborative network design exercises
Interactive Lab Platform
Web-Based ContainerLab Interface
<!-- Interactive lab launcher -->
<!DOCTYPE html>
<html>
<head>
<title>ContainerLab Interactive Labs</title>
<script src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"></script>
</head>
<body>
<div id="lab-selector">
<h2>Choose Your Lab Exercise</h2>
<button onclick="launchLab('basic-switching')">Basic Switching Lab</button>
<button onclick="launchLab('ospf-routing')">OSPF Routing Lab</button>
<button onclick="launchLab('bgp-peering')">BGP Peering Lab</button>
</div>
<div id="topology-viewer"></div>
<div id="lab-instructions"></div>
<div id="terminal-interface"></div>
<script>
function launchLab(labType) {
// Launch ContainerLab topology
fetch(`/api/labs/${labType}/start`, {method: 'POST'})
.then(response => response.json())
.then(data => {
displayTopology(data.topology);
loadInstructions(labType);
connectTerminal(data.containers);
});
}
function displayTopology(topology) {
const container = document.getElementById('topology-viewer');
const data = {
nodes: topology.nodes,
edges: topology.links
};
const options = {
physics: {enabled: true},
interaction: {hover: true}
};
new vis.Network(container, data, options);
}
</script>
</body>
</html>Guided Lab Exercises
#!/usr/bin/env python3
# Interactive lab guide system
class LabGuide:
def __init__(self, lab_name):
self.lab_name = lab_name
self.current_step = 0
self.steps = self.load_lab_steps()
def load_lab_steps(self):
"""Load lab steps from configuration"""
lab_configs = {
'basic-switching': [
{
'title': 'Deploy the Lab',
'instruction': 'Run: containerlab deploy -t basic-switching.yml',
'validation': self.validate_deployment,
'hint': 'Make sure Docker is running and you have the topology file'
},
{
'title': 'Configure VLANs',
'instruction': 'Create VLANs 10 and 20 on switch1',
'validation': self.validate_vlans,
'hint': 'Use: vlan 10 name USERS'
},
{
'title': 'Test Connectivity',
'instruction': 'Verify hosts can communicate within same VLAN',
'validation': self.validate_connectivity,
'hint': 'Use ping between hosts in same VLAN'
}
]
}
return lab_configs.get(self.lab_name, [])
def get_current_step(self):
"""Get current step information"""
if self.current_step < len(self.steps):
return self.steps[self.current_step]
return None
def validate_step(self):
"""Validate current step completion"""
step = self.get_current_step()
if step and step['validation']():
self.current_step += 1
return True
return False
def validate_deployment(self):
"""Validate lab deployment"""
import subprocess
try:
result = subprocess.run(['containerlab', 'inspect'],
capture_output=True, text=True)
return 'basic-switching' in result.stdout
except:
return False
def validate_vlans(self):
"""Validate VLAN configuration"""
# Implementation for VLAN validation
return True
def validate_connectivity(self):
"""Validate network connectivity"""
# Implementation for connectivity validation
return True
# Usage in web interface
lab_guide = LabGuide('basic-switching')
current_step = lab_guide.get_current_step()Summary
Interactive learning components enhance the educational experience by providing: - Real-time feedback and validation - Visual topology representation - Guided step-by-step exercises - Collaborative learning opportunities - Progress tracking and assessment
These features make the learning process more engaging and effective for students at all levels.