At any given time of the day or night, there are about 5,000 commercial airplanes in the sky over the U.S. That's not counting recreational aircraft or, heaven help us, drones. For some interactive visualizations of it all, check out the somewhat terrifying FlightRadar24 online tracker.

So what keeps all these airplanes from slamming into one another, all day every day? High technology and several million rules, as Trace Dominguez reports in today's DNews report.

The U.S. air traffic control system is a massively complex operation, in terms of both technology and raw logistics. To function properly, pilots and air traffic controllers must agree on and abide by a looong list of rules. For starters, each aircraft must file a flight plan with information on departure and arrival points, estimated flight time, passengers on board and alternate destinations in case of emergency.

With thousands of such flight plans rolling in on a continual basis, air traffic technicians rely on complex computer algorithms to figure out the safest and most efficient route for each and every aircraft. A minimum distance of 1,000 feet (305 meters) between aircraft is maintained at all times, to avoid unpleasantness. .

The airspace around airports is naturally the most crowded, in terms of three-dimensional real estate, so still more rules are applied there -- enforced by even more computers. Radar technology is thoroughly integrated at this point, so that the controllers (and their computers) can track the range and bearing of everything in the air.

In addition, a complementary system called secondary surveillance radar (SSR) is used for commercial airliners and many of the smaller private planes. SSR communicates directly with each airplane's transponder, relaying critical information like altitude and identification information.

Transponders can also be used so that aircraft can communicate with each other, which is nice when you're 30,000 feet over the Pacific and see another set of navigation lights dead ahead. Transponders can detect other transponders and alert pilots to make a course correction if anything seems amiss.

That's the basic gist on how airplanes avoid each other up in sky. If you're curious about how several hundred tons of metal gets up there in the first place, check out this here video on the interesting physics of lightweight metals.