This is a basic lab where Ixia-c has two traffic ports connected back-2-back using a veth pair. The lab is defined via Docker Compose YAML file. Once the lab is up, a CLI tool otgen
is used to request Ixia-c to generate traffic and report statistics.
- Linux host or VM with sudo permissions and Docker support
- Docker
- Python3.9 for
snappi
part
-
Install
docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
-
Install
otgen
bash -c "$(curl -sL https://get.otgcdn.net/otgen)" -- -v 0.6.2
-
Make sure
/usr/local/bin
is in your$PATH
variable (by default this is not the case on CentOS 7)cmd=docker-compose dir=/usr/local/bin if ! command -v ${cmd} &> /dev/null && [ -x ${dir}/${cmd} ]; then echo "${cmd} exists in ${dir} but not in the PATH, updating PATH to:" PATH="/usr/local/bin:${PATH}" echo $PATH fi
-
Clone this repository
git clone --recursive https://github.com/open-traffic-generator/otg-examples.git cd otg-examples/docker-compose/b2b
-
Create veth pair
veth0 - veth1
sudo ip link add name veth0 type veth peer name veth1 sudo ip link set dev veth0 up sudo ip link set dev veth1 up sudo sysctl net.ipv6.conf.veth0.disable_ipv6=1 sudo sysctl net.ipv6.conf.veth1.disable_ipv6=1
-
Launch the deployment and adjust MTUs on the veth pair
sudo docker-compose up -d sudo ip link set veth0 mtu 9500 sudo ip link set veth1 mtu 9500
-
Make sure you have all three containers running:
sudo docker ps
-
Start with using
otgen
to request Ixia-c to run traffic flows defined inotg.yml
. If successful, the result will come as OTG port metrics in JSON formatcat otg.yml | otgen run -k -a https://localhost:8443
-
You can now repeat this exercise, but transform output to a table
cat otg.yml | otgen run -k -a https://localhost:8443 | otgen transform -m port | otgen display -m table
-
The same, but with flow metrics
cat otg.yml | otgen run -k -a https://localhost:8443 -m flow | otgen transform -m flow | otgen display -m table
-
The same, but with byte instead of frame count (only receive stats are reported)
cat otg.yml | otgen run -k -a https://localhost:8443 -m flow | otgen transform -m flow -c bytes | otgen display -m table
-
Now report packet per second rate, as a line chart (end with
Crtl-c
)cat otg.yml | otgen run -k -a https://localhost:8443 -m flow | otgen transform -m flow -c pps | otgen display -m chart
If you have issues with setting up Python virtual environment, see an alternative way to run snappi
scripts from inside a Docker container below.
-
Setup virtualenv for Python
python3.9 -m venv venv source venv/bin/activate pip install -r snappi/requirements.txt
-
Run flows via snappi script, reporting port metrics
./snappi/otg-flows.py -m port
-
Run flows via snappi script, reporting port flow
./snappi/otg-flows.py -m flow
-
Build a Docker image with
snappi
librarysudo docker build -t snappi:local snappi
-
Run flows via snappi script in a container, reporting port metrics
sudo docker run --rm -t --net host -v $(pwd)/snappi:/snappi --name snappi snappi:local bash -c "python otg-flows.py -m port"
-
Run flows via snappi script in a container, reporting port flow
sudo docker run --rm -t --net host -v $(pwd)/snappi:/snappi --name snappi snappi:local bash -c "python otg-flows.py -m flow"
To destroy the lab, including veth pair, use:
docker-compose down
sudo ip link del name veth0 type veth peer name veth1