The Snappi Open Traffic Generator Python Package
Project description
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.19.tar.gz
(45.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snappi-0.1.19.tar.gz.
File metadata
- Download URL: snappi-0.1.19.tar.gz
- Upload date:
- Size: 45.3 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de1e27742d78a6d87a7874dd1b100c1d8f746c3d67a26faebe1dd8ed4867ad6a
|
|
| MD5 |
88df29fb6743aff9ec50af870b488a2f
|
|
| BLAKE2b-256 |
1c5538b5c21a4ea4cde441d3b8e45d923014817490438c3781528b23dbac2927
|
File details
Details for the file snappi-0.1.19-py2.py3-none-any.whl.
File metadata
- Download URL: snappi-0.1.19-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
929dbe829a2470f96ea53b3f0099292e878a18ea550f1c95c6bb9d896ba2c432
|
|
| MD5 |
556da589325c4e48df0a0eaf374561d9
|
|
| BLAKE2b-256 |
70f14829eb5c8f4e2db913c1ad70ce0d19c16f4e8f24bedb26dc3354b55e8e61
|