📄 tcp.h
字号:
For now, it is off by default. */
int closed_; /* whether this connection has closed */
TracedInt ndatapack_; /* number of data packets sent */
TracedInt ndatabytes_; /* number of data bytes sent */
TracedInt nackpack_; /* number of ack packets received */
TracedInt nrexmit_; /* number of retransmit timeouts
when there was data outstanding */
TracedInt nrexmitpack_; /* number of retransmited packets */
TracedInt nrexmitbytes_; /* number of retransmited bytes */
int trace_all_oneline_; /* TCP tracing vars all in one line or not? */
int nam_tracevar_; /* Output nam's variable trace or just plain
text variable trace? */
int first_decrease_; /* First decrease of congestion window. */
/* Used for decrease_num_ != 0.5. */
TracedInt singledup_; /* Send on a single dup ack. */
int noFastRetrans_; /* No Fast Retransmit option. */
int oldCode_; /* Use old code. */
/* these function are now obsolete, see other above */
void closecwnd(int how);
void quench(int how);
void process_qoption_after_send() ;
void process_qoption_after_ack(int seqno) ;
int QOption_ ; /* TCP quiescence option */
int EnblRTTCtr_ ; /* are we using a corase grained timer? */
int T_full ; /* last time the window was full */
int T_last ;
int T_prev ;
int T_start ;
int RTT_count ;
int RTT_prev ;
int RTT_goodcount ;
int F_counting ;
int W_used ;
int W_timed ;
int F_full ;
int Backoffs ;
int control_increase_ ;
int prev_highest_ack_ ;
//Added by Zhenghua for realtime access the tracefile
FILE * tfilefp_;
char tfile_[20];
//added by Zhenghua for virtual monitor
int get_reason();
//added by xiaoqiao
int Discri_Analysis(double time,FILE* pftrace,int Fureason );
void ReadMetricHistory( FILE* ,Value_t MetricHistory[MAX_PKTNO], int* pnbMetricHistory,double dCurrentTime,int MetricType,FILE* pftrace );
void ComputeRecentMeanandDeviation( double dCurrentTime );
void RecentMeanandDeviation( Value_t metricHistory[MAX_PKTNO], int nbMetricHistory, double* pdMean, double* pdDeviation, double dCurrentTime, double pSample[MAX_PKTNO], int* pnbSample, double timespan );
void WriteIDDandTHRUtoFile( double t, MetricVector_ CurrentVector, FILE* fptrace );
void GetCurrentMetricVector( MetricVector_* );
int GoodTrainingSet();
int IsCongestion_Threshold( MetricVector_ , double );
int IsCongest_LDA( MetricVector_ );
void FurtherClassify( MetricVector_ , int* );
double MahaDistance( MetricVector_* , MetricVector_* , double a[4][4] );
void UpdateConNonConTrainingSet( MetricVector_ , double, int );
void TrainingLDF();
void EraseOutdateSample( MetricVector_ CongSample[LDA_Con_NonCon_MAXSAMPLENUMBER], int *pnb, double dCurrentTime );
void EraseFirstElement( MetricVector_ Array[LDA_Con_NonCon_MAXSAMPLENUMBER], int *pnb );
double ldf( double coefficient[3], MetricVector_ Sample );
//added ended
int tracefile_pos;
int from_nodeid_; /* for identifying this node at tracefile */
int to_nodeid_;
int nodeid_;
//int acks[1000];
int ifConn(int n1, int n2, double t);
double node_x1[MAX_NODES];
double node_y1[MAX_NODES];
double node_x2[MAX_NODES];
double node_y2[MAX_NODES];
double node_sp[MAX_NODES];
double node_t0[MAX_NODES];
double node_T[MAX_NODES];
double getCurrentX(int n1, double t);
double getCurrentY(int n1, double t);
double getDist(double x1, double y1, double x2, double y2);
int prev_reason[MAX_NODES];
int last_reason;
int tcp_pkt_recvd;
double prev_reason_time[MAX_NODES];
double int_cnt_idd[MAX_INTERVALS];
double time_cnt_idd[MAX_INTERVALS];
double int_cnt_iad[MAX_INTERVALS];
double time_cnt_iad[MAX_INTERVALS];
double int_cnt_thu[MAX_INTERVALS];
double time_cnt_thu[MAX_INTERVALS];
double int_cnt_po[MAX_INTERVALS];
double time_cnt_po[MAX_INTERVALS];
double int_cnt_los[MAX_INTERVALS];
double time_cnt_los[MAX_INTERVALS];
int int_cnt_iad_average[MAX_INTERVALS];
double snd[1024];
double rcvd[MAX_PKTNO];
//added by xiaoqiao
Value_t IDDHistory[MAX_PKTNO];
int nbIDDHistory;
Value_t POHistory[MAX_PKTNO];
int nbPOHistory;
Value_t THRUHistory[MAX_PKTNO];
int nbTHRUHistory;
Value_t LOSHistory[MAX_PKTNO];
int nbLOSHistory;
Params_ HistoryData;
//used in Linear Discriminant analysis coefficients
double LDA_Con_NonCon_Coef[3];
MetricVector_ CongSample[LDA_Con_NonCon_MAXSAMPLENUMBER];
int inbCongSample;
MetricVector_ NonCongSample[LDA_Con_NonCon_MAXSAMPLENUMBER];
int inbNonCongSample;
//used in threshold based congestion-noncongestion classfication
#define MAX_NBSAMPLE_INTIMESLIT 200
#define TIMESLIP 2
Value_t SampleInCurrentSlit[MAX_NBSAMPLE_INTIMESLIT][2];//...[i][0] is idd value, ...[i][1] is thru value
int LastReason;
double LastReason_Time;
//added ended-------------------------------------------------
int pkts[MAX_PKTS];
int pkts_no[MAX_PKTNO];
int ack_no;
int fr_recover_no;
int ack_cnt;
int fr_pending;
double fr_pending_start_time;
int cur_pkt;
int last_pkt;
int last_pktno;
double cur_time;
double last_time;
int maxrt;
void putidd(double idd, double t);
void putiad(double iad, double t);
double tot_iad;
double tot_idd;
double tot_po;
double tot_los;
double tot_thu;
double pc_iad;
double pc_idd;
double pc_weight;
double current_pc_idd_exp;
double current_pc_idd;
double current_pc_iad_exp;
double current_pc_iad;
double idd_table[MAX_HIST_TABLE];
int cur_table_pos;
double current_iad_average;
double current_pc_iad_average_exp;
double current_pc_iad_average;
double current_idd_average;
double current_iad_var;
double current_idd_var;
double current_pc_thu;
double current_pc_po;
double current_pc_los;
int iad_ind;
int idd_ind;
double alpha;
double beta;
double nocong_threshold;
double pc_weight_exp;
double acc_exp;
double acc_lin;
double acc_wt;
double acc_iad_exp;
double acc_iad_lin;
int acc_ct;
double getmax(double d1,double d2, double d3);
double thu_lin;
double thu_exp;
double po_lin;
double po_exp;
double los_lin;
double los_exp;
void putthu(double t, double thu);
void putpo(double t, double po);
void putlos(double t, double los);
void record_matrics(int what, double t, double sample);
double cur_rtt;
double cur_ts;
int ts_tot_pkts;
double ts_start_time;
int ts_tot_po;
int ts_start_sn;
int ts_tot_los;
double current_thu_var, current_thu_average, current_los_var, current_los_average, current_po_var, current_po_average;
int po_ind, los_ind, thu_ind, acc_thu, acc_po, acc_los;
int inited ;
double max_snd_time;
double start_time;
int get_thresh_ident(void);
int get_ml_ident(int reason);
int get_maxml(void);
double ml[5];
double ml_epsilon[5];
int ml_cnt[5];
double nt_rtt_;
int probing_state;
int probing_data_backoff;
int psn[256];
int preason[256];
long wptr,rptr;
double t0;
void output_paced(void);
void output_real(int seqno, int reason = 0);
double t_myrtt;
double last_wnd_thru;
int old_cwnd_;
double wnd_thru[256];
int rtt_inited;
int frfr;
};
/* TCP Reno */
class RenoTcpAgent : public virtual TcpAgent {
public:
RenoTcpAgent();
virtual int window();
virtual double windowd();
virtual void recv(Packet *pkt, Handler*);
virtual void timeout(int tno);
virtual void dupack_action();
protected:
int allow_fast_retransmit(int last_cwnd_action_);
unsigned int dupwnd_;
};
/* TCP New Reno */
class NewRenoTcpAgent : public virtual RenoTcpAgent {
public:
NewRenoTcpAgent();
virtual void recv(Packet *pkt, Handler*);
virtual void partialnewack_helper(Packet* pkt);
virtual void dupack_action();
protected:
int newreno_changes_; /* 0 for fixing unnecessary fast retransmits */
/* 1 for additional code from Allman, */
/* to implement other algorithms from */
/* Hoe's paper */
int newreno_changes1_; /* 1 for more aggressive retransmissions */
/* in response to partial acks */
void partialnewack(Packet *pkt);
int allow_fast_retransmit(int last_cwnd_action_);
int acked_, new_ssthresh_; /* used if newreno_changes_ == 1 */
double ack2_, ack3_, basertt_; /* used if newreno_changes_ == 1 */
int firstpartial_; /* For the first partial ACK. */
int partial_window_deflation_; /* 0 if set cwnd to ssthresh upon */
/* partial new ack (default) */
/* 1 if deflate (cwnd + dupwnd) by */
/* amount of data acked */
int exit_recovery_fix_; /* 0 for setting cwnd to ssthresh upon */
/* leaving fast recovery (default) */
/* 1 for setting cwnd to min(ssthresh, */
/* amnt. of data in network) when leaving */
int save_cwnd_, save_ssthresh_; /* for po reference behavior 3, Zhenghua */
};
/* TCP vegas (VegasTcpAgent) */
class VegasTcpAgent : public virtual TcpAgent {
public:
VegasTcpAgent();
virtual void recv(Packet *pkt, Handler *);
virtual void timeout(int tno);
protected:
double vegastime() {
return(Scheduler::instance().clock() - firstsent_);
}
virtual void output(int seqno, int reason = 0);
virtual void recv_newack_helper(Packet*);
int vegas_expire(Packet*);
void reset();
void vegas_inflate_cwnd(int win, double current_time);
virtual void delay_bind_init_all();
virtual int delay_bind_dispatch(const char *varName, const char *localName, TclObject *tracer);
double t_cwnd_changed_; // last time cwnd changed
double firstrecv_; // time recv the 1st ack
int v_alpha_; // vegas thruput thresholds in pkts
int v_beta_;
int v_gamma_; // threshold to change from slow-start to
// congestion avoidance, in pkts
int v_slowstart_; // # of pkts to send after slow-start, deflt(2)
int v_worried_; // # of pkts to chk after dup ack (1 or 2)
double v_timeout_; // based on fine-grained timer
double v_rtt_;
double v_sa_;
double v_sd_;
int v_cntRTT_; // # of rtt measured within one rtt
double v_sumRTT_; // sum of rtt measured within one rtt
double v_begtime_; // tagged pkt sent
int v_begseq_; // tagged pkt seqno
double* v_sendtime_; // each unacked pkt's sendtime is recorded.
int* v_transmits_; // # of retx for an unacked pkt
int v_maxwnd_; // maxwnd size for v_sendtime_[]
double v_newcwnd_; // record un-inflated cwnd
double v_baseRTT_; // min of all rtt
double v_incr_; // amount cwnd is increased in the next rtt
int v_inc_flag_; // if cwnd is allowed to incr for this rtt
double v_actual_; // actual send rate (pkt/s; needed for tcp-rbp)
int ns_vegas_fix_level_; // see comment at end of tcp-vegas.cc for details of fixes
};
// Local Variables:
// mode:c++
// End:
#endif
// vm added by Zhenghua for testing reference behavior
/* static class vm {
public:
char filename[100];
char buf[100];
FILE *fp;
int state = 0;
void getcontent(char *s);
void putcontent(char *s);
} */
// added by Zhenghua for test reference behavior
/* void vm::putcontent(char *s) {
while(state == 1) usleep(1000);
state = 1;
fp = fopen("vm.tr","a+");
fprintf(fp,"%s",s);
fclose(fp);
state = 0;
}
void vm::getcontent(char *s) {
FILE*tempfp;
while(state == 1) usleep(1000);
state = 1;
fp = fopen(filename,"r");
fseek(fp,-20,SEEK_END);
tempfp = fopen("test.out","a+");
while(!feof(fp))
{
fscanf(fp,"%c",buf);
fprintf(tempfp,"%c",buf[0]);
}
fclose(fp); state = 0;
fclose(tempfp);
} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -