Distributed Denial of Service (DDoS) attack is one of the most disruptive attacks in computer networks. It utilizes legitimate requests from hundreds or thousands of computers to specific targets to occupy targets' bandwidth and deplete targets' resource. In this work, we have attempted to not only mitigate DDoS attacks but also identify the source of attacks even behind Network Address Translation (NAT). This is followed by remedial actions such as denying further access or informing them that they have participated in the attacks. This report presents a new algorithm to prevent servers from DDoS attacks. This algorithm requires that network routers or gateways collaborate with each other in order to detect suspicious traffic. The algorithm initiates a peer-to-peer communication among network routers or gateways to increase the probability of detecting unwanted traffic. We derive mathematical proofs based on cryptographic concepts such as birthday attacks to estimate the rate of attacks generated and passed along the routers. This implementation is to prevent the attacker from sending spam traffic to the server which can lead to DDoS attacks. The effectiveness of our implementation is evidenced in our experimental results.