Skip to content

Ixia-c traffic engine back-to-back setup with Docker Compose

Overview

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.

Diagram

Prerequisites

  • Linux host or VM with sudo permissions and Docker support
  • Docker
  • Python3.9 for snappi part

Install components

  1. 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
    
  2. Install otgen

    bash -c "$(curl -sL https://get.otgcdn.net/otgen)" -- -v 0.6.2
    
  3. 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
    
  4. Clone this repository

    git clone --recursive https://github.com/open-traffic-generator/otg-examples.git
    cd otg-examples/docker-compose/b2b
    

Deploy Ixia-c lab

  1. 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
    
  2. 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
    
  3. Make sure you have all three containers running:

    sudo docker ps
    

Run OTG traffic flows with otgen tool

  1. Start with using otgen to request Ixia-c to run traffic flows defined in otg.yml. If successful, the result will come as OTG port metrics in JSON format

    cat otg.yml | otgen run -k -a https://localhost:8443
    
  2. 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
    
  3. 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
    
  4. 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
    
  5. 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
    

Run OTG traffic flows with Python snappi library

If you have issues with setting up Python virtual environment, see an alternative way to run snappi scripts from inside a Docker container below.

  1. Setup virtualenv for Python

    python3.9 -m venv venv
    source venv/bin/activate
    pip install -r snappi/requirements.txt
    
  2. Run flows via snappi script, reporting port metrics

    ./snappi/otg-flows.py -m port
    
  3. Run flows via snappi script, reporting port flow

    ./snappi/otg-flows.py -m flow
    

Running snappi scripts from a Docker container

  1. Build a Docker image with snappi library

    sudo docker build -t snappi:local snappi
    
  2. 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"
    
  3. 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"
    

Destroy the lab

To destroy the lab, including veth pair, use:

docker-compose down
sudo ip link del name veth0 type veth peer name veth1