btalgorithmrechoke.h

来自「模拟P2P各种网络环境的,适合新手们的学习,不错的源码.」· C头文件 代码 · 共 50 行

H
50
字号
#ifndef __BTALGORITHMRECHOKE_H__
#define __BTALGORITHMRECHOKE_H__
#include <vector>
#include "SimEventHandler.h"
#include "Sysparameter.h"
using namespace std;
class BTPeer;
class BTSession;
class BTSocket;
class SimEvent;
class BTEvent;
#define DEFAULTRECHOKEINTERVAL 20
#define DEFAULTOPTIMISTICINTERVAL 40
#define DEFAULTSNUBDETECTINTERVAL 80
#define DEFAULTUNCHOKENUM 10
#define DEFAULTSNUBUNCHOKENUM 4
class BTAlgorithmRechoke: public SimEventHandler{
public:
	double mRechokeInterval;
	double mOptimisticInterval;
	double mSnubDetectInterval;
	double mSnubUnchokeNum;
	int 	   mUnchokeNum;
	double mOptimisticLastRunningTime;
	double mSnubDetectLastRunningTime;
	BTSession* mSession;
	BTEvent* mRechoke;

public:
	BTAlgorithmRechoke( BTSession* session);
	~BTAlgorithmRechoke(){};
	void handler(SimEvent*);
	void nextSchedule(void);	
	void optimisticUnchoke(void);
	void snubDetect(void);
	void cancelRechoke(void);
private:
	void print(void);
	void printCon( vector<BTSocket*>* conlist);
};
class InCompare{
	public:
		bool operator()( BTSocket* const &, BTSocket* const &) const;
};
class OutCompare{
	public:
		bool operator()(BTSocket* const &, BTSocket* const &) const;
};
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?