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 #ifndef ns_iflist_h
00053 #define ns_iflist_h
00054
00055 #include <stdio.h>
00056 #include "config.h"
00057
00058 #define INTF_INSERT(x,y) x->InsertFront((Agent_List **)&x, (Agent_List *)y)
00059 #define INTF_REMOVE(x,y) y->Remove(x,y)
00060 #define INTF_FIND(x,y) x->Find((Agent_List **)&x, y)
00061 #define INTF_FREEALL(x) x->FreeAll((Agent_List **)&x)
00062 #define INTF_UNION(x,y) x->Union((Agent_List **)&x, (Agent_List *)y)
00063
00064 #define AGENT_NEXT(x) x->next
00065 #define FROM_NEXT(x) (From_List *)(x->next)
00066 #define OUT_NEXT(x) (Out_List *)(x->next)
00067 #define IN_NEXT(x) (In_List *)(x->next)
00068
00069 #define AGT_ADDR(x) x->agent_addr
00070 #define NODE_ADDR(x) x->agent_addr.addr_
00071 #define PORT(x) x->agent_addr.port_
00072 #define RANK(x) ((From_List *)x)->rank
00073 #define IS_SINK(x) ((From_List *)x)->is_sink
00074
00075 #define GRADIENT(x) ((Out_List *)x)->gradient
00076 #define GRAD_TMOUT(x) ((Out_List *)x)->timeout
00077 #define FROM_SLOT(x) ((Out_List *)x)->from
00078 #define TO_SLOT(x) ((Out_List *)x)->to
00079 #define NUM_DATA_SEND(x) ((Out_List *)x)->num_data_send
00080 #define NUM_NEG_RECV(x) ((Out_List *)x)->num_neg_recv
00081 #define NUM_POS_RECV(x) ((Out_List *)x)->num_pos_recv
00082
00083 #define NUM_POS_SEND(x) ((In_List *)x)->num_pos_send
00084 #define NUM_NEG_SEND(x) ((In_List *)x)->num_neg_send
00085 #define LAST_TS_NEW_SUB(x) ((In_List *)x)->last_ts_new_sub
00086 #define NEW_SUB_RECV(x) ((In_List *)x)->new_sub_recv
00087 #define NEW_ORG_RECV(x) ((In_List *)x)->new_org_recv
00088 #define OLD_ORG_RECV(x) ((In_List *)x)->old_org_recv
00089 #define TOTAL_NEW_SUB_RECV(x) ((In_List *)x)->total_new_sub_recv
00090 #define TOTAL_NEW_ORG_RECV(x) ((In_List *)x)->total_new_org_recv
00091 #define TOTAL_OLD_ORG_RECV(x) ((In_List *)x)->total_old_org_recv
00092
00093 #define TOTAL_RECV(x) ((In_List *)x)->total_received
00094 #define PREV_RECV(x) ((In_List *)x)->prev_received
00095 #define NUM_LOSS(x) ((In_List *)x)->num_loss
00096 #define AVG_DELAY(x) ((In_List *)x)->avg_delay
00097 #define VAR_DELAY(x) ((In_List *)x)->var_delay
00098
00099 #define WHERE_TO_GO(x) x->WhereToGo()
00100 #define FIND_MAX_IN(x) x->FindMaxIn()
00101 #define CAL_RANGE(x) x->CalRange()
00102 #define NORMALIZE(x) x->NormalizeGradient()
00103
00104 class Agent_List;
00105
00106
00107 class PrvCurPtr {
00108 public:
00109 Agent_List **prv;
00110 Agent_List *cur;
00111 };
00112
00113
00114 class Agent_List {
00115 public:
00116 ns_addr_t agent_addr;
00117 Agent_List *next;
00118
00119 Agent_List() {
00120 next = NULL;
00121 agent_addr.addr_=0;
00122 agent_addr.port_=0;
00123 }
00124
00125 virtual ~Agent_List () {}
00126
00127 void InsertFront(Agent_List **, Agent_List *);
00128 void Remove(Agent_List **, Agent_List *);
00129 PrvCurPtr Find(Agent_List **, ns_addr_t);
00130 void FreeAll(Agent_List **);
00131 void Union(Agent_List **, Agent_List *);
00132
00133 virtual void print();
00134 };
00135
00136
00137 class From_List : public Agent_List {
00138 public:
00139 int rank;
00140 bool is_sink;
00141
00142 From_List() : Agent_List() { rank = 0; is_sink = false; }
00143
00144 virtual ~From_List () {}
00145 };
00146
00147
00148 class Out_List : public From_List {
00149 public:
00150 float gradient;
00151 double timeout;
00152 double from;
00153 double to;
00154 int num_data_send;
00155 int num_neg_recv;
00156 int num_pos_recv;
00157
00158 Out_List() : From_List() { gradient = 0; from=0.0; to=0.0; num_data_send=0;
00159 timeout = 0.0; num_neg_recv = 0; num_pos_recv=0;}
00160 virtual ~Out_List () {}
00161
00162 Out_List *WhereToGo();
00163 void CalRange();
00164 void NormalizeGradient();
00165 };
00166
00167
00168 class In_List : public Agent_List {
00169 public:
00170 double avg_delay;
00171 double var_delay;
00172 int total_received;
00173 int prev_received;
00174 int num_loss;
00175 int num_neg_send;
00176 int num_pos_send;
00177
00178 int total_new_org_recv;
00179 int total_old_org_recv;
00180 int total_new_sub_recv;
00181 int new_org_recv;
00182 int old_org_recv;
00183 int new_sub_recv;
00184 double last_ts_new_sub;
00185
00186 In_List() : Agent_List() {
00187 avg_delay =0;
00188 var_delay =0;
00189 total_received=0;
00190 prev_received =0;
00191 num_loss =0;
00192 num_neg_send = 0;
00193 num_pos_send = 0;
00194
00195 total_new_org_recv=0;
00196 total_old_org_recv=0;
00197 total_new_sub_recv=0;
00198
00199 new_org_recv=0;
00200 old_org_recv=0;
00201 new_sub_recv=0;
00202
00203 last_ts_new_sub = -1.0;
00204 }
00205
00206 virtual ~In_List () {}
00207
00208 In_List *FindMaxIn();
00209 };
00210
00211 #endif
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254