- def set_mode(self):
- if self.config.service_chain == ChainType.EXT and not self.config.no_arp:
- self.__set_l3_mode()
- else:
- self.__set_l2_mode()
-
- def __set_l3_mode(self):
- self.client.set_service_mode(ports=self.port_handle, enabled=True)
- for port, device in zip(self.port_handle, self.generator_config.devices):
- try:
- self.client.set_l3_mode(port=port,
- src_ipv4=device.tg_gateway_ip,
- dst_ipv4=device.dst.gateway_ip,
- vlan=device.vlan_tag if device.vlan_tagging else None)
- except STLError:
- # TRex tries to resolve ARP already, doesn't have to be successful yet
- continue
- self.client.set_service_mode(ports=self.port_handle, enabled=False)
-
- def __set_l2_mode(self):
- self.client.set_service_mode(ports=self.port_handle, enabled=True)
- for port, device in zip(self.port_handle, self.generator_config.devices):
- for cfg in device.get_stream_configs():
- self.client.set_l2_mode(port=port, dst_mac=cfg['mac_dst'])
- self.client.set_service_mode(ports=self.port_handle, enabled=False)
-