udp_1pkt_1mac_step.py revision e3c6ee9f
1from trex_stl_lib.api import *
2
3
4# step is not 1.
5class STLS1(object):
6
7    def __init__ (self):
8        self.fsize  =64; # the size of the packet
9
10    def create_stream (self):
11
12        # Create base packet and pad it to size
13        size = self.fsize - 4; # HW will add 4 bytes ethernet FCS
14        base_pkt =  Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)
15        pad = max(0, size - len(base_pkt)) * 'x'
16
17        vm = STLScVmRaw( [ STLVmFlowVar(name="mac_src", min_value=1, max_value=35, size=1, op="dec",step=7),
18                           STLVmWrFlowVar(fv_name="mac_src", pkt_offset= 11)                           # write it to LSB of SRC offset it 11
19                          ]
20                       )
21
22        return STLStream(packet = STLPktBuilder(pkt = base_pkt/pad,vm = vm),
23                         mode = STLTXCont( pps=10 ))
24
25    def get_streams (self, direction = 0, **kwargs):
26        # create 1 stream
27        return [ self.create_stream() ]
28
29
30# dynamic load - used for trex console or simulator
31def register():
32    return STLS1()
33
34
35
36