|
a |
|
b/src/policies/DIF/RA/Forwarding/DistanceVector/DistanceVectorPolicy.h |
|
|
1 |
//
|
|
|
2 |
// This program is free software: you can redistribute it and/or modify
|
|
|
3 |
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
4 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
5 |
// (at your option) any later version.
|
|
|
6 |
//
|
|
|
7 |
// This program is distributed in the hope that it will be useful,
|
|
|
8 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
10 |
// GNU Lesser General Public License for more details.
|
|
|
11 |
//
|
|
|
12 |
// You should have received a copy of the GNU Lesser General Public License
|
|
|
13 |
// along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
14 |
//
|
|
|
15 |
|
|
|
16 |
/* Author: Kewin Rausch (kewin.rausch@create-net.org) */
|
|
|
17 |
|
|
|
18 |
#ifndef __RINA_DISTANCEVECTORPOLICY_H
|
|
|
19 |
#define __RINA_DISTANCEVECTORPOLICY_H
|
|
|
20 |
|
|
|
21 |
#include <omnetpp.h>
|
|
|
22 |
|
|
|
23 |
#include "PDUFTGPolicy.h"
|
|
|
24 |
|
|
|
25 |
#define PDUFTG_SELFMSG_FSUPDATE 0x01
|
|
|
26 |
|
|
|
27 |
// This implements a basic distance-vector routing policy.
|
|
|
28 |
// The metric used is in term of hops.
|
|
|
29 |
//
|
|
|
30 |
class DistanceVectorPolicy :
|
|
|
31 |
public PDUFTGPolicy
|
|
|
32 |
{
|
|
|
33 |
private:
|
|
|
34 |
/* msec between updates. */
|
|
|
35 |
unsigned int updateT;
|
|
|
36 |
|
|
|
37 |
// Just prepare an update fo a destination host.
|
|
|
38 |
PDUFTGUpdate * prepareFSUpdate(Address destination);
|
|
|
39 |
|
|
|
40 |
protected:
|
|
|
41 |
|
|
|
42 |
void handleMessage(cMessage *msg);
|
|
|
43 |
void initialize();
|
|
|
44 |
|
|
|
45 |
public:
|
|
|
46 |
DistanceVectorPolicy();
|
|
|
47 |
~DistanceVectorPolicy();
|
|
|
48 |
|
|
|
49 |
// Computes the initial state of the forwarding table.
|
|
|
50 |
//
|
|
|
51 |
void computeForwardingTable();
|
|
|
52 |
|
|
|
53 |
// Evaluated in term of policy defined flow if a flow exists.
|
|
|
54 |
//
|
|
|
55 |
virtual PDUFTGInfo * flowExists(Address addr, unsigned short qos);
|
|
|
56 |
|
|
|
57 |
/* Get the update timer actual tick value.
|
|
|
58 |
*/
|
|
|
59 |
unsigned int getUpdateTimeout();
|
|
|
60 |
|
|
|
61 |
// Insert a new flow which has been open locally to this IPC Process.
|
|
|
62 |
//
|
|
|
63 |
void insertNewFlow(Address addr, short unsigned int qos, RMTPort * port);
|
|
|
64 |
|
|
|
65 |
// Merge an incoming information with the existing ones.
|
|
|
66 |
//
|
|
|
67 |
void mergeForwardingInfo(PDUFTGUpdate * info);
|
|
|
68 |
|
|
|
69 |
// Removes a local opened flow.
|
|
|
70 |
//
|
|
|
71 |
virtual void removeFlow(Address addr, short unsigned int qos);
|
|
|
72 |
|
|
|
73 |
/* Set a new timeout between an update message and another, in seconds.
|
|
|
74 |
*/
|
|
|
75 |
void setUpdateTimeout(unsigned int sec);
|
|
|
76 |
};
|
|
|
77 |
|
|
|
78 |
#endif // __RINA_DISTANCEVECTORPOLICY_H
|