Skip to content
LinkState
Go back

Can AI isolate a stuck OSPF session safely

Comparing Deterministic CLI Workflows, Scripted State Collection, and an AI‑Assisted Triage Workbench for OSPF Adjacency Troubleshooting

Introduction

Three complementary approaches can be used to diagnose a stuck OSPF adjacency:

All three rely on the same evidence set (the output of a defined list of OSPF‑related show commands) and the AI is constrained to read‑only tools; it may not alter device state.


Deterministic CLI Workflows

How It Works

The operator logs into the router, runs a predetermined sequence of CLI commands, interprets the output (optionally with simple grep/awk filters), and decides the next step based on observable facts. Because the same commands on the same device state produce identical output, the workflow is deterministic and fully reproducible when the command log is retained.

Advantages

Disadvantages

Typical OSPF Adjacency Troubleshooting Commands

GoalCommand (IOS‑XR/Junos‑style)What to Look For
Verify OSPF process statusshow ospf or show ospf neighborProcess ID, area, neighbor state (Full/2‑Way/Init/Down)
Check interface OSPF settingsshow ospf interface <iface>Hello/dead intervals, area, authentication, network type
Examine link‑state database (LSDB)show ospf databasePresence of neighbor’s router‑LSA, LS age, sequence number
Review interface IP/maskshow ip interface brief or show interfaces <iface> terseIP address, subnet mask, line‑protocol status
Look for ACL/filter blocking OSPFshow access-lists (or firewall filter) applied to the interfaceOSPF protocol (89) denied
Check physical layershow interfaces <iface>Errors, CRC, drops, transceiver status
Verify routing table for OSPF routesshow route ospf or show ip route ospfWhether OSPF routes are installed

Step‑by‑Step CLI Guide

  1. Establish session – SSH/console to the router where adjacency is stuck.
  2. Confirm OSPF process – show ospf → note process ID and area.
  3. List neighbors – show ospf neighbor → identify the neighbor not in Full state.
  4. Inspect the problematic interface – show ospf interface <iface> → verify hello/dead timers match the neighbor.
  5. Check IP connectivity – ping <neighbor‑ip> (if allowed) or show ip interface brief to confirm interface is up.
  6. Review LSDB – show ospf database → look for the neighbor’s router‑LSA; note if missing or stale.
  7. Examine physical/log errors – show interfaces <iface> → check for increasing error counters.
  8. Verify filters – show access-lists applied to the interface → ensure OSPF (protocol 89) is not blocked.
  9. Form hypothesis – based on mismatched timers, missing LSA, or physical errors.
  10. Test hypothesis – adjust timers, clear OSPF process (clear ospf process), or fix physical layer, then re‑check neighbor state.
  11. Document – capture the final show ospf neighbor output showing Full state and any configuration changes made.

Scripted State Collection

How It Works

A pre‑written script (Python/Bash, often using frameworks such as Nornir, Ansible, or PyATS) logs into devices, executes a defined command set, and stores the results in a structured format (JSON, YAML, CSV, or a time‑series database). The script removes manual typing and enables repeatable, version‑controlled data collection across many devices.

Benefits

Limitations

Example Python/Nornir Script

# collect_ospf_state.py
from nornir import InitNornir
from nornir_netmiko.tasks import netmiko_send_command
from nornir_utils.plugins.functions import print_result
import json
import os

def collect_ospf(task):
    # Gather three key show commands
    commands = [
        "show ospf neighbor",
        "show ospf interface",
        "show ospf database"
    ]
    result = {}
    for cmd in commands:
        res = task.run(task=netmiko_send_command, command_string=cmd)
        if res.failed:
            result[cmd] = {"error": str(res.exception)}
        else:
            # Store raw output; could be parsed later with textfsm or ttp
            result[cmd] = res.result
    # Create host‑specific directory
    host_dir = os.path.join("collected", task.host)
    os.makedirs(host_dir, exist_ok=True)
    out_path = os.path.join(host_dir, "ospf_state.json")
    with open(out_path, "w") as f:
        json.dump(result, f, indent=2)
    return result

def main():
    nr = InitNornir(config_file="config.yaml")  # inventory, credentials, etc.
    agg = nr.run(task=collect_ospf)
    print_result(agg)

if __name__ == "__main__":
    main()

Assumptions

Integrating Scripted Collection with CLI Workflows

  1. Baseline collection – Run the script nightly or on demand to build a repository of known‑good OSPF states.
  2. Delta analysis – When an adjacency is reported stuck, run the script on the affected device(s) and diff the current JSON against the baseline using jq or a Python diff script.
  3. Focused CLI – Use the diff output to narrow down which specific command(s) show anomalies, then jump to those commands in an interactive CLI session for deeper inspection (e.g., show ospf interface <iface> | include hello|dead).
  4. Automation loop – Optionally feed the diff into a ticketing system or chat‑ops bot that presents the operator with a concise summary and suggested next CLI commands.

