From aeefbd4e9fd0230a39dde91fa60ee8222a3ebf9a Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Wed, 3 Feb 2010 13:26:39 -0800 Subject: [PATCH] Review feedback --- examples/wireless/wifi-simple-adhoc-grid.cc | 2 +- examples/wireless/wifi-simple-adhoc.cc | 2 +- examples/wireless/wifi-simple-infra.cc | 2 +- examples/wireless/wifi-simple-interference.cc | 2 +- examples/wireless/wifi-wired-bridging.cc | 2 +- src/common/pcap-file-object.cc | 25 ++++++- src/common/pcap-file-object.h | 3 +- src/helper/trace-helper.h | 16 +++-- src/helper/yans-wifi-helper.cc | 16 ++--- src/helper/yans-wifi-helper.h | 37 +++------- src/node/radiotap-header.h | 72 ++++++++++--------- .../ns3wifi/wifi-interference-test-suite.cc | 3 +- 12 files changed, 94 insertions(+), 88 deletions(-) diff --git a/examples/wireless/wifi-simple-adhoc-grid.cc b/examples/wireless/wifi-simple-adhoc-grid.cc index a94757efe..c8fb1dbf5 100644 --- a/examples/wireless/wifi-simple-adhoc-grid.cc +++ b/examples/wireless/wifi-simple-adhoc-grid.cc @@ -160,7 +160,7 @@ int main (int argc, char *argv[]) // 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"); diff --git a/examples/wireless/wifi-simple-adhoc.cc b/examples/wireless/wifi-simple-adhoc.cc index 92c93aa9f..3c2c89f91 100644 --- a/examples/wireless/wifi-simple-adhoc.cc +++ b/examples/wireless/wifi-simple-adhoc.cc @@ -135,7 +135,7 @@ int main (int argc, char *argv[]) // 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"); diff --git a/examples/wireless/wifi-simple-infra.cc b/examples/wireless/wifi-simple-infra.cc index 11a05dc17..f9ec5021f 100644 --- a/examples/wireless/wifi-simple-infra.cc +++ b/examples/wireless/wifi-simple-infra.cc @@ -136,7 +136,7 @@ int main (int argc, char *argv[]) // 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"); diff --git a/examples/wireless/wifi-simple-interference.cc b/examples/wireless/wifi-simple-interference.cc index 51aaf3c1d..005d7ec76 100644 --- a/examples/wireless/wifi-simple-interference.cc +++ b/examples/wireless/wifi-simple-interference.cc @@ -181,7 +181,7 @@ int main (int argc, char *argv[]) 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"); diff --git a/examples/wireless/wifi-wired-bridging.cc b/examples/wireless/wifi-wired-bridging.cc index 989b31970..87438c548 100644 --- a/examples/wireless/wifi-wired-bridging.cc +++ b/examples/wireless/wifi-wired-bridging.cc @@ -90,7 +90,7 @@ int main (int argc, char *argv[]) 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) { diff --git a/src/common/pcap-file-object.cc b/src/common/pcap-file-object.cc index c445fbbd4..f2275a935 100644 --- a/src/common/pcap-file-object.cc +++ b/src/common/pcap-file-object.cc @@ -17,6 +17,7 @@ */ #include "ns3/log.h" +#include "ns3/uinteger.h" #include "buffer.h" #include "header.h" @@ -34,6 +35,11 @@ PcapFileObject::GetTypeId (void) static TypeId tid = TypeId ("ns3::PcapFileObject") .SetParent () .AddConstructor () + .AddAttribute ("CaptureSize", + "Maximum length of captured packets (cf. pcap snaplen)", + UintegerValue (PcapFile::SNAPLEN_DEFAULT), + MakeUintegerAccessor (&PcapFileObject::m_snapLen), + MakeUintegerChecker (0, PcapFile::SNAPLEN_DEFAULT)) ; return tid; } @@ -63,7 +69,24 @@ PcapFileObject::Open (std::string const &filename, std::string const &mode) 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::max ()) + { + return m_file.Init (dataLinkType, snapLen, tzCorrection); + } + else + { + return m_file.Init (dataLinkType, m_snapLen, tzCorrection); + } + + // + // Quiet the compiler + // + return true; } bool diff --git a/src/common/pcap-file-object.h b/src/common/pcap-file-object.h index 6faa6b5c4..1dc18b09f 100644 --- a/src/common/pcap-file-object.h +++ b/src/common/pcap-file-object.h @@ -129,7 +129,7 @@ public: * any existing data. */ bool Init (uint32_t dataLinkType, - uint32_t snapLen = PcapFile::SNAPLEN_DEFAULT, + uint32_t snapLen = std::numeric_limits::max (), int32_t tzCorrection = PcapFile::ZONE_DEFAULT); /** @@ -226,6 +226,7 @@ public: private: PcapFile m_file; + uint32_t m_snapLen; }; } //namespace ns3 diff --git a/src/helper/trace-helper.h b/src/helper/trace-helper.h index 1bb8cf819..db2f694ae 100644 --- a/src/helper/trace-helper.h +++ b/src/helper/trace-helper.h @@ -48,13 +48,15 @@ public: // 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. diff --git a/src/helper/yans-wifi-helper.cc b/src/helper/yans-wifi-helper.cc index d65f34b4b..b40721bf1 100644 --- a/src/helper/yans-wifi-helper.cc +++ b/src/helper/yans-wifi-helper.cc @@ -363,17 +363,17 @@ PcapSniffRxEvent ( } 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: @@ -381,12 +381,6 @@ YansWifiPhyHelper::SetPcapFormat (enum PcapFormat format) } } -void -YansWifiPhyHelper::SetPcapDataLinkType (uint32_t dlt) -{ - m_pcapDlt = dlt; -} - void YansWifiPhyHelper::EnablePcapInternal (std::string prefix, Ptr nd, bool promiscuous) { diff --git a/src/helper/yans-wifi-helper.h b/src/helper/yans-wifi-helper.h index 30ff6f3c5..d00afc590 100644 --- a/src/helper/yans-wifi-helper.h +++ b/src/helper/yans-wifi-helper.h @@ -201,45 +201,26 @@ public: 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: /** diff --git a/src/node/radiotap-header.h b/src/node/radiotap-header.h index 8ca3087a1..436661101 100644 --- a/src/node/radiotap-header.h +++ b/src/node/radiotap-header.h @@ -117,15 +117,17 @@ public: */ 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 @@ public: */ 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 @@ public: 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(); diff --git a/src/test/ns3wifi/wifi-interference-test-suite.cc b/src/test/ns3wifi/wifi-interference-test-suite.cc index 9979877c7..5f8d220bb 100644 --- a/src/test/ns3wifi/wifi-interference-test-suite.cc +++ b/src/test/ns3wifi/wifi-interference-test-suite.cc @@ -149,8 +149,7 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs 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");