Traffic Generator

TRex Stateless mode [ Traffic : Single Stream 10Mbps Two Direction / 2 Traffic Profile ]

2021年12月26日

Overview

Stateless mode で 2 Traffice Profile を用いて Two Direction (双方向)の Traffic を発生させる。

Network Diagram

t-rex-64 -i

root@svr-ub20:/opt/trex/v2.92# ./t-rex-64 -i
Starting Scapy server.... Scapy server is started
The ports are bound/configured.
Starting  TRex v2.92 please wait  ...
 set driver name net_e1000_em
 driver capability  : TCP_UDP_OFFLOAD
 set dpdk queues mode to ONE_QUE
 Number of ports found: 2
zmq publisher at: tcp://*:4500
 wait 1 sec .
port : 0
------------
link         :  link : Link Up - speed 1000 Mbps - full-duplex
promiscuous  : 0
port : 1
------------
link         :  link : Link Up - speed 1000 Mbps - full-duplex
promiscuous  : 0
 number of ports         : 2
 max cores for 2 ports   : 1  <--- Traffic Transmit and Recieve CPU
 tx queues per port      : 3
 -------------------------------
RX core uses TX queue number 65535 on all ports
 core, c-port, c-queue, s-port, s-queue, lat-queue
 ------------------------------------------
 1        0      0       1       0      0
 -------------------------------



-Per port stats table
      ports |               0 |               1
 -----------------------------------------------------------------------------------------
   opackets |               0 |               0
     obytes |               0 |               0
   ipackets |               0 |               0
     ibytes |               0 |               0
    ierrors |               0 |               0
    oerrors |               0 |               0
      Tx Bw |       0.00  bps |       0.00  bps

-Global stats enabled
 Cpu Utilization : 0.0  %
 Platform_factor : 1.0
 Total-Tx        :       0.00  bps
 Total-Rx        :       0.00  bps
 Total-PPS       :       0.00  pps
 Total-CPS       :       0.00  cps

 Expected-PPS    :       0.00  pps
 Expected-CPS    :       0.00  cps
 Expected-BPS    :       0.00  bps

 Active-flows    :        0  Clients :        0   Socket-util : 0.0000 %
 Open-flows      :        0  Servers :        0   Socket :        0 Socket/Clients :  -nan
 drop-rate       :       0.00  bps
 current time    : 7.2 sec
 test duration   : 0.0 sec

trex-console command

trex>start -p 0 -f rlab/HostAtoHostB.py -p 1 -f rlab/HostBtoHostA.py -m 10mbps -d 120

-p 0 -f rlab/HostAtoHostB.py // Port 0 から Traffic Profile HostAtoHostB.py の Traffic を送出

-p 1 -f rlab/HostBtoHostA.py // Port 1 から Traffic Profile HostBtoHost1.py の Traffic を送出

-m 10mbps // 10Mbps(L2) で Traffic を送出

-d 120 // 120秒間 Traffic を送出

Environment

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
$

Traffic Profile

HostAtoHostB.py

#
# Single Stream
# One Direction
#

from trex_stl_lib.api import *
import argparse

class STLS1(object):

    def __init__ (self):
        self.mode  =0
        self.fsize  =64

    def create_pkt_base (self):
        t=[
        Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
        ]
        return t[self.mode]

    def create_stream (self):
        # Create base packet and pad it to size
        size = self.fsize - 4; # HW will add 4 bytes ethernet FCS

        base_pkt = self.create_pkt_base ()

        pad = max(0, size - len(base_pkt)) * 'x'

        pkt = STLPktBuilder(pkt = base_pkt/pad,
                            vm = [])

        return STLStream(packet = pkt,
                         mode = STLTXCont())

    def get_streams (self, tunables, **kwargs):
        parser = argparse.ArgumentParser(description='Argparser for {}'.format(os.path.basename(__file__)), 
                                         formatter_class=argparse.ArgumentDefaultsHelpFormatter)

        args = parser.parse_args(tunables)
        # create 1 stream 
        return [ self.create_stream() ]

# dynamic load - used for trex console or simulator
def register():
    return STLS1()

HostBtoHostA.py

#
# Single Stream
# One Direction
#

from trex_stl_lib.api import *
import argparse

