Minor tweaks to stats API.
This commit is contained in:
@@ -54,9 +54,8 @@ NS_LOG_COMPONENT_DEFINE ("WiFiDistanceExperiment");
|
||||
|
||||
|
||||
void TxCallback(Ptr<CounterCalculator<uint32_t> > datac,
|
||||
std::string path, Ptr<const Packet> packet,
|
||||
Mac48Address realto) {
|
||||
NS_LOG_INFO("Sent frame to " << realto << "; counted in " <<
|
||||
std::string path, Ptr<const Packet> packet) {
|
||||
NS_LOG_INFO("Sent frame counted in " <<
|
||||
datac->GetKey());
|
||||
datac->Update();
|
||||
// end TxCallback
|
||||
@@ -201,7 +200,7 @@ int main(int argc, char *argv[]) {
|
||||
Ptr<CounterCalculator<uint32_t> > totalTx =
|
||||
CreateObject<CounterCalculator<uint32_t> >();
|
||||
totalTx->SetKey("wifi-tx-frames");
|
||||
Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Tx",
|
||||
Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
|
||||
MakeBoundCallback(&TxCallback, totalTx));
|
||||
data.AddDataCalculator(totalTx);
|
||||
|
||||
@@ -212,9 +211,9 @@ int main(int argc, char *argv[]) {
|
||||
Ptr<PacketCounterCalculator> totalRx =
|
||||
CreateObject<PacketCounterCalculator>();
|
||||
totalRx->SetKey("wifi-rx-frames");
|
||||
Config::Connect("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Rx",
|
||||
MakeCallback(&PacketCounterCalculator::FrameUpdate,
|
||||
totalRx));
|
||||
Config::Connect("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
|
||||
MakeCallback(&PacketCounterCalculator::PacketUpdate,
|
||||
totalRx));
|
||||
data.AddDataCalculator(totalRx);
|
||||
|
||||
|
||||
|
||||
@@ -45,3 +45,15 @@ DataOutputInterface::DoDispose()
|
||||
Object::DoDispose();
|
||||
// end DataOutputInterface::DoDispose
|
||||
}
|
||||
|
||||
void
|
||||
DataOutputInterface::SetFilePrefix(const std::string prefix)
|
||||
{
|
||||
m_filePrefix = prefix;
|
||||
}
|
||||
|
||||
std::string
|
||||
DataOutputInterface::GetFilePrefix() const
|
||||
{
|
||||
return m_filePrefix;
|
||||
}
|
||||
|
||||
@@ -37,9 +37,14 @@ namespace ns3 {
|
||||
|
||||
virtual void Output(DataCollector &dc) = 0;
|
||||
|
||||
void SetFilePrefix(const std::string prefix);
|
||||
std::string GetFilePrefix() const;
|
||||
|
||||
protected:
|
||||
virtual void DoDispose();
|
||||
|
||||
std::string m_filePrefix;
|
||||
|
||||
// end class DataOutputInterface
|
||||
};
|
||||
|
||||
|
||||
@@ -34,9 +34,10 @@ NS_LOG_COMPONENT_DEFINE("OmnetDataOutput");
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//----------------------------------------------
|
||||
OmnetDataOutput::OmnetDataOutput() :
|
||||
m_filePrefix("data")
|
||||
OmnetDataOutput::OmnetDataOutput()
|
||||
{
|
||||
m_filePrefix = "data";
|
||||
|
||||
NS_LOG_FUNCTION_NOARGS();
|
||||
}
|
||||
OmnetDataOutput::~OmnetDataOutput()
|
||||
@@ -52,17 +53,6 @@ OmnetDataOutput::DoDispose()
|
||||
// end OmnetDataOutput::DoDispose
|
||||
}
|
||||
|
||||
void
|
||||
OmnetDataOutput::SetFilePrefix(const std::string prefix)
|
||||
{
|
||||
m_filePrefix = prefix;
|
||||
}
|
||||
std::string
|
||||
OmnetDataOutput::GetFilePrefix() const
|
||||
{
|
||||
return m_filePrefix;
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
void
|
||||
OmnetDataOutput::Output(DataCollector &dc)
|
||||
|
||||
@@ -37,9 +37,6 @@ namespace ns3 {
|
||||
|
||||
virtual void Output(DataCollector &dc);
|
||||
|
||||
void SetFilePrefix(const std::string prefix);
|
||||
std::string GetFilePrefix() const;
|
||||
|
||||
protected:
|
||||
virtual void DoDispose();
|
||||
|
||||
@@ -73,7 +70,6 @@ namespace ns3 {
|
||||
// end class OmnetOutputCallback
|
||||
};
|
||||
|
||||
std::string m_filePrefix;
|
||||
// end class OmnetDataOutput
|
||||
};
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ NS_LOG_COMPONENT_DEFINE("SqliteDataOutput");
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//----------------------------------------------
|
||||
SqliteDataOutput::SqliteDataOutput() :
|
||||
m_dbFile("data.db")
|
||||
SqliteDataOutput::SqliteDataOutput()
|
||||
{
|
||||
m_filePrefix = "data";
|
||||
NS_LOG_FUNCTION_NOARGS();
|
||||
}
|
||||
SqliteDataOutput::~SqliteDataOutput()
|
||||
@@ -53,17 +53,6 @@ SqliteDataOutput::DoDispose()
|
||||
// end SqliteDataOutput::DoDispose
|
||||
}
|
||||
|
||||
void
|
||||
SqliteDataOutput::SetDBFile(const std::string file)
|
||||
{
|
||||
m_dbFile = file;
|
||||
}
|
||||
std::string
|
||||
SqliteDataOutput::GetDBFile() const
|
||||
{
|
||||
return m_dbFile;
|
||||
}
|
||||
|
||||
int
|
||||
SqliteDataOutput::Exec(std::string exe) {
|
||||
int res;
|
||||
@@ -111,6 +100,7 @@ SqliteDataOutput::Exec(std::string exe) {
|
||||
void
|
||||
SqliteDataOutput::Output(DataCollector &dc)
|
||||
{
|
||||
std::string m_dbFile = m_filePrefix + ".db";
|
||||
|
||||
if (sqlite3_open(m_dbFile.c_str(), &m_db)) {
|
||||
NS_LOG_ERROR("Could not open sqlite3 database \"" << m_dbFile << "\"");
|
||||
|
||||
@@ -40,9 +40,6 @@ namespace ns3 {
|
||||
|
||||
virtual void Output(DataCollector &dc);
|
||||
|
||||
void SetDBFile(const std::string file);
|
||||
std::string GetDBFile() const;
|
||||
|
||||
protected:
|
||||
virtual void DoDispose();
|
||||
|
||||
@@ -82,7 +79,6 @@ namespace ns3 {
|
||||
sqlite3 *m_db;
|
||||
int Exec(std::string exe);
|
||||
|
||||
std::string m_dbFile;
|
||||
// end class SqliteDataOutput
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user