The document describes a proposed mechanism for early detection and prevention of distributed denial of service (DDoS) attacks using software-defined networking (SDN). The mechanism uses an SDN controller and Mininet network simulator. It calculates entropy values from network traffic to identify anomalous patterns indicating potential DDoS attacks. Once detected, the SDN controller dynamically reconfigures network paths to divert malicious traffic away from the target. The mechanism is evaluated using statistical metrics and shows superior performance over existing methods in detection rate, false positives, and response time. It provides a practical solution for safeguarding network services against DDoS attacks.