def set_dst_ip4(self, dst_ip4): """ 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 = STLVmFlowVar(name="dst_ip4", min_value=min_value, max_value=max_value, size=4, op='random', step=1) 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_ip4(self, src_ip4): """ 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 = STLVmFlowVar(name="ip4_src", min_value=min_value, max_value=max_value, size=4, op='random', step=1) 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)