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 (a .pka: its items and tests; --answers adds the values)
pktlib audit lab.pkt problems you can see without running the simulation; exit code 1 if any (a .pka: its answer network)
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

  • Not Cisco's. pktlib is an independent project, not affiliated with or endorsed by Cisco. Cisco and Packet Tracer are Cisco's trademarks.
  • No Cisco code. The file format comes from published work by the projects below, and was checked by opening files in Packet Tracer. The device templates in the package are copied from files Packet Tracer 8.2 saved. To open what pktlib writes, you need your own copy of Packet Tracer from Cisco Networking Academy.
  • Coursework. Follow your course's rules. Anyone holding a .pka can read its answer network and graded items: pktlib info --answers lists them, and the activity password only locks Packet Tracer's Activity Wizard. Don't use pktlib to read the answers to an activity you're being graded on. And if you set activities, don't count on a .pka to keep its answers secret.
  • No course material here. This repo holds no lecturer or NetAcad files. Every sample file says where it came from in tests/fixtures/README.md.
  • pka2xml (BSD-2-Clause, 2020): the first public description of the encryption. pktlib's codec re-implements it in Python.
  • packet-tracer-pkt-format (GPL-3.0): a full format reference, covering files from Packet Tracer 4.1 to 9.0.1. Read its FORMAT.md if you want to know exactly how a .pkt is built. pktlib uses none of its code.

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.2

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.2
File Size Uploaded Provenance Actions
pktlib-0.2.2.tar.gz 363.7 kB With provenance Details for pktlib-0.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 740.5 kB

Release files / pktlib-0.2.2.tar.gz

Download URL pktlib-0.2.2.tar.gz
Size 363.7 kB
Tags Source
SHA-256 checksum
How to use checksums
815edf222cdf3d4884cab0632b21a398e3b86aebb8cfee07b954b01d16b904cf
BLAKE2b-256 checksum
How to use checksums
2586e564bdeae2fe11d960580246421b21014eb81f5e27cd50338dff645b1b8a
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 29, 2026.

Transparency log

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

Download URL pktlib-0.2.2-py3-none-any.whl
Size 376.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
940f779bcf6b60f239d66604887e2b80df8ff97cfb66e1ccf33bf17c44fd5d69
BLAKE2b-256 checksum
How to use checksums
5f60c8050b778ddf79aff8811743d083137bb8ef331712f997c73d0ea77c95f4
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 29, 2026.

Transparency log

Security for pktlib 0.2.2

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.2.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 29, 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.2 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