try:
self.update_config(opts)
self.setup()
-
+ new_frame_sizes = []
+ min_packet_size = "68" if self.config.vlan_tagging else "64"
+ for frame_size in self.config.frame_sizes:
+ try:
+ if int(frame_size) < int(min_packet_size):
+ new_frame_sizes.append(min_packet_size)
+ LOG.info("Adjusting frame size %s Bytes to minimum size %s Bytes due to "
+ + "traffic generator restriction", frame_size, min_packet_size)
+ else:
+ new_frame_sizes.append(frame_size)
+ except ValueError:
+ new_frame_sizes.append(frame_size)
+ self.config.frame_sizes = tuple(new_frame_sizes)
result = {
"date": datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
"nfvbench_version": __version__,
class AbstractTrafficGenerator(object):
- # src_mac (6) + dst_mac (6) + mac_type (2) + frame_check (4) = 18
- l2_header_size = 18
-
- imix_l2_sizes = [64, 594, 1518]
- imix_l3_sizes = [size - l2_header_size for size in imix_l2_sizes]
- imix_ratios = [7, 4, 1]
- imix_avg_l2_size = sum(
- [1.0 * imix[0] * imix[1] for imix in zip(imix_l2_sizes, imix_ratios)]) / sum(imix_ratios)
-
- traffic_utils.imix_avg_l2_size = imix_avg_l2_size
-
def __init__(self, config):
self.config = config
+ self.imix_l2_sizes = [64, 594, 1518]
+ self.imix_ratios = [7, 4, 1]
+ self.imix_avg_l2_size = 0
+ self.adjust_imix_min_size(64)
@abc.abstractmethod
def get_version(self):
def cleanup(self):
# Must be implemented by sub classes
return None
+
+ def adjust_imix_min_size(self, min_size):
+ # assume the min size is always the first entry
+ self.imix_l2_sizes[0] = min_size
+ self.imix_avg_l2_size = sum(
+ [1.0 * imix[0] * imix[1] for imix in zip(self.imix_l2_sizes, self.imix_ratios)]) / sum(
+ self.imix_ratios)
+ traffic_utils.imix_avg_l2_size = self.imix_avg_l2_size
def create_pkt(self, stream_cfg, l2frame_size):
pkt_base = Ether(src=stream_cfg['mac_src'], dst=stream_cfg['mac_dst'])
- # TRex requires minimum payload size 16B
if stream_cfg['vlan_tag'] is not None:
# 50 = 14 (Ethernet II) + 4 (Vlan tag) + 4 (CRC Checksum) + 20 (IPv4) + 8 (UDP)
pkt_base /= Dot1Q(vlan=stream_cfg['vlan_tag'])
- l2payload_size = max(max(64, int(l2frame_size)) - 50, 16)
+ l2payload_size = int(l2frame_size) - 50
else:
# 46 = 14 (Ethernet II) + 4 (CRC Checksum) + 20 (IPv4) + 8 (UDP)
- l2payload_size = max(max(64, int(l2frame_size)) - 46, 16)
+ l2payload_size = int(l2frame_size) - 46
payload = 'x' * l2payload_size
udp_args = {}
if stream_cfg['udp_src_port']:
idx_lat = None
streams = []
if l2frame == 'IMIX':
+ min_size = 64 if stream_cfg['vlan_tag'] is None else 68
+ self.adjust_imix_min_size(min_size)
for t, (ratio, l2_frame_size) in enumerate(zip(self.imix_ratios, self.imix_l2_sizes)):
pkt = self.create_pkt(stream_cfg, l2_frame_size)
streams.append(STLStream(packet=pkt,