Skip to content

Commit

Permalink
quick start ready
Browse files Browse the repository at this point in the history
  • Loading branch information
bortok committed Nov 14, 2023
1 parent 1f296f6 commit 52f77fd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 99 deletions.
5 changes: 0 additions & 5 deletions docs/developer/hello-snappi.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<div align="center">
<h1>Hello, snappi!</h1>
<h3>Your first snappi script</h3>
</div>

## Use Case

This tutorial explains some key elements that are required to write a **snappi script** for exercising the following topology.
Expand Down
151 changes: 58 additions & 93 deletions docs/quick-start/introduction.md
Original file line number Diff line number Diff line change
@@ -1,103 +1,68 @@
## What is Ixia-c ?

# What is ixia-c
- A modern, powerful and **API-driven** traffic generator designed to cater to the needs of hyper-scalers, network hardware vendors and hobbyists alike.

Ixia-c is a modern, powerful, and API-driven traffic generator designed to cater to the needs of hyperscalers, network hardware vendors, and hobbyists alike.
- **Free for basic use-cases** and distributed / deployed as a multi-container application consisting primarily of a [controller](https://github.com/orgs/open-traffic-generator/packages/container/package/keng-controller), a [traffic-engine](https://github.com/orgs/open-traffic-generator/packages/container/package/Ixia-c-traffic-engine) and a [protocol-engine](https://github.com/orgs/open-traffic-generator/packages/container/package/Ixia-c-protocol-engine).

It is distributed and deployed as a multi-container application that consists of a [controller](https://github.com/orgs/open-traffic-generator/packages/container/package/keng-controller), a [traffic-engine](https://github.com/orgs/open-traffic-generator/packages/container/package/ixia-c-traffic-engine), and an [app-usage-reporter](https://github.com/orgs/open-traffic-generator/packages/container/package/keng-app-usage-reporter).
- As a reference implementation of [Open Traffic Generator API](https://github.com/open-traffic-generator/models), supports client SDKs in various languages, most prevalent being [snappi](https://github.com/open-traffic-generator/snappi) (Python SDK) and [gosnappi](https://github.com/open-traffic-generator/snappi/tree/main/gosnappi).

As a reference implementation of [Open Traffic Generator API](https://github.com/open-traffic-generator/models), Ixia-c supports client SDKs in various languages, most prevalent being [snappi](https://pypi.org/project/snappi/) (Python SDK).
<p align="center">
<img src="/res/ixia-c.drawio.svg" alt="Ixia-c deployment for two-arm test with DUT">
</p>

!["Ixia-c Deployment for Bidirectional Traffic](../res/ixia-c.drawio.svg)
## Quick Start

> [Keysight](https://www.keysight.com) also offers a well supported commercial version, [Keysight Elastic Network Generator](https://www.keysight.com/us/en/products/network-test/protocol-load-test/keysight-elastic-network-generator.html), with no restrictions on **performance and scalability**. Scripts written for the free version are **compatible** with this version.
Please ensure that following prerequisites are met by the setup:

## Quick Demo
* At least **2 x86_64 CPU cores** and **7GB RAM**, preferably running **Ubuntu 22.04 LTS** OS
* **Python 3.8+** (and **pip**) or **Go 1.19+**
* **Docker Engine** (Community Edition)

![Quick Demo](../res/quick-demo.gif)

## Quick Start
### 1. Deploy Ixia-c

```bash
# clone this repository
git clone --recurse-submodules https://github.com/open-traffic-generator/Ixia-c.git && cd Ixia-c

# create a veth pair and deploy Ixia-c containers where one traffic-engine is bound
# to each interface in the pair, and controller is configured to figure out how to
# talk to those traffic-engine containers
cd conformance && ./do.sh topo new dp
```

### 2. Setup and run standalone test using [snappi](https://github.com/open-traffic-generator/snappi) or [gosnappi](https://github.com/open-traffic-generator/snappi/tree/main/gosnappi)

```bash
# change dir to conformance if you haven't already
cd conformance

# setup python virtual environment and install dependencies
./do.sh prepytest

# run standalone snappi test that configures and sends UDP traffic
# upon successful run, flow metrics shall be printed on console
./do.sh pytest examples/test_quickstart.py

# optionally, go equivalent of the test can be run like so
./do.sh gotest examples/quickstart_test.go
```

> Checkout the contents of [test_quickstart.py](https://github.com/open-traffic-generator/conformance/blob/22563e20fe512ef13baf44c1bc69bc59f87f6c25/examples/test_quickstart.py) and equivalent [quickstart_test.go](https://github.com/open-traffic-generator/conformance/blob/22563e20fe512ef13baf44c1bc69bc59f87f6c25/examples/quickstart_test.go) for quick explanation on test steps
### 3. Optionally, run test using [curl](https://curl.se/)

We can also pass equivalent **JSON configuration** directly to **controller**, just by using **curl**.
The description of each node in the configuration is detailed in self-updating [online documentation](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/open-traffic-generator/models/v0.13.0/artifacts/openapi.yaml).


```bash
# push traffic configuration
curl -skL https://localhost:8443/config -H "Content-Type: application/json" -d @conformance/examples/quickstart_config.json

# start transmitting configured flows
curl -skL https://localhost:8443/control/state -H "Content-Type: application/json" -d @conformance/examples/quickstart_control.json

Before you proceed, ensure that the [system prerequisites](../prerequisites.md) are met.

* Deploy Ixia-c

```bash
# start KENG controller
docker run -d --network=host ghcr.io/open-traffic-generator/keng-controller --accept-eula
docker run --net=host -d ghcr.io/open-traffic-generator/keng-app-usage-reporter

# start ixia-c traffic engine on eth1 interface
docker run -d --network=host --privileged \
-e ARG_IFACE_LIST="virtual@af_packet,eth1" \
-e OPT_NO_HUGEPAGES="Yes" \
ghcr.io/open-traffic-generator/ixia-c-traffic-engine
```

> Once the containers are up, accessing https://controller-ip/docs/ will open up an interactive REST API documentation. For more information, see [deployment guide](../deployments.md).
* Generate Traffic using [snappi](https://pypi.org/project/snappi/). For more details on snappi, see [hello-snappi](../developer/hello-snappi.md).

```bash
# clone repo for test suites, useful helper scripts, deployment files, etc.
git clone --recurse-submodules https://github.com/open-traffic-generator/ixia-c && cd ixia-c

# install snappi
python -m pip install --upgrade snappi==0.9.4
# run a standalone script to generate TCP traffic and fetch metrics
python snappi-tests/scripts/quickstart_snappi.py
```

> After a successful run, the port metrics will be printed on the console.
??? abstract "Expand this section for an overview of the script you just ran"

```python
import snappi
# create a new API instance over HTTPS transport where location points to controller
api = snappi.api(location="https://localhost", verify=False)
# OR
# create a new API instance over gRPC transport where location points to controller
api = snappi.api(location="localhost:40051", transport=snappi.Transport.GRPC)

# create a config object to be pushed to controller
config = api.config()
# add a port with location pointing to traffic engine
prt = config.ports.port(name='prt', location='localhost:5555')[-1]
# add a flow and assign endpoints
flw = config.flows.flow(name='flw')[-1]
flw.tx_rx.port.tx_name = prt.name

# configure 100 packets to be sent, each having a size of 128 bytes
flw.size.fixed = 128
flw.duration.fixed_packets.packets = 100

# add Ethernet, IP and TCP protocol headers with defaults
flw.packet.ethernet().ipv4().tcp()

# push configuration
api.set_config(config)

# start transmitting configured flows
ts = api.transmit_state()
ts.state = ts.START
api.set_transmit_state(ts)

# fetch & print port metrics
req = api.metrics_request()
req.port.port_names = [prt.name]
print(api.get_metrics(req))
```

* Optionally, you can generate the traffic by using [curl](https://curl.se/).

>You can also pass an equivalent **JSON configuration** directly to the KENG controller by using **curl** and without installing snappi.
>For the detailed description of each node (and their attributes) in the JSON configuration, see [Open Traffic Generator API](https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/open-traffic-generator/models/v0.9.1/artifacts/openapi.yaml).
```bash
# push the contents of config file snappi-tests/configs/quickstart_snappi.json
curl -k https://localhost/config -H "Content-Type: application/json" -d @snappi-tests/configs/quickstart_snappi.json
# start transmitting configured flows
curl -k https://localhost/control/transmit -H "Content-Type: application/json" -d '{"state": "start"}'
# fetch all port metrics
curl -k https://localhost/results/metrics -H "Content-Type: application/json" -d '{"choice": "port"}}'
```
# fetch flow metrics
curl -skL https://localhost:8443/monitor/metrics -H "Content-Type: application/json" -d @conformance/examples/quickstart_metrics.json
```
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ nav:
- EULA: eula.md # Check / update
- Quick Start:
- Introduction: quick-start/introduction.md # Now goes as Ixia-c Quick Start. Add a paragraph why
- Deployment: quick-start/deployment.md # Link to deployment dir is broken. Need a compose file in text. Need to move to docker compose later
# - Deployment: quick-start/deployment.md # Link to deployment dir is broken. Need a compose file in text. Need to move to docker compose later
# - Sample test: quick-start/sample-test.md # Empty - otgen example or hello snappi?. See "clients" in UG Intro
- First script: developer/hello-snappi.md # Took from Developer Guide
- User Guide:
Expand Down

0 comments on commit 52f77fd

Please sign in to comment.