src/network/utils/radiotap-header.cc
author Maja Grubišić <maja.grubisic@live.com>
Sat, 01 Dec 2012 20:05:49 +0100
changeset 9157 2d4305dd159a
parent 9144 6a15c50388bc
child 10410 4d4eb8097fa3
permissions -rw-r--r--
Fix printing of uint8_t data in NS_LOG_FUNCTION introduced by 9144:6a15c50388bc Clean up function logging of network module.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7256
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * Copyright (c) 2009 CTTC
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 *
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 *
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 *
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
 * Foundation, Include., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
 *
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
 * Author: Nicola Baldo <nbaldo@cttc.es>
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
 */
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
#include <iomanip>
9063
32755d0516f4 Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents: 7704
diff changeset
    22
#include <cmath>
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
#include "ns3/log.h"
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
#include "radiotap-header.h"
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
    26
NS_LOG_COMPONENT_DEFINE ("RadiotapHeader");
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
namespace ns3 {
6393
f7e1f9dfa08d ensure objects are regsitered
Josh Pelkey <jpelkey@gatech.edu>
parents: 6036
diff changeset
    29
f7e1f9dfa08d ensure objects are regsitered
Josh Pelkey <jpelkey@gatech.edu>
parents: 6036
diff changeset
    30
NS_OBJECT_ENSURE_REGISTERED (RadiotapHeader);
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
RadiotapHeader::RadiotapHeader()
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
    33
  : m_length (8),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
    34
    m_present (0),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
    35
    m_tsft (0),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
    36
    m_flags (FRAME_FLAG_NONE),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
    37
    m_rate (0),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
    38
    m_channelFreq (0),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
    39
    m_channelFlags (CHANNEL_FLAG_NONE),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
    40
    m_antennaSignal (0),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
    41
    m_antennaNoise (0)
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
    42
{
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
  NS_LOG_FUNCTION (this);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
TypeId RadiotapHeader::GetTypeId (void)
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
{
6393
f7e1f9dfa08d ensure objects are regsitered
Josh Pelkey <jpelkey@gatech.edu>
parents: 6036
diff changeset
    48
  static TypeId tid = TypeId ("ns3::RadiotapHeader")
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
    .SetParent<Header> ()
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
    .AddConstructor<RadiotapHeader> ()
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
    51
  ;
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
  return tid;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    54
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    55
TypeId 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
RadiotapHeader::GetInstanceTypeId (void) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
  return GetTypeId ();
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    59
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    60
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
    61
uint32_t
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    62
RadiotapHeader::GetSerializedSize (void) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
  NS_LOG_FUNCTION (this);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
  return m_length;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
    68
void
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
RadiotapHeader::Serialize (Buffer::Iterator start) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
{
9144
6a15c50388bc Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents: 9063
diff changeset
    71
  NS_LOG_FUNCTION (this << &start);
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
  start.WriteU8 (0); // major version of radiotap header
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    74
  start.WriteU8 (0); // pad field
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
  start.WriteU16 (m_length); // entire length of radiotap data + header
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
  start.WriteU32 (m_present); // bits describing which fields follow header
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
    77
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
  // Time Synchronization Function Timer (when the first bit of the MPDU 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
  // arrived at the MAC)
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
  if (m_present & RADIOTAP_TSFT) // bit 0
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
      start.WriteU64 (m_tsft);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
  // Properties of transmitted and received frames.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    89
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    90
  if (m_present & RADIOTAP_FLAGS) // bit 1
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
      start.WriteU8 (m_flags);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
  // TX/RX data rate in units of 500 kbps
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
  if (m_present & RADIOTAP_RATE) // bit 2
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
      start.WriteU8 (m_rate);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   104
  // Tx/Rx frequency in MHz, followed by flags.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
  if (m_present & RADIOTAP_CHANNEL) // bit 3
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   107
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   108
      start.WriteU16 (m_channelFreq);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   109
      start.WriteU16 (m_channelFlags);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   110
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   111
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   112
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   113
  // RF signal power at the antenna, decibel difference from an arbitrary, fixed
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
  // reference.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
  if (m_present & RADIOTAP_DBM_ANTSIGNAL) // bit 5
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   117
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
      start.WriteU8 (m_antennaSignal);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   121
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
  // RF noise power at the antenna, decibel difference from an arbitrary, fixed 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   123
  // reference.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   124
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   125
  if (m_present & RADIOTAP_DBM_ANTNOISE) // bit 6
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   126
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
      start.WriteU8 (m_antennaNoise);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   129
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   130
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   131
uint32_t
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   132
RadiotapHeader::Deserialize (Buffer::Iterator start)
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
{
9144
6a15c50388bc Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents: 9063
diff changeset
   134
  NS_LOG_FUNCTION (this << &start);
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   135
7704
aef733235832 Bug 1170: Formulate best practices for dealing with unused debug variables.
Andrey Mazo <mazo@iitp.ru>
parents: 7385
diff changeset
   136
  uint8_t tmp = start.ReadU8 (); // major version of radiotap header
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   137
  NS_ASSERT_MSG (tmp == 0x00, "RadiotapHeader::Deserialize(): Unexpected major version");
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   138
  start.ReadU8 (); // pad field
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   139
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   140
  m_length = start.ReadU16 (); // entire length of radiotap data + header
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
  m_present = start.ReadU32 (); // bits describing which fields follow header
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   142
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
  uint32_t bytesRead = 8;
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   144
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   145
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
  // Time Synchronization Function Timer (when the first bit of the MPDU arrived at the MAC)
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   147
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   148
  if (m_present & RADIOTAP_TSFT) // bit 0
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   150
      m_tsft = start.ReadU64 ();
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
      bytesRead += 8;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   152
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   154
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   155
  // Properties of transmitted and received frames.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   156
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   157
  if (m_present & RADIOTAP_FLAGS) // bit 1
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   159
      m_flags = start.ReadU8 ();
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   160
      ++bytesRead;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   161
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   162
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   164
  // TX/RX data rate in units of 500 kbps
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   166
  if (m_present & RADIOTAP_RATE) // bit 2
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   167
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   168
      m_rate = start.ReadU8 ();
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   169
      ++bytesRead;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   170
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   171
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
  // Tx/Rx frequency in MHz, followed by flags.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   174
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   175
  if (m_present & RADIOTAP_CHANNEL) // bit 3
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   176
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   177
      m_channelFreq = start.ReadU16 ();
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   178
      m_channelFlags = start.ReadU16 ();
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   179
      bytesRead += 4;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   180
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   181
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   182
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   183
  // The hop set and pattern for frequency-hopping radios.  We don't need it but
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   184
  // still need to account for it.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   185
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   186
  if (m_present & RADIOTAP_FHSS) // bit 4
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   187
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   188
      start.ReadU8 ();
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   189
      ++bytesRead;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   190
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   191
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   192
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   193
  // RF signal power at the antenna, decibel difference from an arbitrary, fixed
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   194
  // reference.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   195
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   196
  if (m_present & RADIOTAP_DBM_ANTSIGNAL) // bit 5
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   197
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   198
      m_antennaSignal = start.ReadU8 ();
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   199
      ++bytesRead;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   200
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   201
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   202
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   203
  // RF noise power at the antenna, decibel difference from an arbitrary, fixed 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   204
  // reference.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   205
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   206
  if (m_present & RADIOTAP_DBM_ANTNOISE) // bit 6
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   207
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   208
      m_antennaNoise = start.ReadU8 ();
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   209
      ++bytesRead;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   210
    }
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   211
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   212
  NS_ASSERT_MSG (m_length == bytesRead, "RadiotapHeader::Deserialize(): expected and actual lengths inconsistent");
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   213
  return bytesRead;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   214
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   215
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   216
void
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   217
RadiotapHeader::Print (std::ostream &os) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   218
{
9144
6a15c50388bc Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents: 9063
diff changeset
   219
  NS_LOG_FUNCTION (this << &os);
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   220
  os << " tsft=" << m_tsft
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   221
     << " flags=" << std::hex << m_flags << std::dec
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   222
     << " rate=" << (uint16_t) m_rate
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   223
     << " freq=" << m_channelFreq
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   224
     << " chflags=" << std::hex << (uint32_t)m_channelFlags << std::dec
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   225
     << " signal=" << (int16_t) m_antennaSignal
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   226
     << " noise=" << (int16_t) m_antennaNoise;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   227
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   228
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   229
void
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   230
RadiotapHeader::SetTsft (uint64_t value)
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   231
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   232
  NS_LOG_FUNCTION (this << value);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   233
  m_tsft = value;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   234
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   235
  if (!(m_present & RADIOTAP_TSFT))
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   236
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   237
      m_present |= RADIOTAP_TSFT;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   238
      m_length += 8;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   239
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   240
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   241
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   242
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   243
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   244
uint64_t
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   245
RadiotapHeader::GetTsft () const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   246
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   247
  NS_LOG_FUNCTION (this);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   248
  return m_tsft;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   249
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   250
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   251
void 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   252
RadiotapHeader::SetFrameFlags (uint8_t flags)
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   253
{
9157
2d4305dd159a Fix printing of uint8_t data in NS_LOG_FUNCTION introduced by 9144:6a15c50388bc Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents: 9144
diff changeset
   254
  NS_LOG_FUNCTION (this << static_cast<uint32_t> (flags));
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   255
  m_flags = flags;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   256
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   257
  if (!(m_present & RADIOTAP_FLAGS))
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   258
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   259
      m_present |= RADIOTAP_FLAGS;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   260
      m_length += 1;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   261
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   262
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   263
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   264
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   265
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   266
uint8_t
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   267
RadiotapHeader::GetFrameFlags (void) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   268
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   269
  NS_LOG_FUNCTION (this);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   270
  return m_flags;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   271
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   272
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   273
void 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   274
RadiotapHeader::SetRate (uint8_t rate)
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   275
{
9157
2d4305dd159a Fix printing of uint8_t data in NS_LOG_FUNCTION introduced by 9144:6a15c50388bc Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents: 9144
diff changeset
   276
  NS_LOG_FUNCTION (this << static_cast<uint32_t> (rate));
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   277
  m_rate = rate;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   278
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   279
  if (!(m_present & RADIOTAP_RATE))
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   280
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   281
      m_present |= RADIOTAP_RATE;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   282
      m_length += 1;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   283
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   284
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   285
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   286
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   287
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   288
uint8_t
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   289
RadiotapHeader::GetRate (void) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   290
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   291
  NS_LOG_FUNCTION (this);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   292
  return m_rate;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   293
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   294
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   295
void 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   296
RadiotapHeader::SetChannelFrequencyAndFlags (uint16_t frequency, uint16_t flags)
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   297
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   298
  NS_LOG_FUNCTION (this << frequency << flags);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   299
  m_channelFreq = frequency;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   300
  m_channelFlags = flags;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   301
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   302
  if (!(m_present & RADIOTAP_CHANNEL))
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   303
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   304
      m_present |= RADIOTAP_CHANNEL;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   305
      m_length += 4;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   306
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   307
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   308
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   309
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   310
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   311
uint16_t 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   312
RadiotapHeader::GetChannelFrequency (void) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   313
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   314
  NS_LOG_FUNCTION (this);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   315
  return m_channelFreq;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   316
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   317
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   318
uint16_t 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   319
RadiotapHeader::GetChannelFlags (void) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   320
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   321
  NS_LOG_FUNCTION (this);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   322
  return m_channelFlags;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   323
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   324
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   325
void 
7027
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   326
RadiotapHeader::SetAntennaSignalPower (double signal)
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   327
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   328
  NS_LOG_FUNCTION (this << signal);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   329
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   330
  if (!(m_present & RADIOTAP_DBM_ANTSIGNAL))
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   331
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   332
      m_present |= RADIOTAP_DBM_ANTSIGNAL;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   333
      m_length += 1;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   334
    }
7027
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   335
  if (signal > 127)
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   336
    {
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   337
      m_antennaSignal = 127;
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   338
    }
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   339
  else if (signal < -128)
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   340
    {
7027
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   341
      m_antennaSignal = -128;
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   342
    }
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   343
  else
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   344
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7182
diff changeset
   345
      m_antennaSignal = static_cast<int8_t> (floor (signal + 0.5));
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   346
    }
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   347
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   348
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   349
}
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   350
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   351
uint8_t
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   352
RadiotapHeader::GetAntennaSignalPower (void) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   353
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   354
  NS_LOG_FUNCTION (this);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   355
  return m_antennaSignal;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   356
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   357
7182
5ecfee5d17de network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7027
diff changeset
   358
void
7027
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   359
RadiotapHeader::SetAntennaNoisePower (double noise)
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   360
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   361
  NS_LOG_FUNCTION (this << noise);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   362
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   363
  if (!(m_present & RADIOTAP_DBM_ANTNOISE))
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   364
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   365
      m_present |= RADIOTAP_DBM_ANTNOISE;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   366
      m_length += 1;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   367
    }
7027
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   368
  if (noise > 127.0)
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   369
    {
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   370
      m_antennaNoise = 127;
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   371
    }
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   372
  else if (noise < -128.0)
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   373
    {
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   374
      m_antennaNoise = -128;
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   375
    }
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   376
  else
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   377
    {
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   378
      m_antennaNoise = static_cast<int8_t> (floor (noise + 0.5));
169e09e9428d avoid ambiguous method overloads for python bindings
Mathieu Lacage <mathieu.lacage@inria.fr>
parents: 6823
diff changeset
   379
    }
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   380
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   381
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   382
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   383
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   384
uint8_t 
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   385
RadiotapHeader::GetAntennaNoisePower (void) const
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   386
{
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   387
  NS_LOG_FUNCTION (this);
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   388
  return m_antennaNoise;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   389
}
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   390
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   391
} // namespace ns3