rdt-app.h

来自「用ns写的一个网络模拟 实现rdt 里面有所有源代码和文档说明」· C头文件 代码 · 共 82 行

H
82
字号
#include "timer-handler.h"#include "packet.h"#include "app.h"#include "rdt.h"// This is used for receiver's received packet accountingstruct pkt_accounting {         int last_seq;   // sequence number of last received rdt pkt        int last_scale; // rate (0-4) of last acked        int lost_pkts;  // number of lost pkts since last ack        int recv_pkts;  // number of received pkts since last ack        double rtt;     // round trip time};class rdtApp;// Sender uses this timer to // schedule next app data packet transmission timeclass SendTimer : public TimerHandler { public:	SendTimer(rdtApp* t) : TimerHandler(), t_(t) {}	inline virtual void expire(Event*); protected:	rdtApp* t_;};// Reciver uses this timer to schedule// next ack packet transmission timeclass AckTimer : public TimerHandler { public:	AckTimer(rdtApp* t) : TimerHandler(), t_(t) {}	inline virtual void expire(Event*); protected:	rdtApp* t_;};// RDT Application Class Definitionclass rdtApp : public Application { public:	rdtApp();	void send_rdt_pkt();  // called by SendTimer:expire (Sender)	void send_ack_pkt(); // called by AckTimer:expire (Receiver)	void send_rej_pkt(); // (Receiver)	void resend_rdt_pkt(const hdr_rdt *mh_buf); // called by sender to resend rdt_pkts protected:	int command(int argc, const char*const* argv);	void start();       // Start sending data packets (Sender)	void stop();        // Stop sending data packets (Sender) private:	void init();	inline double next_snd_time();                          // (Sender)	virtual void recv_msg(int nbytes, const char *msg = 0); // (Sender/Receiver)	void set_scale(const hdr_rdt *mh_buf);                   // (Sender)	void adjust_scale(void);                                // (Receiver)	void account_recv_pkt(const hdr_rdt *mh_buf);            // (Receiver)	void init_recv_pkt_accounting();                        // (Receiver)	void adjust_rwindow();                          //receiver adjusts its window after receive a rdt_pkt or send a ack_pkt	void adjust_swindow(const hdr_rdt *mh_buf); //sender adjusts its window after receive a rdt_pkt or send a ack_pkt		double rate[5];        // Transmission rates associated to scale values	double interval_;      // Application data packet transmission interval	int pktsize_;          // Application data packet size	int random_;           // If 1 add randomness to the interval	int running_;          // If 1 application is running	int rwindow_;		//接收方的窗口大小	int swindow_;		//发送方的窗口大小	int lastack_;		//上次ack的帧的序号	int rseq_;		//接收方已接收的最后一帧	int sseq_;              // 发送方已发送的最后一帧,Application data packet sequence number	int scale_;            // Media scale parameter	pkt_accounting p_accnt;	SendTimer snd_timer_;  // SendTimer	AckTimer  ack_timer_;  // AckTimer};

⌨️ 快捷键说明

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