tests: replace pycodestyle with black
[vpp.git] / src / plugins / nat / extras / nat_out2in_10Ms.py
1 from trex_stl_lib.api import *
2
3
4 class STLS1:
5     def create_stream(self):
6         base_pkt = Ether() / IP(src="2.2.0.1") / UDP(sport=12)
7
8         pad = Padding()
9         if len(base_pkt) < 64:
10             pad_len = 64 - len(base_pkt)
11             pad.load = "\x00" * pad_len
12
13         vm = STLVM()
14
15         vm.tuple_var(
16             name="tuple",
17             ip_min="173.16.1.3",
18             ip_max="173.17.135.162",
19             port_min=1025,
20             port_max=1124,
21             limit_flows=10000000,
22         )
23
24         vm.write(fv_name="tuple.ip", pkt_offset="IP.dst")
25         vm.fix_chksum()
26
27         vm.write(fv_name="tuple.port", pkt_offset="UDP.dport")
28
29         pkt = STLPktBuilder(pkt=base_pkt / pad, vm=vm)
30
31         return STLStream(packet=pkt, mode=STLTXCont())
32
33     def get_streams(self, direction=0, **kwargs):
34         return [self.create_stream()]
35
36
37 # dynamic load - used for trex console or simulator
38 def register():
39     return STLS1()