PastryRoutingTable.h

Go to the documentation of this file.
00001 #ifndef __PASTRYROUTINGTABLE_H_
00002 #define __PASTRYROUTINGTABLE_H_
00003 
00004 //
00005 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 //
00021 
00027 #include <vector>
00028 
00029 #include <omnetpp.h>
00030 
00031 #include <NodeHandle.h>
00032 
00033 #include "PastryStateObject.h"
00034 #include "PastryTypes.h"
00035 #include "PastryMessage_m.h"
00036 
00040 typedef std::vector<PastryExtendedNode> PRTRow;
00041 
00045 struct PRTTrackRepair
00046 {
00047     TransportAddress node;//*< the node last asked for repair
00048     simtime_t timestamp;  //*< the time when it was asked
00049     uint32_t failedRow;       //*< row of the failed node
00050     uint32_t failedCol;   //*< col of the failed node
00051     uint32_t askedRow;    //*< row of the node last asked
00052     uint32_t askedCol;    //*< col of the node last asked
00053 };
00054 
00063 class PastryRoutingTable : public PastryStateObject
00064 {
00065 
00066   public:
00074     void initializeTable(uint32_t bitsPerDigit, double repairTimeout,
00075                          const NodeHandle& owner);
00076 
00084     const NodeHandle& lookupNextHop(const OverlayKey& destination);
00085 
00097     virtual const NodeHandle& findCloserNode(const OverlayKey& destination,
00098                                              bool optimize = false);
00099 
00100     void findCloserNodes(const OverlayKey& destination,
00101                          NodeVector* nodes);
00102 
00109     virtual const TransportAddress& failedNode(const TransportAddress& failed);
00110 
00119     virtual const TransportAddress& repair(const PastryStateMessage* msg,
00120                                            const PastryStateMsgProximity* prox);
00121 
00127     virtual void dumpToStateMessage(PastryStateMessage* msg) const;
00128 
00134     virtual void dumpRowToMessage(PastryRoutingRowMessage* msg, int row) const;
00135 
00141     virtual void dumpRowToMessage(PastryStateMessage* msg, int row) const;
00142 
00147     int getLastRow();
00148 
00155     virtual const TransportAddress& getRandomNode(int row);
00156 
00157 
00165     bool mergeNode(const NodeHandle& node, simtime_t prox);
00166 
00175     bool initStateFromHandleVector(const std::vector<PastryStateMsgHandle>& handles);
00176 
00184     virtual void dumpToVector(std::vector<TransportAddress>& affected) const;
00185 
00186     uint32_t nodesPerRow; //TODO getter/setter + private
00187 
00188   private:
00189     double repairTimeout;
00190     std::vector<PRTRow> rows;
00191     std::vector<PRTTrackRepair> awaitingRepair;
00192 
00193     virtual void earlyInit(void);
00194 
00198     void addRow(void);
00199 
00207     uint32_t digitAt(uint32_t n, const OverlayKey& key) const;
00208 
00215     const PastryExtendedNode& nodeAt(uint32_t row, uint32_t col) const;
00216 
00223     void findNextNodeToAsk(PRTTrackRepair& track) const;
00224 
00225 };
00226 
00231 std::ostream& operator<<(std::ostream& os, const PRTRow& row);
00232 
00233 #endif
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3