00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __INET_RSVP_H
00016 #define __INET_RSVP_H
00017
00018 #include <vector>
00019 #include <omnetpp.h>
00020
00021 #include "IScriptable.h"
00022 #include "IntServ.h"
00023 #include "RSVPPathMsg.h"
00024 #include "RSVPResvMsg.h"
00025 #include "RSVPHelloMsg.h"
00026 #include "SignallingMsg_m.h"
00027 #include "IRSVPClassifier.h"
00028 #include "NotificationBoard.h"
00029
00030 class SimpleClassifier;
00031 class IRoutingTable;
00032 class IInterfaceTable;
00033 class TED;
00034 class LIBTable;
00035
00036
00040 class INET_API RSVP : public cSimpleModule, public IScriptable
00041 {
00042 protected:
00043
00044 struct traffic_path_t
00045 {
00046 SenderTemplateObj_t sender;
00047 SenderTspecObj_t tspec;
00048
00049 EroVector ERO;
00050 simtime_t max_delay;
00051
00052 int owner;
00053 bool permanent;
00054 int color;
00055 };
00056
00057 struct traffic_session_t
00058 {
00059 SessionObj_t sobj;
00060
00061 std::vector<traffic_path_t> paths;
00062 };
00063
00064 std::vector<traffic_session_t> traffic;
00065
00069 struct PathStateBlock_t
00070 {
00071
00072 SessionObj_t Session_Object;
00073
00074
00075 SenderTemplateObj_t Sender_Template_Object;
00076
00077
00078 SenderTspecObj_t Sender_Tspec_Object;
00079
00080
00081 IPAddress Previous_Hop_Address;
00082
00083
00084
00085
00086
00087 IPAddress OutInterface;
00088
00089
00090 EroVector ERO;
00091
00092
00093 int id;
00094
00095
00096 int color;
00097
00098
00099 PsbTimerMsg *timerMsg;
00100 PsbTimeoutMsg *timeoutMsg;
00101
00102
00103 int handler;
00104 };
00105
00106 typedef std::vector<PathStateBlock_t> PSBVector;
00107
00111 struct ResvStateBlock_t
00112 {
00113
00114 SessionObj_t Session_Object;
00115
00116
00117 IPAddress Next_Hop_Address;
00118
00119
00120 IPAddress OI;
00121
00122
00123 FlowDescriptorVector FlowDescriptor;
00124
00125
00126 std::vector<int> inLabelVector;
00127
00128
00129
00130
00131
00132 FlowSpecObj_t Flowspec_Object;
00133
00134
00135 int id;
00136
00137
00138 RsbRefreshTimerMsg *refreshTimerMsg;
00139 RsbCommitTimerMsg *commitTimerMsg;
00140 RsbTimeoutMsg *timeoutMsg;
00141 };
00142
00143 typedef std::vector<ResvStateBlock_t> RSBVector;
00144
00148 struct HelloState_t
00149 {
00150 IPAddress peer;
00151
00152 int srcInstance;
00153 int dstInstance;
00154
00155 HelloTimerMsg *timer;
00156 HelloTimeoutMsg *timeout;
00157
00158
00159 bool request;
00160 bool ack;
00161
00162
00163 bool ok;
00164 };
00165
00166 typedef std::vector<HelloState_t> HelloVector;
00167
00168 simtime_t helloInterval;
00169 simtime_t helloTimeout;
00170 simtime_t retryInterval;
00171
00172 protected:
00173 TED *tedmod;
00174 IRoutingTable *rt;
00175 IInterfaceTable *ift;
00176 LIBTable *lt;
00177 NotificationBoard *nb;
00178
00179 IRSVPClassifier *rpct;
00180
00181 int maxPsbId;
00182 int maxRsbId;
00183
00184 int maxSrcInstance;
00185
00186 IPAddress routerId;
00187
00188 PSBVector PSBList;
00189 RSBVector RSBList;
00190 HelloVector HelloList;
00191
00192 protected:
00193 virtual void processSignallingMessage(SignallingMsg *msg);
00194 virtual void processPSB_TIMER(PsbTimerMsg *msg);
00195 virtual void processPSB_TIMEOUT(PsbTimeoutMsg* msg);
00196 virtual void processRSB_REFRESH_TIMER(RsbRefreshTimerMsg *msg);
00197 virtual void processRSB_COMMIT_TIMER(RsbCommitTimerMsg *msg);
00198 virtual void processRSB_TIMEOUT(RsbTimeoutMsg* msg);
00199 virtual void processHELLO_TIMER(HelloTimerMsg* msg);
00200 virtual void processHELLO_TIMEOUT(HelloTimeoutMsg* msg);
00201 virtual void processPATH_NOTIFY(PathNotifyMsg* msg);
00202 virtual void processRSVPMessage(RSVPMessage* msg);
00203 virtual void processHelloMsg(RSVPHelloMsg* msg);
00204 virtual void processPathMsg(RSVPPathMsg* msg);
00205 virtual void processResvMsg(RSVPResvMsg* msg);
00206 virtual void processPathTearMsg(RSVPPathTear* msg);
00207 virtual void processPathErrMsg(RSVPPathError* msg);
00208
00209 virtual PathStateBlock_t* createPSB(RSVPPathMsg *msg);
00210 virtual PathStateBlock_t* createIngressPSB(const traffic_session_t& session, const traffic_path_t& path);
00211 virtual void removePSB(PathStateBlock_t *psb);
00212 virtual ResvStateBlock_t* createRSB(RSVPResvMsg *msg);
00213 virtual ResvStateBlock_t* createEgressRSB(PathStateBlock_t *psb);
00214 virtual void updateRSB(ResvStateBlock_t* rsb, RSVPResvMsg *msg);
00215 virtual void removeRSB(ResvStateBlock_t *rsb);
00216 virtual void removeRsbFilter(ResvStateBlock_t *rsb, unsigned int index);
00217
00218 virtual void refreshPath(PathStateBlock_t *psbEle);
00219 virtual void refreshResv(ResvStateBlock_t *rsbEle);
00220 virtual void refreshResv(ResvStateBlock_t *rsbEle, IPAddress PHOP);
00221 virtual void commitResv(ResvStateBlock_t *rsb);
00222
00223 virtual void scheduleRefreshTimer(PathStateBlock_t *psbEle, simtime_t delay);
00224 virtual void scheduleTimeout(PathStateBlock_t *psbEle);
00225 virtual void scheduleRefreshTimer(ResvStateBlock_t *rsbEle, simtime_t delay);
00226 virtual void scheduleCommitTimer(ResvStateBlock_t *rsbEle);
00227 virtual void scheduleTimeout(ResvStateBlock_t *rsbEle);
00228
00229 virtual void sendPathErrorMessage(PathStateBlock_t *psb, int errCode);
00230 virtual void sendPathErrorMessage(SessionObj_t session, SenderTemplateObj_t sender, SenderTspecObj_t tspec, IPAddress nextHop, int errCode);
00231 virtual void sendPathTearMessage(IPAddress peerIP, const SessionObj_t& session, const SenderTemplateObj_t& sender, IPAddress LIH, IPAddress NHOP, bool force);
00232 virtual void sendPathNotify(int handler, const SessionObj_t& session, const SenderTemplateObj_t& sender, int status, simtime_t delay);
00233
00234 virtual void setupHello();
00235 virtual void startHello(IPAddress peer, simtime_t delay);
00236
00237 virtual void recoveryEvent(IPAddress peer);
00238
00239 virtual bool allocateResource(IPAddress OI, const SessionObj_t& session, double bandwidth);
00240 virtual void preempt(IPAddress OI, int priority, double bandwidth);
00241 virtual bool doCACCheck(const SessionObj_t& session, const SenderTspecObj_t& tspec, IPAddress OI);
00242 virtual void announceLinkChange(int tedlinkindex);
00243
00244 virtual void sendToIP(cMessage *msg, IPAddress destAddr);
00245
00246 virtual bool evalNextHopInterface(IPAddress destAddr, const EroVector& ERO, IPAddress& OI);
00247
00248 virtual PathStateBlock_t* findPSB(const SessionObj_t& session, const SenderTemplateObj_t& sender);
00249 virtual ResvStateBlock_t* findRSB(const SessionObj_t& session, const SenderTemplateObj_t& sender, unsigned int& index);
00250
00251 virtual PathStateBlock_t* findPsbById(int id);
00252 virtual ResvStateBlock_t* findRsbById(int id);
00253
00254 std::vector<traffic_session_t>::iterator findSession(const SessionObj_t& session);
00255 std::vector<traffic_path_t>::iterator findPath(traffic_session_t *session, const SenderTemplateObj_t &sender);
00256
00257 virtual HelloState_t* findHello(IPAddress peer);
00258
00259 virtual void print(RSVPPathMsg *p);
00260 virtual void print(RSVPResvMsg *r);
00261
00262 virtual void readTrafficFromXML(const cXMLElement *traffic);
00263 virtual void readTrafficSessionFromXML(const cXMLElement *session);
00264 virtual EroVector readTrafficRouteFromXML(const cXMLElement *route);
00265
00266 virtual void createPath(const SessionObj_t& session, const SenderTemplateObj_t& sender);
00267
00268 virtual void pathProblem(PathStateBlock_t *psb);
00269
00270 virtual void addSession(const cXMLElement& node);
00271 virtual void delSession(const cXMLElement& node);
00272
00273 protected:
00274
00275 friend class SimpleClassifier;
00276
00277 virtual int getInLabel(const SessionObj_t& session, const SenderTemplateObj_t& sender);
00278
00279 public:
00280 RSVP();
00281 virtual ~RSVP();
00282
00283 protected:
00284 virtual int numInitStages() const {return 5;}
00285 virtual void initialize(int stage);
00286 virtual void handleMessage(cMessage *msg);
00287
00288
00289 virtual void processCommand(const cXMLElement& node);
00290
00291 };
00292
00293 bool operator==(const SessionObj_t& a, const SessionObj_t& b);
00294 bool operator!=(const SessionObj_t& a, const SessionObj_t& b);
00295
00296 bool operator==(const FilterSpecObj_t& a, const FilterSpecObj_t& b);
00297 bool operator!=(const FilterSpecObj_t& a, const FilterSpecObj_t& b);
00298
00299 bool operator==(const SenderTemplateObj_t& a, const SenderTemplateObj_t& b);
00300 bool operator!=(const SenderTemplateObj_t& a, const SenderTemplateObj_t& b);
00301
00302 std::ostream& operator<<(std::ostream& os, const SessionObj_t& a);
00303 std::ostream& operator<<(std::ostream& os, const SenderTemplateObj_t& a);
00304 std::ostream& operator<<(std::ostream& os, const FlowSpecObj_t& a);
00305
00306 #endif
00307
00308