fd-net-device, lte, wifi: Replace printf() with NS_LOG()

This commit is contained in:
Eduardo Almeida
2023-07-14 18:02:38 +01:00
parent 2f31e1ef91
commit a031bd2bd4
3 changed files with 25 additions and 28 deletions

View File

@@ -146,7 +146,7 @@ DpdkNetDevice::CheckAllPortsLinkStatus()
{
if (!link.link_status)
{
printf("Port %d Link Down\n", m_portId);
NS_LOG_INFO("Port " << +m_portId << " Link Down");
}
continue;
@@ -183,7 +183,7 @@ DpdkNetDevice::SignalHandler(int signum)
{
if (signum == SIGINT || signum == SIGTERM)
{
printf("\n\nSignal %d received, preparing to exit...\n", signum);
NS_LOG_INFO("Signal " << signum << " received, preparing to exit...");
m_forceQuit = true;
}
}
@@ -257,7 +257,7 @@ DpdkNetDevice::InitDpdk(int argc, char** argv, std::string dpdkDriver)
command.append(dpdkDriver);
command.append(" ");
command.append(m_deviceName);
printf("Executing: %s\n", command.c_str());
NS_LOG_INFO("Executing: " << command);
if (system(command.c_str()))
{
rte_exit(EXIT_FAILURE, "Execution failed - bye\n");

View File

@@ -23,7 +23,6 @@
#include <cmath>
#include <sstream>
#include <stdio.h>
namespace ns3
{
@@ -165,7 +164,7 @@ Asn1Header::SerializeBitset(std::bitset<N> data) const
// Clause 16.11 ITU-T X.691
else
{
printf("FRAGMENTATION NEEDED!\n");
NS_LOG_DEBUG("Fragmentation needed!");
}
}

View File

@@ -30,6 +30,7 @@
#include <fstream>
#include <iomanip>
#include <sstream>
namespace ns3
{
@@ -292,30 +293,27 @@ AthstatsWifiTraceSink::WriteStats()
return;
}
// The comments below refer to how each value maps to madwifi's athstats
// I know C strings are ugly but that's the quickest way to use exactly the same format as in
// madwifi
char str[200];
snprintf(
str,
200,
"%8u %8u %7u %7u %7u %6u %6u %6u %7u %4u %3uM\n",
(unsigned int)m_txCount, // /proc/net/dev transmitted packets to which we should subtract
// management frames
(unsigned int)
m_rxCount, // /proc/net/dev received packets but subtracts management frames from it
(unsigned int)0, // ast_tx_altrate
(unsigned int)m_shortRetryCount, // ast_tx_shortretry
(unsigned int)m_longRetryCount, // ast_tx_longretry
(unsigned int)m_exceededRetryCount, // ast_tx_xretries
(unsigned int)m_phyRxErrorCount, // ast_rx_crcerr
(unsigned int)0, // ast_rx_badcrypt
(unsigned int)0, // ast_rx_phyerr
(unsigned int)0, // ast_rx_rssi
(unsigned int)0 // rate
);
// The comments below refer to how each value maps to madwifi's athstats.
// Format: "%8lu %8lu %7u %7u %7u %6u %6u %6u %7u %4u %3uM"
std::stringstream ss;
*m_writer << str;
// /proc/net/dev transmitted packets to which we should subtract management frames
ss << std::setw(8) << m_txCount << " ";
// /proc/net/dev received packets but subtracts management frames from it
ss << std::setw(8) << m_rxCount << " ";
ss << std::setw(7) << 0 << " "; // ast_tx_altrate
ss << std::setw(7) << m_shortRetryCount << " "; // ast_tx_shortretry
ss << std::setw(7) << m_longRetryCount << " "; // ast_tx_longretry
ss << std::setw(6) << m_exceededRetryCount << " "; // ast_tx_xretries
ss << std::setw(6) << m_phyRxErrorCount << " "; // ast_rx_crcerr
ss << std::setw(6) << 0 << " "; // ast_rx_badcrypt
ss << std::setw(7) << 0 << " "; // ast_rx_phyerr
ss << std::setw(4) << 0 << " "; // ast_rx_rssi
ss << std::setw(3) << 0 << "M"; // rate
*m_writer << ss.str() << std::endl;
ResetCounters();
Simulator::Schedule(m_interval, &AthstatsWifiTraceSink::WriteStats, this);