Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

iflist.h

Go to the documentation of this file.
00001 // Copyright (c) 2000 by the University of Southern California
00002 // All rights reserved.
00003 //
00004 // Permission to use, copy, modify, and distribute this software and its
00005 // documentation in source and binary forms for non-commercial purposes
00006 // and without fee is hereby granted, provided that the above copyright
00007 // notice appear in all copies and that both the copyright notice and
00008 // this permission notice appear in supporting documentation. and that
00009 // any documentation, advertising materials, and other materials related
00010 // to such distribution and use acknowledge that the software was
00011 // developed by the University of Southern California, Information
00012 // Sciences Institute.  The name of the University may not be used to
00013 // endorse or promote products derived from this software without
00014 // specific prior written permission.
00015 //
00016 // THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about
00017 // the suitability of this software for any purpose.  THIS SOFTWARE IS
00018 // PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
00019 // INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00020 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 //
00022 // Other copyrights might apply to parts of this software and are so
00023 // noted when applicable.
00024 //
00025 
00026 /**********************************************************/
00027 /* iflist.h : Chalermek Intanagonwiwat (USC/ISI) 06/25/99 */
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;        // for simple mode. New original sample counter.
00156   int    old_org_recv;        // for simple mode. Old original sample counter.
00157   int    new_sub_recv;        // for simple mode. New subsample counter.
00158   double last_ts_new_sub;     // Last timestamp in receiving a new subsample.
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 /* Example 
00188 
00189 void main () {
00190 
00191   From_List *start, *cur;
00192 
00193   start=NULL;
00194 
00195   cur = new From_List;
00196   cur->agent_addr.addr_ =1;
00197   cur->agent_addr.port_ =1;
00198   INTF_INSERT(start,cur);
00199 
00200   cur = new From_List;
00201   cur->agent_addr.addr_ = 3;
00202   cur->agent_addr.port_ = 3;
00203   INTF_INSERT(start,cur);
00204 
00205   cur = new From_List;
00206   cur->agent_addr.addr_ = 5;
00207   cur->agent_addr.port_ = 5;
00208   INTF_INSERT(start,cur);
00209 
00210   start->print();
00211 
00212   PrvCurPtr RetVal;
00213   ns_addr_t fnd_addr;
00214 
00215   fnd_addr.addr_ = 1;
00216   fnd_addr.port_ = 1;
00217   RetVal= INTF_FIND(start, fnd_addr);
00218   INTF_REMOVE(RetVal.prv, RetVal.cur);
00219 
00220   start->print();
00221 
00222 }
00223 
00224 */
00225 
00226 

Generated on Tue Apr 20 12:14:20 2004 for NS2.26SourcesOriginal by doxygen 1.3.3