profile_code.rst revision 138686f3
1
2Traffic profile modules 
3=======================
4
5The TRex STLProfile traffic profile includes a number of streams. The profile is a ``program`` of related streams.
6Each stream can trigger another stream. Each stream can be named. For a full set of examples, see Manual_.
7
8..   _Manual: ../trex_stateless.html
9
10
11Example::
12
13    def create_stream (self):
14
15        # create a base packet and pad it to size
16        size = self.fsize - 4; # no FCS
17        base_pkt =  Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
18        base_pkt1 =  Ether()/IP(src="16.0.0.2",dst="48.0.0.1")/UDP(dport=12,sport=1025)
19        base_pkt2 =  Ether()/IP(src="16.0.0.3",dst="48.0.0.1")/UDP(dport=12,sport=1025)
20        pad = max(0, size - len(base_pkt)) * 'x'
21
22
23        return STLProfile( [ STLStream( isg = 1.0, # star in delay in usec 
24                                        packet = STLPktBuilder(pkt = base_pkt/pad),
25                                        mode = STLTXCont( pps = 10),
26                                        ), 
27
28                             STLStream( isg = 2.0,
29                                        packet  = STLPktBuilder(pkt = base_pkt1/pad),
30                                        mode    = STLTXCont( pps = 20),
31                                        ),
32
33                             STLStream(  isg = 3.0,
34                                         packet = STLPktBuilder(pkt = base_pkt2/pad),
35                                         mode    = STLTXCont( pps = 30)
36                                         
37                                        )
38                            ]).get_streams()
39
40
41STLProfile class
42----------------
43
44.. autoclass:: trex_stl_lib.trex_stl_streams.STLProfile
45    :members: 
46    :member-order: bysource
47
48STLStream 
49---------
50
51.. autoclass:: trex_stl_lib.trex_stl_streams.STLStream
52    :members: 
53    :member-order: bysource
54    
55
56STLStream modes
57----------------
58
59.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXMode
60    :members: 
61    :member-order: bysource
62
63.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXCont
64    :members: 
65    :member-order: bysource
66
67.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXSingleBurst
68    :members: 
69    :member-order: bysource
70
71.. autoclass:: trex_stl_lib.trex_stl_streams.STLTXMultiBurst
72    :members: 
73    :member-order: bysource
74
75.. autoclass:: trex_stl_lib.trex_stl_streams.STLFlowStats
76    :members: 
77    :member-order: bysource
78
79.. autoclass:: trex_stl_lib.trex_stl_streams.STLFlowLatencyStats
80    :members: 
81    :member-order: bysource
82    
83
84
85
86STLProfile snippet
87------------------
88
89
90.. code-block:: python
91
92    # STLProfile Example1
93
94
95        size = self.fsize - 4; # no FCS
96        base_pkt =  Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
97        base_pkt1 =  Ether()/IP(src="16.0.0.2",dst="48.0.0.1")/UDP(dport=12,sport=1025)
98        base_pkt2 =  Ether()/IP(src="16.0.0.3",dst="48.0.0.1")/UDP(dport=12,sport=1025)
99        pad = max(0, size - len(base_pkt)) * 'x'
100
101
102        return STLProfile( [ STLStream( isg = 10.0, # star in delay 
103                                        name    ='S0',
104                                        packet = STLPktBuilder(pkt = base_pkt/pad),
105                                        mode = STLTXSingleBurst( pps = 10, total_pkts = 10),
106                                        next = 'S1'), # point to next stream 
107
108                             STLStream( self_start = False, # stream is  disabled enable trow S0
109                                        name    ='S1',
110                                        packet  = STLPktBuilder(pkt = base_pkt1/pad),
111                                        mode    = STLTXSingleBurst( pps = 10, total_pkts = 20),
112                                        next    = 'S2' ),
113
114                             STLStream(  self_start = False, # stream is  disabled enable trow S0
115                                         name   ='S2',
116                                         packet = STLPktBuilder(pkt = base_pkt2/pad),
117                                         mode = STLTXSingleBurst( pps = 10, total_pkts = 30 )
118                                        )
119                            ]).get_streams()
120
121
122.. code-block:: python
123
124    # STLProfile Example2
125
126
127        class STLS1(object):
128        
129            def get_streams (self, direction = 0):
130                return [STLStream(packet = STLPktBuilder(pkt ="stl/yaml/udp_64B_no_crc.pcap"), 
131                                  mode = STLTXCont(pps=1000),
132                                  flow_stats = STLFlowStats(pg_id = 7)),
133        
134                        STLStream(packet = STLPktBuilder(pkt ="stl/yaml/udp_594B_no_crc.pcap"),
135                                  mode = STLTXCont(pps=5000),
136                                  flow_stats = STLFlowStats(pg_id = 12))
137                       ]
138        
139
140
141