2006-09-19 14:52:59 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
2006-09-21 15:31:24 +00:00
|
|
|
* aria2 - The high speed download utility
|
2006-09-19 14:52:59 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-09-21 15:31:24 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
2006-09-19 14:52:59 +00:00
|
|
|
*/
|
|
|
|
/* copyright --> */
|
|
|
|
#ifndef _D_PEER_STAT_H_
|
|
|
|
#define _D_PEER_STAT_H_
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "SpeedCalc.h"
|
|
|
|
#include "SharedHandle.h"
|
2008-08-04 17:06:47 +00:00
|
|
|
#include <string>
|
2006-09-19 14:52:59 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2006-09-19 14:52:59 +00:00
|
|
|
class PeerStat {
|
|
|
|
public:
|
|
|
|
enum STATUS {
|
|
|
|
IDLE,
|
2006-09-21 06:56:54 +00:00
|
|
|
ACTIVE,
|
|
|
|
REQUEST_IDLE,
|
2006-09-19 14:52:59 +00:00
|
|
|
};
|
|
|
|
private:
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t cuid;
|
2008-08-04 17:06:47 +00:00
|
|
|
std::string _hostname;
|
|
|
|
std::string _protocol;
|
2006-09-19 14:52:59 +00:00
|
|
|
SpeedCalc downloadSpeed;
|
* src/PeerChokeCommand.cc
(optUnchokingPeer): Updated according to the changes in Peer.
(ResetDelta): Removed.
(UploadFaster): Updated according to the changes in Peer.
(DownloadFaster): Updated according to the changes in Peer.
(execute): I clarify the meaning of "upload" and "download"
here.
"upload" means the transfer from localhost to remote host.
"download" means the transfer from remote host to localhost.
Based on this rule, I swapped orderByUploadRate and
orderByDownloadRate.
* src/PeerInteractionCommand.cc
(PeerInteraction): Removed peerInteraction->setUploadLImit().
(executeInternal): Removed the argument of
peerInteraction->sendMessages().
(receiveMessages): Rewritten download speed limit.
(sendKeepAlive): Removed peerInteraction->sendMessages().
* src/HttpResponseCommand.cc
(handleDefaultEncoding): If file size is unknown in torrent
request,
do not call segmentMan->initBitfield() here.
Disabled persistent connection feature in torrent request.
* src/UrlRequestInfo.h
(UrlRequestInfo): Removed const qualifier from option.
* src/TorrentMan.h
(TransferStat): New class.
(deltaDownloadLength): Removed.
(deltaUploadLength): Removed.
(addDeltaDownloadLength): Removed.
(getDeltaDownloadLength): Removed.
(resetDeltaDownloadLength): Removed.
(addDeltaUploadLength): Removed.
(getDeltaUploadLength): Removed.
(resetDeltaUploadLength): Removed.
(addActivePeer): Added peer->activate().
(deleteActivePeer): Added peer->deactivate().
(calculateStat): New function.
* src/TorrentMan.cc
(TorrentMan): Removed deltaDownloadLength and deltaUploadLength.
(calculateStat): New function.
* src/PeerInteraction.h
(uploadLimit): Removed.
(option): New variable.
(setUploadLimit): Removed.
(getUploadSpeed): Removed.
(sendMessages): Removed the argument "currentUploadSpeed".
* src/PeerInteraction.cc
(prefs.h): Included.
(PeerInteraction): Removed uploadLimit. Added option.
(sendMessages): Rewritten upload speed limit.
(sendHandshake): Removed the argument from sendMessages().
(sendBitfield): Removed the argument from sendMessages().
* src/PeerAbstractCommand.cc
(execute): Commented out the portion of upload limit.
(onAbort): Removed peer->resetStatus().
* src/TorrentRequestInfo.cc
(timeoutSpecified): Declared extern.
(execute): Set timeout to 180 if timeout is not specified by.
command-line.
* src/PieceMessage.cc
(receivedAction): Added peer->updateDownloadLength().
Removed peer->addPeerUpload().
Removed torrentMan->addDeltaDownloadLength().
(send): Added peer->updateUploadLength().
Removed peer->addPeerDownload().
Removed torrentMan->addDeltaUploadLength().
* src/main.cc
(timeoutSpecified): New variable.
(main): Set timeoutSpecified to false.
If the command-line option "--upload-limit" is specified, then
timeoutSpecified is set to true. This option will remain in the
next
release, but be deprecated in the future release.
* src/TorrentRequestInfo.h
(TorrentRequestInfo): Removed const qualifier from op.
* src/PeerStat.h
(uploadSpeed): New variable.
(PeerStat): Added default value to cuid.
(calculateUploadSpeed): New function.
(updateUploadLength): New function.
(getMaxUploadSpeed): New function.
(getAvgUploadSpeed): New function.
(reset): Added uploadSpeed. Set status to IDLE.
* src/TorrentDownloadEngine.h
(cp): Declared as Time.
(sessionDownloadLengthArray): Removed.
(sessionUploadLengthArray): Removed.
(currentCp): Removed.
(lastCalcStat): New variable
(lastElapsed): Removed.
(sessionDownloadLength): Removed.
(calculateStat): New function.
* src/TorrentDownloadEngine.cc
(initStatistics): Removed lastElapsed, cp[],
sessionDownloadLengthArray[], sessionUploadLengthArray[],
currentCp, sessionDownloadLength.
Added cp.reset() and lastCalcStat.reset().
(calculateSpeed): Changed the name of the argument.
(calculateStatistics): Rewritten.
(calculateStat): New function.
* src/Peer.h
(PeerStat.h): Included.
(peerUpload): Removed.
(peerDownload): Removed.
(peerStat): New variable.
(sessionUploadLength): New variable.
(sessionDownloadLength): New variable.
(deltaUpload): Removed.
(deltaDownload): Removed.
(resetStatus): Made private.
(Peer): Added sessionUploadLength, sessionDownloadLength.
Removed peerUpload, peerDownload.
(updateUploadLength): New function.
(addDeltaUpload): Removed.
(updateDownloadLength): New function.
(resetDeltaUpload): Removed.
(getDeltaUpload): Removed.
(addDeltaDownload): Removed.
(calculateUploadSpeed): New function.
(resetDeltaDownload): Removed.
(getDeltaDownload): Removed.
(calculateDownloadSpeed): New function.
(getSessionUploadLength): New function.
(getSessionDownloadLength): New function.
(activate): New function.
(deactivate): New function.
(addPeerUpload): Removed.
(setPeerUpload): Removed.
(getPeerUpload): Removed.
(addPeerDownload): Removed.
(setPeerDownload): Removed.
(getPeerDownload): Removed.
* src/Peer.cc
(resetStatus): Removed resetDeltaUpload() and
resetDeltaDownload().
* src/MetalinkRequestInfo.h
(MetalinkRequestInfo): Removed const qualifier from op.
* src/RequestInfo.h
(op): Removed const qualifier.
(RequestInfo): Removed const qualifier from op.
2006-09-21 13:49:06 +00:00
|
|
|
SpeedCalc uploadSpeed;
|
2006-09-19 14:52:59 +00:00
|
|
|
Time downloadStartTime;
|
2006-11-08 16:25:38 +00:00
|
|
|
PeerStat::STATUS status;
|
2008-07-20 07:41:33 +00:00
|
|
|
unsigned int _avgDownloadSpeed;
|
|
|
|
unsigned int _avgUploadSpeed;
|
2006-09-19 14:52:59 +00:00
|
|
|
public:
|
|
|
|
|
2008-08-04 17:06:47 +00:00
|
|
|
PeerStat(int32_t cuid, const std::string& hostname,
|
|
|
|
const::std::string& protocol):
|
|
|
|
cuid(cuid),
|
|
|
|
_hostname(hostname),
|
|
|
|
_protocol(protocol),
|
|
|
|
status(PeerStat::IDLE),
|
|
|
|
_avgDownloadSpeed(0),
|
|
|
|
_avgUploadSpeed(0) {}
|
|
|
|
|
2008-07-20 07:41:33 +00:00
|
|
|
PeerStat(int32_t cuid = 0):cuid(cuid), status(PeerStat::IDLE),
|
|
|
|
_avgDownloadSpeed(0),
|
|
|
|
_avgUploadSpeed(0) {}
|
2006-09-19 14:52:59 +00:00
|
|
|
|
|
|
|
~PeerStat() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns current download speed in byte per sec.
|
|
|
|
*/
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int calculateDownloadSpeed() {
|
2006-09-19 14:52:59 +00:00
|
|
|
return downloadSpeed.calculateSpeed();
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int calculateDownloadSpeed(const struct timeval& now) {
|
2007-06-20 14:43:34 +00:00
|
|
|
return downloadSpeed.calculateSpeed(now);
|
|
|
|
}
|
|
|
|
|
2008-07-20 07:41:33 +00:00
|
|
|
unsigned int calculateAvgDownloadSpeed() {
|
|
|
|
_avgDownloadSpeed = downloadSpeed.calculateAvgSpeed();
|
|
|
|
return _avgDownloadSpeed;
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int calculateUploadSpeed() {
|
* src/PeerChokeCommand.cc
(optUnchokingPeer): Updated according to the changes in Peer.
(ResetDelta): Removed.
(UploadFaster): Updated according to the changes in Peer.
(DownloadFaster): Updated according to the changes in Peer.
(execute): I clarify the meaning of "upload" and "download"
here.
"upload" means the transfer from localhost to remote host.
"download" means the transfer from remote host to localhost.
Based on this rule, I swapped orderByUploadRate and
orderByDownloadRate.
* src/PeerInteractionCommand.cc
(PeerInteraction): Removed peerInteraction->setUploadLImit().
(executeInternal): Removed the argument of
peerInteraction->sendMessages().
(receiveMessages): Rewritten download speed limit.
(sendKeepAlive): Removed peerInteraction->sendMessages().
* src/HttpResponseCommand.cc
(handleDefaultEncoding): If file size is unknown in torrent
request,
do not call segmentMan->initBitfield() here.
Disabled persistent connection feature in torrent request.
* src/UrlRequestInfo.h
(UrlRequestInfo): Removed const qualifier from option.
* src/TorrentMan.h
(TransferStat): New class.
(deltaDownloadLength): Removed.
(deltaUploadLength): Removed.
(addDeltaDownloadLength): Removed.
(getDeltaDownloadLength): Removed.
(resetDeltaDownloadLength): Removed.
(addDeltaUploadLength): Removed.
(getDeltaUploadLength): Removed.
(resetDeltaUploadLength): Removed.
(addActivePeer): Added peer->activate().
(deleteActivePeer): Added peer->deactivate().
(calculateStat): New function.
* src/TorrentMan.cc
(TorrentMan): Removed deltaDownloadLength and deltaUploadLength.
(calculateStat): New function.
* src/PeerInteraction.h
(uploadLimit): Removed.
(option): New variable.
(setUploadLimit): Removed.
(getUploadSpeed): Removed.
(sendMessages): Removed the argument "currentUploadSpeed".
* src/PeerInteraction.cc
(prefs.h): Included.
(PeerInteraction): Removed uploadLimit. Added option.
(sendMessages): Rewritten upload speed limit.
(sendHandshake): Removed the argument from sendMessages().
(sendBitfield): Removed the argument from sendMessages().
* src/PeerAbstractCommand.cc
(execute): Commented out the portion of upload limit.
(onAbort): Removed peer->resetStatus().
* src/TorrentRequestInfo.cc
(timeoutSpecified): Declared extern.
(execute): Set timeout to 180 if timeout is not specified by.
command-line.
* src/PieceMessage.cc
(receivedAction): Added peer->updateDownloadLength().
Removed peer->addPeerUpload().
Removed torrentMan->addDeltaDownloadLength().
(send): Added peer->updateUploadLength().
Removed peer->addPeerDownload().
Removed torrentMan->addDeltaUploadLength().
* src/main.cc
(timeoutSpecified): New variable.
(main): Set timeoutSpecified to false.
If the command-line option "--upload-limit" is specified, then
timeoutSpecified is set to true. This option will remain in the
next
release, but be deprecated in the future release.
* src/TorrentRequestInfo.h
(TorrentRequestInfo): Removed const qualifier from op.
* src/PeerStat.h
(uploadSpeed): New variable.
(PeerStat): Added default value to cuid.
(calculateUploadSpeed): New function.
(updateUploadLength): New function.
(getMaxUploadSpeed): New function.
(getAvgUploadSpeed): New function.
(reset): Added uploadSpeed. Set status to IDLE.
* src/TorrentDownloadEngine.h
(cp): Declared as Time.
(sessionDownloadLengthArray): Removed.
(sessionUploadLengthArray): Removed.
(currentCp): Removed.
(lastCalcStat): New variable
(lastElapsed): Removed.
(sessionDownloadLength): Removed.
(calculateStat): New function.
* src/TorrentDownloadEngine.cc
(initStatistics): Removed lastElapsed, cp[],
sessionDownloadLengthArray[], sessionUploadLengthArray[],
currentCp, sessionDownloadLength.
Added cp.reset() and lastCalcStat.reset().
(calculateSpeed): Changed the name of the argument.
(calculateStatistics): Rewritten.
(calculateStat): New function.
* src/Peer.h
(PeerStat.h): Included.
(peerUpload): Removed.
(peerDownload): Removed.
(peerStat): New variable.
(sessionUploadLength): New variable.
(sessionDownloadLength): New variable.
(deltaUpload): Removed.
(deltaDownload): Removed.
(resetStatus): Made private.
(Peer): Added sessionUploadLength, sessionDownloadLength.
Removed peerUpload, peerDownload.
(updateUploadLength): New function.
(addDeltaUpload): Removed.
(updateDownloadLength): New function.
(resetDeltaUpload): Removed.
(getDeltaUpload): Removed.
(addDeltaDownload): Removed.
(calculateUploadSpeed): New function.
(resetDeltaDownload): Removed.
(getDeltaDownload): Removed.
(calculateDownloadSpeed): New function.
(getSessionUploadLength): New function.
(getSessionDownloadLength): New function.
(activate): New function.
(deactivate): New function.
(addPeerUpload): Removed.
(setPeerUpload): Removed.
(getPeerUpload): Removed.
(addPeerDownload): Removed.
(setPeerDownload): Removed.
(getPeerDownload): Removed.
* src/Peer.cc
(resetStatus): Removed resetDeltaUpload() and
resetDeltaDownload().
* src/MetalinkRequestInfo.h
(MetalinkRequestInfo): Removed const qualifier from op.
* src/RequestInfo.h
(op): Removed const qualifier.
(RequestInfo): Removed const qualifier from op.
2006-09-21 13:49:06 +00:00
|
|
|
return uploadSpeed.calculateSpeed();
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int calculateUploadSpeed(const struct timeval& now) {
|
2007-06-20 14:43:34 +00:00
|
|
|
return uploadSpeed.calculateSpeed(now);
|
|
|
|
}
|
|
|
|
|
2008-07-20 07:41:33 +00:00
|
|
|
unsigned int calculateAvgUploadSpeed() {
|
|
|
|
_avgUploadSpeed = uploadSpeed.calculateAvgSpeed();
|
|
|
|
return _avgUploadSpeed;
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
void updateDownloadLength(size_t bytes) {
|
2006-09-19 14:52:59 +00:00
|
|
|
downloadSpeed.update(bytes);
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
void updateUploadLength(size_t bytes) {
|
* src/PeerChokeCommand.cc
(optUnchokingPeer): Updated according to the changes in Peer.
(ResetDelta): Removed.
(UploadFaster): Updated according to the changes in Peer.
(DownloadFaster): Updated according to the changes in Peer.
(execute): I clarify the meaning of "upload" and "download"
here.
"upload" means the transfer from localhost to remote host.
"download" means the transfer from remote host to localhost.
Based on this rule, I swapped orderByUploadRate and
orderByDownloadRate.
* src/PeerInteractionCommand.cc
(PeerInteraction): Removed peerInteraction->setUploadLImit().
(executeInternal): Removed the argument of
peerInteraction->sendMessages().
(receiveMessages): Rewritten download speed limit.
(sendKeepAlive): Removed peerInteraction->sendMessages().
* src/HttpResponseCommand.cc
(handleDefaultEncoding): If file size is unknown in torrent
request,
do not call segmentMan->initBitfield() here.
Disabled persistent connection feature in torrent request.
* src/UrlRequestInfo.h
(UrlRequestInfo): Removed const qualifier from option.
* src/TorrentMan.h
(TransferStat): New class.
(deltaDownloadLength): Removed.
(deltaUploadLength): Removed.
(addDeltaDownloadLength): Removed.
(getDeltaDownloadLength): Removed.
(resetDeltaDownloadLength): Removed.
(addDeltaUploadLength): Removed.
(getDeltaUploadLength): Removed.
(resetDeltaUploadLength): Removed.
(addActivePeer): Added peer->activate().
(deleteActivePeer): Added peer->deactivate().
(calculateStat): New function.
* src/TorrentMan.cc
(TorrentMan): Removed deltaDownloadLength and deltaUploadLength.
(calculateStat): New function.
* src/PeerInteraction.h
(uploadLimit): Removed.
(option): New variable.
(setUploadLimit): Removed.
(getUploadSpeed): Removed.
(sendMessages): Removed the argument "currentUploadSpeed".
* src/PeerInteraction.cc
(prefs.h): Included.
(PeerInteraction): Removed uploadLimit. Added option.
(sendMessages): Rewritten upload speed limit.
(sendHandshake): Removed the argument from sendMessages().
(sendBitfield): Removed the argument from sendMessages().
* src/PeerAbstractCommand.cc
(execute): Commented out the portion of upload limit.
(onAbort): Removed peer->resetStatus().
* src/TorrentRequestInfo.cc
(timeoutSpecified): Declared extern.
(execute): Set timeout to 180 if timeout is not specified by.
command-line.
* src/PieceMessage.cc
(receivedAction): Added peer->updateDownloadLength().
Removed peer->addPeerUpload().
Removed torrentMan->addDeltaDownloadLength().
(send): Added peer->updateUploadLength().
Removed peer->addPeerDownload().
Removed torrentMan->addDeltaUploadLength().
* src/main.cc
(timeoutSpecified): New variable.
(main): Set timeoutSpecified to false.
If the command-line option "--upload-limit" is specified, then
timeoutSpecified is set to true. This option will remain in the
next
release, but be deprecated in the future release.
* src/TorrentRequestInfo.h
(TorrentRequestInfo): Removed const qualifier from op.
* src/PeerStat.h
(uploadSpeed): New variable.
(PeerStat): Added default value to cuid.
(calculateUploadSpeed): New function.
(updateUploadLength): New function.
(getMaxUploadSpeed): New function.
(getAvgUploadSpeed): New function.
(reset): Added uploadSpeed. Set status to IDLE.
* src/TorrentDownloadEngine.h
(cp): Declared as Time.
(sessionDownloadLengthArray): Removed.
(sessionUploadLengthArray): Removed.
(currentCp): Removed.
(lastCalcStat): New variable
(lastElapsed): Removed.
(sessionDownloadLength): Removed.
(calculateStat): New function.
* src/TorrentDownloadEngine.cc
(initStatistics): Removed lastElapsed, cp[],
sessionDownloadLengthArray[], sessionUploadLengthArray[],
currentCp, sessionDownloadLength.
Added cp.reset() and lastCalcStat.reset().
(calculateSpeed): Changed the name of the argument.
(calculateStatistics): Rewritten.
(calculateStat): New function.
* src/Peer.h
(PeerStat.h): Included.
(peerUpload): Removed.
(peerDownload): Removed.
(peerStat): New variable.
(sessionUploadLength): New variable.
(sessionDownloadLength): New variable.
(deltaUpload): Removed.
(deltaDownload): Removed.
(resetStatus): Made private.
(Peer): Added sessionUploadLength, sessionDownloadLength.
Removed peerUpload, peerDownload.
(updateUploadLength): New function.
(addDeltaUpload): Removed.
(updateDownloadLength): New function.
(resetDeltaUpload): Removed.
(getDeltaUpload): Removed.
(addDeltaDownload): Removed.
(calculateUploadSpeed): New function.
(resetDeltaDownload): Removed.
(getDeltaDownload): Removed.
(calculateDownloadSpeed): New function.
(getSessionUploadLength): New function.
(getSessionDownloadLength): New function.
(activate): New function.
(deactivate): New function.
(addPeerUpload): Removed.
(setPeerUpload): Removed.
(getPeerUpload): Removed.
(addPeerDownload): Removed.
(setPeerDownload): Removed.
(getPeerDownload): Removed.
* src/Peer.cc
(resetStatus): Removed resetDeltaUpload() and
resetDeltaDownload().
* src/MetalinkRequestInfo.h
(MetalinkRequestInfo): Removed const qualifier from op.
* src/RequestInfo.h
(op): Removed const qualifier.
(RequestInfo): Removed const qualifier from op.
2006-09-21 13:49:06 +00:00
|
|
|
uploadSpeed.update(bytes);
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int getMaxDownloadSpeed() const {
|
2006-09-19 14:52:59 +00:00
|
|
|
return downloadSpeed.getMaxSpeed();
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int getMaxUploadSpeed() const {
|
* src/PeerChokeCommand.cc
(optUnchokingPeer): Updated according to the changes in Peer.
(ResetDelta): Removed.
(UploadFaster): Updated according to the changes in Peer.
(DownloadFaster): Updated according to the changes in Peer.
(execute): I clarify the meaning of "upload" and "download"
here.
"upload" means the transfer from localhost to remote host.
"download" means the transfer from remote host to localhost.
Based on this rule, I swapped orderByUploadRate and
orderByDownloadRate.
* src/PeerInteractionCommand.cc
(PeerInteraction): Removed peerInteraction->setUploadLImit().
(executeInternal): Removed the argument of
peerInteraction->sendMessages().
(receiveMessages): Rewritten download speed limit.
(sendKeepAlive): Removed peerInteraction->sendMessages().
* src/HttpResponseCommand.cc
(handleDefaultEncoding): If file size is unknown in torrent
request,
do not call segmentMan->initBitfield() here.
Disabled persistent connection feature in torrent request.
* src/UrlRequestInfo.h
(UrlRequestInfo): Removed const qualifier from option.
* src/TorrentMan.h
(TransferStat): New class.
(deltaDownloadLength): Removed.
(deltaUploadLength): Removed.
(addDeltaDownloadLength): Removed.
(getDeltaDownloadLength): Removed.
(resetDeltaDownloadLength): Removed.
(addDeltaUploadLength): Removed.
(getDeltaUploadLength): Removed.
(resetDeltaUploadLength): Removed.
(addActivePeer): Added peer->activate().
(deleteActivePeer): Added peer->deactivate().
(calculateStat): New function.
* src/TorrentMan.cc
(TorrentMan): Removed deltaDownloadLength and deltaUploadLength.
(calculateStat): New function.
* src/PeerInteraction.h
(uploadLimit): Removed.
(option): New variable.
(setUploadLimit): Removed.
(getUploadSpeed): Removed.
(sendMessages): Removed the argument "currentUploadSpeed".
* src/PeerInteraction.cc
(prefs.h): Included.
(PeerInteraction): Removed uploadLimit. Added option.
(sendMessages): Rewritten upload speed limit.
(sendHandshake): Removed the argument from sendMessages().
(sendBitfield): Removed the argument from sendMessages().
* src/PeerAbstractCommand.cc
(execute): Commented out the portion of upload limit.
(onAbort): Removed peer->resetStatus().
* src/TorrentRequestInfo.cc
(timeoutSpecified): Declared extern.
(execute): Set timeout to 180 if timeout is not specified by.
command-line.
* src/PieceMessage.cc
(receivedAction): Added peer->updateDownloadLength().
Removed peer->addPeerUpload().
Removed torrentMan->addDeltaDownloadLength().
(send): Added peer->updateUploadLength().
Removed peer->addPeerDownload().
Removed torrentMan->addDeltaUploadLength().
* src/main.cc
(timeoutSpecified): New variable.
(main): Set timeoutSpecified to false.
If the command-line option "--upload-limit" is specified, then
timeoutSpecified is set to true. This option will remain in the
next
release, but be deprecated in the future release.
* src/TorrentRequestInfo.h
(TorrentRequestInfo): Removed const qualifier from op.
* src/PeerStat.h
(uploadSpeed): New variable.
(PeerStat): Added default value to cuid.
(calculateUploadSpeed): New function.
(updateUploadLength): New function.
(getMaxUploadSpeed): New function.
(getAvgUploadSpeed): New function.
(reset): Added uploadSpeed. Set status to IDLE.
* src/TorrentDownloadEngine.h
(cp): Declared as Time.
(sessionDownloadLengthArray): Removed.
(sessionUploadLengthArray): Removed.
(currentCp): Removed.
(lastCalcStat): New variable
(lastElapsed): Removed.
(sessionDownloadLength): Removed.
(calculateStat): New function.
* src/TorrentDownloadEngine.cc
(initStatistics): Removed lastElapsed, cp[],
sessionDownloadLengthArray[], sessionUploadLengthArray[],
currentCp, sessionDownloadLength.
Added cp.reset() and lastCalcStat.reset().
(calculateSpeed): Changed the name of the argument.
(calculateStatistics): Rewritten.
(calculateStat): New function.
* src/Peer.h
(PeerStat.h): Included.
(peerUpload): Removed.
(peerDownload): Removed.
(peerStat): New variable.
(sessionUploadLength): New variable.
(sessionDownloadLength): New variable.
(deltaUpload): Removed.
(deltaDownload): Removed.
(resetStatus): Made private.
(Peer): Added sessionUploadLength, sessionDownloadLength.
Removed peerUpload, peerDownload.
(updateUploadLength): New function.
(addDeltaUpload): Removed.
(updateDownloadLength): New function.
(resetDeltaUpload): Removed.
(getDeltaUpload): Removed.
(addDeltaDownload): Removed.
(calculateUploadSpeed): New function.
(resetDeltaDownload): Removed.
(getDeltaDownload): Removed.
(calculateDownloadSpeed): New function.
(getSessionUploadLength): New function.
(getSessionDownloadLength): New function.
(activate): New function.
(deactivate): New function.
(addPeerUpload): Removed.
(setPeerUpload): Removed.
(getPeerUpload): Removed.
(addPeerDownload): Removed.
(setPeerDownload): Removed.
(getPeerDownload): Removed.
* src/Peer.cc
(resetStatus): Removed resetDeltaUpload() and
resetDeltaDownload().
* src/MetalinkRequestInfo.h
(MetalinkRequestInfo): Removed const qualifier from op.
* src/RequestInfo.h
(op): Removed const qualifier.
(RequestInfo): Removed const qualifier from op.
2006-09-21 13:49:06 +00:00
|
|
|
return uploadSpeed.getMaxSpeed();
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int getAvgDownloadSpeed() const {
|
2008-07-20 07:41:33 +00:00
|
|
|
return _avgDownloadSpeed;
|
2006-09-21 06:56:54 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int getAvgUploadSpeed() const {
|
2008-07-20 07:41:33 +00:00
|
|
|
return _avgUploadSpeed;
|
* src/PeerChokeCommand.cc
(optUnchokingPeer): Updated according to the changes in Peer.
(ResetDelta): Removed.
(UploadFaster): Updated according to the changes in Peer.
(DownloadFaster): Updated according to the changes in Peer.
(execute): I clarify the meaning of "upload" and "download"
here.
"upload" means the transfer from localhost to remote host.
"download" means the transfer from remote host to localhost.
Based on this rule, I swapped orderByUploadRate and
orderByDownloadRate.
* src/PeerInteractionCommand.cc
(PeerInteraction): Removed peerInteraction->setUploadLImit().
(executeInternal): Removed the argument of
peerInteraction->sendMessages().
(receiveMessages): Rewritten download speed limit.
(sendKeepAlive): Removed peerInteraction->sendMessages().
* src/HttpResponseCommand.cc
(handleDefaultEncoding): If file size is unknown in torrent
request,
do not call segmentMan->initBitfield() here.
Disabled persistent connection feature in torrent request.
* src/UrlRequestInfo.h
(UrlRequestInfo): Removed const qualifier from option.
* src/TorrentMan.h
(TransferStat): New class.
(deltaDownloadLength): Removed.
(deltaUploadLength): Removed.
(addDeltaDownloadLength): Removed.
(getDeltaDownloadLength): Removed.
(resetDeltaDownloadLength): Removed.
(addDeltaUploadLength): Removed.
(getDeltaUploadLength): Removed.
(resetDeltaUploadLength): Removed.
(addActivePeer): Added peer->activate().
(deleteActivePeer): Added peer->deactivate().
(calculateStat): New function.
* src/TorrentMan.cc
(TorrentMan): Removed deltaDownloadLength and deltaUploadLength.
(calculateStat): New function.
* src/PeerInteraction.h
(uploadLimit): Removed.
(option): New variable.
(setUploadLimit): Removed.
(getUploadSpeed): Removed.
(sendMessages): Removed the argument "currentUploadSpeed".
* src/PeerInteraction.cc
(prefs.h): Included.
(PeerInteraction): Removed uploadLimit. Added option.
(sendMessages): Rewritten upload speed limit.
(sendHandshake): Removed the argument from sendMessages().
(sendBitfield): Removed the argument from sendMessages().
* src/PeerAbstractCommand.cc
(execute): Commented out the portion of upload limit.
(onAbort): Removed peer->resetStatus().
* src/TorrentRequestInfo.cc
(timeoutSpecified): Declared extern.
(execute): Set timeout to 180 if timeout is not specified by.
command-line.
* src/PieceMessage.cc
(receivedAction): Added peer->updateDownloadLength().
Removed peer->addPeerUpload().
Removed torrentMan->addDeltaDownloadLength().
(send): Added peer->updateUploadLength().
Removed peer->addPeerDownload().
Removed torrentMan->addDeltaUploadLength().
* src/main.cc
(timeoutSpecified): New variable.
(main): Set timeoutSpecified to false.
If the command-line option "--upload-limit" is specified, then
timeoutSpecified is set to true. This option will remain in the
next
release, but be deprecated in the future release.
* src/TorrentRequestInfo.h
(TorrentRequestInfo): Removed const qualifier from op.
* src/PeerStat.h
(uploadSpeed): New variable.
(PeerStat): Added default value to cuid.
(calculateUploadSpeed): New function.
(updateUploadLength): New function.
(getMaxUploadSpeed): New function.
(getAvgUploadSpeed): New function.
(reset): Added uploadSpeed. Set status to IDLE.
* src/TorrentDownloadEngine.h
(cp): Declared as Time.
(sessionDownloadLengthArray): Removed.
(sessionUploadLengthArray): Removed.
(currentCp): Removed.
(lastCalcStat): New variable
(lastElapsed): Removed.
(sessionDownloadLength): Removed.
(calculateStat): New function.
* src/TorrentDownloadEngine.cc
(initStatistics): Removed lastElapsed, cp[],
sessionDownloadLengthArray[], sessionUploadLengthArray[],
currentCp, sessionDownloadLength.
Added cp.reset() and lastCalcStat.reset().
(calculateSpeed): Changed the name of the argument.
(calculateStatistics): Rewritten.
(calculateStat): New function.
* src/Peer.h
(PeerStat.h): Included.
(peerUpload): Removed.
(peerDownload): Removed.
(peerStat): New variable.
(sessionUploadLength): New variable.
(sessionDownloadLength): New variable.
(deltaUpload): Removed.
(deltaDownload): Removed.
(resetStatus): Made private.
(Peer): Added sessionUploadLength, sessionDownloadLength.
Removed peerUpload, peerDownload.
(updateUploadLength): New function.
(addDeltaUpload): Removed.
(updateDownloadLength): New function.
(resetDeltaUpload): Removed.
(getDeltaUpload): Removed.
(addDeltaDownload): Removed.
(calculateUploadSpeed): New function.
(resetDeltaDownload): Removed.
(getDeltaDownload): Removed.
(calculateDownloadSpeed): New function.
(getSessionUploadLength): New function.
(getSessionDownloadLength): New function.
(activate): New function.
(deactivate): New function.
(addPeerUpload): Removed.
(setPeerUpload): Removed.
(getPeerUpload): Removed.
(addPeerDownload): Removed.
(setPeerDownload): Removed.
(getPeerDownload): Removed.
* src/Peer.cc
(resetStatus): Removed resetDeltaUpload() and
resetDeltaDownload().
* src/MetalinkRequestInfo.h
(MetalinkRequestInfo): Removed const qualifier from op.
* src/RequestInfo.h
(op): Removed const qualifier.
(RequestInfo): Removed const qualifier from op.
2006-09-21 13:49:06 +00:00
|
|
|
}
|
|
|
|
|
2006-09-19 14:52:59 +00:00
|
|
|
void reset() {
|
|
|
|
downloadSpeed.reset();
|
* src/PeerChokeCommand.cc
(optUnchokingPeer): Updated according to the changes in Peer.
(ResetDelta): Removed.
(UploadFaster): Updated according to the changes in Peer.
(DownloadFaster): Updated according to the changes in Peer.
(execute): I clarify the meaning of "upload" and "download"
here.
"upload" means the transfer from localhost to remote host.
"download" means the transfer from remote host to localhost.
Based on this rule, I swapped orderByUploadRate and
orderByDownloadRate.
* src/PeerInteractionCommand.cc
(PeerInteraction): Removed peerInteraction->setUploadLImit().
(executeInternal): Removed the argument of
peerInteraction->sendMessages().
(receiveMessages): Rewritten download speed limit.
(sendKeepAlive): Removed peerInteraction->sendMessages().
* src/HttpResponseCommand.cc
(handleDefaultEncoding): If file size is unknown in torrent
request,
do not call segmentMan->initBitfield() here.
Disabled persistent connection feature in torrent request.
* src/UrlRequestInfo.h
(UrlRequestInfo): Removed const qualifier from option.
* src/TorrentMan.h
(TransferStat): New class.
(deltaDownloadLength): Removed.
(deltaUploadLength): Removed.
(addDeltaDownloadLength): Removed.
(getDeltaDownloadLength): Removed.
(resetDeltaDownloadLength): Removed.
(addDeltaUploadLength): Removed.
(getDeltaUploadLength): Removed.
(resetDeltaUploadLength): Removed.
(addActivePeer): Added peer->activate().
(deleteActivePeer): Added peer->deactivate().
(calculateStat): New function.
* src/TorrentMan.cc
(TorrentMan): Removed deltaDownloadLength and deltaUploadLength.
(calculateStat): New function.
* src/PeerInteraction.h
(uploadLimit): Removed.
(option): New variable.
(setUploadLimit): Removed.
(getUploadSpeed): Removed.
(sendMessages): Removed the argument "currentUploadSpeed".
* src/PeerInteraction.cc
(prefs.h): Included.
(PeerInteraction): Removed uploadLimit. Added option.
(sendMessages): Rewritten upload speed limit.
(sendHandshake): Removed the argument from sendMessages().
(sendBitfield): Removed the argument from sendMessages().
* src/PeerAbstractCommand.cc
(execute): Commented out the portion of upload limit.
(onAbort): Removed peer->resetStatus().
* src/TorrentRequestInfo.cc
(timeoutSpecified): Declared extern.
(execute): Set timeout to 180 if timeout is not specified by.
command-line.
* src/PieceMessage.cc
(receivedAction): Added peer->updateDownloadLength().
Removed peer->addPeerUpload().
Removed torrentMan->addDeltaDownloadLength().
(send): Added peer->updateUploadLength().
Removed peer->addPeerDownload().
Removed torrentMan->addDeltaUploadLength().
* src/main.cc
(timeoutSpecified): New variable.
(main): Set timeoutSpecified to false.
If the command-line option "--upload-limit" is specified, then
timeoutSpecified is set to true. This option will remain in the
next
release, but be deprecated in the future release.
* src/TorrentRequestInfo.h
(TorrentRequestInfo): Removed const qualifier from op.
* src/PeerStat.h
(uploadSpeed): New variable.
(PeerStat): Added default value to cuid.
(calculateUploadSpeed): New function.
(updateUploadLength): New function.
(getMaxUploadSpeed): New function.
(getAvgUploadSpeed): New function.
(reset): Added uploadSpeed. Set status to IDLE.
* src/TorrentDownloadEngine.h
(cp): Declared as Time.
(sessionDownloadLengthArray): Removed.
(sessionUploadLengthArray): Removed.
(currentCp): Removed.
(lastCalcStat): New variable
(lastElapsed): Removed.
(sessionDownloadLength): Removed.
(calculateStat): New function.
* src/TorrentDownloadEngine.cc
(initStatistics): Removed lastElapsed, cp[],
sessionDownloadLengthArray[], sessionUploadLengthArray[],
currentCp, sessionDownloadLength.
Added cp.reset() and lastCalcStat.reset().
(calculateSpeed): Changed the name of the argument.
(calculateStatistics): Rewritten.
(calculateStat): New function.
* src/Peer.h
(PeerStat.h): Included.
(peerUpload): Removed.
(peerDownload): Removed.
(peerStat): New variable.
(sessionUploadLength): New variable.
(sessionDownloadLength): New variable.
(deltaUpload): Removed.
(deltaDownload): Removed.
(resetStatus): Made private.
(Peer): Added sessionUploadLength, sessionDownloadLength.
Removed peerUpload, peerDownload.
(updateUploadLength): New function.
(addDeltaUpload): Removed.
(updateDownloadLength): New function.
(resetDeltaUpload): Removed.
(getDeltaUpload): Removed.
(addDeltaDownload): Removed.
(calculateUploadSpeed): New function.
(resetDeltaDownload): Removed.
(getDeltaDownload): Removed.
(calculateDownloadSpeed): New function.
(getSessionUploadLength): New function.
(getSessionDownloadLength): New function.
(activate): New function.
(deactivate): New function.
(addPeerUpload): Removed.
(setPeerUpload): Removed.
(getPeerUpload): Removed.
(addPeerDownload): Removed.
(setPeerDownload): Removed.
(getPeerDownload): Removed.
* src/Peer.cc
(resetStatus): Removed resetDeltaUpload() and
resetDeltaDownload().
* src/MetalinkRequestInfo.h
(MetalinkRequestInfo): Removed const qualifier from op.
* src/RequestInfo.h
(op): Removed const qualifier.
(RequestInfo): Removed const qualifier from op.
2006-09-21 13:49:06 +00:00
|
|
|
uploadSpeed.reset();
|
2006-09-19 14:52:59 +00:00
|
|
|
downloadStartTime.reset();
|
2006-11-08 16:25:38 +00:00
|
|
|
status = PeerStat::IDLE;
|
2006-09-19 14:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void downloadStart() {
|
|
|
|
reset();
|
2006-11-08 16:25:38 +00:00
|
|
|
status = PeerStat::ACTIVE;
|
2006-09-19 14:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void downloadStop() {
|
2008-07-20 07:41:33 +00:00
|
|
|
calculateAvgDownloadSpeed();
|
|
|
|
calculateAvgUploadSpeed();
|
2006-11-08 16:25:38 +00:00
|
|
|
status = PeerStat::IDLE;
|
2006-09-19 14:52:59 +00:00
|
|
|
}
|
|
|
|
|
2006-09-21 06:56:54 +00:00
|
|
|
void requestIdle() {
|
2006-11-08 16:25:38 +00:00
|
|
|
status = PeerStat::REQUEST_IDLE;
|
2006-09-21 06:56:54 +00:00
|
|
|
}
|
|
|
|
|
2006-09-19 14:52:59 +00:00
|
|
|
const Time& getDownloadStartTime() const {
|
|
|
|
return downloadStartTime;
|
|
|
|
}
|
|
|
|
|
2006-11-08 16:25:38 +00:00
|
|
|
PeerStat::STATUS getStatus() const {
|
2006-09-19 14:52:59 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t getCuid() const {
|
2006-09-19 14:52:59 +00:00
|
|
|
return cuid;
|
|
|
|
}
|
2008-08-04 17:06:47 +00:00
|
|
|
|
|
|
|
const std::string& getHostname() const
|
|
|
|
{
|
|
|
|
return _hostname;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& getProtocol() const
|
|
|
|
{
|
|
|
|
return _protocol;
|
|
|
|
}
|
2006-09-19 14:52:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef SharedHandle<PeerStat> PeerStatHandle;
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|
2006-09-19 14:52:59 +00:00
|
|
|
|
|
|
|
#endif // _D_PEER_STAT_H_
|