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 hashes)
Built Distribution
snappi-0.1.1-py2.py3-none-any.whl
(74.0 kB
view hashes)
Close
Hashes for snappi-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01c7c494c3cfad10be33150a0892ede85105c927474633916845874dd8cbcc36 |
|
MD5 | 6041b869acd8e06a68b6e39524975477 |
|
BLAKE2b-256 | 618c4a0020b3eca88e8ae032478153b6018a4f87cb05ae6d8c787ed968d93eb6 |