00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef ns_tcp_linux_h
00056 #define ns_tcp_linux_h
00057
00058 #include "tcp.h"
00059 #include "scoreboard1.h"
00060 #include "linux/ns-linux-util.h"
00061
00062
00063 #define DEBUG_LEVEL 0
00064 #define DEBUG(level, ...) if (DEBUG_LEVEL>=level) printf(__VA_ARGS__);
00065
00066
00067 class ParamList {
00068 private:
00069 typedef struct paramNode {
00070 int* addr;
00071 int value;
00072 int default_value;
00073 struct paramNode* next;
00074 };
00075 struct paramNode* head;
00076 public:
00077 ParamList():head(NULL) {};
00078 ~ParamList();
00080 void set_param(int* address, int value);
00081 bool get_param(int* address, int* valuep);
00082
00084 void refresh_default();
00085
00087 void restore_default();
00088 void load_local();
00089 };
00090
00091
00092
00093 class LinuxParamManager {
00094 private:
00095 ParamList localValues;
00096 static struct cc_list* find_cc_by_proto(const char* proto);
00097 static struct cc_param_list* find_param_by_proto_name(const char* proto, const char* name);
00098 public:
00099 LinuxParamManager(){};
00100 static bool set_default_param(const char* proto, const char* param, const int value);
00101 static bool get_default_param(const char* proto, const char* param, int* valuep);
00102 static bool query_param(const char* proto);
00103 bool set_param(const char* proto, const char* param, const int value);
00104 bool get_param(const char* proto, const char* param, int* valuep);
00105 void load_local() {localValues.load_local();};
00106 void restore_default() {localValues.restore_default();};
00107 };
00108
00109
00110
00111 class LinuxTcpAgent : public TcpAgent {
00112 private:
00113 LinuxParamManager paramManager;
00114 public:
00115 LinuxTcpAgent();
00116 virtual ~LinuxTcpAgent();
00117 virtual void recv(Packet *pkt, Handler*);
00118 virtual void timeout(int tno);
00119 virtual int window();
00120 virtual double windowd();
00121 void oldack (Packet* pkt);
00122 int maxsack (Packet* pkt);
00123 void plot();
00124 void reset();
00125 virtual void send_much(int force, int reason, int maxburst = 0);
00126 virtual int packets_in_flight();
00127 virtual int command(int argc, const char*const* argv);
00128
00129 protected:
00130 ScoreBoard1 *scb_;
00131 struct tcp_sock linux_;
00132 bool initialized_;
00133
00134 TracedInt next_pkts_in_flight_;
00135
00136
00137 virtual bool is_congestion();
00138
00139 void rtt_update(double tao, unsigned long pkt_seq_no=0);
00140
00141 unsigned char ack_processing(Packet* pkt, unsigned char flag);
00142 void time_processing(Packet* pkt, unsigned char flag,s32* seq_urtt_p);
00143
00144
00145
00146
00147
00148 void touch_cwnd();
00149
00150 void enter_loss();
00151
00152
00153 void tcp_fastretrans_alert(unsigned char flag);
00154 void tcp_moderate_cwnd();
00155
00156 void load_to_linux();
00157 void load_to_linux_once();
00158
00159 void save_from_linux();
00160
00161 char install_congestion_control(const char* name);
00162 void remove_congestion_control();
00163
00164 inline void tcp_set_ca_state(const u8 ca_state) {
00165 if ((linux_.icsk_ca_ops)&&(linux_.icsk_ca_ops->set_state))
00166 linux_.icsk_ca_ops->set_state(&linux_, ca_state);
00167
00168 linux_.icsk_ca_state = ca_state;
00169
00170 };
00171 inline void tcp_ca_event(const enum tcp_ca_event event) {
00172 if ((linux_.icsk_ca_ops)&&(linux_.icsk_ca_ops->cwnd_event))
00173 linux_.icsk_ca_ops->cwnd_event(&linux_, event);
00174
00175 };
00176 };
00177
00178 class CongestionControlManager
00179 {
00180
00181 public:
00182 CongestionControlManager();
00183
00184 struct tcp_congestion_ops* get_ops(const char* name);
00185 void dump();
00186 void scan();
00187 private:
00188 int num_;
00189 struct tcp_congestion_ops** ops_list;
00190 };
00191 extern CongestionControlManager cong_ops_manager;
00192
00193
00194
00195 #endif