- raise RuntimeError("Rx timeout")
- if ether.src != dst_mac or ether.dst != src_mac:
- raise RuntimeError("MAC mismatch in mirrored response.")
- if ptype == "ARP":
- if ether['ARP'].op != 2:
- raise RuntimeError("Mirrored packet is not an ARP reply.")
- if ether['ARP'].hwsrc != dst_mac or ether['ARP'].hwdst != src_mac:
- raise RuntimeError("ARP MAC does not match l2 MAC "
- "in mirrored response.")
- if ether['ARP'].psrc != dst_ip or ether['ARP'].pdst != src_ip:
- raise RuntimeError("ARP IP address mismatch in mirrored response.")
- elif ptype == "ICMP" and ether.haslayer(IP):
- if ether['IP'].src != dst_ip or ether['IP'].dst != src_ip:
- raise RuntimeError("IP address mismatch in mirrored reply.")
- if ether['ICMP'].type != 0:
- raise RuntimeError("Mirrored packet is not an ICMP reply.")
- elif ptype == "ICMP" and ether.haslayer(IPv6):
- if ether['IPv6'].src != dst_ip or ether['IPv6'].dst != src_ip:
- raise RuntimeError("IP address mismatch in mirrored reply.")
- if not ether.haslayer(ICMPv6EchoReply):
- raise RuntimeError("Mirrored packet is not an ICMP reply.")
-
+ raise RuntimeError("Rx timeout of mirrored Tx packet")
+ if str(ether) != str(ether_repl):
+ print("Mirrored Tx packet doesn't match the received Tx packet.")
+ if ether.src != ether_repl.src or ether.dst != ether_repl.dst:
+ raise RuntimeError("MAC mismatch in mirrored Tx packet.")
+ if ptype == "ARP":
+ if not ether.haslayer(ARP):
+ raise RuntimeError("Mirrored Tx packet is not an ARP packet.")
+ if ether['ARP'].op != ether_repl['ARP'].op: # 2=is_at
+ raise RuntimeError("ARP operational code mismatch "
+ "in mirrored Tx packet.")
+ if ether['ARP'].hwsrc != ether_repl['ARP'].hwsrc\
+ or ether['ARP'].hwdst != ether_repl['ARP'].hwdst:
+ raise RuntimeError("MAC mismatch in mirrored Tx ARP packet.")
+ if ether['ARP'].psrc != ether_repl['ARP'].psrc\
+ or ether['ARP'].pdst != ether_repl['ARP'].pdst:
+ raise RuntimeError("IP address mismatch in mirrored "
+ "Tx ARP packet.")
+ elif ptype == "ICMP":
+ if not ether.haslayer(IP):
+ raise RuntimeError("Mirrored Tx packet is not an IPv4 packet.")
+ if ether['IP'].src != ether_repl['IP'].src\
+ or ether['IP'].dst != ether_repl['IP'].dst:
+ raise RuntimeError("IP address mismatch in mirrored "
+ "Tx IPv4 packet.")
+ if not ether.haslayer(ICMP):
+ raise RuntimeError("Mirrored Tx packet is not an ICMP packet.")
+ if ether['ICMP'].type != ether_repl['ICMP'].type: # 0=echo-reply
+ raise RuntimeError("ICMP packet type mismatch "
+ "in mirrored Tx packet.")
+ elif ptype == "ICMPv6":
+ if not ether.haslayer(IPv6):
+ raise RuntimeError("Mirrored Tx packet is not an IPv6 packet.")
+ if ether['IPv6'].src != ether_repl['IPv6'].src\
+ or ether['IPv6'].dst != ether_repl['IPv6'].dst:
+ raise RuntimeError("IP address mismatch in mirrored "
+ "Tx IPv6 packet.")
+ if ether[2].name != ether_repl[2].name:
+ raise RuntimeError("ICMPv6 message type mismatch "
+ "in mirrored Tx packet.")
+ print("Mirrored Tx packet check OK.\n")