Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More trex examples #112

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/trex/dual_node_single_instance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# TRex

```
tinet upconf | sudo sh -xe
docker exec -it T2 ./t-rex-64 --astf --astf-server-only -f tcp_open.py --cfg server.yaml
docker exec -it T1 ./t-rex-64 --astf --astf-client-mask 0x1 -f tcp_open.py --cfg client.yaml
```
9 changes: 9 additions & 0 deletions examples/trex/dual_node_single_instance/client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- port_limit: 2
version: 2
interfaces: ["net0","dum0"]
platform:
master_thread_id: 3
latency_thread_id: 4
dual_if:
- socket: 0
threads: [5]
9 changes: 9 additions & 0 deletions examples/trex/dual_node_single_instance/server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- port_limit: 2
version: 2
interfaces: ["dum0","net0"]
platform:
master_thread_id: 0
latency_thread_id: 1
dual_if:
- socket: 0
threads: [2]
36 changes: 36 additions & 0 deletions examples/trex/dual_node_single_instance/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
nodes:
- name: T1
#image: nicolaka/netshoot
image: tinynetwork/trex:develop
docker_run_extra_args: --entrypoint bash
interfaces:
- { name: net0, type: direct, args: T2#net0 }
sysctls:
- sysctl: net.ipv4.ip_forward=1
- name: T2
image: tinynetwork/trex:develop
docker_run_extra_args: --entrypoint bash
interfaces:
- { name: net0, type: direct, args: T1#net0 }

node_configs:
- name: T1
cmds:
- cmd: ip link add dum0 type dummy
- cmd: ip link set dum0 up
- name: T2
cmds:
- cmd: ip link add dum0 type dummy
- cmd: ip link set dum0 up

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: ln -s /proc/$(docker inspect T2 -f {{.State.Pid}})/ns/net /var/run/netns/T2
- cmd: docker cp client.yaml T1:/opt/trex
- cmd: docker cp tcp_open.py T1:/opt/trex
- cmd: docker cp tcp_openclose.py T1:/opt/trex
- cmd: docker cp server.yaml T2:/opt/trex
- cmd: docker cp tcp_open.py T2:/opt/trex
- cmd: docker cp tcp_openclose.py T2:/opt/trex
7 changes: 7 additions & 0 deletions examples/trex/single_node_dual_instance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# TRex

```
tinet upconf | sudo sh -xe
docker exec -it T1 ./t-rex-64 --astf --astf-server-only -f tcp_open.py --cfg server.yaml
docker exec -it T1 ./t-rex-64 --astf --astf-client-mask 0x1 -f tcp_open.py --cfg client.yaml
```
12 changes: 12 additions & 0 deletions examples/trex/single_node_dual_instance/client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- port_limit: 2
version: 2
prefix: client
zmq_pub_port: 4600
zmq_rpc_port: 4601
interfaces: ["net0","dum0"]
platform:
master_thread_id: 3
latency_thread_id: 4
dual_if:
- socket: 0
threads: [5]
12 changes: 12 additions & 0 deletions examples/trex/single_node_dual_instance/server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- port_limit: 2
version: 2
prefix: server
zmq_pub_port: 4700
zmq_rpc_port: 4701
interfaces: ["dum1","net1"]
platform:
master_thread_id: 0
latency_thread_id: 1
dual_if:
- socket: 0
threads: [2]
38 changes: 38 additions & 0 deletions examples/trex/single_node_dual_instance/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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: T1
cmds:
- cmd: ip link add dum0 type dummy
- cmd: ip link add dum1 type dummy
- cmd: ip link set dum0 up
- cmd: ip link set dum1 up
- 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 client.yaml T1:/opt/trex
- cmd: docker cp server.yaml T1:/opt/trex
- cmd: docker cp tcp_open.py T1:/opt/trex
- cmd: docker cp tcp_openclose.py T1:/opt/trex
43 changes: 43 additions & 0 deletions examples/trex/single_node_dual_instance/tcp_open.py
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()
42 changes: 42 additions & 0 deletions examples/trex/single_node_dual_instance/tcp_openclose.py
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()
File renamed without changes.
43 changes: 43 additions & 0 deletions examples/trex/single_node_single_instance/tcp_open.py
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()
42 changes: 42 additions & 0 deletions examples/trex/single_node_single_instance/tcp_openclose.py
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()
Loading