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
import pandas
api = snappi.Api()
config = api.control_state.config_state.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.port_tx_rx.set(tx_port_name=config.ports[0].name,
rx_port_name=config.ports[1].name)
flow.packet.append(choice=snappi.FLOWHEADER_ETHERNET) \
.append(choice=snappi.FLOWHEADER_VLAN) \
.append(choice=snappi.FLOWHEADER_IPV4) \
.append(choice=snappi.FLOWHEADER_TCP)
flow.size.fixed = 128
flow.duration.fixed_packets = 10000
flow.rate.pps = 1000
api.control_state.config_state.state = snappi.CONTROLCONFIGSTATE_SET
api.set_state(api.control_state)
api.control_state.flow_transmit_state.state = snappi.FLOWTRANSMITSTATE_START
api.set_state(api.control_state)
while True:
results = api.get_port_results(api.result_portrequest)
df = pandas.DataFrame.from_dict(results)
print(df)
if df.frames_tx.sum() >= config.flows[0].duration.fixed_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.1.tar.gz
(40.9 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.1.tar.gz.
File metadata
- Download URL: snappi-0.1.1.tar.gz
- Upload date:
- Size: 40.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d19e0ae5ce592a3b30bbccb19e339089d29df0fb3f2b1f5b3a9839a9c8d95b8b
|
|
| MD5 |
b8d810b3812288628cd8323664ed8c5f
|
|
| BLAKE2b-256 |
76d782c9a61ddce2efaf9bea4c1d89f699c4da883d53fe805694c040b8d65667
|
File details
Details for the file snappi-0.1.1-py2.py3-none-any.whl.
File metadata
- Download URL: snappi-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 74.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01c7c494c3cfad10be33150a0892ede85105c927474633916845874dd8cbcc36
|
|
| MD5 |
6041b869acd8e06a68b6e39524975477
|
|
| BLAKE2b-256 |
618c4a0020b3eca88e8ae032478153b6018a4f87cb05ae6d8c787ed968d93eb6
|