Lbr-trex-client package contains TRex traffic generator client API as Python package.
Low maintenance activity. Last release over 2 years ago, commits in 0 of the last 26 weeks. Weaker on commit activity and recent releases.
pip install lbr-trex-clientPython package lbr-trex-client
Cisco TRex traffic generator is distributed as a single .tar.gz archive and contains all external libraries/packages for running TRex. This means trying to use or import TRex Client Python API in your code is relatively complicated, especially if your code runs on different machine than TRex itself.
The purpose of this package is to provide client API in form of Python package
which can be easily installed via pip. This API is part of
TRex as another tar.gz archive.
It was repackaged as standard Python module.
Versions of this package follow TRex version scheme.
Although module was tested only on Python 3.8, it is likely that newer Python versions will work as well.
Official source code can be also found on TRex GitHub.
Installation
You can use following command for installation:
python3.8 -m pip install lbr-trex-client
Usage
Importing lbr_trex_client automatically sets paths and environment variables
for hassle-free usage of TRex Client API. Imports used in, for example,
TRex Cookbook
will then work as well.
import lbr_trex_client
from trex.stl.api import *
from trex.astf.api import *
from trex_stl_lib.api import *
from trex_client import CTRexClient
from trex_exceptions import TRexInUseError
from scapy.layers.dns import *
...
Alternatively you can use
from lbr_trex_client.interactive.trex.stl.api import *
from lbr_trex_client.interactive.trex.astf.api import *
...
You can notice that imports above also contain Scapy. As mentioned, TRex archive contains all dependencies, including modified Scapy. Explore external_libs to see all external packages.
Note that if your code already imported given package, then TRex will replace it with it's own version of package. The however is not perfect and you can still be left with some local and some TRex version of modules. This is mostly evident with Scapy, especially with import. It can then lead to strange errors.