My friend, Robert, and I finished our big networks project about 2 weeks ago, and I just wanted to share the project. We were given Nokia N800s and told to write a P2P file sharing application in C. Awesome.
Phase 1: The Basics
We follow the specified protocol and write a program that lets N800s request lists of files and also request files from their neighbors. Neighbors are discovered by UDP broadcast packets that are sent every few seconds. All other communication – file list and file requests – are done over TCP. I’m leaving a lot of detail out such as port selection and protocol details, but the project was relatively simple and fun – lots of buffer/network code.
Phase 2: Routing
We build off of phase 1 and implement a link state routing mechanism. We also use Dijkstra’s algorithm to compute the shortest path between all nodes. We build a ping and ping reply feature to test our routing. Link state packets and ping packets are sent via UDP. This part of the project was long, hard, and awesome – tons of fun data structure/algorithm code.
Phase 3: Enhancements to Phase 1
We build a file search and request mechanism so N800s can ask their neighbors for a particular file instead of first viewing a list and then downloading. Neighbors queue requests that they can’t fulfill and send these queued requests to their neighbors. Files are downloaded automatically when a request is fulfilled. I can’t remember what network transport layer is used, but I’m pretty sure file requests and downloads were both sent over TCP. Again, a really fun phase.
This project was awesome. Robert and I probably spent at least 100 hours each in the labs, and we enjoyed most of it. The biggest pains were cross-compiling and running on the N800s and odd GCC behavior. If you’re a UW CSE student and plan to take networks (CSE 461), then try and take it with Arvind Krishnamurthy. Robert and I both have a few complaints about the class, but the project was tons of fun. We ended up writing around 4,000 lines of C code from scratch, including a generic hash map, list, set, and many-to-many table. Great project. I wanted to post the source code, but then I realized that I probably shouldn’t ;).