Developers.NetMap

From Shareaza Wiki
Revision as of 20:09, 20 June 2009 by Kevogod (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

mapping out the key classes of the core of the peer-to-peer networking part of shareaza

so far, I totally understand CConnection - wraps a socket CNeighbour - adds compression ability, has a heap of member variables for every network

these are all the classes im going to try to put into one picture

CConnection

CNeighbour CNeighbours CNeighboursBase

CEDNeighbour CG1Neighbour CG2Neighbour

CHandshake CHandshakes CShakeNeighbour

CNeighboursWithConnect CNeighboursWithED2K CNeighboursWithG1 CNeighboursWithG2 CNeighboursWithRouting

This line of code in Neighbour.h shows how CNeighbour inherits from CConnection:

[code Neighbour.h] class CNeighbour : public CConnection </source>

CConnection is at the root of a large inheritance tree. CNeighbour and CHandshake inherit from it. Four more classes inherit from CNeighbour.

File:Neighbour.gif

Now I'll try to figure out what each of these classes represents, and what they do.

CConnection wraps the socket, m_hSocket, and has methods like OnRead and OnWrite to send data through it. It can monitor and limit bandwidth.

'CNeighbour inherits from CConnection. This means it picks up all of CConnections member variables and methods, and on top of that starts to add its own. It introduces many member variables which aren't used here, but must be used by objects further up the inheritance tree. It adds methods to compress the data going into the socket, and decompress the data coming out.

The remaining classes I haven't commented yet, so now I'm just looking at them and guessing.

CHandshake also inherits from CConnection, so it must need a socket itself. Methods there look at the very first few bytes a remote computer sends to determine what network it is browsing. Push appears a lot, this may be the Gnutella push packet. The OnConnected method gives the other computer our GUID.

CHandshakes isn't linked to any of these other classes through inheritance, but is closely related to CHandshake.

The next 4 classes inherit from CNeighbour and, through it, CConnection.

CShakeNeighbour is where the string GNUTELLA CONNECT/0.6\r\n resides. These methods are in charge of reading and understanding the handshakes for all the networks.

CG1Neighbour lists methods that send or receive one Gnutella packet each. These have names like SendPing and OnPing.

CG2Neighbour is the same, except here the packets are for Gnutella2.

CEDNeighbour is for eDonkey2000. I'm more familiar with Gnutella, but the methods here also seem to be communicating with the other computer, reading in packets and handling them, and sending out more.

I've already commented CConnection and CNeighbour. It looks like a logical next step would be to do CHandshake, CHandshakes, and CShakeNeighbour.

The other classes are organized like a totem pole. I'm not sure why the classes for Gnutella, Gnutella2, and eDonkey2000 inherit from one another. Shouldn't they be next to one another here, as they are above?

File:With.gif

These are the same diagrams as Developers.ClassDiagram. A note by ten9 there says that the classes in the line above are just building up strength - only the final one, CNeighbours, is actually used by Shareaza when it runs.