X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftraffic_scripts%2Fsend_icmp_check_multipath.py;h=5da3b7b09631cd860c124904238c5197fee56ddb;hb=25e203b678e1cfd3691a450050115c66813165c3;hp=4e39efdfcd2d3f2c1c1faf90df45c44c95f0e379;hpb=149c67b82f9af5144431f4d5b781ed345ca09fb8;p=csit.git diff --git a/resources/traffic_scripts/send_icmp_check_multipath.py b/resources/traffic_scripts/send_icmp_check_multipath.py index 4e39efdfcd..5da3b7b096 100755 --- a/resources/traffic_scripts/send_icmp_check_multipath.py +++ b/resources/traffic_scripts/send_icmp_check_multipath.py @@ -18,10 +18,9 @@ and check if it is divided into two paths.""" import sys import ipaddress -from scapy.layers.inet import ICMP, IP -from scapy.layers.inet6 import IPv6 from scapy.all import Ether -from scapy.layers.inet6 import ICMPv6EchoRequest +from scapy.layers.inet import ICMP, IP +from scapy.layers.inet6 import IPv6, ICMPv6EchoRequest, ICMPv6ND_NS from resources.libraries.python.PacketVerifier import RxQueue, TxQueue from resources.libraries.python.TrafficScriptArg import TrafficScriptArg @@ -94,27 +93,38 @@ def main(): sent_packets.append(pkt_raw) txq.send(pkt_raw) - ether = rxq.recv(2) + + while True: + ether = rxq.recv(2) + if ether is None: + raise RuntimeError('ICMPv6 echo reply Rx timeout') + + if ether.haslayer(ICMPv6ND_NS): + # read another packet in the queue in case of ICMPv6ND_NS packet + continue + else: + # otherwise process the current packet + break if ether is None: raise RuntimeError("ICMP echo Rx timeout") if not ether.haslayer(ip_format): - raise RuntimeError("Not an IP packet received {0}" - .format(ether.__repr__())) + raise RuntimeError("Not an IP packet received {0}". + format(ether.__repr__())) - if ether['Ethernet'].src != dut_if2_mac: + if ether[Ether].src != dut_if2_mac: raise RuntimeError("Source MAC address error") - if ether['Ethernet'].dst == path_1_mac: + if ether[Ether].dst == path_1_mac: path_1_counter += 1 - elif ether['Ethernet'].dst == path_2_mac: + elif ether[Ether].dst == path_2_mac: path_2_counter += 1 else: raise RuntimeError("Destination MAC address error") if (path_1_counter + path_2_counter) != 100: - raise RuntimeError("Packet loss: recevied only {} packets of 100 " - .format(path_1_counter + path_2_counter)) + raise RuntimeError("Packet loss: recevied only {} packets of 100 ". + format(path_1_counter + path_2_counter)) if path_1_counter == 0: raise RuntimeError("Path 1 error!") @@ -127,5 +137,6 @@ def main(): sys.exit(0) + if __name__ == "__main__": main()