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.14.tar.gz
(43.6 kB
view hashes)
Built Distribution
Close
Hashes for snappi-0.1.14-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d73ab8ca8f48c53988fe98ad9ab8f2caa866b29fc16982ce821bd30f933edd8 |
|
MD5 | e7303785d3c8ebc8b7fad585cd1ea77e |
|
BLAKE2b-256 | 422579c39aa56e9ba8d16eda9234cacda36887291ac158c2f6a6c3cf0ebbc4b7 |