Inspiration

We were thinking about what the biggest issues that a hypothetical lunar colony might face. We realized a few hours into the planning day that Earth-like Internet infrastructure on the lunar surface would be inconsistent at best (in Tranquility Base) and nonexistent at worst (most places outside Tranquility Base). Until humanity gets comfortable enough on the surface and builds reliable communication infrastructure, there needs to be a backup system.

What it does (& Who It's For)

We imagine basically every person on the moon using Moonlink. Lunar explorers would probably venture too far out to have Internet access, and coverage in Tranquility Base would be spotty and unreliable as well.

Eventually, we decided to create a fully decentralized, fault-tolerant mesh network, inspired by the original design of the Internet on Earth. The goal was to create a resilient messaging system for everyone on the Moon.

How we built it

Essentially, a node uses its copy of the nodes, their locations, and BFS pathfinding to pre-calculate a path to the destination node. If at any point the path is interrupted, the current node recalculates, or - if there's no way it can proceed forward - keeps the message for roughly 24 hours and retries periodically (the retries follow an exponential backoff).

Nodes attempt to connect to nodes in a 10km radius - our assumed limit for how far one transmission can reach. It verifies all its connections every 2 seconds (if a connected node doesn't reply in three consecutive pings, it's disconnected) and also searches for more in the radius based on its copy of the routing table. When two nodes meet, they also intelligently synchronize their routing tables using field-specific lastUpdated timestamps.

We built the local server (that handles all the connections on the device) with Golang and its TCP APIs (more on that later). The frontend was built with HTML, CSS, and JavaScript - the only stack we had enough time to use. We used TCP for communication between nodes, even though with our assumed transmission distances and presumed lack of infrastructure it wouldn't work very well. This is because we didn't have enough time in the 24hr duration to use radio communication instead (the alternative we think we'd use if Moonlink was deployed in production). We also hardcoded the locations and IPs of each node because all of them were running on the same device (for a demo). When we actually deploy it, these issues will be fixed.

Challenges we ran into

The TCP communications got really complicated around hour 15 and all of us were tired too. But we pushed through and managed to debug it before hour 17. We also discovered a bug with ephemeral ports while connections were being made and had to overhaul pretty much the entire server. CORS restrictions from our browser also made integrating the frontend and backend a nightmare. Other than those two, though, things were pretty smooth because of our smart delegation and teamwork.

Accomplishments that we're proud of

We're pretty proud of how Moonlink turned out, given the time constraints. The frontend is slick and pretty responsive, and the backend is surprisingly clean and consistent. I also personally got the chance to work on my first big project after learning a bunch of Go hacks, idioms, and best practices from Effective Go (by the Go team) and Go 101 by Tapir Liu. Overall, we as Team Moonlink feel pretty proud that we got a good PoC and demo working.

What we learned

  • How TCP works (both generally and how to use it in Go)
  • How to fix CORS errors safely
  • How the Internet works (for our inspiration)
  • Smart system design from some adults

What's next for Moonlink

  • All of the hardcoded values/methods will be made dynamic (esp. location with the setLocation() method)
  • The RouteTables will be organically generated from a Source node (not yet implemented)
  • Overall, the system also needs to be strengthened with stronger error handling
  • If we wanted to actually deploy it on the Moon, we'd also sync with radio transmitters/recievers

Built With

Share this project:

Updates