+ if self.ip_addrs_step == 'random':
+ # Set step to 1 to calculate the IP range size (see check_ip_size below)
+ step = '0.0.0.1'
+ else:
+ step = self.ip_addrs_step
+ self.ip_size = self.check_ipsize(IPNetwork(self.ip_addrs).size, Device.ip_to_int(step))
+ self.ip = str(IPNetwork(self.ip_addrs).network)
+ ip_addrs_left = generator_config.ip_addrs[0]
+ ip_addrs_right = generator_config.ip_addrs[1]
+ self.ip_addrs_size = {
+ 'left': self.check_ipsize(IPNetwork(ip_addrs_left).size, Device.ip_to_int(step)),
+ 'right': self.check_ipsize(IPNetwork(ip_addrs_right).size, Device.ip_to_int(step))}
+ udp_src_port = generator_config.gen_config.udp_src_port
+ if udp_src_port is None:
+ udp_src_port = 53
+ udp_dst_port = generator_config.gen_config.udp_dst_port
+ if udp_dst_port is None:
+ udp_dst_port = 53
+ src_max, src_min = self.define_udp_range(udp_src_port, 'udp_src_port')
+ dst_max, dst_min = self.define_udp_range(udp_dst_port, 'udp_dst_port')
+ udp_src_range = int(src_max) - int(src_min) + 1
+ udp_dst_range = int(dst_max) - int(dst_min) + 1
+ lcm_port = self.lcm(udp_src_range, udp_dst_range)
+ if self.ip_src_static is True:
+ lcm_ip = self.lcm(1, min(self.ip_addrs_size['left'], self.ip_addrs_size['right']))
+ else:
+ lcm_ip = self.lcm(self.ip_addrs_size['left'], self.ip_addrs_size['right'])
+ flow_max = self.lcm(lcm_port, lcm_ip)
+ if self.flow_count > flow_max:
+ raise TrafficClientException('Trying to set unachievable traffic (%d > %d)' %
+ (self.flow_count, flow_max))
+
+ # manage udp range regarding flow count value
+ # UDP dst range is greater than FC => range will be limited to min + FC
+ if self.flow_count <= udp_dst_range:
+ dst_max = int(dst_min) + self.flow_count - 1
+ # UDP src range is greater than FC => range will be limited to min + FC
+ if self.flow_count <= udp_src_range:
+ src_max = int(src_min) + self.flow_count - 1
+ # Define IP block limit regarding flow count
+ if self.flow_count <= self.ip_size:
+ self.ip_block = IpBlock(self.ip, step, self.flow_count)
+ else:
+ self.ip_block = IpBlock(self.ip, step, self.ip_size)
+
+ if generator_config.gen_config.udp_port_step == 'random':
+ step = 1
+ else:
+ step = generator_config.gen_config.udp_port_step
+ self.udp_ports = UdpPorts(src_min, src_max, dst_min, dst_max, step)