Review feedback
authorCraig Dowell <craigdo@ee.washington.edu>
Wed, 03 Feb 2010 13:26:39 -0800
changeset 6041 b65c6d6794f8
parent 6040 a30eb0e5758a
child 6042 b6f6c23303e8
Review feedback
examples/wireless/wifi-simple-adhoc-grid.cc
examples/wireless/wifi-simple-adhoc.cc
examples/wireless/wifi-simple-infra.cc
examples/wireless/wifi-simple-interference.cc
examples/wireless/wifi-wired-bridging.cc
src/common/pcap-file-object.cc
src/common/pcap-file-object.h
src/helper/trace-helper.h
src/helper/yans-wifi-helper.cc
src/helper/yans-wifi-helper.h
src/node/radiotap-header.h
src/test/ns3wifi/wifi-interference-test-suite.cc
--- a/examples/wireless/wifi-simple-adhoc-grid.cc	Mon Feb 01 14:23:41 2010 -0800
+++ b/examples/wireless/wifi-simple-adhoc-grid.cc	Wed Feb 03 13:26:39 2010 -0800
@@ -160,7 +160,7 @@
   // set it to zero; otherwise, gain will be added
   wifiPhy.Set ("RxGain", DoubleValue (-10) ); 
   // ns-3 supports RadioTap and Prism tracing extensions for 802.11b
-  wifiPhy.SetPcapDataLinkType (PcapHelper::DLT_IEEE802_11_RADIO); 
+  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); 
 
   YansWifiChannelHelper wifiChannel ;
   wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
--- a/examples/wireless/wifi-simple-adhoc.cc	Mon Feb 01 14:23:41 2010 -0800
+++ b/examples/wireless/wifi-simple-adhoc.cc	Wed Feb 03 13:26:39 2010 -0800
@@ -135,7 +135,7 @@
   // set it to zero; otherwise, gain will be added
   wifiPhy.Set ("RxGain", DoubleValue (0) ); 
   // ns-3 supports RadioTap and Prism tracing extensions for 802.11b
-  wifiPhy.SetPcapDataLinkType (PcapHelper::DLT_IEEE802_11_RADIO); 
+  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); 
 
   YansWifiChannelHelper wifiChannel ;
   wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
--- a/examples/wireless/wifi-simple-infra.cc	Mon Feb 01 14:23:41 2010 -0800
+++ b/examples/wireless/wifi-simple-infra.cc	Wed Feb 03 13:26:39 2010 -0800
@@ -136,7 +136,7 @@
   // set it to zero; otherwise, gain will be added
   wifiPhy.Set ("RxGain", DoubleValue (0) ); 
   // ns-3 supports RadioTap and Prism tracing extensions for 802.11b
-  wifiPhy.SetPcapDataLinkType (PcapHelper::DLT_IEEE802_11_RADIO); 
+  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); 
 
   YansWifiChannelHelper wifiChannel ;
   wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
--- a/examples/wireless/wifi-simple-interference.cc	Mon Feb 01 14:23:41 2010 -0800
+++ b/examples/wireless/wifi-simple-interference.cc	Wed Feb 03 13:26:39 2010 -0800
@@ -181,7 +181,7 @@
   wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0) );
 
   // ns-3 supports RadioTap and Prism tracing extensions for 802.11b
-  wifiPhy.SetPcapDataLinkType (PcapHelper::DLT_IEEE802_11_RADIO); 
+  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); 
 
   YansWifiChannelHelper wifiChannel ;
   wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
--- a/examples/wireless/wifi-wired-bridging.cc	Mon Feb 01 14:23:41 2010 -0800
+++ b/examples/wireless/wifi-wired-bridging.cc	Wed Feb 03 13:26:39 2010 -0800
@@ -90,7 +90,7 @@
   double wifiX = 0.0;
 
   YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
