File: iflist.h

package info (click to toggle)
ns2 2.35%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 78,796 kB
  • sloc: cpp: 172,923; tcl: 107,130; perl: 6,391; sh: 6,143; ansic: 5,846; makefile: 816; awk: 525; csh: 355
file content (254 lines) | stat: -rwxr-xr-x 7,144 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254

/*
 * iflist.h
 * Copyright (C) 2000 by the University of Southern California
 * $Id: iflist.h,v 1.5 2005/08/25 18:58:04 johnh Exp $
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 *
 *
 * The copyright of this module includes the following
 * linking-with-specific-other-licenses addition:
 *
 * In addition, as a special exception, the copyright holders of
 * this module give you permission to combine (via static or
 * dynamic linking) this module with free software programs or
 * libraries that are released under the GNU LGPL and with code
 * included in the standard release of ns-2 under the Apache 2.0
 * license or under otherwise-compatible licenses with advertising
 * requirements (or modified versions of such code, with unchanged
 * license).  You may copy and distribute such a system following the
 * terms of the GNU GPL for this module and the licenses of the
 * other code concerned, provided that you include the source code of
 * that other code when and as the GNU GPL requires distribution of
 * source code.
 *
 * Note that people who make modified versions of this module
 * are not obligated to grant this special exception for their
 * modified versions; it is their choice whether to do so.  The GNU
 * General Public License gives permission to release a modified
 * version without this exception; this exception also makes it
 * possible to release a modified version which carries forward this
 * exception.
 *
 */

/**********************************************************/
/* iflist.h : Chalermek Intanagonwiwat (USC/ISI) 06/25/99 */
/**********************************************************/


#ifndef ns_iflist_h
#define ns_iflist_h

#include <stdio.h>
#include "config.h"

#define INTF_INSERT(x,y)  x->InsertFront((Agent_List **)&x, (Agent_List *)y)
#define INTF_REMOVE(x,y)  y->Remove(x,y)
#define INTF_FIND(x,y)    x->Find((Agent_List **)&x, y)
#define INTF_FREEALL(x)   x->FreeAll((Agent_List **)&x)
#define INTF_UNION(x,y)   x->Union((Agent_List **)&x, (Agent_List *)y)

#define AGENT_NEXT(x)     x->next
#define FROM_NEXT(x)      (From_List *)(x->next)
#define OUT_NEXT(x)       (Out_List *)(x->next)
#define IN_NEXT(x)        (In_List *)(x->next)

#define AGT_ADDR(x)       x->agent_addr
#define NODE_ADDR(x)      x->agent_addr.addr_
#define PORT(x)           x->agent_addr.port_
#define RANK(x)           ((From_List *)x)->rank
#define IS_SINK(x)        ((From_List *)x)->is_sink

#define GRADIENT(x)       ((Out_List *)x)->gradient
#define GRAD_TMOUT(x)     ((Out_List *)x)->timeout
#define FROM_SLOT(x)      ((Out_List *)x)->from
#define TO_SLOT(x)        ((Out_List *)x)->to
#define NUM_DATA_SEND(x)       ((Out_List *)x)->num_data_send
#define NUM_NEG_RECV(x)       ((Out_List *)x)->num_neg_recv
#define NUM_POS_RECV(x)       ((Out_List *)x)->num_pos_recv

#define NUM_POS_SEND(x)   ((In_List *)x)->num_pos_send
#define NUM_NEG_SEND(x)   ((In_List *)x)->num_neg_send
#define LAST_TS_NEW_SUB(x) ((In_List *)x)->last_ts_new_sub
#define NEW_SUB_RECV(x)   ((In_List *)x)->new_sub_recv
#define NEW_ORG_RECV(x)   ((In_List *)x)->new_org_recv
#define OLD_ORG_RECV(x)   ((In_List *)x)->old_org_recv
#define TOTAL_NEW_SUB_RECV(x)   ((In_List *)x)->total_new_sub_recv
#define TOTAL_NEW_ORG_RECV(x)   ((In_List *)x)->total_new_org_recv
#define TOTAL_OLD_ORG_RECV(x)   ((In_List *)x)->total_old_org_recv

