00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SIMTRACER_H
00024 #define SIMTRACER_H
00025
00026 #include <string>
00027 #include <sstream>
00028 #include <fstream>
00029 #include <vector>
00030 #include <map>
00031 #include <BaseWorldUtility.h>
00032 #include <BaseLayer.h>
00033 #include <ConnectionManager.h>
00034 #include "Packet.h"
00035 # include "ImNotifiable.h"
00036
00037 using namespace std;
00038
00044 class SimTracer:public cSimpleModule, ImNotifiable
00045 {
00046
00047 public:
00048 SimTracer(): packet(100) {}
00049
00051 virtual void initialize(int);
00052
00054 virtual void finish();
00055
00057 void namLog(string namString);
00058
00059 void radioEnergyLog(unsigned long mac, int state, simtime_t duration,
00060 double power, double newPower);
00061
00063 void logLink(int parent, int child);
00065 void logPosition(int node, double x, double y);
00066
00068 virtual void receiveBBItem(int category, const BBItem * details, int scopeModuleId);
00069
00070 double getAvgSensorPowerConsumption();
00071
00072 double getSinkPowerConsumption();
00073
00074 protected:
00075 ofstream namFile, radioEnergyFile, treeFile;;
00076 vector < string > packetsColors;
00077 cOutVector goodputVec;
00078 cOutVector pSinkVec;
00079 cOutVector pSensorVec;
00080 map < unsigned long, double >powerConsumptions;
00081 int catPacket;
00082 Packet packet;
00083 long nbApplPacketsSent;
00084 long nbApplPacketsReceived;
00085 int catEnergy;
00086 map < unsigned long, double >powerConsumptions2;
00087 map < unsigned long, double >currPower;
00088 map < unsigned long, simtime_t> lastUpdates;
00089 BaseWorldUtility* world;
00090 };
00091
00092
00093 #endif
00094