#include <Choker.h> [code]
Inherits Protocols::BitTorrent::Transfers::PacketProcessor.
Inheritance diagram for Protocols::BitTorrent::Transfers::Choker:


Implements the standard choking algorithm presented in the official BitTorrent specs: http://www.bittorrent.org/protocol.html
Supports:
Definition at line 78 of file Choker.h.
Public Member Functions | |
| Choker (Timer *, RandomNumberGenerator *, TransferManagerState *) | |
| Constructs a Choker object. | |
| ~Choker () | |
| Destructor. | |
| void | start () |
| Start the Choker - it will choke/unchoke sessions in a regular interval. | |
| void | stop () |
| Stop the Choker - it will no longer choke/unchoke sessions. | |
| void | chokingTime () |
| The handler that gets called for each choking/unchoking round. | |
| void | openedSession (TransferSession *) |
| Add a new session to the Choker. | |
| void | incomingPacket (TransferSession *, const Packet &) |
| We ignore all incoming packets. | |
| void | outgoingPacket (TransferSession *, const Packet &) |
| We ignore all outgoing packets. | |
| void | closedSession (TransferSession *) |
| When a connection is closed just remove if from the internal lists. | |
Private Types | |
| typedef QList< TransferSession * > | Sessions |
Private Member Functions | |
| CALITKO_TESTABLE | Choker (const Choker &) |
| Choker & | operator= (const Choker &) |
| void | doOptimisticUnchokingIfTimeHasCome () |
| Helper that does optimistic unchoking only if we have reached this round. | |
| Choker::Sessions | choseOptimisticlyUnchokedSessions () |
| Helper that selects a session to be our optimistic unchoke. | |
| void | sortSessionsForSelection () |
| Helper that sorts the session by putting the best peers first. | |
| void | reallocateUploadSlotsAndChokeUnchokeSessions () |
| Helper that unchokes best uploading peers and chokes the others. | |
| int | numberOfUploadSlots () const |
| Helper that returns the number of upload slots we have available. | |
Static Private Member Functions | |
| static void | chokeSessionIfNeeded (TransferSession *) |
| Helper that send a Choke packet only if peer is currently unchoked. | |
| static void | unchokeSessionIfNeeded (TransferSession *) |
| Helper that send an Unchoke packet only if peer is currently choked. | |
| static bool | moreDownloadedAndMoreInterested (const TransferSession *, const TransferSession *) |
| MoreThan comparison helper. | |
| static bool | moreUploadedAndMoreInterested (const TransferSession *, const TransferSession *) |
| MoreThan comparison helper. | |
Private Attributes | |
| Timer * | timer |
| RandomNumberGenerator * | randomNumberGenerator |
| TransferManagerState * | transferManagerState |
| Sessions | sessions |
| Sessions | newSessions |
| Sessions | optimisticlyUnchokedSessions |
| int | optimisticChokingCounter |
Static Private Attributes | |
| static const int | UploadSlotsCount = 4 |
| static const int | OptimisticChokingRate = 3 |
| static const int | ChokingTimeout = 10000 |
| static const Choke | choke |
| static const Unchoke | unchoke |
|
|
|
|
|
|
|
||||||||||||||||
|
Constructs a Choker object.
Definition at line 33 of file Choker.cpp. |
|
|
Destructor.
Definition at line 44 of file Choker.cpp. |
|
|
Helper that send a Choke packet only if peer is currently unchoked.
Definition at line 244 of file Choker.cpp. |
|
|
The handler that gets called for each choking/unchoking round.
Definition at line 94 of file Choker.cpp. |
|
|
Helper that selects a session to be our optimistic unchoke. Randomly selects one of the choked sessions to become the next optimistic unchoke. New connections (since the last optimistic choke) are given three times bigger chance to get elected.
Definition at line 141 of file Choker.cpp. |
|
|
When a connection is closed just remove if from the internal lists.
Implements Protocols::BitTorrent::Transfers::PacketProcessor. Definition at line 87 of file Choker.cpp. |
|
|
Helper that does optimistic unchoking only if we have reached this round.
Definition at line 110 of file Choker.cpp. |
|
||||||||||||
|
We ignore all incoming packets.
Implements Protocols::BitTorrent::Transfers::PacketProcessor. Definition at line 70 of file Choker.cpp. |
|
||||||||||||
|
MoreThan comparison helper.
Definition at line 267 of file Choker.cpp. |
|
||||||||||||
|
MoreThan comparison helper.
Definition at line 291 of file Choker.cpp. |
|
|
Helper that returns the number of upload slots we have available.
Definition at line 232 of file Choker.cpp. |
|
|
Add a new session to the Choker.
Implements Protocols::BitTorrent::Transfers::PacketProcessor. Definition at line 63 of file Choker.cpp. |
|
|
|
|
||||||||||||
|
We ignore all outgoing packets.
Implements Protocols::BitTorrent::Transfers::PacketProcessor. Definition at line 76 of file Choker.cpp. |
|
|
Helper that unchokes best uploading peers and chokes the others.
Definition at line 207 of file Choker.cpp. |
|
|
Helper that sorts the session by putting the best peers first. Best peers are the peers that we download most from. If two peers upload the same ammount to us then a better one is the one that is interested in downloading from us.
Definition at line 185 of file Choker.cpp. |
|
|
Start the Choker - it will choke/unchoke sessions in a regular interval.
Definition at line 49 of file Choker.cpp. |
|
|
Stop the Choker - it will no longer choke/unchoke sessions.
Definition at line 57 of file Choker.cpp. |
|
|
Helper that send an Unchoke packet only if peer is currently choked.
Definition at line 251 of file Choker.cpp. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|