Python API, client - server mode, trex_daemon

142 views
Skip to first unread message

Blazej Mirowski

unread,
Feb 17, 2023, 10:00:11 AM2/17/23
to trex...@googlegroups.com
Hi,

I have a small virtual network created in GNS3 - where I use TRex client - server architecture:
Client -- DUT -- Server
[TRex client, debian] (10.0.0.101) -- (br0) [DUT, debian] (br0) -- (10.0.0.1) [TRex server, debian]
- [TRex client, debian] mgmt IP addr: 192.168.1.1
- [TRex client, server] mgmt IP addr: 192.168.1.100

## Client cfg file:
 - port_limit      : 2
  version         : 2
  low_end: true
  low_end_core: 3
  interfaces      : ["00:04.0","dummy"]
  port_info       :
          - ip         : 10.0.0.101
            default_gw : 10.0.0.1

          - ip         : 10.0.0.101
            default_gw : 10.0.0.1

## Server cfg file:
 - port_limit      : 2
  version         : 2
  low_end: true
  low_end_core: 3
  interfaces      : ["dummy", "00:04.0"]
  port_info       :
          - ip         : 10.0.0.1
            default_gw : 10.0.0.101
          - ip         : 10.0.0.1
            default_gw : 10.0.0.101


DUT interfaces are bridge (br0) interfaces.

I would like to use Python API to generate traffic in ASTF mode. On both TRex machines (client and server) I start TRex daemon: "/opt/trex/v3.02# ./trex_daemon_server start". What is the correct way to connect to TRex machines and generate the traffic?
So far, I managed to run traffic this way (I am not sure if this is a proper way):
#######################################
...
c_port, s_port = 0, 1
dur = 5

# connect to TRex
trex_client = CTRexClient("192.168.1.1")
trex_server = CTRexClient("192.168.1.100")

# tell TRex to use astf mode, so ASTFClient could connect
trex_server.start_astf(lro_disable=True, limit_arp_request=1)
trex_client.start_astf(lro_disable=True, limit_arp_request=1)

# astf client connection
c = ASTFClient(server="192.168.1.1")
s = ASTFClient(server="192.168.1.100")

# establish connection
s.connect()
c.connect()

# Force acquire ports, stop the traffic, remove loaded traffic and clear stats
c.reset()
s.reset()

profile_path = os.path.join(os.getcwd(), "http_simple.py")
# Upload ASTF profile to server
c.load_profile(profile_path)
s.load_profile(profile_path)

# Starts a low rate packet capturing
c_capture = c.start_capture(tx_ports=c_port, rx_ports=c_port)
s_capture = s.start_capture(tx_ports=s_port, rx_ports=s_port)

# Start the traffic on loaded profile, server should be launched first?
s.start(duration=dur, nc=True)
c.start(duration=dur, nc=True)

# Block until traffic stops
c.wait_on_traffic(timeout=dur + 1)
#######################################

Could you please advise if this is the correct way to use Python API?

I also wonder if there is a possibility to start TRex daemon in ASTF mode, I could not find such option.

I would greatly appreciate your feedback :)
Have a good day.

BR,
Blazej


Reply all
Reply to author
Forward
0 new messages