bug 644: make sure we set standard and frequency correctly in radiotap output
This commit is contained in:
@@ -196,7 +196,7 @@ PcapWriter::WritePacket (Ptr<const Packet> packet)
|
||||
}
|
||||
|
||||
|
||||
void PcapWriter::WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz,
|
||||
void PcapWriter::WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber,
|
||||
uint32_t rate, bool isShortPreamble, bool isTx,
|
||||
double signalDbm, double noiseDbm)
|
||||
{
|
||||
@@ -288,10 +288,8 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t chann
|
||||
|
||||
Write32(PRISM_DID_CHANNEL);
|
||||
Write16(PRISM_STATUS_PRESENT);
|
||||
Write16(PRISM_ITEM_LENGTH);
|
||||
// convert from frequency to channel number. This conversion is
|
||||
// correct only for IEEE 802.11b/g channels 1-13.
|
||||
Write32((2437 - 2407) / 5);
|
||||
Write16(PRISM_ITEM_LENGTH);
|
||||
Write32((uint32_t) channelNumber);
|
||||
|
||||
Write32(PRISM_DID_RSSI);
|
||||
Write16(PRISM_STATUS_PRESENT);
|
||||
@@ -372,14 +370,18 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t chann
|
||||
#define RADIOTAP_FLAG_DATAPAD 0x20
|
||||
#define RADIOTAP_FLAG_BADFCS 0x40
|
||||
|
||||
#define RADIOTAP_CHANNEL_TURBO 0x0010
|
||||
#define RADIOTAP_CHANNEL_CCK 0x0020
|
||||
#define RADIOTAP_CHANNEL_OFDM 0x0040
|
||||
#define RADIOTAP_CHANNEL_2GHZ 0x0080
|
||||
#define RADIOTAP_CHANNEL_5GHZ 0x0100
|
||||
#define RADIOTAP_CHANNEL_PASSIVE 0x0200
|
||||
#define RADIOTAP_CHANNEL_DYN 0x0400
|
||||
#define RADIOTAP_CHANNEL_GFSK 0x0800
|
||||
#define RADIOTAP_CHANNEL_TURBO 0x0010
|
||||
#define RADIOTAP_CHANNEL_CCK 0x0020
|
||||
#define RADIOTAP_CHANNEL_OFDM 0x0040
|
||||
#define RADIOTAP_CHANNEL_2GHZ 0x0080
|
||||
#define RADIOTAP_CHANNEL_5GHZ 0x0100
|
||||
#define RADIOTAP_CHANNEL_PASSIVE 0x0200
|
||||
#define RADIOTAP_CHANNEL_DYN_CCK_OFDM 0x0400
|
||||
#define RADIOTAP_CHANNEL_GFSK 0x0800
|
||||
#define RADIOTAP_CHANNEL_GSM 0x1000
|
||||
#define RADIOTAP_CHANNEL_STATIC_TURBO 0x2000
|
||||
#define RADIOTAP_CHANNEL_HALF_RATE 0x4000
|
||||
#define RADIOTAP_CHANNEL_QUARTER_RATE 0x8000
|
||||
|
||||
#define RADIOTAP_RX_PRESENT (RADIOTAP_TSFT | RADIOTAP_FLAGS | RADIOTAP_RATE | RADIOTAP_CHANNEL | RADIOTAP_DBM_ANTSIGNAL | RADIOTAP_DBM_ANTNOISE)
|
||||
#define RADIOTAP_RX_LENGTH (8+8+1+1+2+2+1+1)
|
||||
@@ -433,12 +435,24 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t chann
|
||||
|
||||
Write8(rate);
|
||||
|
||||
Write16((uint16_t) 2437);
|
||||
|
||||
// we might want to make this setting depend on the WifiMode and
|
||||
// on the ChannelFrequency at some time in the future. But for now
|
||||
// I think a fixed setting is more than enough for most purposes.
|
||||
Write16(RADIOTAP_CHANNEL_OFDM | RADIOTAP_CHANNEL_2GHZ);
|
||||
Write16(channelFreqMhz);
|
||||
|
||||
uint16_t channelFlags;
|
||||
if (channelFreqMhz < 2500)
|
||||
{
|
||||
// TODO: when 802.11g WifiModes will be implemented
|
||||
// we will need to check dinamically whether channelFlags
|
||||
// needs to be set to RADIOTAP_CHANNEL_CCK,
|
||||
// RADIOTAP_CHANNEL_DYN or RADIOTAP_CHANNEL_OFDM.
|
||||
channelFlags = RADIOTAP_CHANNEL_2GHZ | RADIOTAP_CHANNEL_CCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: we should handle correctly the case of half rate
|
||||
// (10 MHz channel) and quarter rate (5 Mhz channel).
|
||||
channelFlags = RADIOTAP_CHANNEL_5GHZ | RADIOTAP_CHANNEL_OFDM;
|
||||
}
|
||||
Write16(channelFlags);
|
||||
|
||||
if (!isTx)
|
||||
{
|
||||
|
||||
@@ -117,6 +117,8 @@ public:
|
||||
* transmitted. This is because it is possible to have the receiver
|
||||
* tuned on a given channel and still to be able to receive packets
|
||||
* on a nearby channel.
|
||||
* @param channelNumber the channel number, as defined by the
|
||||
* IEEE 802.11 standard.
|
||||
* @param rate the PHY data rate in units of 500kbps (i.e., the same
|
||||
* units used both for the radiotap and for the prism header)
|
||||
* @param isShortPreamble true if short preamble is used, false otherwise
|
||||
@@ -125,7 +127,7 @@ public:
|
||||
* @param signalDbm signal power in dBm
|
||||
* @param noiseDbm noise power in dBm
|
||||
*/
|
||||
void WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz,
|
||||
void WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber,
|
||||
uint32_t rate, bool isShortPreamble, bool isTx,
|
||||
double signalDbm, double noiseDbm);
|
||||
|
||||
|
||||
@@ -205,15 +205,15 @@ WifiPhy::NotifyRxDrop (Ptr<const Packet> packet)
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhy::NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
|
||||
WifiPhy::NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
|
||||
{
|
||||
m_phyPromiscSniffRxTrace (packet, channelFreqMhz, rate, isShortPreamble, signalDbm, noiseDbm);
|
||||
m_phyPromiscSniffRxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble, signalDbm, noiseDbm);
|
||||
}
|
||||
|
||||
void
|
||||
WifiPhy::NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble)
|
||||
WifiPhy::NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble)
|
||||
{
|
||||
m_phyPromiscSniffTxTrace (packet, channelFreqMhz, rate, isShortPreamble);
|
||||
m_phyPromiscSniffTxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble);
|
||||
}
|
||||
|
||||
WifiMode
|
||||
|
||||
@@ -341,7 +341,7 @@ public:
|
||||
* @param signalDbm signal power in dBm
|
||||
* @param noiseDbm noise power in dBm
|
||||
*/
|
||||
void NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble,
|
||||
void NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble,
|
||||
double signalDbm, double noiseDbm);
|
||||
|
||||
/**
|
||||
@@ -361,7 +361,7 @@ public:
|
||||
* units used both for the radiotap and for the prism header)
|
||||
* @param isShortPreamble true if short preamble is used, false otherwise
|
||||
*/
|
||||
void NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble);
|
||||
void NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble);
|
||||
|
||||
|
||||
private:
|
||||
@@ -422,7 +422,7 @@ private:
|
||||
*
|
||||
* \see class CallBackTraceSource
|
||||
*/
|
||||
TracedCallback<Ptr<const Packet>, uint16_t, uint32_t, bool, double, double> m_phyPromiscSniffRxTrace;
|
||||
TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool, double, double> m_phyPromiscSniffRxTrace;
|
||||
|
||||
/**
|
||||
* A trace source that emulates a wifi device in monitor mode
|
||||
@@ -434,7 +434,7 @@ private:
|
||||
*
|
||||
* \see class CallBackTraceSource
|
||||
*/
|
||||
TracedCallback<Ptr<const Packet>, uint16_t, uint32_t, bool> m_phyPromiscSniffTxTrace;
|
||||
TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool> m_phyPromiscSniffTxTrace;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -451,7 +451,7 @@ YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble
|
||||
NotifyTxBegin (packet);
|
||||
uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;
|
||||
bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
|
||||
NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble);
|
||||
NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
|
||||
m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
|
||||
m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
|
||||
}
|
||||
@@ -657,7 +657,7 @@ YansWifiPhy::EndSync (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event)
|
||||
bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
|
||||
double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
|
||||
double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNoiseFigure() + 30 ;
|
||||
NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
|
||||
NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
|
||||
m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
|
||||
}
|
||||
else
|
||||
|
||||
@@ -32,18 +32,18 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
static void PcapSniffTxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz,
|
||||
static void PcapSniffTxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber,
|
||||
uint32_t rate, bool isShortPreamble)
|
||||
{
|
||||
const double unusedValue = 0;
|
||||
writer->WriteWifiMonitorPacket(packet, channelFreqMhz, rate, isShortPreamble, true, unusedValue, unusedValue);
|
||||
writer->WriteWifiMonitorPacket(packet, channelFreqMhz, channelNumber, rate, isShortPreamble, true, unusedValue, unusedValue);
|
||||
}
|
||||
|
||||
|
||||
static void PcapSniffRxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz,
|
||||
static void PcapSniffRxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber,
|
||||
uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
|
||||
{
|
||||
writer->WriteWifiMonitorPacket(packet, channelFreqMhz, rate, isShortPreamble, false, signalDbm, noiseDbm);
|
||||
writer->WriteWifiMonitorPacket(packet, channelFreqMhz, channelNumber, rate, isShortPreamble, false, signalDbm, noiseDbm);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user