-  wifiPhy.SetPcapDataLinkType (PcapHelper::DLT_IEEE802_11_RADIO); 
+  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); 
 
   for (uint32_t i = 0; i < nWifis; ++i)
     {
--- a/src/common/pcap-file-object.cc	Mon Feb 01 14:23:41 2010 -0800
+++ b/src/common/pcap-file-object.cc	Wed Feb 03 13:26:39 2010 -0800
@@ -17,6 +17,7 @@
  */
 
 #include "ns3/log.h"
+#include "ns3/uinteger.h"
 
 #include "buffer.h"
 #include "header.h"
@@ -34,6 +35,11 @@
   static TypeId tid = TypeId ("ns3::PcapFileObject")
     .SetParent<Object> ()
     .AddConstructor<PcapFileObject> ()
+    .AddAttribute ("CaptureSize",
+                   "Maximum length of captured packets (cf. pcap snaplen)",
+                   UintegerValue (PcapFile::SNAPLEN_DEFAULT),
+                   MakeUintegerAccessor (&PcapFileObject::m_snapLen),
+                   MakeUintegerChecker<uint32_t> (0, PcapFile::SNAPLEN_DEFAULT))
     ;
   return tid;
 }
@@ -63,7 +69,24 @@
 bool
 PcapFileObject::Init (uint32_t dataLinkType, uint32_t snapLen, int32_t tzCorrection)
 {
-  return m_file.Init (dataLinkType, snapLen, tzCorrection);
+  //
+  // If the user doesn't provide a snaplen, the default value will come in.  If
+  // this happens, we use the "CaptureSize" Attribute.  If the user does provide
+  // a snaplen, we use the one provided.
+  //
+  if (snapLen != std::numeric_limits<uint32_t>::max ())
+    {
+      return m_file.Init (dataLinkType, snapLen, tzCorrection);
+    } 
+  else
+    {
+      return m_file.Init (dataLinkType, m_snapLen, tzCorrection);
+    } 
+
+  //
+  // Quiet the compiler
+  //
+  return true;
 }
 
 bool
--- a/src/common/pcap-file-object.h	Mon Feb 01 14:23:41 2010 -0800
+++ b/src/common/pcap-file-object.h	Wed Feb 03 13:26:39 2010 -0800
@@ -129,7 +129,7 @@
    * any existing data.
    */
   bool Init (uint32_t dataLinkType, 
-             uint32_t snapLen = PcapFile::SNAPLEN_DEFAULT, 
+             uint32_t snapLen = std::numeric_limits<uint32_t>::max (), 
              int32_t tzCorrection = PcapFile::ZONE_DEFAULT);
 
   /**
@@ -226,6 +226,7 @@
   
 private:
   PcapFile m_file;
+  uint32_t m_snapLen;
 };
 
 } //namespace ns3
--- a/src/helper/trace-helper.h	Mon Feb 01 14:23:41 2010 -0800
+++ b/src/helper/trace-helper.h	Wed Feb 03 13:26:39 2010 -0800
@@ -48,13 +48,15 @@
   // and we don't make an enumeration of all of the values to make it easy to
   // pass new values in.
   //
-  enum {DLT_NULL = 0};
-  enum {DLT_EN10MB = 1};
-  enum {DLT_PPP = 9};
-  enum {DLT_RAW = 101};
-  enum {DLT_IEEE802_11 = 105};
-  enum {DLT_PRISM_HEADER = 119};
-  enum {DLT_IEEE802_11_RADIO = 127};
+  enum {
+    DLT_NULL = 0,
+    DLT_EN10MB = 1,
+    DLT_PPP = 9,
+    DLT_RAW = 101,
+    DLT_IEEE802_11 = 105,
+    DLT_PRISM_HEADER = 119,
+    DLT_IEEE802_11_RADIO = 127
+  };
 
   /**
    * @brief Create a pcap helper.
--- a/src/helper/yans-wifi-helper.cc	Mon Feb 01 14:23:41 2010 -0800
+++ b/src/helper/yans-wifi-helper.cc	Wed Feb 03 13:26:39 2010 -0800
@@ -363,17 +363,17 @@
 }
 
 void 
-YansWifiPhyHelper::SetPcapFormat (enum PcapFormat format)
+YansWifiPhyHelper::SetPcapDataLinkType (enum SupportedPcapDataLinkTypes dlt)
 {
-  switch (format)
+  switch (dlt)
     {
-    case PCAP_FORMAT_80211:
+    case DLT_IEEE802_11:
       m_pcapDlt = PcapHelper::DLT_IEEE802_11;
       return;
-    case PCAP_FORMAT_80211_PRISM:
+    case DLT_PRISM_HEADER:
       m_pcapDlt = PcapHelper::DLT_PRISM_HEADER;
       return;
-    case PCAP_FORMAT_80211_RADIOTAP:
+    case DLT_IEEE802_11_RADIO:
       m_pcapDlt = PcapHelper::DLT_IEEE802_11_RADIO;
       return;
     default:
@@ -382,12 +382,6 @@
 }
 
 void 
-YansWifiPhyHelper::SetPcapDataLinkType (uint32_t dlt)
-{
-  m_pcapDlt = dlt;
-}
-
-void 
 YansWifiPhyHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous)
 {
   //
--- a/src/helper/yans-wifi-helper.h	Mon Feb 01 14:23:41 2010 -0800
+++ b/src/helper/yans-wifi-helper.h	Wed Feb 03 13:26:39 2010 -0800
@@ -201,45 +201,26 @@
                           std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
 
   /**
-   * PCAP formats 
-   * 
+   * An enumeration of the pcap data link types (DLTs) which this helper 
+   * supports.  See http://wiki.wireshark.org/Development/LibpcapFileFormat
+   * for more information on these formats.
    */