class STLS1(object):

    def __init__ (self):
        self.mode  =0
        self.fsize  =64

    def create_pkt_base (self):
        t=[
        Ether()/IP(src="48.0.0.1",dst="16.0.0.1")/UDP(dport=12,sport=1025)
        ]
        return t[self.mode]

    def create_stream (self):
        # Create base packet and pad it to size
        size = self.fsize - 4; # HW will add 4 bytes ethernet FCS

        base_pkt = self.create_pkt_base ()

        pad = max(0, size - len(base_pkt)) * 'x'

        pkt = STLPktBuilder(pkt = base_pkt/pad,
                            vm = [])

        return STLStream(packet = pkt,
                         mode = STLTXCont())

    def get_streams (self, tunables, **kwargs):
        parser = argparse.ArgumentParser(description='Argparser for {}'.format(os.path.basename(__file__)), 
                                         formatter_class=argparse.ArgumentDefaultsHelpFormatter)

        args = parser.parse_args(tunables)
        # create 1 stream 
        return [ self.create_stream() ]

# dynamic load - used for trex console or simulator
def register():
    return STLS1()

trex-console

trex>clear  <--- Counter Clear

Clearing stats :                                             [SUCCESS]

4.04 [ms]

trex>
trex>
trex>stats
Global Statistics

connection   : localhost, Port 4501                       total_tx_L2  : 0 bps                         
version      : STL @ v2.92                                total_tx_L1  : 0 bps                         
cpu_util.    : 0.0% @ 1 cores (1 per dual port)           total_rx     : 0 bps                         
rx_cpu_util. : 0.0% / 0 pps                               total_pps    : 0 pps                         
async_util.  : 0% / 9.62 bps                              drop_rate    : 0 bps                         
total_cps.   : 0 cps                                      queue_full   : 0 pkts                        

Port Statistics

   port    |         0         |         1         |       total
-----------+-------------------+-------------------+------------------
owner      |              root |              root |
link       |                UP |                UP |
state      |              IDLE |              IDLE |
speed      |            1 Gb/s |            1 Gb/s |
CPU util.  |              0.0% |              0.0% |
--         |                   |                   |
Tx bps L2  |             0 bps |             0 bps |             0 bps
Tx bps L1  |             0 bps |             0 bps |             0 bps
Tx pps     |             0 pps |             0 pps |             0 pps
Line Util. |               0 % |               0 % |
---        |                   |                   |
Rx bps     |             0 bps |             0 bps |             0 bps
Rx pps     |             0 pps |             0 pps |             0 pps
----       |                   |                   |
opackets   |                 0 |                 0 |                 0
ipackets   |                 0 |                 0 |                 0
obytes     |                 0 |                 0 |                 0
ibytes     |                 0 |                 0 |                 0
tx-pkts    |            0 pkts |            0 pkts |            0 pkts
rx-pkts    |            0 pkts |            0 pkts |            0 pkts
tx-bytes   |               0 B |               0 B |               0 B
rx-bytes   |               0 B |               0 B |               0 B
-----      |                   |                   |
oerrors    |                 0 |                 0 |                 0
ierrors    |                 0 |                 0 |                 0

trex>start -p 0 -f rlab/HostAtoHostB.py -p 1 -f rlab/HostBtoHostA.py -m 10mbps -d 120

Removing all streams from port(s) [0._, 1._]:                [SUCCESS]


Attaching 1 streams to port(s) [0._]:                        [SUCCESS]


Attaching 1 streams to port(s) [1._]:                        [SUCCESS]


Starting traffic on port(s) [0._, 1._]:                      [SUCCESS]

18.27 [ms]

trex>

2021-12-26 07:25:21 - [server][info]     - Profile 0._ job done

trex>

2021-12-26 07:25:21 - [server][info]     - Port 0 job done

trex>

2021-12-26 07:25:21 - [server][info]     - Profile 1._ job done

trex>

2021-12-26 07:25:21 - [server][info]     - Port 1 job done

trex>stats
Global Statistics

