--- a/src/common/pcap-writer.cc Thu Aug 13 13:12:44 2009 +0200
+++ b/src/common/pcap-writer.cc Thu Aug 13 13:39:14 2009 +0200
@@ -196,7 +196,7 @@
}
-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 @@
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 @@
#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 @@
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)
{
--- a/src/common/pcap-writer.h Thu Aug 13 13:12:44 2009 +0200
+++ b/src/common/pcap-writer.h Thu Aug 13 13:39:14 2009 +0200
@@ -117,6 +117,8 @@
* 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 @@
* @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);
--- a/src/devices/wifi/wifi-phy.cc Thu Aug 13 13:12:44 2009 +0200
+++ b/src/devices/wifi/wifi-phy.cc Thu Aug 13 13:39:14 2009 +0200
@@ -205,15 +205,15 @@
}
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
--- a/src/devices/wifi/wifi-phy.h Thu Aug 13 13:12:44 2009 +0200
+++ b/src/devices/wifi/wifi-phy.h Thu Aug 13 13:39:14 2009 +0200
@@ -341,7 +341,7 @@
* @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 @@
* 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 @@
*
* \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 @@
*
* \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;
};
--- a/src/devices/wifi/yans-wifi-phy.cc Thu Aug 13 13:12:44 2009 +0200
+++ b/src/devices/wifi/yans-wifi-phy.cc Thu Aug 13 13:39:14 2009 +0200
@@ -451,7 +451,7 @@
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 @@
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
--- a/src/helper/yans-wifi-helper.cc Thu Aug 13 13:12:44 2009 +0200
+++ b/src/helper/yans-wifi-helper.cc Thu Aug 13 13:39:14 2009 +0200
@@ -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);
}