#!/usr/bin/env python """ Script di test per verificare che l'invio UDP funzioni correttamente. Prova ad inviare alcuni pacchetti alle porte 55001 e 55002. """ import socket import time def test_udp_send(): """Testa l'invio di pacchetti UDP sulle porte di profiling.""" # Crea un socket UDP sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) test_data = b"TEST_PACKET_" + str(time.time()).encode("ascii") port_a = 55001 port_b = 55002 dest = "127.0.0.1" print(f"Tentativo di invio su {dest}:{port_a}") try: bytes_sent = sock.sendto(test_data, (dest, port_a)) print(f"✓ Inviati {bytes_sent} bytes alla porta {port_a}") except Exception as e: print(f"✗ ERRORE nell'invio alla porta {port_a}: {e}") import traceback traceback.print_exc() time.sleep(0.1) print(f"\nTentativo di invio su {dest}:{port_b}") try: bytes_sent = sock.sendto(test_data, (dest, port_b)) print(f"✓ Inviati {bytes_sent} bytes alla porta {port_b}") except Exception as e: print(f"✗ ERRORE nell'invio alla porta {port_b}: {e}") import traceback traceback.print_exc() sock.close() print( "\nTest completato. Controlla Wireshark per vedere se i pacchetti sono stati catturati." ) print("Filtro Wireshark suggerito: udp.port == 55001 || udp.port == 55002") if __name__ == "__main__": test_udp_send()