Skip to content

Commit c8a8fda

Browse files
Ryangwaitemssonicbld
authored andcommitted
Ignore received packets that weren't sent during examine_flow (sonic-net#13203)
What is the motivation for this PR? The platform_tests.test_advanced_reboot.test_fast_reboot test was failing due to received packets that weren't sent. How did you do it? How did you verify/test it? Modified the examine_flow function to run independently then tested the logic with a series of pcap files with various missing packets in the sequence. The cases included: 100 packets, happy path 100 packets, 0th packet receive missing 100 packets, 0th packet send missing 100 packets, 10th packet both missing, 11th packet both missing 100 packets, 10th packet both missing, 11th packet receive missing 100 packets, 10th packet both missing, 11th packet send missing 100 packets, 10th packet both missing 100 packets, 10th packet receive missing, 11th packet receive missing 100 packets, 10th packet receive missing, 11th packet send missing 100 packets, 10th packet receive missing 100 packets, 10th packet send missing, 11th packet receive missing 100 packets, 10th packet send missing, 11th packet send missing 100 packets, 10th packet send missing 100 packets, bunch of sad cases all in one: pkt-10 both missing pkt-15 send missing pkt-20 receive missing pkt-25 both missing, pkt-26 both missing pkt-30 both missing, pkt-31 send missing pkt-35 both missing, pkt-36 receive missing pkt-45 receive missing, pkt-46 receive missing pkt-55 receive missing, pkt-56 send missing pkt-65 send missing, pkt-66 send missing pkt-75 send missing, pkt-76 receive missing 100 packets, first 10 packets missing Any platform specific information?
1 parent c47a03e commit c8a8fda

File tree

1 file changed

+59
-21
lines changed

1 file changed

+59
-21
lines changed

ansible/roles/test/files/ptftests/py3/advanced-reboot.py

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ def sad_revert(self):
628628

