Skip to main content

The Snappi Open Traffic Generator Python Package

Project description

snappi

The open traffic generator client.

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
import pandas

api = snappi.Api()
control_state = api.control_state.set(choice='config_state')
config = control_state.config_state.set(state='set').config
config.ports.append(name='Tx Port', location='10.36.74.26;02;13')
config.ports.append(name='Rx Port', location='10.36.74.26;02;14')
flow = config.flows.append(name='Tx -> Rx Flow')
flow.tx_rx.set(choice='port').port.set(tx_port_name=config.ports[0].name,
                                       rx_port_name=config.ports[1].name)

# use flowheader.choice and create property accessors
flow.packet.ethernet().vlan().ipv4().tcp() 

flow.packet.append(choice='ethernet').append(choice='vlan').append(
    choice='ipv4').append(choice='tcp')

flow.packet[0].ethernet

flow.packet.append().ethernet
flow.packet.append().ipv4
flow.packet.append().tcp

flow.packet = [ixsnappi.flowethernet.FlowEthernet(), FlowIpv4()]

flow.size.set(choice='fixed').fixed = 128
flow.duration.set(choice='packets').packets.set(packets=100000)
flow.rate.set(units='pps', value=1000)
api.set_state(api.control_state)

control_state.set(choice='flow_transmit_state')
control_state.flow_transmit_state.state = 'start'
api.set_state(control_state)

request = result.PortRequest(
    column_names=['name', 'location', 'frames_tx', 'frames_rx'])
while True:
    results = api.get_port_results(request)
    df = pandas.DataFrame.from_dict(results)
    print(df)
    if df.frames_tx.sum() >= config.flows[0].duration.packets.packets:
        break

Project details


Release history Release notifications | RSS feed

This version

0.0.5

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.0.5.tar.gz (35.7 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.0.5-py2.py3-none-any.whl (68.9 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: snappi-0.0.5.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for snappi-0.0.5.tar.gz
Algorithm Hash digest
SHA256 ae239edbbe5b6135a8ce622902f3ed67105a7beec168e9242cdf744ce8aafd8d
MD5 84bd63986baddb3e7cbf2603a7d34a3d
BLAKE2b-256 56550899a6bf10d6c1baee68edb760cde43fdb1f8c6f710074a0a96fd45bc473

See more details on using hashes here.

File details

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

File metadata

  • Download URL: snappi-0.0.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 68.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

File hashes

Hashes for snappi-0.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6dff08962caebe157bf85b1db4c46939635782efa9fa762ccdbe29c376cbb59a
MD5 d75baa2e2b66300133f85740879b43be
BLAKE2b-256 af2d87cf2a3a7d5e749fe3a6c2177521ed9e66ea45df35f517eef595e07d39b5

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