import socket, struct def icmp_checksum(data): s = 0 for i in range(0, len(data), 2): w = (data[i] << 8) + (data[i+1] if i+1 < len(data) else 0) s += w s = (s >> 16) + (s & 0xffff) s += (s >> 16) return ~s & 0xffff def icmp_ping(ip, timeout=0.3): try: sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP) sock.settimeout(timeout) hdr = struct.pack("bbHHh", 8, 0, 0, 1, 1) cs = icmp_checksum(hdr + b"X") hdr = struct.pack("bbHHh", 8, 0, cs, 1, 1) sock.sendto(hdr + b"X", (ip, 1)) sock.recv(1024) return True except: return False finally: try: sock.close() except: pass # Scan the pod subnet live = [] for i in range(1, 255): ip = f"10.112.184.{i}" if icmp_ping(ip): live.append(ip) print("LIVE:", live)