CBR-DHT.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2007 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #ifndef __CBRDHT_H_
00025 #define __CBRDHT_H_
00026 
00027 #include <omnetpp.h>
00028 
00029 #include <OverlayKey.h>
00030 #include <SHA1.h>
00031 #include <CommonMessages_m.h>
00032 
00033 #include "CBR-DHTMessage_m.h"
00034 #include "DHTMessage_m.h"
00035 #include "DHTDataStorage.h"
00036 
00037 #include "BaseApp.h"
00038 #include <RpcMacros.h>
00039 
00040 class CoordBasedRouting;
00041 class NeighborCache;
00042 
00048 class CBRDHT : public BaseApp
00049 {
00050 public:
00051     CBRDHT();
00052     virtual ~CBRDHT();
00053 
00054 protected:
00055     typedef std::vector<NodeHandle> ReplicaVector;
00056 
00057     struct GetMapEntry
00058     {
00059         ReplicaVector replica;
00060         std::map<BinaryValue, ReplicaVector> hashes;
00061         int numSent;
00062         int numAvailableReplica;
00063         int numResponses;
00064         int teamNumber;
00065         DHTgetCAPICall* callMsg;
00066         ReplicaVector* hashVector;
00067     };
00068 
00069     struct PutMapEntry
00070     {
00071         int numSent;
00072         int numFailed;
00073         int numResponses;
00074         DHTputCAPICall* callMsg;
00075     };
00076 
00077     void initializeApp(int stage);
00078     void finishApp();
00079     void handleTimerEvent(cMessage* msg);
00080 
00081     bool handleRpcCall(BaseCallMessage* msg);
00082     void handleRpcResponse(BaseResponseMessage* msg, cPolymorphic *context,
00083                            int rpcId, simtime_t rtt);
00084     void handleRpcTimeout(BaseCallMessage* msg, const TransportAddress& dest,
00085                           cPolymorphic* context, int rpcId,
00086                           const OverlayKey& destKey);
00087     void handleUpperMessage(cMessage* msg);
00088     void handlePutRequest(DHTPutCall* dhtMsg);
00089     void handleGetRequest(CBRDHTGetCall* dhtMsg);
00090     void handlePutResponse(DHTPutResponse* dhtMsg, int rpcId);
00091     void handleGetResponse(CBRDHTGetResponse* dhtMsg, int rpcId);
00092     void handlePutCAPIRequest(DHTputCAPICall* capiPutMsg);
00093     void handleGetCAPIRequest(DHTgetCAPICall* capiGetMsg, int teamnum = 0);
00094 
00095     void handleDumpDhtRequest(DHTdumpCall* call);
00096     void update(const NodeHandle& node, bool joined);
00097     void handleLookupResponse(LookupResponse* lookupMsg);
00098 
00099     int resultValuesBitLength(DHTGetResponse* msg);
00100 
00101 
00102     int numReplica;
00103     uint8_t numReplicaTeams;
00104 
00105     double maintenanceMessages;
00106     double normalMessages;
00107     double numBytesMaintenance;
00108     double numBytesNormal;
00109     double lastGetCall;
00110     std::map<unsigned int, BaseCallMessage*> rpcIdMap; 
00111     std::map<int, GetMapEntry> getMap;
00112     std::map<int, PutMapEntry> putMap;
00113 
00114     // module references
00115     DHTDataStorage* dataStorage; 
00116     CoordBasedRouting* coordBasedRouting;
00117     NeighborCache* neighborCache;
00118 };
00119 
00120 #endif
Generated on Wed May 26 16:21:13 2010 for OverSim by  doxygen 1.6.3