Skip to main content

pktlib

PyPI Python CI License: MIT

Read, edit and write Cisco Packet Tracer .pkt files (and .pka activities) from Python. Build a network in code, open it in Packet Tracer, and it works.

Tested on Packet Tracer 8.2.0 (build 8.2.0.0162). Plain Python 3.10+, no dependencies. MIT licensed. Not affiliated with Cisco.

import pktlib

net = pktlib.new()
r1 = net.router("R1", "2911", at=(300, 200))
sw = net.switch("SW1", at=(300, 320))
pc = net.pc("PC1", at=(300, 440), ip="192.168.1.10/24", gateway="192.168.1.1")

pc["fa0"].connect(sw["fa0/1"])  # the right cable is picked for you
sw["fa0/2"].connect(r1["g0/0"])
r1["g0/0"].address = "192.168.1.1/24"  # interface, ip address, no shutdown
r1.config("""
router ospf 1
 network 192.168.1.0 0.0.0.255 area 0
""")
net.save("lab.pkt")

Installation

pktlib is on PyPI:

pip install pktlib

In a uv project, uv add pktlib. To use only the command line (pktlib audit lab.pkt, pktlib info, pktlib dump) without installing anything into a project:

pipx install pktlib
# or run it once with uv
uvx pktlib audit lab.pkt

The latest unreleased version: pip install git+https://github.com/conor-sometimes/pktlib.

What it does

  • Build routers, switches, PCs, phones and any of the 64 models in the 8.2 palette; cable them, address them, configure them with IOS text, fit modules, draw labels.
  • Read any .pkt: devices, ports, cables, addresses, VLANs, config. Files from older Packet Tracers (6.2 and up) load and save as 8.2.
  • Activities (.pka, pktlib.activity): read one, score a network against it, or write a new one from two networks that Packet Tracer grades with Check Results.
  • Check a file before handing it in: pktlib audit lab.pkt finds duplicate addresses, wrong gateways, shut ports, missing clock rates and config Packet Tracer drops.
  • Teach with it: troubleshooting labs with planted faults, an answer key and grading (pktlib.lab); ping checks students click in Packet Tracer.
  • Round-trip: pktlib dump lab.pkt turns any file into a script that rebuilds it.

Every behaviour was seen in Packet Tracer before pktlib relied on it. Where Packet Tracer does something surprising, pktlib handles it; docs/packet-tracer.md lists what and how we know.

Command line

Command What it does
pktlib info lab.pkt devices, links and addresses
pktlib audit lab.pkt problems you can see without running the simulation; exit code 1 if any
pktlib dump lab.pkt [out.py] a Python script that rebuilds the file
pktlib decode lab.pkt [out.xml] / encode in.xml out.pkt the raw XML

Documentation

Development

uv sync
just check     # ruff, the type checkers, then the tests (about a minute)
just soak 3    # every random test on every core but two for 3 hours, counted

CLAUDE.md has the project's rules, starting with the main one: Packet Tracer is the source of truth.

Metadata

Release files for pktlib 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pktlib 0.2.1
File Size Uploaded Provenance Actions
pktlib-0.2.1.tar.gz 358.2 kB With provenance Details for pktlib-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pktlib 0.2.1
File Interpreter ABI Platform Actions
pktlib-0.2.1-py3-none-any.whl Python 3 none any Details for pktlib-0.2.1-py3-none-any.whl

Total release size: 729.3 kB

Release files / pktlib-0.2.1.tar.gz

Download URL pktlib-0.2.1.tar.gz
Size 358.2 kB
Tags Source
SHA-256 checksum
How to use checksums
957a6ba5c144ac7dcbe49636dbb46c899554ae10296646a0e8cdcc3c88453a05
BLAKE2b-256 checksum
How to use checksums
72903371be81fe36cff60bb0e18094a9fac27c3c22f951fa294e047ad08f10c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / pktlib-0.2.1-py3-none-any.whl

Download URL pktlib-0.2.1-py3-none-any.whl
Size 371.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6688c42f0c8ede80e5abb7643282e75fa054107d9cb5d48754201dd2f23a53c3
BLAKE2b-256 checksum
How to use checksums
838b0b348c0d98221011f4f53f1938ac57da73d898d276cf5f9f5e7fc2475b60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for pktlib 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pktlib-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files Full provenance

0.2.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page