-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.h
47 lines (39 loc) · 975 Bytes
/
node.h
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
#ifndef NODE_H
#define NODE_H
#include <iostream>
#include <vector>
#include "network.h"
class Network;
class Packet;
class Node{
struct DV{
int cost;
int destination;
int nextHop;
DV(int c,int d, int n){ destination=d; cost=c; nextHop=n;}
};
struct neighbor{
int neighid;
double delay;
int defaultCost;
neighbor(int c, double d, int def){neighid=c;delay=d;defaultCost=def;}
};
public:
Node();
Node(int id);
~Node();
int nodeId;
std::vector<DV> dvTable; //routing table
std::vector<neighbor> neighborList;
void addRoute(int src, int dest,int c);
void updateRoute(int dest,int nextHop, int c);
void addNeighbor(int id, double d, int c);
int returnCost(int a, int b, Network net);
void printNeighborList();
int returnId(int a, int b, Network net);
bool routeExists(int a,int b,Network net);
void printRoutingTable();
bool getsPacket(Packet pac,Network &net);
private:
};
#endif