trafficgen icon indicating copy to clipboard operation
trafficgen copied to clipboard

trex_tg_lib.py issue

Open jianzzha opened this issue 4 years ago • 4 comments

trex_tg_lib.py, current line 261 base = base/IP(src = str(ip_src['start']), dst = str(ip_dst['start']))

ip_src['start'] and ip_dst['start']) are integer, for traffic 1.1.1.1 -> 2.2.2.2, the above line is equivalent to : base = base/IP(src = '16843009', dst = '33686018')

And this cause following exception (with binary search command: ./binary-search.py --traffic-generator=trex-txrx --device-pairs=0:1 --search-runtime=10 --validation-runtime=10 --traffic-direction=bidirectional --num-flows=1): [2020-09-13 22:36:35.718527][001] EXCEPTION: Traceback (most recent call last): [2020-09-13 22:36:35.718548][001] File "./trex-txrx.py", line 1075, in main [2020-09-13 22:36:35.718607][001] create_traffic_profile("->", device_pair, rate_multiplier, (port_info[device_pair['->']['ports']['tx']]['speed'] * 1000 * 1000 * 1000)) [2020-09-13 22:36:35.718676][001] File "./trex-txrx.py", line 342, in create_traffic_profile [2020-09-13 22:36:35.718689][001] t_global.args.enable_flow_cache) [2020-09-13 22:36:35.718699][001] File "/root/trafficgen/trex_tg_lib.py", line 268, in create_generic_pkt [2020-09-13 22:36:35.718710][001] pad = max(0, size-len(baseT)) * 'x' [2020-09-13 22:36:35.718724][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/packet.py", line 568, in len [2020-09-13 22:36:35.718740][001] return len(self.bytes()) [2020-09-13 22:36:35.718753][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/packet.py", line 533, in bytes [2020-09-13 22:36:35.718763][001] return self.build() [2020-09-13 22:36:35.718774][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/packet.py", line 703, in build [2020-09-13 22:36:35.718784][001] p = self.do_build(result) [2020-09-13 22:36:35.718794][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/packet.py", line 665, in do_build [2020-09-13 22:36:35.718805][001] pay = self.do_build_payload() [2020-09-13 22:36:35.718818][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/packet.py", line 639, in do_build_payload [2020-09-13 22:36:35.718835][001] return self.payload.do_build(None) [2020-09-13 22:36:35.718846][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/packet.py", line 665, in do_build [2020-09-13 22:36:35.718856][001] pay = self.do_build_payload() [2020-09-13 22:36:35.718866][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/packet.py", line 639, in do_build_payload [2020-09-13 22:36:35.718876][001] return self.payload.do_build(None) [2020-09-13 22:36:35.718887][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/packet.py", line 670, in do_build [2020-09-13 22:36:35.718897][001] p = self.post_build(pkt, pay) [2020-09-13 22:36:35.718907][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/layers/inet.py", line 705, in post_build [2020-09-13 22:36:35.718917][001] ck = in4_chksum(socket.IPPROTO_UDP, self.underlayer, p) [2020-09-13 22:36:35.718927][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/layers/inet.py", line 606, in in4_chksum [2020-09-13 22:36:35.718940][001] inet_pton(socket.AF_INET, u.src), [2020-09-13 22:36:35.718950][001] File "/opt/trex/v2.83/external_libs/scapy-2.4.3/scapy/pton_ntop.py", line 87, in inet_pton [2020-09-13 22:36:35.718960][001] return socket.inet_pton(af, addr) [2020-09-13 22:36:35.718970][001] error: illegal IP address string passed to inet_pton

I don't know how this worked before, but it didn't work on my system unless I change this line to: base = base/IP(src = socket.inet_ntoa(struct.pack('!L', ip_src['start'])), dst = socket.inet_ntoa(struct.pack('!L', ip_dst['start']))) for 1.1.1.1->2.2.2.2, this line change is equivalent to: base = base/IP(src = '1.1.1.1', dst = '2.2.2.2')

jianzzha avatar Sep 14 '20 02:09 jianzzha

Can you give some context on this environment? Is this a new trafficgen install and the first time it has been run? Or is it an existing install that was working and one of the recent changes has broken it?

Also, it looks like you are using TRex v2.83 which is not what trafficgen is currently installing (which is v2.82 and has been somewhat thoroughly tested). Why are you using v2.83?

k-rister avatar Sep 14 '20 13:09 k-rister

This is a new system, never worked before. It's a super micro server and I'm trying to dockerize the binary search with trex - so basically no pbench trafficgen, just the binary search + txrx + trex.

This container image used to work on dell server with trex v2.53. Somehow trex 2.53 complains about the XL710 firmware on super micro so I updated the trex to the v2.83 to get rid of the complains, and then run into this issue. I will try trex v2.82.

Regardless, for me it is strange this worked in the past: base = base/IP(src = '16843009', dst = '33686018'). I would think it should be base = base/IP(src = '1.1.1.1', dst = '2.2.2.2')

jianzzha avatar Sep 14 '20 13:09 jianzzha

@k-rister v2.82 works and v2.83 doesn't. So the scapy behavior might have changed in v2.83.

jianzzha avatar Sep 14 '20 13:09 jianzzha

According to the release notes for v2.83 they updated Scapy...

k-rister avatar Sep 14 '20 14:09 k-rister