Lbr-trex-client package contains TRex traffic generator client API as Python package.
Project description
Python 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 replacement method
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 from scapy.all import *
import.
It can then lead to strange errors.
Differences compared to official TRex API
Package lbr-trex-client
has few changes compared to official client package:
stf/examples
directory is removed (examples are not required for API).interactive/profiles
directory is removed (contains more examples and tests).interactive/trex/examples
directory is removed (more examples).interactive/trex/.vscode/tags
file is removed (unimportant).interactive/trex/wireless
unit tests, examples and Sphinx docs removed.__pycache__
and*.pyc
files removed.sys.path
andos.environ
are modified on module import for hassle-free usage.
Known issues
On import you can get warning messages from Scapy:
...lbr_trex_client/external_libs/scapy-2.4.3/scapy/layers/ipsec.py:469: CryptographyDeprecationWarning: Blowfish has been deprecated
cipher=algorithms.Blowfish,
...lbr_trex_client/external_libs/scapy-2.4.3/scapy/layers/ipsec.py:483: CryptographyDeprecationWarning: CAST5 has been deprecated
cipher=algorithms.CAST5,
This is related to the fact that TRex uses older Scapy version.
Links to official TRex documentation
Here are links to API reference of main components:
- Stateless[trex.stl.api] - API for stateless mode.
- Advanced Stateful[trex.astf.api] - API for advanced stateful mode.
- trex_client[CTRexClient] - API for communication with TRex daemon.
General TRex documentation can be found here.
Custom TRex API
You can also use lbr-testsuite
package for custom TRex API that is built on top of this package.
For more information see testsuite.
Hosting and contribution
Package lbr-trex-client
is hosted publicly on Python Package Index (PyPI)
and internally in GitLab's Package Registry.
This project uses GitLab CI pipeline which is triggered with every new commit. Pipeline creates .whl package from contents inside lbr_trex_client folder.
If pipeline triggers on master
branch, then package is also uploaded into
GitLab Package Registry. Version of package is defined by git tags.
Additionally, package is also uploaded on PyPI if it has a tag.
Repository Maintainer
- Dominik Tran, tran@cesnet.cz
License
Package is published under Apache License Version 2.0, which is inherited from the TRex traffic generator source. The TRex client API contains also modified version of Scapy library, which is published under GPLv2 license.
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 Distributions
Built Distribution
File details
Details for the file lbr_trex_client-3.4.0-py3-none-any.whl
.
File metadata
- Download URL: lbr_trex_client-3.4.0-py3-none-any.whl
- Upload date:
- Size: 5.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9c01c51a2f7b3ebe5eeb78e863285524d8f19e66c5361a6f8b720f8c8aac188 |
|
MD5 | f2fac28c057775887952b14180b0ed14 |
|
BLAKE2b-256 | 14d8b2792ccdfd97044c68af9cf38afc1a3e6a6ec168be30edafdb67635bc738 |