These days, everyone wants to get in on the drone game. Amazon and Google have both announced their intentions to deliver packages by drone. They’re already being used to find missing people and map out areas hit by a natural disaster. One day, they may be used to transport emergency supplies to people who need them but can’t be reached.

This is all pretty cool. But it’s also a bit of a problem. Criminals and terrorists are also figuring out how to use the technology for their own gains. People are using them to drop drugs into prisons. And drones carrying high-tech camera and audio equipment raise big questions about personal privacy. (Shooting down drones, even if they are flying over your property, is not recommended.)

The future of package delivery.

Enter NASA. The agency is working on a traffic management system for drones that is supposed to deal with a lot of these potential problems. If anyone is up to the challenge, it’s them.

“In 1956 when two aircraft collided over the Grand Canyon, that’s what started air traffic management,” says NASA’s Parimal Kopardekar, who’s in charge of the project. “What we’re trying to do is avoid that history. We learn from history and make sure we have a system in place to safely enable these operations.”

The drone airspace is going to get crowded.

Kopardekar compares a drone traffic management system to road infrastructure like lanes, traffic lights, and signs. Sure, Google, can build a self-driving car, but it would be lost without this information about where it can and can’t go, and how to get around.

This is not so much applicable to you in your backyard or neighborhood field flying a drone around for fun or to take some pictures. If you do stuff like that in airspace reserved for recreational flying and the drone stays within your sight, the potential for traffic conflicts is pretty low. The bigger problem comes when commercial operations are sending unmanned flights through shared airspace, with no way of knowing what else is up there.

For that reason, part of the system would involve a way for commercial fliers to log in and pre-program their drone trajectories. If you imagine all of Amazon and Google’s drones buzzing over Los Angeles, say, you could imagine there being some issues if there wasn’t a way to reserve a piece of the airspace for your particular drone.

“If I commit to my costumers a delivery in 30 minutes, am I sure that if I put out a trajectory, that trajectory will get me there?” asks Kopardekar.

Logging their flights in advance is in the own best interest of commercial operators, since it provides some security for their drone and their interests, he says. Weather data and no-fly-zones would be automatically integrated into the system.

Then there’s the issue of tracking. Once the flights are logged, how do you ensure they’re going where they are supposed to? There are two kinds of issues that might come up, says Kopardekar. Either drones that are flying legitimately could lose their bearings and go astray, or there could be rogue drones with nefarious intentions.

There are a few ways to deal with the safety threats posed by this, too. Cellphone towers or satellites could be used to keep track of where the drones are. If a drone has gone astray, it may be possible in some cases to reach the operator and get it back on track, says Kopardekar. If not, depending on the security risk, it may be necessary to take it out.

Areas of a high-security risk would have “geofences” built around them. These could be permanent (e.g. an airport or the White House) or temporary (e.g. a forest fire or crime scene). What is required here are sensors to detect if any drone has breached the barrier, and depending on the security risk, some way of stopping rogue drones. (One company is already selling rifles designed specifically to take down drones. We imagine the White House’s system will be a little more high-tech.)

NASA is not planing to roll out all of this at once. The first step is to get a system in place so operators can reserve a piece of airspace for a flight. By late next year, there could be the potential for commercial flights beyond the line-of-sight of the operator. Tracking systems and management in high-risk, high-density areas are still a couple years out.

NASA plans to hand the system over to the Federal Aviation Administration in 2019. It’s also in discussions with other governments and agencies internationally on setting up similar systems in other parts of the world.

How crowded will the drone airspace get? “What we are postulating is that demand is going to be really high for these low-altitudes,” says Kopardekar.