24 #include "radiotap-header.h"
30 NS_OBJECT_ENSURE_REGISTERED (RadiotapHeader);
32 RadiotapHeader::RadiotapHeader()
36 m_flags (FRAME_FLAG_NONE),
39 m_channelFlags (CHANNEL_FLAG_NONE),
46 TypeId RadiotapHeader::GetTypeId (
void)
48 static TypeId tid = TypeId (
"ns3::RadiotapHeader")
50 .AddConstructor<RadiotapHeader> ()
82 if (m_present & RADIOTAP_TSFT)
90 if (m_present & RADIOTAP_FLAGS)
98 if (m_present & RADIOTAP_RATE)
106 if (m_present & RADIOTAP_CHANNEL)
116 if (m_present & RADIOTAP_DBM_ANTSIGNAL)
118 start.
WriteU8 (m_antennaSignal);
125 if (m_present & RADIOTAP_DBM_ANTNOISE)
127 start.
WriteU8 (m_antennaNoise);
136 uint8_t tmp = start.
ReadU8 ();
137 NS_ASSERT_MSG (tmp == 0x00,
"RadiotapHeader::Deserialize(): Unexpected major version");
143 uint32_t bytesRead = 8;
148 if (m_present & RADIOTAP_TSFT)
157 if (m_present & RADIOTAP_FLAGS)
159 m_flags = start.
ReadU8 ();
166 if (m_present & RADIOTAP_RATE)
175 if (m_present & RADIOTAP_CHANNEL)
177 m_channelFreq = start.
ReadU16 ();
178 m_channelFlags = start.
ReadU16 ();
186 if (m_present & RADIOTAP_FHSS)
196 if (m_present & RADIOTAP_DBM_ANTSIGNAL)
198 m_antennaSignal = start.
ReadU8 ();
206 if (m_present & RADIOTAP_DBM_ANTNOISE)
208 m_antennaNoise = start.
ReadU8 ();
212 NS_ASSERT_MSG (m_length == bytesRead,
"RadiotapHeader::Deserialize(): expected and actual lengths inconsistent");
220 os <<
" tsft=" << m_tsft
221 <<
" flags=" << std::hex << m_flags << std::dec
222 <<
" rate=" << (uint16_t) m_rate
223 <<
" freq=" << m_channelFreq
224 <<
" chflags=" << std::hex << (uint32_t)m_channelFlags << std::dec
225 <<
" signal=" << (int16_t) m_antennaSignal
226 <<
" noise=" << (int16_t) m_antennaNoise;
235 if (!(m_present & RADIOTAP_TSFT))
237 m_present |= RADIOTAP_TSFT;
241 NS_LOG_LOGIC (
this <<
" m_length=" << m_length <<
" m_present=0x" << std::hex << m_present << std::dec);
257 if (!(m_present & RADIOTAP_FLAGS))
259 m_present |= RADIOTAP_FLAGS;
263 NS_LOG_LOGIC (
this <<
" m_length=" << m_length <<
" m_present=0x" << std::hex << m_present << std::dec);
279 if (!(m_present & RADIOTAP_RATE))
281 m_present |= RADIOTAP_RATE;
285 NS_LOG_LOGIC (
this <<
" m_length=" << m_length <<
" m_present=0x" << std::hex << m_present << std::dec);
299 m_channelFreq = frequency;
300 m_channelFlags = flags;
302 if (!(m_present & RADIOTAP_CHANNEL))
304 m_present |= RADIOTAP_CHANNEL;
308 NS_LOG_LOGIC (
this <<
" m_length=" << m_length <<
" m_present=0x" << std::hex << m_present << std::dec);
315 return m_channelFreq;
322 return m_channelFlags;
330 if (!(m_present & RADIOTAP_DBM_ANTSIGNAL))
332 m_present |= RADIOTAP_DBM_ANTSIGNAL;
337 m_antennaSignal = 127;
339 else if (signal < -128)
341 m_antennaSignal = -128;
345 m_antennaSignal =
static_cast<int8_t
> (floor (signal + 0.5));
348 NS_LOG_LOGIC (
this <<
" m_length=" << m_length <<
" m_present=0x" << std::hex << m_present << std::dec);
355 return m_antennaSignal;
363 if (!(m_present & RADIOTAP_DBM_ANTNOISE))
365 m_present |= RADIOTAP_DBM_ANTNOISE;
370 m_antennaNoise = 127;
372 else if (noise < -128.0)
374 m_antennaNoise = -128;
378 m_antennaNoise =
static_cast<int8_t
> (floor (noise + 0.5));
381 NS_LOG_LOGIC (
this <<
" m_length=" << m_length <<
" m_present=0x" << std::hex << m_present << std::dec);
388 return m_antennaNoise;
#define NS_LOG_FUNCTION(parameters)
#define NS_LOG_COMPONENT_DEFINE(name)
iterator in a Buffer instance
void WriteU16(uint16_t data)
void WriteU64(uint64_t data)
#define NS_LOG_LOGIC(msg)
#define NS_ASSERT_MSG(condition, message)
void WriteU8(uint8_t data)
void WriteU32(uint32_t data)