Skip to main content

How to inject faults for testing

Fault injection is a feature of the GNS3 AI Assistant. It simulates network problems in your topology. This helps you practice your network troubleshooting skills. The feature uses AI to automatically analyze your network topology, choose the right fault type, and inject it into the project.

Steps to Use

  1. On the project topology page, click the fault injection button in the left toolbar (shown in the image below).

    Fault Injection Button in Toolbar
  2. In the "Fault Injection" dialog, click the "Inject Fault" button.

    Fault Injection Dialog
  3. Choose how many faults to inject (you can pick 1-3 faults or a random number). Then click the "Confirm & Inject" button.

    Choose Fault Count
  4. Wait for the fault injection to finish. The screen shows real-time progress.

    Fault Injection in Progress
  5. After the fault injection is done, you can see the results.

    Fault Injection Complete
  6. Check the AI Assistant for the detailed steps of the fault injection. This can help you if you are not sure about the cause of the problem.

    View Details in AI Assistant

Architecture Overview

Core Flow

Fault Injection Core Flow

Tool Overview

ToolSource FilePurposeAvailable Modes
InjectionSkillsToolregistry.py (skills module)Query protocol-level fault definitions (config change commands)troubleshooting_injection
GNS3PacketFilterToolgns3_packet_filter.pyLink-layer fault injection (delay, loss, corruption, BPF)troubleshooting_injection
ExecuteMultipleDeviceConfigCommandsconfig_tools_nornir.pyBatch execute device config changestroubleshooting_injection
ExecuteMultipleDeviceCommandsdisplay_tools_nornir.pyRead device configuration (read-only)troubleshooting_injection
GNS3TopologyToolgns3_clientGet project topology infotroubleshooting_injection

Fault Injection API

EndpointFunction
POST /v3/projects/{pid}/chat/injectTrigger fault injection, set troubleshooting_injection mode and start Agent

Prerequisite: Project must be in opened state, otherwise returns 403.

Simulates network impairment at the link layer by applying delay, packet loss, corruption, or dropping matching traffic to disrupt link quality. The bpf filter matches packets using BPF expressions and drops them, enabling precise link interference.

Filter TypeFunctionParameters
delayLatency + jitter[latency(0-32767), jitter(0-32767)]
packet_lossPacket loss rate[chance(0-100)]
corruptPacket corruption rate[chance(0-100)]
frequency_dropDrop every Nth packet[frequency(-1~32767)]
bpfBerkeley Packet Filter (standard BPF syntax)Text expression, supports protocol (arp/icmp/tcp), port (port 80), host (host 10.0.0.1), net (net 192.168.0.0/16), logical combos (and/or/not), same as tcpdump syntax

Agent Workflow (LangGraph)

Fault Injection Agent Workflow

Key Design Points

  1. Dedicated API EndpointPOST /chat/inject is specifically for fault injection, automatically switches to troubleshooting_injection mode
  2. LLM-driven Fault Selection — LLM analyzes topology, queries matching protocol faults via InjectionSkillsTool, no hardcoded scenarios
  3. Dual-layer Injection — Device-level config changes + link-level network impairment for complete troubleshooting coverage
  4. Reversible Faults — Each injection includes recovery commands; link filters can be cleared with action: clear
  5. Safety First — BPF syntax pre-validated via tshark; config commands restricted by command_filter
  6. Context FilteringInjectionSkillsTool requires context parameter, returns only faults matching the topology protocol

Feature Contributor

Fault Injection feature was developed and contributed by YueGuobin.

License

This document is licensed under CC BY-SA 4.0. Author: YueGuobin