def partial(min_value, max_value): stl_vm_flow_var = STLVmFlowVarRepeatableRandom(name="port_{}".format(field), min_value=min_value, max_value=max_value, size=2, limit=int(count), seed=0x1235) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='port_{}'.format(field), pkt_offset=self.udp[field]) self.vm_flow_vars.append(stl_vm_wr_flow_var)
def partial(min_value, max_value): stl_vm_flow_var = STLVmFlowVar(name="dscp", min_value=min_value, max_value=max_value, size=2, op='inc', step=8) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='dscp', pkt_offset='IP.tos') self.vm_flow_vars.append(stl_vm_wr_flow_var)
def partial(min_value, max_value): stl_vm_flow_var = STLVmFlowVar(name="mac_{}".format(direction), min_value=1, max_value=30, size=4, op='inc', step=1) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='mac_{}'.format(direction), pkt_offset='Ether.{}'.format(direction)) self.vm_flow_vars.append(stl_vm_wr_flow_var)
def partial(min_value, max_value, count): # pylint: disable=unused-argument stl_vm_flow_var = STLVmFlowVar(name="dscp", min_value=min_value, max_value=max_value, size=2, op='inc', step=8) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='dscp', pkt_offset='IP.tos') self.vm_flow_vars.append(stl_vm_wr_flow_var)
def partial(min_value, max_value): stl_vm_flow_var = STLVmFlowVarRepeatableRandom(name="ip4_{}".format(direction), min_value=min_value, max_value=max_value, size=4, limit=int(count), seed=0x1235) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='ip4_{}'.format(direction), pkt_offset='IP.{}'.format(direction)) self.vm_flow_vars.append(stl_vm_wr_flow_var) stl_vm_fix_ipv4 = STLVmFixIpv4(offset="IP") self.vm_flow_vars.append(stl_vm_fix_ipv4)
def partial(min_value, max_value): min_value, max_value = self._get_start_end_ipv6(min_value, max_value) stl_vm_flow_var = STLVmFlowVar(name="ip6_{}".format(direction), min_value=min_value, max_value=max_value, size=8, op='random', step=1) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='ip6_{}'.format(direction), pkt_offset='IPv6.{}'.format(direction), offset_fixup=8) self.vm_flow_vars.append(stl_vm_wr_flow_var)
def partial(min_value, max_value, count): # pylint: disable=unused-argument stl_vm_flow_var = STLVmFlowVar(name="mac_{}".format(direction), min_value=1, max_value=30, size=4, op='inc', step=1) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar( fv_name='mac_{}'.format(direction), pkt_offset='Ether.{}'.format(direction)) self.vm_flow_vars.append(stl_vm_wr_flow_var)
def partial(min_value, max_value, count): # pylint: disable=unused-argument min_value, max_value, _ = self._count_ip(min_value, max_value) stl_vm_flow_var = STLVmFlowVar(name="ip6_{}".format(direction), min_value=min_value, max_value=max_value, size=8, op='random', step=1) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar( fv_name='ip6_{}'.format(direction), pkt_offset='IPv6.{}'.format(direction), offset_fixup=8) self.vm_flow_vars.append(stl_vm_wr_flow_var)
def set_dst_mac(self, dst_mac): """ set destination mac address fields """ dst_macs = dst_mac.split('-') min_value = dst_macs[0] if len(dst_macs) == 1: dst_mac = min_value self._set_ether_fields(dst=dst_mac) else: stl_vm_flow_var = STLVmFlowVar(name="mac_dst", min_value=1, max_value=30, size=4, op='inc', step=1) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='mac_dst', pkt_offset='Ether.dst') self.vm_flow_vars.append(stl_vm_wr_flow_var)
def set_src_mac(self, src_mac): """ set source mac address fields """ src_macs = src_mac.split('-') min_value = src_macs[0] if len(src_macs) == 1: src_mac = min_value self._set_ether_fields(src=src_mac) else: stl_vm_flow_var = STLVmFlowVar(name="mac_src", min_value=1, max_value=30, size=4, op='inc', step=1) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='mac_src', pkt_offset='Ether.src') self.vm_flow_vars.append(stl_vm_wr_flow_var)
def set_dscp(self, dscp): """ set dscp for trex """ dscps = str(dscp).split('-') min_value = int(dscps[0]) max_value = int(dscps[1]) if len(dscps) == 2 else int(dscps[0]) if len(dscps) == 1: dscp = min_value self._set_ip_fields(tos=dscp) else: stl_vm_flow_var = STLVmFlowVar(name="dscp", min_value=min_value, max_value=max_value, size=2, op='inc', step=8) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='dscp', pkt_offset='IP.tos') self.vm_flow_vars.append(stl_vm_wr_flow_var)
def set_src_port(self, src_port, count=1): """ set packet source port """ src_ports = str(src_port).split('-') min_value = int(src_ports[0]) if len(src_ports) == 1: max_value = int(src_ports[0]) src_port = min_value self._set_udp_fields(sport=src_port) else: max_value = int(src_ports[1]) stl_vm_flow_var = STLVmFlowVarRepeatableRandom(name="port_src", min_value=min_value, max_value=max_value, size=2, limit=int(count), seed=0x1235) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='port_src', pkt_offset=self.udp_sport) self.vm_flow_vars.append(stl_vm_wr_flow_var)
def set_src_ip4(self, src_ip4, count=1): """ set source ipv4 address fields """ src_ips = src_ip4.split('-') min_value = src_ips[0] max_value = src_ips[1] if len(src_ips) == 2 else src_ips[0] if len(src_ips) == 1: src_ip4 = min_value self._set_ip_fields(src=src_ip4) else: stl_vm_flow_var = STLVmFlowVarRepeatableRandom(name="ip4_src", min_value=min_value, max_value=max_value, size=4, limit=int(count), seed=0x1235) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='ip4_src', pkt_offset='IP.src') self.vm_flow_vars.append(stl_vm_wr_flow_var) stl_vm_fix_ipv4 = STLVmFixIpv4(offset="IP") self.vm_flow_vars.append(stl_vm_fix_ipv4)
def set_dst_ip4(self, dst_ip4, count=1): """ set destination ipv4 address fields """ dst_ips = dst_ip4.split('-') min_value = dst_ips[0] max_value = dst_ips[1] if len(dst_ips) == 2 else dst_ips[0] if len(dst_ips) == 1: dst_ip4 = min_value self._set_ip_fields(dst=dst_ip4) else: stl_vm_flow_var = STLVmFlowVarRepeatableRandom(name="dst_ip4", min_value=min_value, max_value=max_value, size=4, limit=int(count), seed=0x1235) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='dst_ip4', pkt_offset='IP.dst') self.vm_flow_vars.append(stl_vm_wr_flow_var) stl_vm_fix_ipv4 = STLVmFixIpv4(offset="IP") self.vm_flow_vars.append(stl_vm_fix_ipv4)
def set_src_ip6(self, src_ip6): """ set source ipv6 address fields """ src_ips = src_ip6.split('-') min_value = src_ips[0] max_value = src_ips[1] if len(src_ips) == 2 else src_ips[0] src_ip6 = min_value self._set_ip6_fields(src=src_ip6) if len(src_ips) == 2: min_value, max_value = \ self._get_start_end_ipv6(min_value, max_value) stl_vm_flow_var = STLVmFlowVar(name="ip6_src", min_value=min_value, max_value=max_value, size=8, op='random', step=1) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='ip6_src', pkt_offset='IPv6.src', offset_fixup=8) self.vm_flow_vars.append(stl_vm_wr_flow_var)
def set_dst_ip6(self, dst_ip6): """ set destination ipv6 address fields """ dst_ips = dst_ip6.split('-') min_value = dst_ips[0] max_value = dst_ips[1] if len(dst_ips) == 2 else dst_ips[0] dst_ip6 = min_value self._set_ip6_fields(dst=dst_ip6) if len(dst_ips) == 2: min_value, max_value = \ self._get_start_end_ipv6(min_value, max_value) stl_vm_flow_var = STLVmFlowVar(name="dst_ip6", min_value=min_value, max_value=max_value, size=8, op='random', step=1) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='dst_ip6', pkt_offset='IPv6.dst', offset_fixup=8) self.vm_flow_vars.append(stl_vm_wr_flow_var)
def set_dst_port(self, dst_port, count=1): """ set packet destnation port """ dst_ports = str(dst_port).split('-') min_value = int(dst_ports[0]) if len(dst_ports) == 1: max_value = int(dst_ports[0]) dst_port = min_value self._set_udp_fields(dport=dst_port) else: max_value = int(dst_ports[1]) stl_vm_flow_var = \ STLVmFlowVarRepeatableRandom(name="port_dst", min_value=min_value, max_value=max_value, size=2, limit=int(count), seed=0x1235) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar(fv_name='port_dst', pkt_offset=self.udp_dport) self.vm_flow_vars.append(stl_vm_wr_flow_var)
def partial(min_value, max_value, count): ip1 = int(ipaddress.IPv4Address(min_value)) ip2 = int(ipaddress.IPv4Address(max_value)) actual_count = (ip2 - ip1) if not actual_count: count = 1 elif actual_count < int(count): count = actual_count stl_vm_flow_var = STLVmFlowVarRepeatableRandom( name="ip4_{}".format(direction), min_value=min_value, max_value=max_value, size=4, limit=int(count), seed=0x1235) self.vm_flow_vars.append(stl_vm_flow_var) stl_vm_wr_flow_var = STLVmWrFlowVar( fv_name='ip4_{}'.format(direction), pkt_offset='IP.{}'.format(direction)) self.vm_flow_vars.append(stl_vm_wr_flow_var) stl_vm_fix_ipv4 = STLVmFixIpv4(offset="IP") self.vm_flow_vars.append(stl_vm_fix_ipv4)