tracerlab

v0.1.6
io.github.atharv-santosh/tracerlab Checked 2 days ago Published 1 month ago

Build and verify Cisco Packet Tracer networks from an AI agent.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

pt_status

Bridge + Packet Tracer status: connection, PT version, open file, device/link counts.

pt_setup_instructions

How to install the one-time PT-side bridge module (needed if pt_status says NOT CONNECTED).

pt_topology

Whole canvas, compact: every device (model, position, power) with its addressed/cabled interfaces, peers and link state. detail=true adds MACs, switchport modes, descriptions and unused ports.

ParameterTypeDescription
detailboolean

pt_device

One device in depth: all physical ports (IP, peer, state, switchport mode), free ports, module slots.

ParameterTypeDescription
name *string

pt_running_config

Running (or startup) config of an IOS device, read from the device model (fast, no paging). section: only blocks whose header contains this text, e.g. 'interface', 'router ospf', 'line vty'.

ParameterTypeDescription
device *string
section
startupboolean

pt_show

Run show/exec commands (privileged EXEC) on a router/switch and return their output. commands: one or more, e.g. ['show ip interface brief', 'show ip route']. grep: optional regex; keep only matching lines (like '| include').

ParameterTypeDescription
commands *
device *string
grep

pt_command_log

Recent commands typed into any device CLI (PT's command log), oldest first.

ParameterTypeDescription
device
limitinteger

pt_screenshot

Image of the logical workspace (the topology as drawn in PT).

ParameterTypeDescription
fmtstring

pt_add_devices

Add devices. devices: [{name, model, x?, y?}], model like '2911', 'ISR4331', '2960-24TT', '3560-24PS', 'PC-PT', 'Laptop-PT', 'Server-PT' (see pt_catalog). Missing x/y are laid out automatically. Routers/switches have their boot skipped so they are ready immediately.

ParameterTypeDescription
devices *array

pt_connect

Cable devices. links: [{a, b, a_port?, b_port?, cable?}]. Ports are optional: the first free port of the right media is chosen (fastest first; on switches use a_pref/b_pref='access' to keep gigabit uplinks free). cable: auto (default) | straight | cross | serial | fiber | console | coaxial | phone. For serial links the device needs a serial module (pt_add_module).

ParameterTypeDescription
links *array

pt_disconnect

Remove cables by endpoint: ['R1:GigabitEthernet0/0', 'S1:FastEthernet0/3'].

ParameterTypeDescription
ports *array

pt_delete_devices

Delete devices (and their cables).

ParameterTypeDescription
names *array

pt_clear_canvas

Delete EVERY device on the canvas. Requires confirm=true.

ParameterTypeDescription
confirmboolean

pt_update_device

Rename, move and/or power a device on/off.

ParameterTypeDescription
name *string
new_name
power
x
y

pt_add_module

Insert a module (device is power-cycled automatically). Common: HWIC-2T (2 serial, 1941/2901/2911), WIC-2T (1841/2811), NIM-2T (ISR4321/4331), HWIC-4ESW, NM-1FE-TX, PT-ROUTER-NM-1S (Router-PT), AC-POWER-SUPPLY (3650). slot omitted = first slot that accepts it. Returns the device's ports afterwards.

ParameterTypeDescription
device *string
module *string
slot

pt_device_modules

Module slot tree of a device: slot path, slot type and installed module.

ParameterTypeDescription
device *string

pt_build

Build a whole network in one call. spec = { devices: [{name, model, x?, y?, modules?: [{module, slot?}]}], links: [{a, b, a_port?, b_port?, cable?}], # ports auto-picked when omitted configs: {device: ["ios line", ...]}, # global-config lines, applied + saved hosts: {pc: {ip, mask | cidr, gateway, dns} | {dhcp: true}}, auto: {routing: 'ospf'|'eigrp'|'rip'|'static'|'none', lan_pool, p2p_pool, dhcp, lan_prefix}, # optional checks: [[src, dst], ...] # ping pairs, run when verify=true } `aut…

ParameterTypeDescription
spec *object
verifyboolean

pt_lab

Build a complete, pre-computed lab (devices, cabling, IPs, configs, hosts, test pairs) in one call. name='list' shows blueprints and their params: small-office, router-on-a-stick, intervlan-l3, routing (ospf|eigrp|rip|static x chain|ring|star|mesh, optional serial), nat-internet, hsrp, etherchannel-stp, ipv6-dual-stack. verify=true pings the test pairs after convergence.

ParameterTypeDescription
clear_firstboolean
namestring
params
verifyboolean

pt_cli

Run IOS commands on a router/switch/ASA. mode=config: lines are entered from global config (sub-modes like 'interface g0/0' work, 'end' is added); the reply lists only failing lines. mode=exec: privileged EXEC, returns output (prefer pt_show). save=true appends 'write memory'.

ParameterTypeDescription
commands *
device *string
modestring
saveboolean

pt_configure_hosts

IP settings for PCs/laptops/servers/printers. hosts: [{name, ip, mask? | ip:'10.0.0.5/24' | cidr, gateway?, dns?, dhcp?: true, port?, ipv6?: '2001:db8::5/64', gw6?}].

ParameterTypeDescription
hosts *array

pt_apply_feature

Generate IOS config for a feature (see ios_features) and apply it to a device in one step. e.g. feature='ospf', params={'networks':['10.0.0.0/30','192.168.1.0/24'],'router_id':'1.1.1.1', 'passive':['GigabitEthernet0/0']}. dry_run=true returns the lines without applying.

ParameterTypeDescription
device *string
feature *string
params *object
dry_runboolean

pt_auto_address

Address the live topology and generate routing, computed from the actual cabling: each L3 segment (router/host ports joined through switches) gets a subnet: LANs from lan_pool (/lan_prefix, or right-sized when null), router-only links get /30s from p2p_pool. Routers take the first host addresses (gateway), hosts .10+ (or DHCP pools on the router with dhcp=true). Existing addresses are kept unless overwrite=true. apply=false only shows the plan and configs.

ParameterTypeDescription
applyboolean
dhcpboolean
dns
lan_poolstring
lan_prefix
loopbacksboolean
overwriteboolean
p2p_poolstring
routingstring

pt_save_configs

'write memory' on the given (default: all) routers/switches.

ParameterTypeDescription
devices

pt_ping

Ping from devices and report OK/PARTIAL/FAIL per pair. pairs: [[src, dst], ...] where dst is a device name or IP. Sources can be PCs/servers (Command Prompt) or routers/switches (IOS ping). Pairs from different sources run in parallel. A first-ping loss is usually ARP warm-up: count>=2 hides it.

ParameterTypeDescription
pairs *array
countinteger

pt_ping_matrix

All-pairs reachability between end hosts (default: every PC/laptop/server, max 10) as a matrix.

ParameterTypeDescription
countinteger
hosts

pt_traceroute

Traceroute (tracert on hosts) from a device to a device name or IP; returns the hop list.

ParameterTypeDescription
dst *string
src *string

pt_diagnose

Find misconfigurations from the live state: duplicate IPs, mixed subnets on a segment, hosts without IP / wrong or missing gateway, cabled-but-down interfaces, powered-off devices, uncabled hosts. deep=true also reads every router's routing table and lists subnets each router cannot reach.

ParameterTypeDescription
deepboolean

pt_fast_forward

Fast-forward PT's realtime clock (speeds up STP, OSPF/EIGRP convergence, DHCP).

ParameterTypeDescription
timesinteger

pt_simulation

Simulation mode control. action: simulation|realtime (switch mode), pdu (simple ICMP PDU src->dst), forward/back (steps events), reset, frames (last events with status), status.

ParameterTypeDescription
action *string
dst
src
stepsinteger

pt_file

Packet Tracer file operations on the open workspace: new, open <path>, save, save_as <path> (.pkt).

ParameterTypeDescription
action *string
path

pkt_inspect

Read a .pkt/.pka file WITHOUT Packet Tracer: devices, models, IPs, links, and (configs=true) every device's running-config. Good for grading or understanding a lab file.

ParameterTypeDescription
path *string
configsboolean

pkt_convert

Convert .pkt <-> .xml without Packet Tracer (decrypt to editable XML, or re-encrypt XML into a .pkt).

ParameterTypeDescription
dst *string
src *string

pkt_export_configs

Write every device's running-config from a .pkt file to <out_dir>/<device>.txt.

ParameterTypeDescription
out_dir *string
path *string

net_subnet

Subnet facts for an address/prefix: network, mask, wildcard, broadcast, host range, count, class.

ParameterTypeDescription
cidr *string

net_vlsm

VLSM plan: needs = {'Sales': 50, 'Eng': 25, 'R1-R2': 2}. Largest first; returns subnet, mask, wildcard, gateway (first host), host range and broadcast per segment.

ParameterTypeDescription
needs *object
pool *string

net_summarize

Route summarization: exact collapsed set and the single covering supernet (+ how much extra it covers).

ParameterTypeDescription
networks *array

net_split

Split a block into `count` equal subnets or into /new_prefix subnets (first 64 shown).

ParameterTypeDescription
cidr *string
count
new_prefix

ios_features

List IOS config generators and their parameters (used by ios_generate / pt_apply_feature).

ios_generate

Generate IOS config lines for a feature without applying them. See ios_features for names/params. e.g. ('dhcp_pool', {'name':'LAN','network':'192.168.1.0/24','dns':'8.8.8.8','exclude_first':10}).

ParameterTypeDescription
feature *string
params *object

pt_catalog

Device models PT 9 offers (exact names for pt_add_devices) with ports, slots and usage notes. category: router | switch | l3-switch | host | firewall | ap | wireless-router ... modules=true lists modules.

ParameterTypeDescription
category
modulesboolean

pt_api_lookup

Search Packet Tracer's IPC/scripting API (6000+ methods, 374 classes) for use with pt_run_js. query: a class name ('TerminalLine'), a method fragment ('Vlan', 'ospf'), or 'Class.method'.

ParameterTypeDescription
query *string
limitinteger

pt_run_js

Escape hatch: run JavaScript inside PT's script engine and return the JSON result. The code is a function body: use `return`. Globals: ipc (IPC root: ipc.network(), ipc.appWindow(), ipc.simulation()), PTM (this server's helpers: PTM.dev(name), PTM.snapshot(), PTM.cli(name, lines, mode)...). Example: return ipc.network().getDevice('R1').getPort('GigabitEthernet0/0').getMacAddress();

ParameterTypeDescription
code *string
timeoutnumber