A component cannot prevent a DOS or DDOS attack.
Actually it is a good practice to make a separation of concerns. You website (or let us call it web application) has the role of providing business value to your customers.
At another level, a web application firewall (WAF) and/or intrusion detection system (IDS), is another system in your network infrastructure responsible for such security aspects.
PHP should not have to deal with such things. It is not really the best tool.
If you are on a low budget look into a hoster that already provides such a protection. Some of them do this already (for example Siteground). Or you may want to have a look at what www.cloudflare.com has to offer for free.
Be sure to check out the presentation from Tony Perez at the Joomla World Conference 2015.