Denial of Service (DoS/DDoS) in Cybersecurity - Time & Space Complexity
When studying Denial of Service attacks, it's important to understand how the attack's impact grows as more requests are sent.
We want to know how the number of attack requests affects the system's workload and response time.
Analyze the time complexity of this simplified DoS attack simulation code.
for request in attack_requests:
if server.is_alive():
server.process(request)
else:
break
This code sends many requests to a server until it stops responding, simulating a DoS attack.
Look at what repeats in the code.
- Primary operation: Looping through each attack request and processing it.
- How many times: Once for each request until the server stops responding.
As the number of attack requests increases, the server tries to process each one until it fails.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | About 10 request processes |
| 100 | About 100 request processes |
| 1000 | About 1000 request processes |
Pattern observation: The number of operations grows directly with the number of requests sent.
Time Complexity: O(n)
This means the work done grows in a straight line as more attack requests are sent.
[X] Wrong: "The server processes all requests instantly, so time doesn't grow with more requests."
[OK] Correct: Each request takes some time and resources, so more requests mean more work and longer processing time.
Understanding how attack load grows helps you explain system limits and defense strategies clearly in interviews.
"What if the server could process multiple requests at the same time? How would that change the time complexity?"