diff --git a/examples/trex/dual_node_single_instance/README.md b/examples/trex/dual_node_single_instance/README.md new file mode 100644 index 0000000..811d026 --- /dev/null +++ b/examples/trex/dual_node_single_instance/README.md @@ -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 +``` diff --git a/examples/trex/dual_node_single_instance/client.yaml b/examples/trex/dual_node_single_instance/client.yaml new file mode 100644 index 0000000..41c8ac6 --- /dev/null +++ b/examples/trex/dual_node_single_instance/client.yaml @@ -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] diff --git a/examples/trex/dual_node_single_instance/server.yaml b/examples/trex/dual_node_single_instance/server.yaml new file mode 100644 index 0000000..d60bc8d --- /dev/null +++ b/examples/trex/dual_node_single_instance/server.yaml @@ -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] diff --git a/examples/trex/dual_node_single_instance/spec.yaml b/examples/trex/dual_node_single_instance/spec.yaml new file mode 100644 index 0000000..5e58b2b --- /dev/null +++ b/examples/trex/dual_node_single_instance/spec.yaml @@ -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 diff --git a/examples/trex/tcp_open.py b/examples/trex/dual_node_single_instance/tcp_open.py similarity index 100% rename from examples/trex/tcp_open.py rename to examples/trex/dual_node_single_instance/tcp_open.py diff --git a/examples/trex/tcp_openclose.py b/examples/trex/dual_node_single_instance/tcp_openclose.py similarity index 100% rename from examples/trex/tcp_openclose.py rename to examples/trex/dual_node_single_instance/tcp_openclose.py diff --git a/examples/trex/single_node_dual_instance/README.md b/examples/trex/single_node_dual_instance/README.md new file mode 100644 index 0000000..7e432fe --- /dev/null +++ b/examples/trex/single_node_dual_instance/README.md @@ -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 +``` diff --git a/examples/trex/single_node_dual_instance/client.yaml b/examples/trex/single_node_dual_instance/client.yaml new file mode 100644 index 0000000..0b1241a --- /dev/null +++ b/examples/trex/single_node_dual_instance/client.yaml @@ -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] diff --git a/examples/trex/single_node_dual_instance/server.yaml b/examples/trex/single_node_dual_instance/server.yaml new file mode 100644 index 0000000..5e82651 --- /dev/null +++ b/examples/trex/single_node_dual_instance/server.yaml @@ -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] diff --git a/examples/trex/single_node_dual_instance/spec.yaml b/examples/trex/single_node_dual_instance/spec.yaml new file mode 100644 index 0000000..03cf145 --- /dev/null +++ b/examples/trex/single_node_dual_instance/spec.yaml @@ -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 diff --git a/examples/trex/single_node_dual_instance/tcp_open.py b/examples/trex/single_node_dual_instance/tcp_open.py new file mode 100644 index 0000000..1f784c1 --- /dev/null +++ b/examples/trex/single_node_dual_instance/tcp_open.py @@ -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() diff --git a/examples/trex/single_node_dual_instance/tcp_openclose.py b/examples/trex/single_node_dual_instance/tcp_openclose.py new file mode 100644 index 0000000..51cb843 --- /dev/null +++ b/examples/trex/single_node_dual_instance/tcp_openclose.py @@ -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() diff --git a/examples/trex/README.md b/examples/trex/single_node_single_instance/README.md similarity index 100% rename from examples/trex/README.md rename to examples/trex/single_node_single_instance/README.md diff --git a/examples/trex/cfg.yaml b/examples/trex/single_node_single_instance/cfg.yaml similarity index 100% rename from examples/trex/cfg.yaml rename to examples/trex/single_node_single_instance/cfg.yaml diff --git a/examples/trex/spec.yaml b/examples/trex/single_node_single_instance/spec.yaml similarity index 100% rename from examples/trex/spec.yaml rename to examples/trex/single_node_single_instance/spec.yaml diff --git a/examples/trex/single_node_single_instance/tcp_open.py b/examples/trex/single_node_single_instance/tcp_open.py new file mode 100644 index 0000000..1f784c1 --- /dev/null +++ b/examples/trex/single_node_single_instance/tcp_open.py @@ -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() diff --git a/examples/trex/single_node_single_instance/tcp_openclose.py b/examples/trex/single_node_single_instance/tcp_openclose.py new file mode 100644 index 0000000..51cb843 --- /dev/null +++ b/examples/trex/single_node_single_instance/tcp_openclose.py @@ -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()