Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom payload support for UHD #540

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions snappi_ixnetwork/trafficitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ def __init__(self, ixnetworkapi):
self.flows_has_latency = []
self.flows_has_timestamp = []
self.flows_has_loss = []
self.tracking = True

def _get_search_payload(self, parent, child, properties, filters):
payload = {
Expand Down Expand Up @@ -636,16 +637,33 @@ def config_raw_stack(self, xpath, packet):
stack_name = self._HEADER_TO_TYPE.get(
self._getUhdHeader(header.parent.choice)
)
header_xpath = "%s/stack[@alias = '%s-%d']" % (
ce_path,
stack_name,
i + 1,
)
self._append_header(
header, header_xpath, config_elem["stack"], is_raw_traffic=True
)
# TODO: Need to remove custom payload for UHD when
# custom stack support is available
if stack_name == "custom" and self.isUhd is True:
payload_xpath = ce_path + "/framePayload"
config_elem["framePayload"] = (
self._append_payload(header, payload_xpath))
self.tracking = False
else:
header_xpath = "%s/stack[@alias = '%s-%d']" % (
ce_path,
stack_name,
i + 1,
)
self._append_header(
header, header_xpath, config_elem["stack"],
is_raw_traffic=True
)
return [config_elem]

def _append_payload(self, header, payload_xpath):
frame_payload = {}
frame_payload["xpath"] = payload_xpath
frame_payload["type"] = "custom"
frame_payload["customRepeat"] = "false"
frame_payload["customPattern"] = header.bytes
return frame_payload

def _get_mesh_type(self, flow):
if flow.tx_rx.choice == "port":
mesh_type = "oneToOne"
Expand Down Expand Up @@ -813,7 +831,13 @@ def _configure_tracking(self, tr_item_json):
"""Set tracking options"""
xpath = tr_item_json["xpath"]
if tr_item_json.get("trafficType") == "raw":
trackBy = ["trackingenabled0"]
# TODO: Instrumentation is turned off for UHD to support
# custom payload, add Instrumentation back once custom stack is
# supported in UHD
if self.tracking:
trackBy = ["trackingenabled0"]
else:
trackBy = []
else:
trackBy = ["trackingenabled0", "sourceDestPortPair0"]
tracking = [{"xpath": "%s/tracking" % xpath, "trackBy": trackBy}]
Expand Down