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')
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:
    results = api.get_port_results(api.result_portrequest)
    df = pandas.DataFrame.from_dict(results)
    print(df)
    if df.frames_tx.sum() >= flow.duration.fixed_packets.packets:
        break

Project details


Release history Release notifications | RSS feed

This version

0.1.6

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.6.tar.gz (46.8 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.6-py2.py3-none-any.whl (84.1 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: snappi-0.1.6.tar.gz
  • Upload date:
  • Size: 46.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for snappi-0.1.6.tar.gz
Algorithm Hash digest
SHA256 bf80469b0ac5dac1c093eeb1b63cb5358303098fd793aa1e7adc970ba23692e6
MD5 60194461669177f39ef1b4277bea938f
BLAKE2b-256 8abee2c5530c6e956f03e7a37f84f0bc0a91cf0184d624821d60cbe86e18de85

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for snappi-0.1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 25a650582f03d82e7d3042412d5316e49107a18cdc8dc7af4bf18b7b1a1ab448
MD5 7f9987fa84be8f2b037a7cb590e543d6
BLAKE2b-256 de6ac68e41ade76189ce6c7ecc7fe30bd2bd161e331534b0f73cdc8f49a804df

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