Skip to main content

The Snappi Open Traffic Generator Python Package

Project description

snappi

Create test case scripts once using the snappi client and run them using a traffic generator that conforms to the Open Traffic Generator API.

Install the client

pip install snappi

Start scripting

"""A simple test that demonstrates the following:
- A port that transmits an ethernet/vlan/ipv4/tcp flow 
for a specified duration and a port that receives the packets.
- While the flow is transmitting the script prints out tx and rx statistics.
- Once all the packets have been transmitted the script will end. 
"""
import snappi

api = snappi.api()
config = api.config()
tx_port, rx_port = config.ports \
    .port(name='Tx Port', location='10.36.74.26;02;13')
    .port(name='Rx Port', location='10.36.74.26;02;14')
flow = config.flows.flow(name='Tx -> Rx Flow')[-1]
flow.tx_rx.port.tx_name = tx_port.name
flow.tx_rx.port.tx_name = rx_port.name
flow.packet.ethernet().vlan().ipv4().tcp()
flow.size.fixed = 128
flow.rate.pps = 1000
flow.duration.fixed_packets.packets = 10000
api.set_config(config)

tx_state = api.transmit_state(state='start')
api.set_transmit(tx_state)

while True:
    metrics = api.get_port_metrics(api.port_metrics_request())
    tx_frames = sum([metric.frames_tx for metric in metrics])
    if tx_frames >= flow.duration.fixed_packets.packets:
        break

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snappi-0.1.16.tar.gz (45.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snappi-0.1.16-py2.py3-none-any.whl (52.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file snappi-0.1.16.tar.gz.

File metadata

  • Download URL: snappi-0.1.16.tar.gz
  • Upload date:
  • Size: 45.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for snappi-0.1.16.tar.gz
Algorithm Hash digest
SHA256 11736f24321853ba0ae5ad95a9cbf701a4b16800c7e1ac6658c1766053002cca
MD5 d7dc92cfa27458c01ccd9f6128b0d6b8
BLAKE2b-256 91d07e7f64a07c5095e353cb4359355c04ef3d5c024dcae58d03e97d6ee4281b

See more details on using hashes here.

File details

Details for the file snappi-0.1.16-py2.py3-none-any.whl.

File metadata

  • Download URL: snappi-0.1.16-py2.py3-none-any.whl
  • Upload date:
  • Size: 52.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for snappi-0.1.16-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8ed872fb838feadb0d2fb5be74436b8df9a6745673799d07220779a9ab3ad11c
MD5 f37cab2b7ae474ff9f4d4de898f7c1a0
BLAKE2b-256 90029259c99fcd60f5fd2579b4c3fff7ca007997172ac0c9d9b7b08d5559b3f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page