connection   : localhost, Port 4501                       total_tx_L2  : 2.07 Mbps                     
version      : STL @ v2.92                                total_tx_L1  : 2.71 Mbps                     
cpu_util.    : 0.42% @ 1 cores (1 per dual port)          total_rx     : 1.94 Mbps                     
rx_cpu_util. : 0.06% / 4.04 Kpps                          total_pps    : 4.04 Kpps                     
async_util.  : 0% / 10.56 bps                             drop_rate    : 0 bps                         
total_cps.   : 0 cps                                      queue_full   : 0 pkts                        

Port Statistics

   port    |         0         |         1         |       total
-----------+-------------------+-------------------+------------------
owner      |              root |              root |
link       |                UP |                UP |
state      |              IDLE |              IDLE |
speed      |            1 Gb/s |            1 Gb/s |
CPU util.  |              0.0% |              0.0% |
--         |                   |                   |
Tx bps L2  |         1.03 Mbps |         1.03 Mbps |         2.07 Mbps
Tx bps L1  |         1.36 Mbps |         1.36 Mbps |         2.71 Mbps
Tx pps     |         2.02 Kpps |         2.02 Kpps |         4.04 Kpps
Line Util. |            0.14 % |            0.14 % |
---        |                   |                   |
Rx bps     |       968.74 Kbps |       968.64 Kbps |         1.94 Mbps
Rx pps     |         2.02 Kpps |         2.02 Kpps |         4.04 Kpps
----       |                   |                   |
opackets   |           2343750 |           2343750 |           4687500
ipackets   |           2343750 |           2343750 |           4687500
obytes     |         150000000 |         150000000 |         300000000
ibytes     |         141233340 |         141241200 |         282474540  <---- different input bytes
tx-pkts    |        2.34 Mpkts |        2.34 Mpkts |        4.69 Mpkts
rx-pkts    |        2.34 Mpkts |        2.34 Mpkts |        4.69 Mpkts
tx-bytes   |            150 MB |            150 MB |            300 MB
rx-bytes   |         141.23 MB |         141.24 MB |         282.47 MB
-----      |                   |                   |
oerrors    |                 0 |                 0 |                 0
ierrors    |                 0 |                 0 |                 0

trex>

Host CPU usage

top - 07:24:21 up  1:10,  4 users,  load average: 1.42, 1.03, 0.60
Tasks: 166 total,   1 running, 165 sleeping,   0 stopped,   0 zombie
%Cpu0  :  1.0 us,  0.0 sy,  0.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :100.0 us,  0.0 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  :100.0 us,  0.0 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu3  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu4  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu5  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  16013.3 total,  10850.0 free,   4459.1 used,    704.1 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.  11272.0 avail Mem

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
   2391 root      20   0   16.6g  19716  10216 S 200.7   0.1  12:48.32 _t-rex-64
      1 root      20   0  167468  11384   8304 S   0.0   0.1   0:01.32 systemd
      2 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kthreadd
      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp
      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp
      6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0H-kblockd
      7 root      20   0       0      0      0 I   0.0   0.0   0:01.42 kworker/0:1-cgroup_destroy
      9 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_percpu_wq
     10 root      20   0       0      0      0 S   0.0   0.0   0:00.01 ksoftirqd/0
     11 root      20   0       0      0      0 I   0.0   0.0   0:01.02 rcu_sched
     12 root      rt   0       0      0      0 S   0.0   0.0   0:00.03 migration/0
     13 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/0
     14 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/0
     15 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/1
     16 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/1
     17 root      rt   0       0      0      0 S   0.0   0.0   0:00.37 migration/1
     18 root      20   0       0      0      0 S   0.0   0.0   0:00.00 ksoftirqd/1
     20 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/1:0H-kblockd
     21 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/2
     22 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/2
     23 root      rt   0       0      0      0 S   0.0   0.0   0:00.37 migration/2
     24 root      20   0       0      0      0 S   0.0   0.0   0:00.00 ksoftirqd/2
     26 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/2:0H
     27 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/3
     28 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/3
     29 root      rt   0       0      0      0 S   0.0   0.0   0:00.37 migration/3
     30 root      20   0       0      0      0 S   0.0   0.0   0:00.02 ksoftirqd/3
hyamazak@svr-ub20:~$

Result

Port 1 and Port 2 Input bytes are different. Because CPU 2 usage is 100%.