#define TOTAL_RECV(x)     ((In_List *)x)->total_received
#define PREV_RECV(x)      ((In_List *)x)->prev_received
#define NUM_LOSS(x)       ((In_List *)x)->num_loss
#define AVG_DELAY(x)      ((In_List *)x)->avg_delay
#define VAR_DELAY(x)      ((In_List *)x)->var_delay

#define WHERE_TO_GO(x)    x->WhereToGo()
#define FIND_MAX_IN(x)    x->FindMaxIn()
#define CAL_RANGE(x)      x->CalRange()
#define NORMALIZE(x)      x->NormalizeGradient()

class Agent_List;


class PrvCurPtr {
public:
  Agent_List **prv;
  Agent_List *cur;
};


class Agent_List {
public:
  ns_addr_t agent_addr;
  Agent_List *next;

  Agent_List() { 
    next = NULL; 
    agent_addr.addr_=0;
    agent_addr.port_=0;
  }

  virtual ~Agent_List () {}
  
  void InsertFront(Agent_List **, Agent_List *);
  void Remove(Agent_List **, Agent_List *);
  PrvCurPtr Find(Agent_List **, ns_addr_t);
  void FreeAll(Agent_List **);
  void Union(Agent_List **, Agent_List *);

  virtual void print();
};


class From_List : public Agent_List {
public:
  int rank;
  bool  is_sink;

  From_List() : Agent_List() { rank = 0; is_sink = false; }

  virtual ~From_List () {}
};


class Out_List : public From_List {
public:
  float gradient;
  double timeout;
  double   from;
  double   to;
  int   num_data_send;
  int   num_neg_recv;
  int   num_pos_recv;

  Out_List() : From_List() { gradient = 0; from=0.0; to=0.0; num_data_send=0; 
                             timeout = 0.0; num_neg_recv = 0; num_pos_recv=0;}
  virtual ~Out_List () {}

  Out_List *WhereToGo();
  void CalRange();
  void NormalizeGradient();
};


class In_List : public Agent_List {
public:
  double avg_delay;
  double var_delay;
  int    total_received;
  int    prev_received;
  int    num_loss;
  int    num_neg_send;
  int    num_pos_send;

  int    total_new_org_recv;
  int    total_old_org_recv;
  int    total_new_sub_recv;
  int    new_org_recv;        // for simple mode. New original sample counter.
  int    old_org_recv;        // for simple mode. Old original sample counter.
  int    new_sub_recv;        // for simple mode. New subsample counter.
  double last_ts_new_sub;     // Last timestamp in receiving a new subsample.

  In_List() : Agent_List() { 
    avg_delay =0; 
    var_delay =0; 
    total_received=0;
    prev_received =0; 
    num_loss =0; 
    num_neg_send = 0;
    num_pos_send = 0;

    total_new_org_recv=0;
    total_old_org_recv=0;
    total_new_sub_recv=0; 

    new_org_recv=0;
    old_org_recv=0;
    new_sub_recv=0; 

    last_ts_new_sub = -1.0;
  }

  virtual ~In_List () {}

  In_List *FindMaxIn();
};

#endif



/* Example 

void main () {

  From_List *start, *cur;

  start=NULL;

  cur = new From_List;
  cur->agent_addr.addr_ =1;
  cur->agent_addr.port_ =1;
  INTF_INSERT(start,cur);

  cur = new From_List;
  cur->agent_addr.addr_ = 3;
  cur->agent_addr.port_ = 3;
  INTF_INSERT(start,cur);

  cur = new From_List;
  cur->agent_addr.addr_ = 5;
  cur->agent_addr.port_ = 5;
  INTF_INSERT(start,cur);

  start->print();

  PrvCurPtr RetVal;
  ns_addr_t fnd_addr;

  fnd_addr.addr_ = 1;
  fnd_addr.port_ = 1;
  RetVal= INTF_FIND(start, fnd_addr);
  INTF_REMOVE(RetVal.prv, RetVal.cur);

  start->print();

}

*/