pingreq.h

来自「NS2目前广泛采用的网络模拟软件」· C头文件 代码 · 共 94 行

H
94
字号
#ifndef ns_PingReq_h#define ns_PingReq_h#include "agent.h"#include "tclcl.h"#include "packet.h"#include "address.h"#include "ip.h"#include "timer-handler.h"#include <string>#include <iostream>#include <vector>using namespace std;struct hdr_PingReq {	int ret;	double time;	int turn; //one turn will send out 100 packets	static int offset_;	inline static int& offset() {return offset_;}	inline static hdr_PingReq* access(const Packet* p) {			return (hdr_PingReq*) p->access(offset_);		}	};class PingReqAgent;class ReqTimer: public TimerHandler {	public:	 ReqTimer(PingReqAgent* t): TimerHandler(), t_(t) {}	protected:	 virtual void expire(Event*);	 PingReqAgent* t_;};class RecvTimer: public TimerHandler {	public:		RecvTimer(PingReqAgent* t): TimerHandler(), t_(t) {}	protected:		virtual void expire(Event*);		PingReqAgent* t_;};class SendTimer: public TimerHandler {	public:		SendTimer(PingReqAgent* t): TimerHandler(), t_(t) {}	protected:		virtual void expire(Event*);		PingReqAgent* t_;};				class PingReqAgent: public Agent {	public:	 int turn_;	 int running_;	 int resultIndex_;	 int received_; //how many probes have received in this turn	 int sent_;     //how many probes have sent in this turn 	 double turn_RTT_[100]; //RTT samples measured in one turn	 double result_[65535]; //measure result	 double time_[65535]; //the time when get result	 double loss[65535];   //packet loss rate	 double maxSample_;   //the max sample has ever measured	 int lostPackage;	 int recvPackage;	 PingReqAgent();	 //void SendReqPkt(); //send req pkt	 void SendProbes();	 void SendOneProbe();	 //a endless req sending loop, but remember to adjust sendtimer	 //void BeginReqLoop(); 	 //void AdjSendTimer();	 virtual int command (int argc, const char*const* argv);	 virtual void recv (Packet*, Handler*);	private:	 class ReqTimer ReqTimer_;  //timer for request packet sending	 class RecvTimer RecvTimer_; //timer for recv timeout	 class SendTimer SendTimer_; //timer for send probes	 double MaxReqInterval_, MinReqInterval_;	 double CurrentReqInterval_;	 double latest_;  //the time when receive last result	 double step_;   //timer incr/decr step	 FILE* recordFile;	 FILE* recordTime;	 FILE* lossFile;};#endif

⌨️ 快捷键说明

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