APPSIM

Example:

layer to simulate L7 application similar to the ASTF instruction set. This is a simple example for a UDP program. client send one pkt (index buf_list[0]) and expect one packet. The server expect a packet (request) and send a one response packet (index buf_list[1]).

The port is 80. tunables are use here. client will use tos==7

program ={
    "buf_list": [
        "R0VUIC8zMzg0IEhUVFAvMS4xD",
        "SFRUUC8xLjEgMjAwIE9LDQpTZ"
    ],
    "tunable_list": [ {"tos":7},{"tos":2,"mss":7}
    ],
    "program_list": [
        {
            "commands": [
                {"msec": 10,
                "name": "keepalive"
                },
                {
                    "buf_index": 0,
                    "name": "tx_msg"
                },
                {
                    "min_pkts": 1,
                    "name": "rx_msg"
                }
            ]
        },
        {
            "commands": [
                {
                "msec": 10,
                "name": "keepalive"
                },
                {
                    "min_pkts": 1,
                    "name": "rx_msg"
                },
                {
                    "buf_index": 1,
                    "name": "tx_msg"
                }
            ]
        }
    ],
    "templates": [{
                    "client_template" :{
                            "program_index": 0,
                            "tunable_index":0,
                            "port": 80,
                            "cps": 1
                    },
                    "server_template" : {"assoc": [{"port": 80}],
                                        "program_index": 1}
                                        }
                ],
    }

client_ini_json ={ "data" : { "s-1" :
    { "cps": 1.0,
      "t": "c",
     "tid": 0,
     "ipv6": false,
     "stream": false,
     "dst" :"239.255.255.250:1900"}} }

program

Name

Type

Description

buf_list

[]string

The string are base64 of []byte

program_list

object

include one field {“commands”: [{},{}] } with an array of commands objects

templates

[]objects

array of objects each include a client and server object

tunable_list

[] objects

each object include name:value tuples

[ {“tos”:7},{“tos”:2,”mss”:7}

commands objects

Name

args

Description

tx

buf_index:int

send buffer (TCP) buffer index to buf_list

rx

min_bytes:int, clear:bool

waits for min_bytes

keepalive

msec:int,

works in case of UDP msec is the keepalive time to stop the flow in case of inactivity

rx_msg

min_pkts:int,

number of packets to wait in the rx side in case UDP

tx_msg

buf_index:int,

same as tx for UDP

connect

not in use

reset

terminate the flow in RST

nc

wait for other side to close the flow

close_msg

force close in UDP

delay

usec:int

delay in usec

delay_rnd

min_usec:int max_usec:int

delay rand(min,max)

set_var

id:int val:int

set value into a variable (64bit)

jmp_nz

id:int offset:int

reduce 1 from a var in case it is non zero jump to offset in cmds array

tunable key:val

Name

type

Description

tos

ip/int

set the tos

ttl

ip/int

set the ttl

mss

tcp/int

set the tcp mss (bytes)

initwnd

tcp/int

init window value in MSS units.

no_delay

tcp/int

1 - disable nagle, 2 - force PUSH flag

no_delay_counter

tcp/int

number of recv bytes to wait until ack is sent. notice ack can be triggered by tcp timer, in order to ensure fixed number of sent packets until ack you should increase the tcp. initwnd tunable.

delay_ack_msec

tcp/int

delay ack timeout in msec.

rxbufsize

tcp/int

socket rx buffer size in bytes.

txbufsize

tcp/int

socket tx buffer size in bytes.

client template object

Name

type

Description

program_index

int

index to the program list objects

tunable_index

int

index to the program list objects

port

int

destination port

cps

int

not used, taken from the client json

server template object

Name

type

Description

program_index

int

index to the program list objects

tunable_index

int

index to the program list objects

assoc

[]

[{“port”: 80}] list of ports

"templates": [{
"client_template" :{
        "program_index": 0,
        "tunable_index":0,
        "port": 80,
        "cps": 1
},
"server_template" : {"assoc": [{"port": 80}],
                    "program_index": 1}
                    }
],

per client init json

This json can define multiple streams that point to a tid (template id) inside the namespace global program each with different poperies.

uses {data: {“stream-1” :{} ,”stream-2” :{}} to define multiple streams

Name

type

Description

cps

float

new connections in one second

t

string

“c” for client and “s” for server

tid

int

index to a template id inside the namespace program

ipv6

bool

use ipv6 transport

stream

bool

true for TCP and false for UDP

dst

string

the ip:port to use in case of client side

client_ini_json ={ "data" : { "s-1" :
           { "cps": 1.0,
             "t": "c",
            "tid": 0,
            "ipv6": false,
            "stream": false,
            "dst" :"239.255.255.250:1900"}} }
class trex.emu.emu_plugins.emu_plugin_appsim.APPSIMPlugin(emu_client)[source]

Defines Appsim

INIT_JSON_NS = {'appsim': {}}
Parameters

Empty.

INIT_JSON_CLIENT = {'appsim': {}}

see SDK for more info

get_counters(c_key, cnt_filter=None, zero=True, verbose=True)[source]

Get the APPSIM counters of a client.

Parameters
c_key: trex.emu.trex_emu_profile.EMUClientKey

EMUClientKey

cnt_filter: list

List of counters types as strings. i.e: [‘INFO’, ‘ERROR’, ‘WARNING’]. Default is None, means no filter. If verbosity is off, this filter can’t be used.

zero: bool

Get zero values, default is True.

verbose: bool

Show verbose version of each counter, default is True.

Returns

Dictionary of all wanted counters. When verbose is True, each plugin contains a list of counter dictionaries.

{'pluginName': [{'help': 'Explanation 1',
                'info': 'INFO',
                'name': 'counterOne',
                'unit': 'pkts',
                'value': 8,
                'zero': False},
                {'help': 'Explanation 2',
                'info': 'ERROR',
                'name': 'counterTwo',
                'unit': 'pkts',
                'value': 6,
                'zero': False}]}

When verbose is False, each plugins returns a dictionary of counterName, value pairs.

{'pluginName': {'counterOne': 8, 'counterTwo': 6}}

Raises

TRexError

tear_down_ns(ns_key)

This function will be called before removing this plugin from namespace.

parameters
ns_key: EMUNamespaceKey

see trex.emu.trex_emu_profile.EMUNamespaceKey

clear_counters(c_key)[source]

Clear the APPSIM counters of a client.

Parameters
c_key: trex.emu.trex_emu_profile.EMUClientKey

EMUClientKey

Returns

Boolean indicating if clearing was successful.
  • True: Clearing was successful.

  • False: Clearing was not successful.

Raises

TRexError

appsim_show_counters_line(line)[source]

Show appsim counters (per client).

trex.emu.emu_plugins.emu_plugin_appsim.wraps(func)

Replaces functools.wraps in order to undo wrapping.

Can be used to preserve the decorated function’s signature in the documentation generated by Sphinx.