summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Kiselev <anton.kisel@gmail.com>2016-11-18 13:50:35 +0700
committerAnton Kiselev <anton.kisel@gmail.com>2016-11-18 13:56:56 +0700
commitb75910ef6bb781b0d28eb253758bbe65d573b768 (patch)
tree2f331153d91ccc3f53698362c01ff8d53876956c
parentae863c50263aa79391d4b81238c19a4b920ecc47 (diff)
scapy_service: take into account Ether.chksum when building payload with total_size
Signed-off-by: Anton Kiselev <anton.kisel@gmail.com>
-rwxr-xr-xscripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py3
-rw-r--r--scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py9
2 files changed, 7 insertions, 5 deletions
diff --git a/scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py b/scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py
index 88514aa8..8d99fe92 100755
--- a/scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py
+++ b/scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py
@@ -468,7 +468,8 @@ class Scapy_service(Scapy_service_api):
gen.update(val)
total_sz = gen['total_size']
del gen['total_size']
- gen['size'] = total_sz - len(scapy_pkt)
+ ether_chksum_size_bytes = 4 # will be added outside of Scapy. needs to be excluded here
+ gen['size'] = total_sz - len(scapy_pkt) - ether_chksum_size_bytes
return generate_bytes(gen)
else:
return generate_bytes(val)
diff --git a/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py b/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
index d1207ca5..91a457dc 100644
--- a/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
+++ b/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
@@ -6,6 +6,7 @@ import re
from basetest import *
RE_MAC = "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$"
+ether_chksum_sz = 4 # this chksum will be added automatically(outside of scapy/packet editor)
TEST_MAC_1 = "10:10:10:10:10:10"
# Test scapy structure
@@ -78,7 +79,7 @@ def test_build_Raw():
])
assert(str(pkt[Raw].load == "hi"))
-def test_build_fixed_pkt_size_bytes_gen():
+def test_build_fixed_pkt_size_template_gen_64():
pkt = build_pkt_get_scapy([
layer_def("Ether"),
layer_def("IP"),
@@ -91,9 +92,9 @@ def test_build_fixed_pkt_size_bytes_gen():
})
])
print(len(pkt))
- assert(len(pkt) == 64)
+ assert(len(pkt) == 64 - ether_chksum_sz)
-def test_build_fixed_pkt_size_bytes_gen():
+def test_build_fixed_pkt_size_bytes_gen_256():
pkt = build_pkt_get_scapy([
layer_def("Ether"),
layer_def("IP"),
@@ -105,7 +106,7 @@ def test_build_fixed_pkt_size_bytes_gen():
})
])
print(len(pkt))
- assert(len(pkt) == 256)
+ assert(len(pkt) == 256 - ether_chksum_sz)
def test_get_all():
service.get_all(v_handler)