Rasputin was my attempt at creating a Gnutella client using C#. Please excuse my ramblings below as I try to conceptualize my design for this application.
Identification of essential components that make up Rasputin:
- Peer - describes a basic Gnutella peer. Two types of Peers - LocalPeer and RemotePeer. A Peer contains contact information, the time of most recent communication with the peer, the number and size of shared files, and also stores the known abilities of the peer (eg. which protocol it supports). RemotePeer and LocalPeer also have a certain amount of intelligence and packet filtering ability so they reduce the workload on Router.
- Router - the "brain" behind Rasputin. It receives incoming messages (packets), determines what to do with them according to the Gnutella protocol, and dispatches or forwards messages accordingly.
- Gatekeeper - monitors the Gnutella port for any new incoming connections. Upon verification, Gatekeeper then constructs a Connection object and passes it to Router for handling.
- Connection - maintains a single connection with a Gnutella peer. It buffers incoming and outgoing messages and autonomously controls the bandwidth used by prioritizing packets and preventing floods. The incoming buffer is popped and the outgoing buffer is pushed by Router.
- Packet - describes a generic Gnutella packet, which is used by peers to communicate. There are six types of packets defined by the protocol - Ping, Pong, Query, QueryHits, Push, and Bye.
- HttpHeader - describes a generic Gnutella HTTP connection string, which is used for handshaking during the establishment of new connections.
[Click to download the latest source code] (ZIP, 139KB)
I shall post appropriate documentation for the Rasputin engine once I get time to transcribe it from my written notes and diagrams. In the mean time, here are some interesting links: