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