Parent: [6ccca6] (diff)

Download this file

PDUFwdTabGenerator.h    219 lines (163 with data), 6.0 kB

  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
//
// Copyright Š 2014 - 2015 PRISTINE Consortium (http://ict-pristine.eu)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
/**
* @file PDUFwdTabGenerator.h
* @author Tomas Hykel (xhykel01@stud.fit.vutbr.cz) and Kewin Rausch(kewin.rausch@create-net.org)
* @brief PDU forwarding (routing) table generator.
* @detail Responds to various events happening inside the IPC process
* by adding, removing and editing entries in the forwarding table.
*/
#ifndef __RINA_PDUFWDTABGENERATOR_H_
#define __RINA_PDUFWDTABGENERATOR_H_
// Comment this directive to disable private debugging.
// With private debugging all the output will be redirected to a text file.
//#define PDUFTG_PRIVATE_DEBUG
#ifdef PDUFTG_PRIVATE_DEBUG
#include <iostream>
#include <fstream>
extern std::ofstream pduftg_debug_file;
// Log a string as a debug information.
#define pduftg_debug(x) pduftg_debug_file << x;
#else
// Log a string as a debug information.
#define pduftg_debug(x) EV << x;
#endif
#include <omnetpp.h>
#include "ModuleAccess.h"
#include "ConnectionId.h"
#include "RMT.h"
#include "RINASignals.h"
#include "NM1FlowTable.h"
#include "PDUForwardingTable.h"
#include "PDUFTGListeners.h"
#include "PDUFTGPolicy.h"
#include "PDUFTGUpdate.h"
#include "PDUFTGNeighbor.h"
typedef std::list<PDUFTGInfo *> NetworkState;
typedef NetworkState::iterator NIter;
// This is mapped as string --> port because Address do not have <, > operators overloads.
typedef std::list<PDUFTGNeighbor *> NeighborState;
typedef NeighborState::iterator EIter;
// Generator of the forwarding informations.
//
class PDUFwdTabGenerator : public cSimpleModule
{
private:
// Signal to notify forwarding info update occurs.
//
simsignal_t sigPDUFTGFwdInfoUpdate;
// Listener for forwarding information.
//
LisPDUFTGFwdInfoRecv * lisInfoRecv;
// The actual active forwarding policy to use.
//
PDUFTGPolicy * fwdPolicy;
// Contains the actual status of the network we're aware of.
//
NetworkState netState;
// Contains the list of N-DIF neighbors of this IPC Address.
//
NeighborState neiState;
// PDU Forwarding table module pointer(filled during initialization).
//
PDUForwardingTable* fwTable;
// This table will allow us to get the right queue starting from the flow information.
//
NM1FlowTable * flTable;
// The IP Address. We will use this to filter flow informations and collect
// only those of the same DIF.
//
Address ipcAddr;
// Will the network state be visible at upper levels?
//
bool showNetState;
// The module where the report will be posted on.
//
cModule * nstm;
// Gets a user friendly formatted network state report.
//
std::string prepareFriendlyNetState();
protected:
virtual void finish();
virtual void initialize();
virtual void handleMessage(cMessage *msg);
// Initializes the necessary input/output mechanisms.
void initializeSignalsAndListeners();
public:
//
// Getters:
//
// Gets the managed instance of Forwarding table.
PDUForwardingTable * getForwardingTable();
// Gets the address associated with this IPC.
Address getIpcAddress();
// Gets the map of the current mapped neighbors.
NeighborState * getNeighborhoodState();
// Gets the actual network state known by us.
NetworkState * getNetworkState();
// Find the next known neighbor to reach the destination.
PDUFTGNeighbor * getNextNeighbor(Address destination, unsigned short qos);
// Gets the managed instance of the N-1 flow table.
NM1FlowTable * getNM1FlowTable();
//
// No network state actions.
// Actions are defined on data, and data can be policy defined. So procedure to handle
// such data should be shipped with the policy itself.
//
// Returns the actual string formatted network info we have.
std::string netInfo();
//
// Neighbors state actions:
//
// Insert a new neighbor.
void insertNeighbor(Address addr, unsigned short qos, RMTPort * p);
// Check if the neighbor desired exists.
PDUFTGNeighbor * neighborExists(Address src);
// Returns the actual string formatted neighbor state.
std::string neiInfo();
// Removes a neighbor.
void removeNeiInfo(Address addr);
//
// Policy plugin architecture:
//
// Publish a policy replacing the one actually in use.
void publishPolicy(PDUFTGPolicy * p);
// Removes the actual policy in use.
void unpublishPolicy();
//
// Flow up/down operations:
//
// Inserts a new flow through which a neighbor can be reached.
void insertFlowInfo(Address addr, unsigned short qos, RMTPort * port);
// Removes an existing flow from the existing ones.
void removeFlowInfo(RMTPort * port);
//
// Module signal emission:
//
// Signal to whoever listen for SIG_PDUFTG_FwdInfoUpdate event that an update
// information must be handled.
//
void signalForwardingInfoUpdate(PDUFTGUpdate * info);
// Handle an incoming update message.
void handleUpdateMessage(PDUFTGUpdate * info);
//
// Debug only
//
// Bubble out a message on the selected network state report module.
void reportBubbleInfo(const char * message);
};
#endif /* __RINA_PDUFWDTABGENERATOR_H_ */