From 7f5b3c20e0d31e83c745c4e9bde768b325ed4b6e Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Sun, 11 Nov 2018 11:41:01 +0200 Subject: [PATCH] STL: add IPv6 IMIX profile Signed-off-by: Yaroslav Brustinov --- scripts/stl/imix_ipv6.py | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 scripts/stl/imix_ipv6.py diff --git a/scripts/stl/imix_ipv6.py b/scripts/stl/imix_ipv6.py new file mode 100755 index 0000000000..0b052aca22 --- /dev/null +++ b/scripts/stl/imix_ipv6.py @@ -0,0 +1,68 @@ +from trex_stl_lib.api import * + +# IMIX profile - involves 3 streams of UDP packets +# 1 - 60 bytes +# 2 - 590 bytes +# 3 - 1514 bytes +class STLImix(object): + + def __init__ (self): + # default IP range + self.ip_range = {'src': {'start': "16.0.0.1", 'end': "16.0.0.254"}, + 'dst': {'start': "48.0.0.1", 'end': "48.0.0.254"}} + + # default IMIX properties + self.imix_table = [ {'size': 60, 'pps': 28, 'isg':0 }, + {'size': 590, 'pps': 16, 'isg':0.1 }, + {'size': 1514, 'pps': 4, 'isg':0.2 } ] + + + def create_stream (self, size, pps, isg, vm ): + # Create base packet and pad it to size + base_pkt = Ether() + base_pkt /= IPv6(src="ff80::1", dst="ff80::2") + base_pkt /= UDP(sport=12345, dport=12345) + pad = max(0, size - len(base_pkt)) * 'x' + + pkt = STLPktBuilder(pkt = base_pkt/pad, + vm = vm) + + return STLStream(isg = isg, + packet = pkt, + mode = STLTXCont(pps = pps)) + + + def get_streams (self, direction = 0, **kwargs): + + if direction == 0: + src = self.ip_range['src'] + dst = self.ip_range['dst'] + else: + src = self.ip_range['dst'] + dst = self.ip_range['src'] + + # construct the base packet for the profile + vm = STLVM() + + # define two vars (src and dst) + vm.var(name="src",min_value=src['start'],max_value=src['end'],size=4,op="inc") + vm.var(name="dst",min_value=dst['start'],max_value=dst['end'],size=4,op="inc") + + # write them + vm.write(fv_name="src",pkt_offset= "IPv6.src", offset_fixup=12) + vm.write(fv_name="dst",pkt_offset= "IPv6.dst", offset_fixup=12) + + # fix UDP checksum in HW + vm.fix_chksum_hw(l3_offset='IPv6', l4_offset = 'UDP', l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP) + + # create imix streams + return [self.create_stream(x['size'], x['pps'],x['isg'] , vm) for x in self.imix_table] + + + +# dynamic load - used for trex console or simulator +def register(): + return STLImix() + + +