📄 node2.h
字号:
public:
RoutingTableEntry(int a, Node *ss)
{ addr = a; s = ss; n = NULL; d = NULL; };
~RoutingTableEntry();
int address() { return(addr); };
void address(int a) { addr = a; };
Node *source() { return(s); };
void source(Node *ss) { s =ss; };
RoutingTableEntry *next() { return(n); };
void next(RoutingTableEntry *nn) { n = nn; };
NodeListEntry *children() { return(d); };
void addDestination(Node *nd);
void removeDestination(Node *nd);
}; //RoutingTableEntry
class AdjacencyListEntry {
private:
double dist; //distance of the adjacent node
double del; //cell delay propagation and queueing on that link
double wght; // link weight
Node *nd; // pointer to the adjacent node
Queue *q; //each output link has a priority queue
int bsy; // = True if a packet is being transmitted
AdjacencyListEntry *n; // points to the next adjacency list entry
double avg; // sum of avg. rates on link
double pk; // sum of peak rates on link
double cpcty; // The link capacity
public:
void trafficOut(Data *d, double t_global, TheEventList *E);
//a data packet leaving the queue of an output link
AdjacencyListEntry(Node *nn, double x, double y, double c);
~AdjacencyListEntry() { delete q; };
double distance() { return(dist); };
void distance(double d) { dist = d; };
double delay() { return(del); };
void delay(double d) { del = d; };
double cost() { return(wght); };
void cost(double w) { wght = w; };
Node* nodePtr() { return(nd); };
void nodePtr(Node *nn) { nd = nn; };
Queue *queue() { return(q); };
int busy() { return(bsy); };
void busy(int b) { bsy = b; };
AdjacencyListEntry *next() { return(n); };
void next(AdjacencyListEntry *nn) { n = nn; };
double average() { return(avg); };
void average(double a) { avg = a; };
double peak() { return(pk); };
void peak(double a) { pk = a; };
double linkCapacity() { return(cpcty); };
void linkCapacity(double c) { cpcty = c; };
}; //AdjacencyListEntry
class Node { // A node
private:
SourceList *sl; //each node keeps a list of the sources connected
//to it
int id; //node id
RoutingTableEntry *rte; //a look up table for routing
AdjacencyListEntry *ale; //a list of adjacent nodes
double x; // x coordinate of the node's location
double y; // y coordinate of the node's location
public:
Node(double xx = 0.0, double yy = 0.0) {
sl = NULL; rte = NULL; ale = NULL; x = xx; y = yy;
};
~Node();
int name() { return(id); };
void name(int i) { id = i; };
SourceList *sourceList() { return(sl); };
void sourceList(SourceList *s) { sl = s; };
void trafficIn(Data *d, double t_global, TheEventList *E,
TheNodeList *N, int stats);
//a data packet arriving at a node
Source *addSource(int model, int type, int pr, double peak,
double avg_rho, double burstiness, int addr);
int removeSource(int type, int priority, int addr);
void addChild(int addr, Node *source, Node *child);
void removeChild(int addr, Node *source, Node *child);
AdjacencyListEntry *adjacentNodes() { return(ale); };
void adjacentNodes(AdjacencyListEntry *adj) { ale = adj; };
RoutingTableEntry *routingTable() { return(rte); };
void routingTable(RoutingTableEntry *r) { rte = r; };
void addRoutingEntry(int addr, Node *source);
void removeRoutingEntry(int addr, Node *source);
int addNeighbor(Node *nbor, double capacity,
double pk = 0, double avg = 0);
int removeNeighbor(Node *nbor);
double X() { return(x); };
void X(double xx) { x = xx; };
double Y() { return(y); };
void Y(double yy) { y = yy; };
}; //Node
class MCGroup { // A linked list entry for an MC group
private:
NodeListEntry *firstm; //points to the first entry in the linked list
//containing all group members
int num; //number of group members
int addr; //group address
MCGroup *n; //points to the next Group
public:
MCGroup(int a) { firstm = NULL; num = 0; n = NULL; addr = a; };
~MCGroup();
int count() { return(num); };
void count(int nn) { num = nn; };
int address() { return(addr); };
void address(int a) { addr = a; };
MCGroup *next() { return(n); };
void next(MCGroup *nn) { n = nn; };
NodeListEntry *headm() { return(firstm); };
void headm(NodeListEntry *h) { firstm = h; };
int addMember(Node *nd);
void removeMember(Node *nd);
};
class Stats;
class NodeStats;
//The following classes are used by the CBF router only
class edge;
class edgeQueue;
class path;
class pathList;
//The following classes are used by the BSMA router only
class kthPath;
//The following classes are used by the CST router only
class Via;
class TheNodeList { // A linked list of node pointers that the manages the
//operation of the network
private:
NodeListEntry *nodeListHd, *nodeListTl;
//pointers to the head and tail entries of the node list
double distance(Node *n, Node *m);
double edgeProb(double alpha, double beta, double L, double d);
void depth1stSearch(Node *n, int *mark);
int results(Node *source, int addr, Node *current, Node *dest,
double &delay, int &hops, int &gotit);
int prune(MCGroup *group, NodeListEntry **tree, Node *current,
Node *source, int addr, Node *parent, double peak,
double avg);
void prunePIM(int fn, Node *current, Node *dest, Node *bestConn,
NodeListEntry **tree, int &path, int addr,
Node *source, double peak, double avg, double &cost);
void dijkstra(int alg, int fn, Node *source,
double *delay_matrix, double *cost_matrix, double *dbv,
double peak, double average);
int pathWaters(Node *source, int addr, int name, double *delay_matrix,
double *cost_matrix, double db,
NodeListEntry **tree, double peak, double avg,
NodeListEntry **path);
void expand(int from, int member, int *via_matrix,
NodeListEntry **tree, Node *source, int addr,
double peak, double avg);
void expand2(int from, int member, int *via_matrix,
NodeListEntry **tree, Node *source, int addr,
double peak, double avg, int *in, int *fr,
double *del, double *d_matrix, double d);
double leastDelay(Node *source, int addr, MCGroup **group,
NodeListEntry **tree, double &pk, double &avg);
pathList *CBF(int source, double *c_matrix, double *d_matrix);
int relaxed(pathList *pl, edge *e, double *c_matrix, int srce);
void resolveConflict(int gCount, int to, int *member, int *occur,
int *encountered, double *delay, int *waiting,
path **mPath);
int severeConflict(int gCount, int *member, int *occur,
int *encountered, double *delay, double *d_matrix,
int *waiting, path **mPath, int srce);
void condDijkstra(int from, int to, int *tree1, int *tree2, int *inPath,
int *notInPath, kthPath **pl, double *c_matrix,
double *d_matrix, int h);
kthPath *kthShortest(int from, int to, double dBound, double cBound,
int *tree1, int *tree2, double *c_matrix,
double *d_matrix, int h);
void BSMAInfo(Node *source, int addr, Node *current, double *delay,
double *cost, int *hops, int *via, double *d_matrix,
double *c_matrix, int &seCount, int *from, int *to,
double *seCost, double &c, MCGroup *group);
void updateSubtreeDelays(int node, double diff, int *from_m,
double *actual_delay_m, double *max_delay_m);
void sort(int node, int degree, double *cost, int *adj);
void bandb(int alg, int srce, int destn, int node, int pos, int **adj,
double *node_delay, double *perm_delay, int *deg,
double *cost, double *delay, int *head, int *tail,
double *sp, int &nodes_visited, double &ub_now,
int grCount, int *gr_matrix, int *tree,
int *from, int *to, int links, int *child,
double *minwt_at_node);
double lb(int curr_pos, int grCount, int *head, int *tail,
int *child, int *tree, double *cost,
double *minwt_at_node, int *gr_matrix, int links);
int routAlgBF(double *dist_vect, int *parent_vect);
void forward(Node *nd, Node *from, Node *srce,
int addr, NodeListEntry **tree, double pk,
double avg, int *parent_vect);
int num; //number of nodes in the network;
MCGroup *groupsHd; //pointer to the linked list containig the MC
//groups
int grCount; //the number of MC groups
int srceCount; //the number of sources in the network
int maxName; //hold the largest valued node id in the network
TheEventList *E; //An event list managed by the node list
int dlc; //a boolean variable for displaying link costs
int dlcap; //a boolean variable for displaying link capacities
int dnn; //a boolean variable for displaying node names
int dg; //holds the address of the group to be displayed
//if dg = 0 no group will be displayed
int dt; //holds the address of the source for the tree to
//be displayed if dt = -1 no tree will be displayed
NodeStats *nodeStatsHd, *nodeStatsTl;//pointer to the head and tail of a
//linked list of NodeStats
void addNodeStats(Node *current, Node *source, int addr, int batches);
int batchNum;
int fn;
int obj;
public:
TheNodeList() { nodeListHd = nodeListTl = NULL; num = 0; grCount = 0;
srceCount = 0; groupsHd = NULL; E = new TheEventList;
maxName = 0; dlc = False; dnn = True; dg = 0, dt = -1;
nodeStatsHd = nodeStatsTl = NULL; batchNum = 0;
fn = PEAK; obj = PLAIN; ALPHA = 15; dlcap = False;
DELAYBOUND = .025; DELAYSTEP = .002;
ADMITRATIO = 1; DBV = True; defaultCapacity = OC3; };
double ALPHA;
double DELAYBOUND;
double DELAYSTEP;
double ADMITRATIO;
double defaultCapacity;
int DBV;
int objective() { return(obj); };
void objective(int o) { obj = o; };
int function() { return(fn); };
void function(int f) { fn = f; };
int count() { return(num); };
void count(int n) { num = n; };
NodeListEntry *head() { return(nodeListHd); };
void head(NodeListEntry *h) { nodeListHd = h; };
NodeListEntry *tail() { return(nodeListTl); };
void tail(NodeListEntry *t) { nodeListTl = t; };
void addNode(NodeListEntry *n); //add a node to the node list
void removeNode(NodeListEntry *n); //remove a node from the node list
int addLink(NodeListEntry *n1, NodeListEntry *n2);
//add a node to the node list
int removeLink(NodeListEntry *n1, NodeListEntry *n2);
//remove a node from the node list
void deleteGraph();
void deleteLinks();
NodeListEntry *randomGraphGenerator(int n, float alpha, float beta,
float nodeDegree);
NodeListEntry *randomLinkGenerator(float alpha, float beta,
float nodeDegree);
NodeListEntry *findNode(double x, double y);
void addMuxedBackgroundTrafficSources(double minPeak, double maxPeak,
double minRho, double maxRho, double minBurst,
double maxBurst);
void addMuxedSymmetricBackgroundTrafficSources(double minPeak,
double maxPeak,
double minRho, double maxRho, double minBurst,
double maxBurst);
void addBatchBackgroundTrafficSources(double minPeak, double maxPeak,
double minRho, double maxRho, double minBurst,
double maxBurst);
void addBatchSymmetricBackgroundTrafficSources(double minPeak,
double maxPeak,
double minRho, double maxRho, double minBurst,
double maxBurst);
void removeBackgroundTrafficSources();
void addRandomMCGroup(int n, int addr);
void removeMCGroup(int addr);
MCGroup *groupsHead() { return(groupsHd); };
void addMCSource(Node *nd, double peak, double avg_rho, double burst,
int addr, int model);
void removeMCSource(Node *nd, int addr);
void addMCDestination(Node *nd, int addr);
void removeMCDestination(Node *nd, int addr);
double router(int alg, Node *source, int addr,
double &d, double &maxd, double &mind,
double &h, double &nodes);
double routerPIM(Node *source, int addr, double &d, double &maxd,
double &mind, double &h, double &nodes);
double routerWaters(int alg, Node *source, int addr, double &d,
double &maxd, double &mind, double &h,
double &nodes);
double routerCST(int alg, Node *source, int addr, double &d,
double &maxd, double &mind, double &h, double &nodes);
double routerLD(Node *source, int addr, double &d,
double &maxd, double &mind, double &h, double &nodes);
double routerKMB(Node *source, int addr, double &d,
double &maxd, double &mind, double &h, double &nodes);
double routerBF(Node *source, int addr, double &d,
double &maxd, double &mind, double &h, double &nodes);
double routerCAO(Node *source, int addr, double &d,
double &maxd, double &mind, double &h, double &nodes);
double routerBSMA(Node *source, int addr, double &d,
double &maxd, double &mind, double &h, double &nodes);
double routerDCDIMST(int alg, Node *source, int addr, double &d,
double &maxd,
double &mind, double &h, double &nodes);
double routerOPT(int alg, Node *source, int addr, double &d,
double &maxd,
double &mind, double &h, double &nodes);
double routerDVMRP(Node *srce, int addr, double &d, double &maxd,
double &mind, double &h, double &nodes);
double routerBFNOADM(Node *source, int addr, double &d, double &maxd,
double &mind, double &h, double &nodes);
double routerCDKS(Node *source, int addr, double &d, double &maxd,
double &mind, double &h, double &nodes);
void writeToFile(char *fileName);
int readFromFile(char *fileName);
TheEventList *eventManager() { return(E); };
void eventManager(TheEventList *e) { E = e; };
NodeStats *simulation(double batchSize, int minBatches,
int maxBatches, char *outFile);
int removeSubtree(Node *source, int addr, Node *root);
void removeTree(Node *source, int addr);
void displayLinkCost(int d) { dlc = d; };
void displayLinkCap(int d) { dlcap = d; };
void displayNodeName(int d) { dnn = d; };
void displayGroup(int d) { dg = d; };
void displayTree(int t) { dt = t; };
Node *nodeOf(int name);
MCGroup *groupOf(int addr);
double graphDegree();
void statistics(Node *nd, Data *d, double t_global);
void refresh(graphics gr); //redraw the network on the screen
void renumber(); //renumber the nodes before applying any routing
//algorithm.
void loadDistribution(double &mean, double &var, int *hstgrm);
}; //TheNodeList
#include "stats.h"
double ran();
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -