-------------------------------------
To get the RSSI, you need to connect to a TraceSource called "MonitorSnifferRx" belonging to the ns3::WifiPhy class, and this depends on whether you are using a WifiNetDevice or WaveNetDevice. The documentation of ns3::WifiPhy states that it can be accessed as follows
For WifiNetDevice: "/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Phy"
For WaveNetDevice: "/NodeList/[i]/DeviceList/[i]/$ns3::WaveNetDevice/PhyEntities/[i]"
What you can do to access the TraceSource is use the string, and create a callback function with the proper signature, let's say the function is called PromiscHandler. You can use Config::Connect after you have created the nodes & configured their devices as follows:
//If using WifiNetDevice
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/MonitorSnifferRx", MakeCallback (&PromiscHandler));
//if using WaveNetDevice (for WAVE/DSRC)
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/MonitorSnifferRx", MakeCallback (&PromiscHandler));
and then create PromiscHandler as follows
void PromiscHandler (std::string context, Ptr<const Packet> packet, uint16_t channelFreq, WifiTxVector tx, MpduInfo mpdu, SignalNoiseDbm sn)
{
std::cout << "Context : " << context << std::endl;
std::cout << " Signal: " << sn.signal << " Noise: " << sn.noise << std::endl;
}
The context string matches the source of the event. You can use string manipulation functions to get the node id.
Keep in mind that in older versions of ns-3, if the string you used in Config::Connect didn't find a match, then nothing happens. I believe starting from ns-3.31, the call will fail if no matches were found, and a new function called Config::ConnectFailSafe is added which returns true if a match was found, and false otherwise.
---------------------------------
But the signal strength and noise intensity are (probably?) different from the RSSI, and I don't think they can be treated as the same type.
I accidentally saw some structs containing RSSI in src/wifi/model/phy-entity.h in my leisure, does this mean that NS3 can directly help us get RSSI values? Or is this a breakthrough point to solve the problem?Here's the code I found
/// RxSignalInfo structure containing info on the received signal
struct RxSignalInfo
{
double snr; ///< SNR in linear scale
double rssi; ///< RSSI in dBm
};
I hope I don't disturb with dumb questions!
Thank you!