-  enum PcapFormat {   
-    PCAP_FORMAT_80211          = 1,
-    PCAP_FORMAT_80211_PRISM    = 2,
-    PCAP_FORMAT_80211_RADIOTAP = 3,
+  enum SupportedPcapDataLinkTypes {
+    DLT_IEEE802_11       = PcapHelper::DLT_IEEE802_11,       /**< IEEE 802.11 Wireless LAN headers on packets */
+    DLT_PRISM_HEADER     = PcapHelper::DLT_PRISM_HEADER,     /**< Include Prism monitor mode information */
+    DLT_IEEE802_11_RADIO = PcapHelper::DLT_IEEE802_11_RADIO  /**< Include Radiotap link layer information */
   };
-  
-  /** 
-   * Set the format of PCAP traces to be used. This function has to be
-   * called before EnablePcap(), so that the header of the pcap file
-   * can be written correctly.
-   *
-   * In madwifi, this corresponds to setting
-   * /proc/sys/net/ath0/dev_type to a particular value. See
-   * http://madwifi-project.org/wiki/UserDocs/MonitorModeInterface for
-   * more information.
-   * 
-   * @param format the PcapFormat to be used
-   */
-  void SetPcapFormat (enum PcapFormat format) NS_DEPRECATED; 
 
   /** 
    * Set the data link type of PCAP traces to be used. This function has to be
    * called before EnablePcap(), so that the header of the pcap file can be 
    * written correctly.
    *
-   * In madwifi, this corresponds to setting /proc/sys/net/ath0/dev_type to a 
-   * particular value, however we use the pcap DLT instead of the dev_type to
-   * avoid introducing another unnecessary definition. See
+   * @see SupportedPcapDataLinkTypes
    *
-   *   http://madwifi-project.org/wiki/UserDocs/MonitorModeInterface 
-   * 
-   * for more information.
-   * 
    * @param dlt The data link type of the pcap file (and packets) to be used
    */
-  void SetPcapDataLinkType (uint32_t dlt); 
+  void SetPcapDataLinkType (enum SupportedPcapDataLinkTypes dlt); 
 
 private:
   /**
--- a/src/node/radiotap-header.h	Mon Feb 01 14:23:41 2010 -0800
+++ b/src/node/radiotap-header.h	Wed Feb 03 13:26:39 2010 -0800
@@ -117,15 +117,17 @@
    */
   uint64_t GetTsft (void) const;
 
-  enum {FRAME_FLAG_NONE           = 0x00}; /**< No flags set */
-  enum {FRAME_FLAG_CFP            = 0x01}; /**< Frame sent/received during CFP */
-  enum {FRAME_FLAG_SHORT_PREAMBLE = 0x02}; /**< Frame sent/received with short preamble */
-  enum {FRAME_FLAG_WEP            = 0x04}; /**< Frame sent/received with WEP encryption */
-  enum {FRAME_FLAG_FRAGMENTED     = 0x08}; /**< Frame sent/received with fragmentation */
-  enum {FRAME_FLAG_FCS_INCLUDED   = 0x10}; /**< Frame includes FCS */
-  enum {FRAME_FLAG_DATA_PADDING   = 0x20}; /**< Frame has padding between 802.11 header and payload (to 32-bit boundary) */
-  enum {FRAME_FLAG_BAD_FCS        = 0x40}; /**< Frame failed FCS check */
-  enum {FRAME_FLAG_SHORT_GUARD    = 0x80};  /**< Frame used short guard interval (HT) */
+  enum {
+    FRAME_FLAG_NONE           = 0x00, /**< No flags set */
+    FRAME_FLAG_CFP            = 0x01, /**< Frame sent/received during CFP */
+    FRAME_FLAG_SHORT_PREAMBLE = 0x02, /**< Frame sent/received with short preamble */
+    FRAME_FLAG_WEP            = 0x04, /**< Frame sent/received with WEP encryption */
+    FRAME_FLAG_FRAGMENTED     = 0x08, /**< Frame sent/received with fragmentation */
+    FRAME_FLAG_FCS_INCLUDED   = 0x10, /**< Frame includes FCS */
+    FRAME_FLAG_DATA_PADDING   = 0x20, /**< Frame has padding between 802.11 header and payload (to 32-bit boundary) */
+    FRAME_FLAG_BAD_FCS        = 0x40, /**< Frame failed FCS check */
+    FRAME_FLAG_SHORT_GUARD    = 0x80  /**< Frame used short guard interval (HT) */
+  };
 
   /**
    * @brief Set the frame flags of the transmitted or received frame.
@@ -152,15 +154,17 @@
    */
   uint8_t GetRate (void) const;
 
-  enum {CHANNEL_FLAG_NONE          = 0x0000}; /**< No flags set */
-  enum {CHANNEL_FLAG_TURBO         = 0x0010}; /**< Turbo Channel */
-  enum {CHANNEL_FLAG_CCK           = 0x0020}; /**< CCK channel */
-  enum {CHANNEL_FLAG_OFDM          = 0x0040}; /**< OFDM channel */
-  enum {CHANNEL_FLAG_SPECTRUM_2GHZ = 0x0080}; /**< 2 GHz spectrum channel */
-  enum {CHANNEL_FLAG_SPECTRUM_5GHZ = 0x0100}; /**< 5 GHz spectrum channel */
-  enum {CHANNEL_FLAG_PASSIVE       = 0x0200}; /**< Only passive scan allowed */
-  enum {CHANNEL_FLAG_DYNAMIC       = 0x0400}; /**< Dynamic CCK-OFDM channel */
-  enum {CHANNEL_FLAG_GFSK          = 0x0800};  /**< GFSK channel (FHSS PHY) */
+  enum {
+    CHANNEL_FLAG_NONE          = 0x0000, /**< No flags set */
+    CHANNEL_FLAG_TURBO         = 0x0010, /**< Turbo Channel */
+    CHANNEL_FLAG_CCK           = 0x0020, /**< CCK channel */
+    CHANNEL_FLAG_OFDM          = 0x0040, /**< OFDM channel */
+    CHANNEL_FLAG_SPECTRUM_2GHZ = 0x0080, /**< 2 GHz spectrum channel */
+    CHANNEL_FLAG_SPECTRUM_5GHZ = 0x0100, /**< 5 GHz spectrum channel */
+    CHANNEL_FLAG_PASSIVE       = 0x0200, /**< Only passive scan allowed */
+    CHANNEL_FLAG_DYNAMIC       = 0x0400, /**< Dynamic CCK-OFDM channel */
+    CHANNEL_FLAG_GFSK          = 0x0800  /**< GFSK channel (FHSS PHY) */
+  };
 
   /**
    * @brief Set the transmit/receive channel frequency and flags
@@ -238,21 +242,23 @@
   uint8_t GetAntennaNoisePower (void) const;
 
 private:
-  enum {RADIOTAP_TSFT              = 0x00000001};
-  enum {RADIOTAP_FLAGS             = 0x00000002};
-  enum {RADIOTAP_RATE              = 0x00000004};
-  enum {RADIOTAP_CHANNEL           = 0x00000008};
-  enum {RADIOTAP_FHSS              = 0x00000010};
-  enum {RADIOTAP_DBM_ANTSIGNAL     = 0x00000020};
-  enum {RADIOTAP_DBM_ANTNOISE      = 0x00000040};
-  enum {RADIOTAP_LOCK_QUALITY      = 0x00000080};
-  enum {RADIOTAP_TX_ATTENUATION    = 0x00000100};
-  enum {RADIOTAP_DB_TX_ATTENUATION = 0x00000200};
-  enum {RADIOTAP_DBM_TX_POWER      = 0x00000200};
-  enum {RADIOTAP_ANTENNA           = 0x00000400};
-  enum {RADIOTAP_DB_ANTSIGNAL      = 0x00000800};
-  enum {RADIOTAP_DB_ANTNOISE       = 0x00001000};
-  enum {RADIOTAP_EXT               = 0x10000000};
+  enum {
+    RADIOTAP_TSFT              = 0x00000001,
+    RADIOTAP_FLAGS             = 0x00000002,
+    RADIOTAP_RATE              = 0x00000004,
+    RADIOTAP_CHANNEL           = 0x00000008,
+    RADIOTAP_FHSS              = 0x00000010,
+    RADIOTAP_DBM_ANTSIGNAL     = 0x00000020,
+    RADIOTAP_DBM_ANTNOISE      = 0x00000040,
+    RADIOTAP_LOCK_QUALITY      = 0x00000080,
+    RADIOTAP_TX_ATTENUATION    = 0x00000100,
+    RADIOTAP_DB_TX_ATTENUATION = 0x00000200,
+    RADIOTAP_DBM_TX_POWER      = 0x00000200,
+    RADIOTAP_ANTENNA           = 0x00000400,
+    RADIOTAP_DB_ANTSIGNAL      = 0x00000800,
+    RADIOTAP_DB_ANTNOISE       = 0x00001000,
+    RADIOTAP_EXT               = 0x10000000
+  };
  
     void CheckAddChannelField();
     
--- a/src/test/ns3wifi/wifi-interference-test-suite.cc	Mon Feb 01 14:23:41 2010 -0800
+++ b/src/test/ns3wifi/wifi-interference-test-suite.cc	Wed Feb 03 13:26:39 2010 -0800
@@ -149,8 +149,7 @@
   wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0) );
   
   // ns-3 supports RadioTap and Prism tracing extensions for 802.11b
-  const uint32_t DLT_IEEE802_11_RADIO = 127;
-  wifiPhy.SetPcapDataLinkType (DLT_IEEE802_11_RADIO); 
+  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); 
   
   YansWifiChannelHelper wifiChannel ;
   wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");