-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from tinynetwork/example-trex
Example for TRex
- Loading branch information
Showing
7 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM quay.io/centos/centos:stream8 | ||
ARG TREX_VERSION=3.04 | ||
ENV TREX_VERSION ${TREX_VERSION} | ||
|
||
RUN dnf install -y --nodocs \ | ||
git wget procps python3 vim python3-pip pciutils gettext \ | ||
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \ | ||
&& dnf clean all \ | ||
&& dnf install -y --nodocs \ | ||
hostname iproute net-tools ethtool nmap iputils perf numactl \ | ||
sysstat htop rdma-core-devel libibverbs libibverbs-devel net-tools \ | ||
&& dnf clean all | ||
|
||
WORKDIR /opt/ | ||
RUN wget --no-check-certificate https://trex-tgn.cisco.com/trex/release/v${TREX_VERSION}.tar.gz && \ | ||
tar -xzf v${TREX_VERSION}.tar.gz && \ | ||
mv v${TREX_VERSION} trex && \ | ||
rm v${TREX_VERSION}.tar.gz | ||
WORKDIR /opt/trex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
IMG=tinynetwork/trex:develop | ||
build: | ||
docker build -t $(IMG) . | ||
push: | ||
docker push $(IMG) | ||
all: build push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# TRex | ||
|
||
``` | ||
tinet upconf | sudo sh -xe | ||
docker exec -it T1 | ||
./t-rex-64 -i --astf --cfg ./cfg.yaml | ||
./trex-console | ||
trex>start -f http_eflow.py -t cps=10 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- port_limit: 2 | ||
version: 2 | ||
interfaces: ["net0", "net1"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
nodes: | ||
- name: DUT1 | ||
image: nicolaka/netshoot | ||
docker_run_extra_args: --entrypoint bash | ||
interfaces: | ||
- { name: net0, type: direct, args: T1#net0 } | ||
- { name: net1, type: direct, args: T1#net1 } | ||
sysctls: | ||
- sysctl: net.ipv4.ip_forward=1 | ||
- name: T1 | ||
image: tinynetwork/trex:develop | ||
docker_run_extra_args: --entrypoint bash | ||
interfaces: | ||
- { name: net0, type: direct, args: DUT1#net0 } | ||
- { name: net1, type: direct, args: DUT1#net1 } | ||
|
||
node_configs: | ||
- name: DUT1 | ||
cmds: | ||
- cmd: ip link add br0 type bridge | ||
- cmd: ip link set br0 up | ||
- cmd: ip link set net0 master br0 | ||
- cmd: ip link set net1 master br0 | ||
|
||
postinit: | ||
cmds: | ||
- cmd: mkdir -p /var/run/netns | ||
- cmd: ln -s /proc/$(docker inspect T1 -f {{.State.Pid}})/ns/net /var/run/netns/T1 | ||
- cmd: docker cp cfg.yaml T1:/opt/trex | ||
- cmd: docker cp tcp_open.py T1:/opt/trex | ||
- cmd: docker cp tcp_openclose.py T1:/opt/trex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from trex.astf.api import * | ||
import argparse | ||
|
||
|
||
class Prof1(): | ||
def __init__(self): | ||
pass # tunables | ||
|
||
def create_profile(self, cps): | ||
prog_c = ASTFProgram() | ||
prog_c.connect() | ||
prog_c.reset() | ||
prog_s = ASTFProgram() | ||
prog_s.wait_for_peer_close() | ||
|
||
# ip generator | ||
ip_gen_c = ASTFIPGenDist(ip_range=["20.0.0.0", "20.0.255.255"], distribution="seq") | ||
ip_gen_s = ASTFIPGenDist(ip_range=["30.0.0.0", "30.0.255.255"], distribution="seq") | ||
ip_gen = ASTFIPGen(glob=ASTFIPGenGlobal(ip_offset="1.0.0.0"), | ||
dist_client=ip_gen_c, | ||
dist_server=ip_gen_s) | ||
|
||
# template | ||
temp_c = ASTFTCPClientTemplate(program=prog_c, ip_gen=ip_gen, cps=cps,limit=cps) | ||
temp_s = ASTFTCPServerTemplate(program=prog_s) | ||
template = ASTFTemplate(client_template=temp_c, server_template=temp_s) | ||
|
||
# profile | ||
profile = ASTFProfile(default_ip_gen=ip_gen, | ||
templates=template) | ||
return profile | ||
|
||
def get_profile(self, tunables, **kwargs): | ||
parser = argparse.ArgumentParser( | ||
description='Argparser for {}'.format(os.path.basename(__file__)), | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
parser.add_argument('--cps', type=int, default=1) | ||
args = parser.parse_args(tunables) | ||
return self.create_profile(args.cps) | ||
|
||
|
||
def register(): | ||
return Prof1() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from trex.astf.api import * | ||
import argparse | ||
|
||
|
||
class Prof1(): | ||
def __init__(self): | ||
pass # tunables | ||
|
||
def create_profile(self, cps): | ||
prog_c = ASTFProgram() | ||
prog_c.connect() | ||
prog_s = ASTFProgram() | ||
prog_s.wait_for_peer_close() | ||
|
||
# ip generator | ||
ip_gen_c = ASTFIPGenDist(ip_range=["20.0.0.0", "20.0.255.255"], distribution="seq") | ||
ip_gen_s = ASTFIPGenDist(ip_range=["30.0.0.0", "30.0.255.255"], distribution="seq") | ||
ip_gen = ASTFIPGen(glob=ASTFIPGenGlobal(ip_offset="1.0.0.0"), | ||
dist_client=ip_gen_c, | ||
dist_server=ip_gen_s) | ||
|
||
# template | ||
temp_c = ASTFTCPClientTemplate(program=prog_c, ip_gen=ip_gen, cps=cps,limit=cps) | ||
temp_s = ASTFTCPServerTemplate(program=prog_s) | ||
template = ASTFTemplate(client_template=temp_c, server_template=temp_s) | ||
|
||
# profile | ||
profile = ASTFProfile(default_ip_gen=ip_gen, | ||
templates=template) | ||
return profile | ||
|
||
def get_profile(self, tunables, **kwargs): | ||
parser = argparse.ArgumentParser( | ||
description='Argparser for {}'.format(os.path.basename(__file__)), | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
parser.add_argument('--cps', type=int, default=1) | ||
args = parser.parse_args(tunables) | ||
return self.create_profile(args.cps) | ||
|
||
|
||
def register(): | ||
return Prof1() |