Why Layer 2 (Ethernet frames)
The simulator uses Scapy’ssendp() with an Ether() wrapper instead of send(). This distinction matters on Windows:
sendp()at Layer 2 injects raw Ethernet frames through the Npcap driver. The sniffer sees these packets as if they arrived from the network.send()at Layer 3 routes packets through the Windows IP stack, which handles them internally. The Npcap-based sniffer never sees them.
Always use
simular_varios_ataques.py (Layer 2) for testing. The simpler simular_ataque.py also uses sendp() but only simulates a fixed 1,000-packet SYN flood (random ports from 203.0.113.50) — use the multi-attack version for selecting specific attack types.IP spoofing
Each simulation run generates randomized source IPs. This solves a subtle problem: once the IPS blocks an IP, it silently ignores all further packets from that address. If the simulator reused the same hardcoded attacker IP across runs, the IPS would appear to stop working — when in reality it was working correctly by dropping already-blocked traffic. Randomized IPs ensure every simulation run produces fresh, unblocked attacker addresses.How to run
Attack modes
The target IP for all modes is172.10.14.181, configured at the top of the script.
1. Port scan
Sends 999 TCP SYN packets to sequential ports (1–999) from a fixed spoofed IP. This mimics a classic reconnaissance sweep.PORT_SCAN_THRESHOLD = 10).
2. DDoS (distributed botnet)
Sends 1,500 TCP SYN packets to port 80, each from a different randomly generated source IP. This simulates a botnet where many machines attack simultaneously.THRESHOLD_DDOS = 500 — this mode sends three times that volume, producing a clear detection signal without triggering false positives from heavy legitimate traffic.
3. UDP flood
Sends 1,500 UDP packets from203.0.113.99 (an RFC 5737 documentation address) to random high ports. This simulates the kind of traffic used to saturate DNS resolvers or game servers.
THRESHOLD_UDP_FLOOD = 500 to avoid false positives from normal streaming or DNS traffic.
4. Exploit attempt
Sends 100 TCP SYN packets targeting the five most commonly exploited service ports, from a random IP in the192.168.100.x range.
| Port | Service |
|---|---|
| 21 | FTP |
| 22 | SSH |
| 23 | Telnet |
| 445 | SMB |
| 3389 | RDP |
Packet sending mechanism
All modes collect packets into a list and then flush them in batches of 100:What to observe after running
Check the events table
Open the IDS interface and look at the Tráfico en Vivo (live traffic) table. You should see new rows with the detected attack type and the ML confidence score, e.g.
(ML: 98.4%).Verify the IPS panel
Switch to the Respuesta Activa tab. The attacker IP should appear with status Bloqueado, severity level, and a live countdown timer showing time remaining on the block.
If an attack is not detected, confirm the IDS is running and monitoring the correct interface before re-running the simulator. The IDS must be active for the sniffer to process incoming packets.