DoS and DDoS attacks in Computer Networks - Time & Space Complexity
When studying DoS and DDoS attacks, it's important to understand how the attack effort grows as more requests are sent.
We want to know how the number of attack requests affects the load on the target system.
Analyze the time complexity of this simplified attack simulation:
for request in attack_requests:
send request to target_server
wait for response or timeout
log result
This code sends many attack requests one after another to overload the target server.
Look at what repeats as the attack grows:
- Primary operation: Sending each attack request to the server.
- How many times: Once for every request in the attack list.
As the number of attack requests increases, the total operations increase at the same rate.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 requests sent |
| 100 | 100 requests sent |
| 1000 | 1000 requests sent |
Pattern observation: Doubling the requests doubles the work done.
Time Complexity: O(n)
This means the effort grows directly in proportion to the number of attack requests.
[X] Wrong: "Sending more requests will only slightly increase the load because servers handle many requests easily."
[OK] Correct: Each request adds work for the server, so more requests linearly increase the load and can overwhelm it.
Understanding how attack load grows helps you explain system limits and defenses clearly in interviews.
"What if the attack sends requests in parallel instead of one by one? How would the time complexity change?"
Practice
DoS attack and a DDoS attack?Solution
Step 1: Understand DoS attack
A DoS (Denial of Service) attack involves a single attacker trying to overload a system to make it unavailable.Step 2: Understand DDoS attack
A DDoS (Distributed Denial of Service) attack involves many attackers working together to overload the system.Final Answer:
DoS uses one attacker; DDoS uses many attackers. -> Option CQuick Check:
DoS = single attacker, DDoS = multiple attackers [OK]
- Thinking DoS and DDoS differ by target type
- Confusing legality of attacks
- Believing DoS uses viruses
Solution
Step 1: Identify DDoS attack behavior
DDoS attacks involve many computers sending requests at the same time to overload a server.Step 2: Eliminate incorrect options
A single computer sends many requests to a server. describes a DoS attack, not distributed. Options C and D do not describe attacks.Final Answer:
Multiple computers send requests to a server simultaneously. -> Option AQuick Check:
DDoS = many computers attacking together [OK]
- Confusing single computer attack with DDoS
- Thinking server sends requests in DDoS
- Mixing accidental overload with attack
Solution
Step 1: Analyze request sources
One IP sending 1000 requests per second suggests a DoS attack. Multiple IPs sending 10,000 requests per second suggests a DDoS attack.Step 2: Identify attack type
Since 100 different IPs are involved, this matches the definition of a DDoS attack.Final Answer:
DDoS attack from multiple IP addresses -> Option BQuick Check:
Multiple IPs attacking = DDoS [OK]
- Choosing DoS for multiple IPs
- Confusing phishing with DoS/DDoS
- Assuming normal traffic causes overload
Solution
Step 1: Check attack source IPs
DDoS attacks involve many IPs; only one IP means it is a DoS attack.Step 2: Confirm attack type
Since only one IP floods the server, the problem is a DoS attack, not DDoS.Final Answer:
The attack is actually a DoS, not DDoS. -> Option DQuick Check:
One IP flooding = DoS, not DDoS [OK]
- Assuming single IP means DDoS
- Ignoring hardware failure possibility
- Confusing phishing with DoS/DDoS
Solution
Step 1: Identify effective DDoS defenses
Firewalls can block unwanted traffic, traffic filtering can limit suspicious requests, and CDNs distribute traffic to reduce overload.Step 2: Evaluate other options
Antivirus alone does not stop DDoS. Disabling the site is not practical. Password strength helps security but not DDoS protection alone.Final Answer:
Use a firewall, deploy traffic filtering, and employ a content delivery network (CDN). -> Option AQuick Check:
Multiple layered defenses best protect against DDoS [OK]
- Relying only on antivirus
- Thinking disabling site stops attacks
- Ignoring network traffic controls
Ready to prove it?
Pass the test and this pattern moves unknown
