summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/doc_stl/api/profile_code.rst
blob: 335105f1e238f4eab2151d136378dd45615f343f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
Traffic profile modules 
=======================

The TRex STLProfile traffic profile includes a number of streams. The profile is a ``program`` of related streams.
Each stream can trigger another stream. Each stream can be named. For a full set of examples, see Manual_.

..   _Manual: ../trex_stateless.html


Example::

    def create_stream (self):

        # create a base packet and pad it to size
        size = self.fsize - 4; # no FCS
        base_pkt =  Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
        base_pkt1 =  Ether()/IP(src="16.0.0.2",dst="48.0.0.1")/UDP(dport=12,sport=1025)
        base_pkt2 =  Ether()/IP(src="16.0.0.3",dst="48.0.0.1")/UDP(dport=12,sport=1025)
        pad = max(0, size - len(base_pkt)) * 'x'


        return STLProfile( [ STLStream( isg = 1.0, # star in delay in usec 
                                        packet = STLPktBuilder(pkt = base_pkt/pad),
                                        mode = STLTXCont( pps = 10),
                                        ), 

                             STLStream( isg = 2.0,
                                        packet  = STLPktBuilder(pkt = base_pkt1/pad),
                                        mode    = STLTXCont( pps = 20),
                                        ),

                             STLStream(  isg = 3.0,
                                         packet = STLPktBuilder(pkt = base_pkt2/pad),
                                         mode    = STLTXCont( pps = 30)
                                         
                                        )
                            ]).get_streams()


STLProfile class
----------------

.. autoclass:: trex_stl_lib.trex_stl_streams.STLProfile
    :members: 
    :member-order: bysource

STLStream 
---------

.. autoclass:: trex_stl_lib.trex_stl_streams.STLStream
    :members: 
    :member-order: bysource
    

STLStream modes
----------------

.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXMode
    :members: 
    :member-order: bysource

.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXCont
    :members: 
    :member-order: bysource

.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXSingleBurst
    :members: 
    :member-order: bysource

.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXMultiBurst
    :members: 
    :member-order: bysource

.. autoclass:: trex_stl_lib.trex_stl_streams.STLFlowStats
    :members: 
    :member-order: bysource

.. autoclass:: trex_stl_lib.trex_stl_streams.STLFlowLatencyStats
    :members: 
    :member-order: bysource
    



STLProfile snippet
------------------


.. code-block:: python
    :caption: STLProfile Example1


        size = self.fsize - 4; # no FCS
        base_pkt =  Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
        base_pkt1 =  Ether()/IP(src="16.0.0.2",dst="48.0.0.1")/UDP(dport=12,sport=1025)
        base_pkt2 =  Ether()/IP(src="16.0.0.3",dst="48.0.0.1")/UDP(dport=12,sport=1025)
        pad = max(0, size - len(base_pkt)) * 'x'


        return STLProfile( [ STLStream( isg = 10.0, # star in delay 
                                        name    ='S0',
                                        packet = STLPktBuilder(pkt = base_pkt/pad),
                                        mode = STLTXSingleBurst( pps = 10, total_pkts = 10),
                                        next = 'S1'), # point to next stream 

                             STLStream( self_start = False, # stream is  disabled enable trow S0
                                        name    ='S1',
                                        packet  = STLPktBuilder(pkt = base_pkt1/pad),
                                        mode    = STLTXSingleBurst( pps = 10, total_pkts = 20),
                                        next    = 'S2' ),

                             STLStream(  self_start = False, # stream is  disabled enable trow S0
                                         name   ='S2',
                                         packet = STLPktBuilder(pkt = base_pkt2/pad),
                                         mode = STLTXSingleBurst( pps = 10, total_pkts = 30 )
                                        )
                            ]).get_streams()


.. code-block:: python
    :caption: STLProfile Example2


        class STLS1(object):
        
            def get_streams (self, direction = 0):
                return [STLStream(packet = STLPktBuilder(pkt ="stl/yaml/udp_64B_no_crc.pcap"), 
                                  mode = STLTXCont(pps=1000),
                                  flow_stats = STLFlowStats(pg_id = 7)),
        
                        STLStream(packet = STLPktBuilder(pkt ="stl/yaml/udp_594B_no_crc.pcap"),
                                  mode = STLTXCont(pps=5000),
                                  flow_stats = STLFlowStats(pg_id = 12))
                       ]