Hi,
while I am trying to run standalone Trex Stateless Traffic without PyATS & Virtual Environment, I could run Trex STL traffic successfully. But with Python Virtual Environment and PyATS, Its failing during STL Packet Building.
I have tried the following option, still its failing
1. I have installed same scapy version as its in trex external_libs
File "/home/aharon/oracle/systest/lib/trex_lib.py", line 1412, in generate_stateless_udp_streams_per_subnet dst_port_start, dst_port_end, pkt_size, vlan_id ) File "/home/aharon/oracle/systest/lib/trex_lib.py", line 812, in create_udp_pkts pkt = STLPktBuilder(pkt = base_pkt/pad, vm = vm) File "/home/aharon/trex/v2.84/automation/trex_control_plane/interactive/trex/stl/trex_stl_packet_builder_scapy.py", line 1626, in __init__ self.compile() File "/home/aharon/trex/v2.84/automation/trex_control_plane/interactive/trex/stl/trex_stl_packet_builder_scapy.py", line 1789, in compile self._compile_raw(sc) File "/home/aharon/trex/v2.84/automation/trex_control_plane/interactive/trex/stl/trex_stl_packet_builder_scapy.py", line 2017, in _compile_raw desc.compile(self) File "/home/aharon/trex/v2.84/automation/trex_control_plane/interactive/trex/stl/trex_stl_packet_builder_scapy.py", line 1183, in compile t=parent._name_to_offset(self.pkt_offset) File "/home/aharon/trex/v2.84/automation/trex_control_plane/interactive/trex/stl/trex_stl_packet_builder_scapy.py", line 2062, in _name_to_offset return p_utl.get_field_offet_by_str(field_name) File "/home/aharon/trex/v2.84/automation/trex_control_plane/interactive/trex/stl/trex_stl_packet_builder_scapy.py", line 565, in get_field_offet_by_str return self.get_field_offet(layer,layer_cnt,field) File "/home/aharon/trex/v2.84/automation/trex_control_plane/interactive/trex/stl/trex_stl_packet_builder_scapy.py", line 463, in get_field_offet t=self._layer_offset(layer,layer_cnt); File "/home/aharon/trex/v2.84/automation/trex_control_plane/interactive/trex/stl/trex_stl_packet_builder_scapy.py", line 437, in _layer_offset print('Sam Debug: %s, %s' % (pkt, pkt._offset)) File "/home/aharon/trex_env/lib/python3.6/site-packages/scapy/packet.py", line 374, in __getattr__ return self.payload.__getattr__(attr) File "/home/aharon/trex_env/lib/python3.6/site-packages/scapy/packet.py", line 374, in __getattr__ return self.payload.__getattr__(attr) File "/home/aharon/trex_env/lib/python3.6/site-packages/scapy/packet.py", line 374, in __getattr__ return self.payload.__getattr__(attr) File "/home/aharon/trex_env/lib/python3.6/site-packages/scapy/packet.py", line 372, in __getattr__ fld, v = self.getfield_and_val(attr) File "/home/aharon/trex_env/lib/python3.6/site-packages/scapy/packet.py", line 1600, in getfield_and_val raise AttributeError(attr) AttributeError: _offset
2. I have uninstalled scapy in Virtual Environment and added scapy from external_libs in sys.path. Here STL Packet Building is successful, but Traffic is not happening. The TX & RX counters are Zeroes. I could see the following scapy warning messages.
2021-02-22T03:30:24: %SCAPY-WARNING: wrong value: DNS.qdcount=30840
wrong value: DNS.qdcount=30840
2021-02-22T03:30:24: %SCAPY-WARNING: wrong value: DNS.ancount=30840
wrong value: DNS.ancount=30840
2021-02-22T03:30:24: %SCAPY-WARNING: more wrong value: DNS.nscount=30840
more wrong value: DNS.nscount=30840
Ethernet:802.1Q:IP:UDP:DNS:Raw
Here is code snippet:
# Stateless
sys.path.append('/home/aharon/trex/v2.84/automation/trex_control_plane/interactive')
from trex_stl_lib.api import *
# hltapi
from trex.stl.api import *
from trex.stl.trex_stl_hltapi import *
from scapy.all import *
vm = STLScVmRaw(
[
STLVmFlowVar(name="ip_src",
min_value=src_ip_start,
max_value=src_ip_end,
size=4,op="inc", next_var="src_port" ),
STLVmWrFlowVar(fv_name="ip_src",pkt_offset= "IP.src"),
STLVmFlowVar(name="ip_dst",
min_value=dst_ip_start,
max_value=dst_ip_end,
size=4,op="inc"),
STLVmWrFlowVar(fv_name="ip_dst",pkt_offset= "IP.dst"),
STLVmFlowVar(name="src_port", min_value=src_port_start, max_value=src_port_end, size=2, op="inc" ),
STLVmWrFlowVar(fv_name="src_port", pkt_offset= "UDP.sport" ),
STLVmFlowVar(name="dst_port", min_value=dst_port_start, max_value=dst_port_end, size=2, op="inc" ),
STLVmWrFlowVar(fv_name="dst_port", pkt_offset= "UDP.dport" ),
STLVmFixIpv4(offset = "IP"),
STLVmFixChecksumHw(l3_offset="IP",l4_offset="UDP",l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP)
]
)
if vlan_id is None:
base_pkt = Ether( src=src_mac, dst=dst_mac)/IP()/UDP()
else:
print('Vlan id = {}'.format(vlan_id))
print(src_mac, dst_mac)
base_pkt = Ether( src=src_mac, dst=dst_mac )/Dot1Q(vlan=vlan_id)/IP()/UDP()
base_pkt.show()
# Padding data to match the packet size ..
pad = max(0, len(base_pkt)-pkt_size) * 'x'
print('pad: %s' % pad)
pkt = STLPktBuilder(pkt = base_pkt/pad, vm = vm)
#print(pkt)
#print(type(pkt))
#sys.exit(1)
return pkt
(trex_env) -bash-4.2$ ls /home/aharon/trex/v2.84/external_libs/scapy-2.4.3/
LICENSE README.md ipfix-cisco-information-elements.csv ipfix-ietf-information-elements.csv scapy
(trex_env) -bash-4.2$ pip3.6 freeze | grep scapy
scapy==2.4.3
(trex_env) -bash-4.2$
Please suggest.
Thanks & Regards
Aharon