Review feedback

This commit is contained in:
Craig Dowell
2010-02-03 13:26:39 -08:00
parent aa36d223d7
commit aeefbd4e9f
12 changed files with 94 additions and 88 deletions
+1 -1
View File
@@ -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");
+1 -1
View File
@@ -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");
+1 -1
View File
@@ -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");
@@ -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");
+1 -1
View File
@@ -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)
{
+24 -1
View File
@@ -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<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 @@ 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<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
+2 -1
View File
@@ -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<uint32_t>::max (),
int32_t tzCorrection = PcapFile::ZONE_DEFAULT);
/**
@@ -226,6 +226,7 @@ public:
private:
PcapFile m_file;
uint32_t m_snapLen;
};
} //namespace ns3
+9 -7
View File
@@ -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.
+5 -11
View File
@@ -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<NetDevice> nd, bool promiscuous)
{
+9 -28
View File
@@ -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:
/**
+39 -33
View File
@@ -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();
@@ -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");