AI‑Assisted Triage Workbench

Architecture

+-------------------+       +-------------------+       +-------------------+
|   Operator UI     | <---->|   Orchestrator    | <---->|   LLM Engine      |
| (chat / web UI)   |       | (tool‑calling)    |       | (local or remote)|
+-------------------+       +-------------------+       +-------------------+
          ^                         ^                         ^
          |                         |                         |
          |   Evidence JSON/YAML    |   Prompt + Tools        |   Model Weights
          |   (from script)         |   (retriever, safety)   |
          +-------------------------+-------------------------+

Advantages

Limitations & Constraints

Example AI‑Driven Diagnostic Scenarios

Scenario 1 – Mismatched Hello/Dead Intervals
Operator asks: “Why is OSPF neighbor on ge‑0/0/3 stuck in Init state?”

  1. Orchestrator retrieves show ospf interface ge-0/0/3 and show ospf neighbor JSON.
  2. LLM sees hello = 10s, dead = 40s locally; neighbor shows hello = 5s, dead = 20s (from show ospf neighbor detail).
  3. LLM concludes: “Hello/dead timers mismatch; adjust local timers to match neighbor or vice‑versa.”
  4. UI returns the conclusion with evidence snippets and a read‑only suggestion (show ospf interface ge-0/0/3 | include hello|dead). No configuration change is proposed.

Scenario 2 – OSPF Authentication Failure
Operator asks: “OSPF neighbor on te‑0/1/0 is down; what could be wrong?”

  1. Evidence includes show ospf interface te-0/1/0 (shows MD5 authentication) and show ospf neighbor (state Down).
  2. LLM notes that the neighbor’s interface shows no authentication configured (from show ospf interface on the neighbor).
  3. LLM suggests: “Authentication mismatch; verify MD5 key chain on both ends.”
  4. UI provides the evidence and a read‑only command to check the key chain (show ospf md5-key).

Scenario 3 – Physical Layer Issue
Operator asks: “OSPF neighbor on xe‑2/0/1 flaps; any clues?”

  1. Evidence: show interfaces xe-2/0/1 shows increasing CRC errors and input drops.
  2. LLM correlates flaps with error counters and suggests: “Likely physical layer problem; check fiber, transceiver, or port speed/duplex.”
  3. UI returns the analysis and a read‑only command to monitor errors (monitor interface xe-2/0/1).

In each scenario the AI never issues a command that changes state; it only proposes hypotheses and points to specific read‑only checks.


Comparison of Diagnostic Approaches

Deterministic CLI vs. Scripted State Collection

AspectDeterministic CLIScripted State Collection
Speed (single device)Immediate, but manual typing adds latency.Slightly higher latency due to script overhead, but eliminates typing.
ReproducibilityLow unless session is recorded.High – same script yields identical JSON.
Error rateHuman‑induced (typos, missed output).Low for collection; depends on script correctness.
Operator trustHigh – operator sees raw output directly.Moderate – trust in script correctness needed.
ScalePoor – does not scale beyond a few devices.Good – parallel execution across hundreds.
Tooling dependencyNone beyond SSH/telnet.Requires automation framework, inventory, credentials.
Data richnessLimited to what the operator chooses to capture.Can capture a superset of commands consistently.

Scripted State Collection vs. AI‑Assisted Triage Workbench

AspectScripted State CollectionAI‑Assisted Triage Workbench
Primary purposeData gathering.Data interpretation & hypothesis generation.
Speed of insightRequires manual review of output.Can produce a concise summary in seconds.
Error sourcesScript bugs, missing commands.Model hallucination, prompt truncation, tool‑call failures.
Trust levelHigh if script is vetted.Moderate – operator must verify AI output against evidence.
ScalabilityScales with collection parallelism.Scales similarly; AI adds constant overhead per query.
Dependency on humanNone for collection; human needed for analysis.Human needed to approve any action; AI only suggests.

Closing Note

Each method offers a distinct trade‑off between immediacy, scalability, and interpretive power. Deterministic CLI provides the most direct, unmediated view of device state but does not scale. Scripted state collection brings repeatability and scale to data gathering, leaving analysis to the operator. The AI‑assisted triage workbench adds rapid, natural‑language reasoning over the collected evidence while remaining strictly read‑only, ensuring that the operator retains final


Share this post on:

Previous Post
OVS kernel datapath versus Linux bridge under fan-out load
Next Post
Reading FDB aging like an outage timeline