629629
def setUp(self):
630630
self.fails['dut'] = set()
631+
self.fails['infrastructure'] = set()
631632
self.dut_mac = self.test_params['dut_mac']
632633
self.vlan_mac = self.test_params['vlan_mac']
633634
self.lo_prefix = self.test_params['lo_prefix']
@@ -1943,14 +1944,17 @@ def examine_flow(self, filename=None):
19431944
self.lost_packets = dict()
19441945
self.max_disrupt, self.total_disruption = 0, 0
19451946
sent_packets = dict()
1947+
# Track packet id's that were neither sent or received
1948+
missing_sent_and_received_packet_id_sequences = []
19461949
self.fails['dut'].add("Sniffer failed to capture any traffic")
19471950
self.assertTrue(packets, "Sniffer failed to capture any traffic")
19481951
self.fails['dut'].clear()
19491952
prev_payload = None
19501953
if packets:
1951-
prev_payload, prev_time = 0, 0
1954+
prev_payload, prev_time = -1, 0
19521955
sent_payload = 0
19531956
received_counter = 0 # Counts packets from dut.
1957+
received_but_not_sent_packets = set()
19541958
sent_counter = 0
19551959
received_t1_to_vlan = 0
19561960
received_vlan_to_t1 = 0
@@ -1985,31 +1989,60 @@ def examine_flow(self, filename=None):
19851989
prev_time = received_time
19861990
continue
19871991
if received_payload - prev_payload > 1:
1988-
# Packets in a row are missing, a disruption.
1992+
if received_payload not in sent_packets:
1993+
self.log("Ignoring received packet with payload {}, as it was not sent".format(
1994+
received_payload))
1995+
received_but_not_sent_packets.add(received_payload)
1996+
continue
1997+
# Packets in a row are missing, a potential disruption.
19891998
self.log("received_payload: {}, prev_payload: {}, sent_counter: {}, received_counter: {}".format(
19901999
received_payload, prev_payload, sent_counter, received_counter))
19912000
# How many packets lost in a row.
19922001
lost_id = (received_payload - 1) - prev_payload
1993-
# How long disrupt lasted.
1994-
disrupt = (
1995-
sent_packets[received_payload] - sent_packets[prev_payload + 1])
1996-
# Add disrupt to the dict:
1997-
self.lost_packets[prev_payload] = (
1998-
lost_id, disrupt, received_time - disrupt, received_time)
1999-
self.log("Disruption between packet ID %d and %d. For %.4f " % (
2000-
prev_payload, received_payload, disrupt))
2001-
for lost_index in range(prev_payload + 1, received_payload):
2002-
# lost received for packet sent from vlan to T1.
2003-
if (lost_index % 5) == 0:
2004-
missed_vlan_to_t1 += 1
2002+
2003+
# Find previous sequential sent packet that was captured
2004+
missing_sent_and_received_pkt_count = 0
2005+
prev_pkt_pt = prev_payload + 1
2006+
prev_sent_packet_time = None
2007+
while prev_pkt_pt < received_payload:
2008+
if prev_pkt_pt in sent_packets:
2009+
prev_sent_packet_time = sent_packets[prev_pkt_pt]
2010+
break # Found it
20052011
else:
2006-
missed_t1_to_vlan += 1
2007-
self.log("")
2008-
if not self.disruption_start:
2009-
self.disruption_start = datetime.datetime.fromtimestamp(
2010-
prev_time)
2011-
self.disruption_stop = datetime.datetime.fromtimestamp(
2012-
received_time)
2012+
if prev_pkt_pt not in received_but_not_sent_packets:
2013+
missing_sent_and_received_pkt_count += 1
2014+
prev_pkt_pt += 1
2015+
if missing_sent_and_received_pkt_count > 0:
2016+
missing_sent_and_received_packet_id_sequences_fmtd = \
2017+
str(prev_payload + 1) if missing_sent_and_received_pkt_count == 1\
2018+
else "{}-{}".format(prev_payload + 1, received_payload - 1)
2019+
missing_sent_and_received_packet_id_sequences.append(
2020+
missing_sent_and_received_packet_id_sequences_fmtd)
2021+
if prev_sent_packet_time is not None:
2022+
# Disruption occurred - some sent packets were not received
2023+
2024+
# How long disrupt lasted.
2025+
this_sent_packet_time = sent_packets[received_payload]
2026+
disrupt = this_sent_packet_time - prev_sent_packet_time
2027+
2028+
# Add disrupt to the dict:
2029+
self.lost_packets[prev_payload] = (
2030+
lost_id, disrupt, received_time - disrupt, received_time)
2031+
self.log("Disruption between packet ID %d and %d. For %.4f " % (
2032+
prev_payload, received_payload, disrupt))
2033+
for lost_index in range(prev_payload + 1, received_payload):
2034+
# lost received for packet sent from vlan to T1.
2035+
if lost_index in sent_packets:
2036+
if (lost_index % 5) == 0:
2037+
missed_vlan_to_t1 += 1
2038+
else:
2039+
missed_t1_to_vlan += 1
2040+
self.log("")
2041+
if not self.disruption_start:
2042+
self.disruption_start = datetime.datetime.fromtimestamp(
2043+
prev_time)
2044+
self.disruption_stop = datetime.datetime.fromtimestamp(
2045+
received_time)
20132046
prev_payload = received_payload
20142047
prev_time = received_time
20152048
self.log(
@@ -2043,6 +2076,11 @@ def examine_flow(self, filename=None):
20432076
self.total_disrupt_time = 0
20442077
self.log("Gaps in forwarding not found.")
20452078

2079+
if missing_sent_and_received_packet_id_sequences:
2080+
self.fails["infrastructure"].add(
2081+
"Missing sent and received packets: {}"
2082+
.format(missing_sent_and_received_packet_id_sequences))
2083+
20462084
self.dataplane_loss_checked_successfully = True
20472085

20482086
if self.reboot_type == "fast-reboot" and not self.lost_packets:

0 commit comments

Comments
 (0)