Snappi Open Traffic Generator

raw JSON →
1.53.0 verified Mon Apr 27 auth: no python

Snappi is an open-source Python library for generating and testing network traffic. The current version is 1.53.0, with regular releases approximately every 2-3 weeks. It supports Python >=3.8,<4 and integrates with various traffic generator backends (e.g., IxNetwork, Traffic Server). Snappi provides a unified API to configure traffic flows, endpoints, and capture settings.

pip install snappi
error ModuleNotFoundError: No module named 'snappi'
cause snappi not installed or running in a different Python environment.
fix
Run 'pip install snappi' in the correct environment.
error AttributeError: module 'snappi' has no attribute 'Api'
cause Import was not done correctly (e.g., from snappi import snappi).
fix
Use 'import snappi' then 'snappi.Api(...)'.
error ConnectionError: HTTPConnectionPool ... Max retries exceeded
cause The controller address is incorrect or the server is not running.
fix
Verify the API address (e.g., 'https://localhost:11009') and ensure the snappi server is running.
error ValueError: Unsupported protocol version
cause Client version incompatible with server version (server may be older).
fix
Upgrade both client and server to the latest version, or pin to compatible versions.
error TypeError: 'NoneType' object is not iterable
cause Attempting to iterate over a flow before it is properly configured or added.
fix
Ensure you have added flows to config, e.g., config.flows.flow(name='test')...
gotcha The API address must include the protocol (http/https) and port. Local default is https://localhost:11009.
fix Always specify full URL: api = snappi.Api(address='https://10.10.10.10:8443')
deprecated Method set_config() and resulting 'elapsed_time' attribute are deprecated in v1.50+. Use set_config() -> config object directly.
fix Use config = api.config() then api.set_config(config)
breaking In v1.40.0, the default protocol changed from HTTP to HTTPS. Older code using http:// may fail.
fix Update API address to https:// or set ssl=False explicitly.
gotcha Flow packet layers are built using chained methods (e.g., .packet().ethernet().eth_ipv4()). Order matters; .eth_ipv4() is a shorthand for stacking ethernet and IPv4.
fix Use .packet().ethernet().ipv4() for separate layers or .eth_ipv4() for convenience.
breaking The 'config.ports' property was renamed to 'config.port' in v1.20.0.
fix Use config.port instead of config.ports.
gotcha When setting packet headers, some fields require .value assignment, others use .increment or .decrement. Not all fields support all modes.
fix Check docstring: e.g., ipv4.src.increment.start = '10.0.0.1'; ipv4.src.value = '10.0.0.1'

Instantiate the API, create a config, and add a simple IPv4 flow.

import snappi

api = snappi.Api(address='https://localhost:11009')
config = api.config()
config.flows.flow(name='test_flow').packet().ethernet().eth_ipv4().v4().src.value = '10.0.0.1'
# No auth needed for local; for remote, set via os.environ.get('SNAPPI_AUTH_TOKEN', '')