added support for radiotap and prism headers
authorNicola Baldo <nbaldo@cttc.es>
Wed, 03 Jun 2009 11:53:26 +0200
changeset 44923ebeb7bf3c15
parent 4491 893d48fcf7f3
child 4494 c5e4af609e21
added support for radiotap and prism headers
CHANGES.html
RELEASE_NOTES
examples/mixed-wireless.cc
examples/simple-wifi-frame-aggregation.cc
examples/third.cc
examples/wifi-wired-bridging.cc
src/common/pcap-writer.cc
src/common/pcap-writer.h
src/devices/wifi/wifi-phy.cc
src/devices/wifi/wifi-phy.h
src/devices/wifi/yans-wifi-phy.cc
src/devices/wifi/yans-wifi-phy.h
src/helper/yans-wifi-helper.cc
src/helper/yans-wifi-helper.h
     1.1 --- a/CHANGES.html	Wed Jun 03 10:04:51 2009 +0200
     1.2 +++ b/CHANGES.html	Wed Jun 03 11:53:26 2009 +0200
     1.3 @@ -51,7 +51,16 @@
     1.4  </ul>
     1.5  
     1.6  <h2>New API:</h2>
     1.7 +
     1.8  <ul>
     1.9 +<li><b>YansWifiPhyHelper supporting radiotap and prism PCAP output</b>
    1.10 +<p>The newly supported pcap formats can be adopted by calling the following new method of YansWifiPhyHelper:</p>
    1.11 +<pre>
    1.12 + +  void SetPcapFormat (enum PcapFormat format);
    1.13 +</pre>
    1.14 +where format is one of PCAP_FORMAT_80211_RADIOTAP, PCAP_FORMAT_80211_PRISM or  PCAP_FORMAT_80211. By default, PCAP_FORMAT_80211 is used, so the default PCAP format is the same as before.</p>
    1.15 +</li>
    1.16 +
    1.17  <li> <b>attributes for class Ipv4</b>
    1.18  <p> class Ipv4 now contains attributes in ipv4.cc; the first one
    1.19  is called "IpForward" that will enable/disable Ipv4 forwarding.  
    1.20 @@ -61,6 +70,44 @@
    1.21  <h2>Changes to existing API:</h2>
    1.22  <ul>
    1.23  
    1.24 +<p><b>YansWifiPhyHelper::EnablePcap* methods not static any more</b>
    1.25 +<p>To accommodate the possibility of configuring the PCAP format used for wifi promiscuous mode traces, several methods of YansWifiPhyHelper had to be made non-static:
    1.26 +<pre>
    1.27 +-  static void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid);
    1.28 ++         void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid);
    1.29 +-  static void EnablePcap (std::string filename, Ptr<NetDevice> nd);
    1.30 ++         void EnablePcap (std::string filename, Ptr<NetDevice> nd);
    1.31 +-  static void EnablePcap (std::string filename, std::string ndName);
    1.32 ++         void EnablePcap (std::string filename, std::string ndName);
    1.33 +-  static void EnablePcap (std::string filename, NetDeviceContainer d);
    1.34 ++         void EnablePcap (std::string filename, NetDeviceContainer d);
    1.35 +-  static void EnablePcap (std::string filename, NodeContainer n);
    1.36 ++         void EnablePcap (std::string filename, NodeContainer n);
    1.37 +-  static void EnablePcapAll (std::string filename);
    1.38 ++         void EnablePcapAll (std::string filename);
    1.39 +</pre>
    1.40 +</p>
    1.41 +</li>
    1.42 +
    1.43 +<li><b>Wifi Promisc Sniff interface modified </b>
    1.44 +<p> 
    1.45 +To accommodate support for the radiotap and prism headers in PCAP traces, the interface for promiscuos mode sniff in the wifi device was changed. The new implementation was heavily inspired by the way the madwifi driver handles monitor mode. A distinction between TX and RX events is introduced, to account for the fact that different information is to be put in the radiotap/prism header (e.g., RSSI and noise make sense only for RX packets). The following are the relevant modifications to the WifiPhy class:
    1.46 +<pre>
    1.47 +-  void NotifyPromiscSniff (Ptr<const Packet> packet);
    1.48 ++  void NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm);
    1.49 ++  void NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble);
    1.50 +-  TracedCallback<Ptr<const Packet> > m_phyPromiscSnifferTrace;
    1.51 ++  TracedCallback<Ptr<const Packet>, uint16_t, uint32_t, bool, double, double> m_phyPromiscSniffRxTrace;
    1.52 ++  TracedCallback<Ptr<const Packet>, uint16_t, uint32_t, bool> m_phyPromiscSniffTxTrace;
    1.53 +</pre>
    1.54 +The above mentioned callbacks are expected to be used to call the following method to write Wifi PCAP traces in promiscuous mode:
    1.55 +<pre>
    1.56 ++  void WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, bool isTx, double signalDbm, double noiseDbm);
    1.57 +</pre>
    1.58 +In the above method, the isTx parameter is to be used to differentiate between TX and RX packets. For an example of how to implement these callbacks, see the implementation of PcapSniffTxEvent and PcapSniffRxEvent in src/helper/yans-wifi-helper.cc
    1.59 +</p>
    1.60 +</li>
    1.61 +
    1.62  <li><b> Routing decoupled from class Ipv4</b>
    1.63  <p> All calls of the form "Ipv4::AddHostRouteTo ()" etc. (i.e. to 
    1.64  add static routes, both unicast and multicast) have been moved to a new 
     2.1 --- a/RELEASE_NOTES	Wed Jun 03 10:04:51 2009 +0200
     2.2 +++ b/RELEASE_NOTES	Wed Jun 03 11:53:26 2009 +0200
     2.3 @@ -25,6 +25,7 @@
     2.4    b) 802.11 PHY:
     2.5       - 802.11b PHY support (Gary Pei)
     2.6       - Nakagami propagation loss model (Timo Bingmann)
     2.7 +     - radiotap and prism headers for PCAP output (Nicola Baldo)
     2.8    c) GammaVariable and ErlangVariable (Timo Bingmann)
     2.9   
    2.10  API changes from ns-3.4
     3.1 --- a/examples/mixed-wireless.cc	Wed Jun 03 10:04:51 2009 +0200
     3.2 +++ b/examples/mixed-wireless.cc	Wed Jun 03 11:53:26 2009 +0200
     3.3 @@ -392,9 +392,9 @@
     3.4        // Let's do a pcap trace on the application source and sink, ifIndex 0
     3.5        // Csma captures in non-promiscuous mode
     3.6        CsmaHelper::EnablePcap ("mixed-wireless", appSource->GetId (), 0, false);
     3.7 -      YansWifiPhyHelper::EnablePcap ("mixed-wireless", appSink->GetId (), 0);
     3.8 -      YansWifiPhyHelper::EnablePcap ("mixed-wireless", 9, 2);
     3.9 -      YansWifiPhyHelper::EnablePcap ("mixed-wireless", 9, 0);
    3.10 +      wifiPhy.EnablePcap ("mixed-wireless", appSink->GetId (), 0);
    3.11 +      wifiPhy.EnablePcap ("mixed-wireless", 9, 2);
    3.12 +      wifiPhy.EnablePcap ("mixed-wireless", 9, 0);
    3.13      }
    3.14  
    3.15    if (useCourseChangeCallback == true)
     4.1 --- a/examples/simple-wifi-frame-aggregation.cc	Wed Jun 03 10:04:51 2009 +0200
     4.2 +++ b/examples/simple-wifi-frame-aggregation.cc	Wed Jun 03 11:53:26 2009 +0200
     4.3 @@ -141,7 +141,7 @@
     4.4  
     4.5    Simulator::Stop (Seconds (10.0));
     4.6    
     4.7 -  YansWifiPhyHelper::EnablePcap ("test-802.11n", 
     4.8 +  phy.EnablePcap ("test-802.11n", 
     4.9      wifiNodes.Get (nWifi - 1)->GetId (), 0);
    4.10  
    4.11    Simulator::Run ();
     5.1 --- a/examples/third.cc	Wed Jun 03 10:04:51 2009 +0200
     5.2 +++ b/examples/third.cc	Wed Jun 03 11:53:26 2009 +0200
     5.3 @@ -164,7 +164,7 @@
     5.4    Simulator::Stop (Seconds (10.0));
     5.5  
     5.6    PointToPointHelper::EnablePcapAll ("third");
     5.7 -  YansWifiPhyHelper::EnablePcap ("third", apDevices.Get (0));
     5.8 +  phy.EnablePcap ("third", apDevices.Get (0));
     5.9    CsmaHelper::EnablePcap ("third", csmaDevices.Get (0), true);
    5.10  
    5.11    Simulator::Run ();
     6.1 --- a/examples/wifi-wired-bridging.cc	Wed Jun 03 10:04:51 2009 +0200
     6.2 +++ b/examples/wifi-wired-bridging.cc	Wed Jun 03 11:53:26 2009 +0200
     6.3 @@ -89,6 +89,10 @@
     6.4    backboneDevices = csma.Install (backboneNodes);
     6.5  
     6.6    double wifiX = 0.0;
     6.7 +
     6.8 +  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
     6.9 +  wifiPhy.SetPcapFormat(YansWifiPhyHelper::PCAP_FORMAT_80211_RADIOTAP);
    6.10 +
    6.11    for (uint32_t i = 0; i < nWifis; ++i)
    6.12      {
    6.13        // calculate ssid for wifi subnetwork
    6.14 @@ -105,7 +109,6 @@
    6.15        BridgeHelper bridge;
    6.16        WifiHelper wifi = WifiHelper::Default ();
    6.17        NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
    6.18 -      YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
    6.19        YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
    6.20        wifiPhy.SetChannel (wifiChannel.Create ());
    6.21  
    6.22 @@ -182,8 +185,8 @@
    6.23    apps.Start (Seconds (0.5));
    6.24    apps.Stop (Seconds (3.0));
    6.25    
    6.26 -  YansWifiPhyHelper::EnablePcap ("wifi-wired-bridging", apDevices[0]);
    6.27 -  YansWifiPhyHelper::EnablePcap ("wifi-wired-bridging", apDevices[1]);
    6.28 +  wifiPhy.EnablePcap ("wifi-wired-bridging", apDevices[0]);
    6.29 +  wifiPhy.EnablePcap ("wifi-wired-bridging", apDevices[1]);
    6.30  
    6.31    std::ofstream os;
    6.32    os.open ("wifi-wired-bridging.mob");
     7.1 --- a/src/common/pcap-writer.cc	Wed Jun 03 10:04:51 2009 +0200
     7.2 +++ b/src/common/pcap-writer.cc	Wed Jun 03 11:53:26 2009 +0200
     7.3 @@ -41,6 +41,8 @@
     7.4    PCAP_PPP      = 9,
     7.5    PCAP_RAW_IP   = 101,
     7.6    PCAP_80211    = 105,
     7.7 +  PCAP_80211_PRISM = 119,
     7.8 +  PCAP_80211_RADIOTAP  = 127,
     7.9  };
    7.10  
    7.11  PcapWriter::PcapWriter ()
    7.12 @@ -115,6 +117,20 @@
    7.13    WriteHeader (PCAP_80211);
    7.14  }
    7.15  
    7.16 +void
    7.17 +PcapWriter::WriteWifiRadiotapHeader (void)
    7.18 +{
    7.19 +  NS_LOG_FUNCTION_NOARGS ();
    7.20 +  WriteHeader (PCAP_80211_RADIOTAP);
    7.21 +}
    7.22 +
    7.23 +void
    7.24 +PcapWriter::WriteWifiPrismHeader (void)
    7.25 +{
    7.26 +  NS_LOG_FUNCTION_NOARGS ();
    7.27 +  WriteHeader (PCAP_80211_PRISM);
    7.28 +}
    7.29 +
    7.30  void 
    7.31  PcapWriter::WritePppHeader (void)
    7.32  {
    7.33 @@ -133,6 +149,7 @@
    7.34    Write32 (0);
    7.35    Write32 (0xffff);
    7.36    Write32 (network);
    7.37 +  m_pcapMode = network;
    7.38  }
    7.39  
    7.40  void 
    7.41 @@ -151,12 +168,296 @@
    7.42      }
    7.43  }
    7.44  
    7.45 +
    7.46 +void PcapWriter::WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, bool isTx, double signalDbm, double noiseDbm)
    7.47 +{  
    7.48 +  NS_LOG_FUNCTION (this << packet->GetSize() << channelFreqMhz << rate << isShortPreamble << isTx << signalDbm << noiseDbm);
    7.49 +
    7.50 +  if (m_writer == 0) 
    7.51 +    {
    7.52 +      return;
    7.53 +    }
    7.54 +
    7.55 +  if (m_pcapMode == PCAP_80211)
    7.56 +    {
    7.57 +      WritePacket (packet);    
    7.58 +      return;
    7.59 +    }
    7.60 +  
    7.61 +  /* the following is common between PRISM and RADIOTAP */
    7.62 +  
    7.63 +  uint64_t current = Simulator::Now ().GetMicroSeconds ();
    7.64 +  uint64_t s = current / 1000000;
    7.65 +  uint64_t us = current % 1000000;
    7.66 +  Write32 (s & 0xffffffff);
    7.67 +  Write32 (us & 0xffffffff);
    7.68 +    
    7.69 +
    7.70 +  // MAC timestamp. Actually according to radiotap specifications
    7.71 +  // (http://www.radiotap.org/defined-fields/TSFT) this should be
    7.72 +  // the time "when the first bit of the MPDU arrived at the
    7.73 +  // MAC". This is not exactly what we're doing here, but to handle
    7.74 +  // this properly we would need to first of all investigate how
    7.75 +  // real devices (e.g. madwifi) handle this case, especially for TX
    7.76 +  // packets (radiotap specs says TSFT is not used for TX packets,
    7.77 +  // but madwifi actually uses it).
    7.78 +  uint64_t tsft = current;      
    7.79 +    
    7.80 +  if (m_pcapMode == PCAP_80211_PRISM)
    7.81 +    {
    7.82 +      
    7.83 +#define PRISM_MSG_CODE		 0x00000044
    7.84 +#define PRISM_MSG_LENGTH         144
    7.85 +#define PRISM_DID_HOSTTIME	 0x00010044
    7.86 +#define PRISM_DID_MACTIME	 0x00020044
    7.87 +#define PRISM_DID_CHANNEL	 0x00030044
    7.88 +#define PRISM_DID_RSSI	         0x00040044
    7.89 +#define PRISM_DID_SQ		 0x00050044
    7.90 +#define PRISM_DID_SIGNAL	 0x00060044
    7.91 +#define PRISM_DID_NOISE	         0x00070044
    7.92 +#define PRISM_DID_RATE	         0x00080044
    7.93 +#define PRISM_DID_ISTX	         0x00090044
    7.94 +#define PRISM_DID_FRMLEN	 0x000A0044
    7.95 +
    7.96 +#define PRISM_STATUS_PRESENT    0
    7.97 +#define PRISM_STATUS_ABSENT     1
    7.98 +#define PRISM_ITEM_LENGTH       4
    7.99 +
   7.100 +
   7.101 +
   7.102 +      uint32_t size = packet->GetSize () + PRISM_MSG_LENGTH;
   7.103 +      Write32 (size); // total packet size
   7.104 +      Write32 (size); // captured size
   7.105 +
   7.106 +      Write32(PRISM_MSG_CODE);
   7.107 +      Write32(PRISM_MSG_LENGTH);
   7.108 +      WriteData((const uint8_t *)"unknown wifi device!!!!!!!!", 16);
   7.109 +    
   7.110 +      Write32(PRISM_DID_HOSTTIME);
   7.111 +      Write16(PRISM_STATUS_PRESENT);
   7.112 +      Write16(PRISM_ITEM_LENGTH); 
   7.113 +      // madwifi reports hosttime in jiffies. 
   7.114 +      // We calculate jiffies assuming HZ = 10
   7.115 +      Write32((uint32_t) (Now ().GetMilliSeconds () / 10 ) ); 
   7.116 +
   7.117 +      Write32(PRISM_DID_MACTIME);
   7.118 +      Write16(PRISM_STATUS_PRESENT);
   7.119 +      Write16(PRISM_ITEM_LENGTH); 
   7.120 +      // This looses precision, which is a well-known issue of the prism
   7.121 +      // header format.
   7.122 +      Write32((uint32_t) tsft);
   7.123 +
   7.124 +      Write32(PRISM_DID_CHANNEL);
   7.125 +      Write16(PRISM_STATUS_PRESENT);
   7.126 +      Write16(PRISM_ITEM_LENGTH); 
   7.127 +      // convert from frequency to channel number. This conversion is
   7.128 +      // correct only for IEEE 802.11b/g channels 1-13.
   7.129 +      Write32((channelFreqMhz - 2407) / 5);
   7.130 +
   7.131 +      Write32(PRISM_DID_RSSI);
   7.132 +      Write16(PRISM_STATUS_PRESENT);
   7.133 +      Write16(PRISM_ITEM_LENGTH); 
   7.134 +      // madwifi here reports a value which is said to be "the value in
   7.135 +      // dBm above noise". Apart from the fact that this is incorrect
   7.136 +      // (if it is relative to a value in dBm, then it must be in dB,
   7.137 +      // not in dBm again), this means that in fact it is not a RSSI
   7.138 +      // (which stands for Received Signal Strength Indicator) but it is
   7.139 +      // rather a Signal to Noise Ratio (SNR), of course in dB.
   7.140 +      // Anyway, in the end we calculate the value exactly as madwifi does.
   7.141 +      Write32(round(signalDbm - noiseDbm));
   7.142 +
   7.143 +      // SQ field not used. I would expect a PRISM_STATUS_ABSENT to be
   7.144 +      // needed here, but if you look at the prism header that madwifi
   7.145 +      // produces you'll just see that the whole field structure is
   7.146 +      // zeroed. 
   7.147 +      Write32(0);
   7.148 +      Write16(0);
   7.149 +      Write16(0); 
   7.150 +      Write32(0);
   7.151 +
   7.152 +      Write32(PRISM_DID_SIGNAL);
   7.153 +      Write16(PRISM_STATUS_PRESENT);
   7.154 +      Write16(PRISM_ITEM_LENGTH); 
   7.155 +      Write32(round(signalDbm));
   7.156 +
   7.157 +      Write32(PRISM_DID_NOISE);
   7.158 +      Write16(PRISM_STATUS_PRESENT);
   7.159 +      Write16(PRISM_ITEM_LENGTH); 
   7.160 +      Write32(round(noiseDbm));
   7.161 +            
   7.162 +      Write32(PRISM_DID_RATE);    
   7.163 +      Write16(PRISM_STATUS_PRESENT);
   7.164 +      Write16(PRISM_ITEM_LENGTH); 
   7.165 +      Write32(rate);
   7.166 + 
   7.167 +      Write32(PRISM_DID_ISTX);
   7.168 +      Write16(PRISM_STATUS_PRESENT);
   7.169 +      Write16(PRISM_ITEM_LENGTH); 
   7.170 +      Write32(isTx ? 1 : 0);
   7.171 +
   7.172 +      Write32(PRISM_DID_FRMLEN);
   7.173 +      Write16(PRISM_STATUS_ABSENT);
   7.174 +      Write16(PRISM_ITEM_LENGTH); 
   7.175 +      Write32(packet->GetSize ());    
   7.176 +      
   7.177 +    
   7.178 +
   7.179 +    } // PCAP_80211_PRISM
   7.180 +
   7.181 +  else if (m_pcapMode == PCAP_80211_RADIOTAP)
   7.182 +    {      
   7.183 +      NS_LOG_LOGIC("writing radiotap packet");
   7.184 +      
   7.185 +#define	RADIOTAP_TSFT               0x00000001
   7.186 +#define	RADIOTAP_FLAGS              0x00000002
   7.187 +#define	RADIOTAP_RATE               0x00000004
   7.188 +#define RADIOTAP_CHANNEL            0x00000008
   7.189 +#define	RADIOTAP_FHSS               0x00000010
   7.190 +#define RADIOTAP_DBM_ANTSIGNAL      0x00000020
   7.191 +#define RADIOTAP_DBM_ANTNOISE       0x00000040
   7.192 +#define RADIOTAP_LOCK_QUALITY       0x00000080
   7.193 +#define RADIOTAP_TX_ATTENUATION     0x00000100    
   7.194 +#define RADIOTAP_DB_TX_ATTENUATION  0x00000200
   7.195 +#define RADIOTAP_DBM_TX_POWER       0x00000200
   7.196 +#define RADIOTAP_ANTENNA            0x00000400
   7.197 +#define RADIOTAP_DB_ANTSIGNAL       0x00000800
   7.198 +#define RADIOTAP_DB_ANTNOISE        0x00001000
   7.199 +#define RADIOTAP_EXT                0x10000000
   7.200 +
   7.201 +#define	RADIOTAP_FLAG_NONE	   0x00	
   7.202 +#define	RADIOTAP_FLAG_CFP	   0x01	
   7.203 +#define	RADIOTAP_FLAG_SHORTPRE	   0x02	
   7.204 +#define	RADIOTAP_FLAG_WEP	   0x04	
   7.205 +#define	RADIOTAP_FLAG_FRAG	   0x08	
   7.206 +#define	RADIOTAP_FLAG_FCS	   0x10	
   7.207 +#define	RADIOTAP_FLAG_DATAPAD	   0x20	
   7.208 +#define	RADIOTAP_FLAG_BADFCS	   0x40	
   7.209 +
   7.210 +#define	RADIOTAP_CHANNEL_TURBO	  0x0010
   7.211 +#define	RADIOTAP_CHANNEL_CCK	  0x0020
   7.212 +#define	RADIOTAP_CHANNEL_OFDM	  0x0040
   7.213 +#define	RADIOTAP_CHANNEL_2GHZ	  0x0080
   7.214 +#define	RADIOTAP_CHANNEL_5GHZ	  0x0100
   7.215 +#define	RADIOTAP_CHANNEL_PASSIVE  0x0200
   7.216 +#define	RADIOTAP_CHANNEL_DYN	  0x0400
   7.217 +#define	RADIOTAP_CHANNEL_GFSK	  0x0800
   7.218 +
   7.219 +#define RADIOTAP_RX_PRESENT (RADIOTAP_TSFT | RADIOTAP_FLAGS | RADIOTAP_RATE | RADIOTAP_CHANNEL | RADIOTAP_DBM_ANTSIGNAL | RADIOTAP_DBM_ANTNOISE)
   7.220 +#define RADIOTAP_RX_LENGTH (8+8+1+1+2+2+1+1)
   7.221 +
   7.222 +#define RADIOTAP_TX_PRESENT (RADIOTAP_TSFT | RADIOTAP_FLAGS  | RADIOTAP_RATE | RADIOTAP_CHANNEL)
   7.223 +#define RADIOTAP_TX_LENGTH (8+8+1+1+2+2)
   7.224 +
   7.225 +      uint32_t size;
   7.226 +      if (isTx)
   7.227 +        {
   7.228 +          size = packet->GetSize () + RADIOTAP_TX_LENGTH;
   7.229 +        }
   7.230 +      else
   7.231 +        {
   7.232 +          size = packet->GetSize () + RADIOTAP_RX_LENGTH;
   7.233 +        }
   7.234 +      Write32 (size); // total packet size
   7.235 +      Write32 (size); // captured size
   7.236 +
   7.237 +      Write8(0); // radiotap version
   7.238 +      Write8(0); // padding
   7.239 +
   7.240 +      if (isTx)
   7.241 +        {
   7.242 +          Write16(RADIOTAP_TX_LENGTH); 
   7.243 +          Write32(RADIOTAP_TX_PRESENT); 
   7.244 +        }
   7.245 +      else
   7.246 +        {
   7.247 +          Write16(RADIOTAP_RX_LENGTH); 
   7.248 +          Write32(RADIOTAP_RX_PRESENT); 
   7.249 +        }
   7.250 +
   7.251 +      Write64(tsft); 
   7.252 +      
   7.253 +      uint8_t flags = RADIOTAP_FLAG_NONE;
   7.254 +      if (isShortPreamble)
   7.255 +        {
   7.256 +          flags |= RADIOTAP_FLAG_SHORTPRE; 
   7.257 +        }
   7.258 +      Write8(flags);
   7.259 +      
   7.260 +
   7.261 +      Write8(rate); 
   7.262 +
   7.263 +      Write16((uint16_t) channelFreqMhz); 
   7.264 +
   7.265 +      // we might want to make this setting depend on the WifiMode and
   7.266 +      // on the ChannelFrequency at some time in the future. But for now
   7.267 +      // I think a fixed setting is more than enough for most purposes.
   7.268 +      Write16(RADIOTAP_CHANNEL_OFDM | RADIOTAP_CHANNEL_2GHZ); 
   7.269 +    
   7.270 +      if (!isTx)
   7.271 +        {
   7.272 +          
   7.273 +          Write8 (RoundToInt8 (signalDbm)); 
   7.274 +          Write8 (RoundToInt8 (noiseDbm)); 
   7.275 +        }
   7.276 +
   7.277 +    } // PCAP_80211_RADIOTAP
   7.278 +
   7.279 +    
   7.280 +  else
   7.281 +    {
   7.282 +      NS_LOG_ERROR("unknown PCAP mode");      
   7.283 +      return;
   7.284 +    }    
   7.285 +
   7.286 +  // finally, write rest of packet
   7.287 +  WriteData (packet->PeekData (), packet->GetSize ());
   7.288 +}
   7.289 +    
   7.290 +  
   7.291 +
   7.292 +
   7.293 +int8_t 
   7.294 +PcapWriter::RoundToInt8 (double value)
   7.295 +{
   7.296 +  if (value < -128)
   7.297 +    {
   7.298 +      return -128;
   7.299 +    }
   7.300 +  if (value > 127)
   7.301 +    {
   7.302 +      return 127;
   7.303 +    }
   7.304 +  return ((int8_t) round(value));
   7.305 +}
   7.306 +
   7.307 +
   7.308 +
   7.309 +
   7.310 +
   7.311 +
   7.312  void
   7.313  PcapWriter::WriteData (uint8_t const*buffer, uint32_t size)
   7.314  {
   7.315 +  NS_LOG_FUNCTION(this << size);
   7.316    m_writer->write ((char const *)buffer, size);
   7.317  }
   7.318  
   7.319 +
   7.320 +void
   7.321 +PcapWriter::Write64 (uint64_t data)
   7.322 +{
   7.323 +  uint8_t buffer[8];
   7.324 +  buffer[0] = (data >> 0) & 0xff;
   7.325 +  buffer[1] = (data >> 8) & 0xff;
   7.326 +  buffer[2] = (data >> 16) & 0xff;
   7.327 +  buffer[3] = (data >> 24) & 0xff;
   7.328 +  buffer[4] = (data >> 32) & 0xff;
   7.329 +  buffer[5] = (data >> 40) & 0xff;
   7.330 +  buffer[6] = (data >> 48) & 0xff;
   7.331 +  buffer[7] = (data >> 56) & 0xff;
   7.332 +  WriteData (buffer, 8);
   7.333 +}
   7.334 +
   7.335  void
   7.336  PcapWriter::Write32 (uint32_t data)
   7.337  {
   7.338 @@ -177,4 +478,12 @@
   7.339    WriteData (buffer, 2);
   7.340  }
   7.341  
   7.342 +void
   7.343 +PcapWriter::Write8 (uint8_t data)
   7.344 +{
   7.345 +  WriteData (&data, 1);
   7.346 +}
   7.347 +
   7.348 +
   7.349 +
   7.350  } // namespace ns3
     8.1 --- a/src/common/pcap-writer.h	Wed Jun 03 10:04:51 2009 +0200
     8.2 +++ b/src/common/pcap-writer.h	Wed Jun 03 11:53:26 2009 +0200
     8.3 @@ -76,6 +76,24 @@
     8.4  
     8.5    /**
     8.6     * Write a pcap header in the output file which specifies
     8.7 +   * that the content of the file will be 802.11 Packets preceded by a
     8.8 +   * radiotap header providing PHY layer info. This method should be
     8.9 +   * invoked before ns3::PcapWriter::WritePacket and after
    8.10 +   * ns3::PcapWriter::Open. 
    8.11 +   */
    8.12 +  void WriteWifiRadiotapHeader (void);
    8.13 +
    8.14 +  /**
    8.15 +   * Write a pcap header in the output file which specifies
    8.16 +   * that the content of the file will be 802.11 Packets preceded by a
    8.17 +   * prism header providing PHY layer info. This method should be
    8.18 +   * invoked before ns3::PcapWriter::WritePacket and after
    8.19 +   * ns3::PcapWriter::Open. 
    8.20 +   */
    8.21 +  void WriteWifiPrismHeader (void);
    8.22 +
    8.23 +  /**
    8.24 +   * Write a pcap header in the output file which specifies
    8.25     * that the content of the file will be ppp Packets. This 
    8.26     * method should be invoked before ns3::PcapWriter::WritePacket 
    8.27     * and after ns3::PcapWriter::Open.
    8.28 @@ -87,12 +105,40 @@
    8.29     */
    8.30    void WritePacket (Ptr<const Packet> packet);
    8.31  
    8.32 +  /** 
    8.33 +   * Write a Packet, possibly adding wifi PHY layer information to it
    8.34 +   *
    8.35 +   * @param packet the packet being received
    8.36 +   * @param channelFreqMhz the frequency in MHz at which the packet is
    8.37 +   * received. Note that in real devices this is normally the
    8.38 +   * frequency to which  the receiver is tuned, and this can be
    8.39 +   * different than the frequency at which the packet was originally
    8.40 +   * transmitted. This is because it is possible to have the receiver
    8.41 +   * tuned on a given channel and still to be able to receive packets
    8.42 +   * on a nearby channel.
    8.43 +   * @param rate the PHY data rate in units of 500kbps (i.e., the same
    8.44 +   * units used both for the radiotap and for the prism header) 
    8.45 +   * @param isPreambleShort true if short preamble is used, false otherwise
    8.46 +   * @param isTx true if packet is being transmitted, false when
    8.47 +   * packet is being received
    8.48 +   * @param signalDbm signal power in dBm
    8.49 +   * @param noiseDbm  noise power in dBm
    8.50 +   */
    8.51 +  void WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, bool isTx, double signalDbm, double noiseDbm);
    8.52 +
    8.53 +
    8.54 +
    8.55 +
    8.56  private:
    8.57    void WriteData (uint8_t const*buffer, uint32_t size);
    8.58 +  void Write64 (uint64_t data);
    8.59    void Write32 (uint32_t data);
    8.60    void Write16 (uint16_t data);
    8.61 +  void Write8 (uint8_t data);
    8.62    void WriteHeader (uint32_t network);
    8.63 +  int8_t RoundToInt8 (double value);
    8.64    std::ofstream *m_writer;
    8.65 +  uint32_t m_pcapMode;
    8.66  };
    8.67  
    8.68  } // namespace ns3
     9.1 --- a/src/devices/wifi/wifi-phy.cc	Wed Jun 03 10:04:51 2009 +0200
     9.2 +++ b/src/devices/wifi/wifi-phy.cc	Wed Jun 03 11:53:26 2009 +0200
     9.3 @@ -73,9 +73,12 @@
     9.4      .AddTraceSource ("PhyRxDrop", 
     9.5                       "Trace source indicating a packet has been dropped by the device during reception",
     9.6                       MakeTraceSourceAccessor (&WifiPhy::m_phyRxDropTrace))
     9.7 -    .AddTraceSource ("PromiscSniffer", 
     9.8 -                     "Trace source simulating a promiscuous packet sniffer attached to the device",
     9.9 -                     MakeTraceSourceAccessor (&WifiPhy::m_phyPromiscSnifferTrace))
    9.10 +    .AddTraceSource ("PromiscSnifferRx", 
    9.11 +                     "Trace source simulating a wifi device in monitor mode sniffing all received frames",
    9.12 +                     MakeTraceSourceAccessor (&WifiPhy::m_phyPromiscSniffRxTrace))
    9.13 +    .AddTraceSource ("PromiscSnifferTx", 
    9.14 +                     "Trace source simulating the capability of a wifi device in monitor mode to sniff all frames being transmitted",
    9.15 +                     MakeTraceSourceAccessor (&WifiPhy::m_phyPromiscSniffTxTrace))
    9.16      ;
    9.17    return tid;
    9.18  }
    9.19 @@ -194,9 +197,15 @@
    9.20  }
    9.21  
    9.22  void 
    9.23 -WifiPhy::NotifyPromiscSniff (Ptr<const Packet> packet) 
    9.24 +WifiPhy::NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
    9.25  {
    9.26 -  m_phyPromiscSnifferTrace (packet);
    9.27 +  m_phyPromiscSniffRxTrace (packet, channelFreqMhz, rate, isShortPreamble, signalDbm, noiseDbm);
    9.28 +}
    9.29 +
    9.30 +void 
    9.31 +WifiPhy::NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble)
    9.32 +{
    9.33 +  m_phyPromiscSniffTxTrace (packet, channelFreqMhz, rate, isShortPreamble);
    9.34  }
    9.35  
    9.36  WifiMode 
    10.1 --- a/src/devices/wifi/wifi-phy.h	Wed Jun 03 10:04:51 2009 +0200
    10.2 +++ b/src/devices/wifi/wifi-phy.h	Wed Jun 03 11:53:26 2009 +0200
    10.3 @@ -294,11 +294,46 @@
    10.4     */
    10.5    void NotifyRxDrop (Ptr<const Packet> packet);
    10.6  
    10.7 -  /**
    10.8 -   * Public method used to fire a PromiscSniffer trace.  Implemented for encapsulation 
    10.9 +  /** 
   10.10 +   * 
   10.11 +   * Public method used to fire a PromiscSniffer trace for a wifi packet being received.  Implemented for encapsulation 
   10.12     * purposes.
   10.13 +   * 
   10.14 +   * @param packet the packet being received
   10.15 +   * @param channelFreqMhz the frequency in MHz at which the packet is
   10.16 +   * received. Note that in real devices this is normally the
   10.17 +   * frequency to which  the receiver is tuned, and this can be
   10.18 +   * different than the frequency at which the packet was originally
   10.19 +   * transmitted. This is because it is possible to have the receiver
   10.20 +   * tuned on a given channel and still to be able to receive packets
   10.21 +   * on a nearby channel.
   10.22 +   * @param rate the PHY data rate in units of 500kbps (i.e., the same
   10.23 +   * units used both for the radiotap and for the prism header) 
   10.24 +   * @param isPreambleShort true if short preamble is used, false otherwise
   10.25 +   * @param signalDbm signal power in dBm
   10.26 +   * @param noiseDbm  noise power in dBm
   10.27     */
   10.28 -  void NotifyPromiscSniff (Ptr<const Packet> packet);
   10.29 +  void NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm);
   10.30 +
   10.31 +  /** 
   10.32 +   * 
   10.33 +   * Public method used to fire a PromiscSniffer trace for a wifi packet being transmitted.  Implemented for encapsulation 
   10.34 +   * purposes.
   10.35 +   * 
   10.36 +   * @param packet the packet being received
   10.37 +   * @param channelFreqMhz the frequency in MHz at which the packet is
   10.38 +   * received. Note that in real devices this is normally the
   10.39 +   * frequency to which  the receiver is tuned, and this can be
   10.40 +   * different than the frequency at which the packet was originally
   10.41 +   * transmitted. This is because it is possible to have the receiver
   10.42 +   * tuned on a given channel and still to be able to receive packets
   10.43 +   * on a nearby channel.
   10.44 +   * @param rate the PHY data rate in units of 500kbps (i.e., the same
   10.45 +   * units used both for the radiotap and for the prism header) 
   10.46 +   * @param isPreambleShort true if short preamble is used, false otherwise
   10.47 +   */
   10.48 +  void NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble);
   10.49 +  
   10.50  
   10.51  private:
   10.52    /**
   10.53 @@ -349,24 +384,29 @@
   10.54    TracedCallback<Ptr<const Packet> > m_phyRxDropTrace;
   10.55  
   10.56    /**
   10.57 -   * A trace source that emulates a promiscuous mode protocol sniffer connected
   10.58 -   * to the device.  This trace source fire on packets destined for any host
   10.59 -   * just like your average everyday packet sniffer.
   10.60 -   *
   10.61 -   * On the transmit size, this trace hook will fire after a packet is dequeued
   10.62 -   * from the device queue for transmission.  In Linux, for example, this would
   10.63 -   * correspond to the point just before a device hard_start_xmit where 
   10.64 -   * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET 
   10.65 -   * ETH_P_ALL handlers.
   10.66 -   *
   10.67 -   * On the receive side, this trace hook will fire when a packet is received,
   10.68 -   * just before the receive callback is executed.  In Linux, for example, 
   10.69 -   * this would correspond to the point at which the packet is dispatched to 
   10.70 -   * packet sniffers in netif_receive_skb.
   10.71 +   * A trace source that emulates a wifi device in monitor mode
   10.72 +   * sniffing a packet being received. 
   10.73 +   * 
   10.74 +   * As a reference with the real world, firing this trace
   10.75 +   * corresponds in the madwifi driver to calling the function
   10.76 +   * ieee80211_input_monitor()
   10.77     *
   10.78     * \see class CallBackTraceSource
   10.79     */
   10.80 -  TracedCallback<Ptr<const Packet> > m_phyPromiscSnifferTrace;
   10.81 +  TracedCallback<Ptr<const Packet>, uint16_t, uint32_t, bool, double, double> m_phyPromiscSniffRxTrace;
   10.82 +
   10.83 +  /**
   10.84 +   * A trace source that emulates a wifi device in monitor mode
   10.85 +   * sniffing a packet being transmitted. 
   10.86 +   * 
   10.87 +   * As a reference with the real world, firing this trace
   10.88 +   * corresponds in the madwifi driver to calling the function
   10.89 +   * ieee80211_input_monitor()
   10.90 +   *
   10.91 +   * \see class CallBackTraceSource
   10.92 +   */
   10.93 +  TracedCallback<Ptr<const Packet>, uint16_t, uint32_t, bool> m_phyPromiscSniffTxTrace;
   10.94 +
   10.95  };
   10.96  
   10.97  } // namespace ns3
    11.1 --- a/src/devices/wifi/yans-wifi-phy.cc	Wed Jun 03 10:04:51 2009 +0200
    11.2 +++ b/src/devices/wifi/yans-wifi-phy.cc	Wed Jun 03 11:53:26 2009 +0200
    11.3 @@ -121,8 +121,10 @@
    11.4  }
    11.5  
    11.6  YansWifiPhy::YansWifiPhy ()
    11.7 - : m_endSyncEvent (),
    11.8 -   m_random (0.0, 1.0)
    11.9 +  :  m_channelFreqMhz(2437),
   11.10 +     m_endSyncEvent (),
   11.11 +     m_random (0.0, 1.0)
   11.12 +
   11.13  {
   11.14    NS_LOG_FUNCTION (this);
   11.15    m_state = CreateObject<WifiPhyStateHelper> ();
   11.16 @@ -408,7 +410,9 @@
   11.17        m_endSyncEvent.Cancel ();
   11.18      }
   11.19    NotifyTxBegin (packet);
   11.20 -  NotifyPromiscSniff (packet);
   11.21 +  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;   
   11.22 +  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
   11.23 +  NotifyPromiscSniffTx (packet, m_channelFreqMhz, dataRate500KbpsUnits, isShortPreamble);
   11.24    m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
   11.25    m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
   11.26  }
   11.27 @@ -577,11 +581,14 @@
   11.28  
   11.29    NS_LOG_DEBUG ("mode="<<(event->GetPayloadMode ().GetDataRate ())<<
   11.30                  ", snr="<<snrPer.snr<<", per="<<snrPer.per<<", size="<<packet->GetSize ());
   11.31 -  
   11.32    if (m_random.GetValue () > snrPer.per) 
   11.33      {
   11.34 -      NotifyRxEnd (packet);
   11.35 -      NotifyPromiscSniff (packet);
   11.36 +      NotifyRxEnd (packet); 
   11.37 +      uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;   
   11.38 +      bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());  
   11.39 +      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
   11.40 +      double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNoiseFigure() + 30 ;
   11.41 +      NotifyPromiscSniffRx (packet, m_channelFreqMhz, dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
   11.42        m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
   11.43      } 
   11.44    else 
   11.45 @@ -591,5 +598,4 @@
   11.46        m_state->SwitchFromSyncEndError (packet, snrPer.snr);
   11.47      }
   11.48  }
   11.49 -
   11.50  } // namespace ns3
    12.1 --- a/src/devices/wifi/yans-wifi-phy.h	Wed Jun 03 10:04:51 2009 +0200
    12.2 +++ b/src/devices/wifi/yans-wifi-phy.h	Wed Jun 03 11:53:26 2009 +0200
    12.3 @@ -142,6 +142,7 @@
    12.4    double   m_txPowerBaseDbm;
    12.5    double   m_txPowerEndDbm;
    12.6    uint32_t m_nTxPower;
    12.7 +  uint16_t m_channelFreqMhz;
    12.8  
    12.9    Ptr<YansWifiChannel> m_channel;
   12.10    Ptr<Object> m_device;
    13.1 --- a/src/helper/yans-wifi-helper.cc	Wed Jun 03 10:04:51 2009 +0200
    13.2 +++ b/src/helper/yans-wifi-helper.cc	Wed Jun 03 11:53:26 2009 +0200
    13.3 @@ -31,11 +31,19 @@
    13.4  
    13.5  namespace ns3 {
    13.6  
    13.7 -static void PcapSnifferEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet)
    13.8 +static void PcapSniffTxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz,  uint32_t rate, bool isShortPreamble)
    13.9  {
   13.10 -  writer->WritePacket (packet);
   13.11 +  const double unusedValue = 0;
   13.12 +  writer->WriteWifiMonitorPacket(packet, channelFreqMhz, rate, isShortPreamble, true, unusedValue, unusedValue); 
   13.13  }
   13.14  
   13.15 +
   13.16 +static void PcapSniffRxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz,  uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
   13.17 +{
   13.18 +  writer->WriteWifiMonitorPacket(packet, channelFreqMhz, rate, isShortPreamble, false, signalDbm, noiseDbm); 
   13.19 +}
   13.20 +
   13.21 +
   13.22  static void AsciiPhyTxEvent (std::ostream *os, std::string context, 
   13.23                               Ptr<const Packet> packet,
   13.24                               WifiMode mode, WifiPreamble preamble, 
   13.25 @@ -137,7 +145,9 @@
   13.26  
   13.27  
   13.28  YansWifiPhyHelper::YansWifiPhyHelper ()
   13.29 -  : m_channel (0)
   13.30 +  : m_channel (0),
   13.31 +    m_pcapFormat(PCAP_FORMAT_80211)
   13.32 +    
   13.33  {
   13.34    m_phy.SetTypeId ("ns3::YansWifiPhy");
   13.35  }
   13.36 @@ -202,6 +212,14 @@
   13.37    return phy;
   13.38  }
   13.39  
   13.40 +
   13.41 +void 
   13.42 +YansWifiPhyHelper::SetPcapFormat (enum PcapFormat format)
   13.43 +{
   13.44 +  m_pcapFormat = format;
   13.45 +}
   13.46 +
   13.47 +
   13.48  void 
   13.49  YansWifiPhyHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid)
   13.50  {
   13.51 @@ -218,11 +236,28 @@
   13.52    // with the locally-defined WifiPhyHelper::Create method.
   13.53    Ptr<PcapWriter> pcap = ::ns3::Create<PcapWriter> ();
   13.54    pcap->Open (oss.str ());
   13.55 -  pcap->WriteWifiHeader ();
   13.56 +
   13.57 +  switch (m_pcapFormat) {
   13.58 +  case PCAP_FORMAT_80211:
   13.59 +    pcap->WriteWifiHeader ();  
   13.60 +    break;
   13.61 +  case PCAP_FORMAT_80211_RADIOTAP:
   13.62 +    pcap->WriteWifiRadiotapHeader ();  
   13.63 +    break;
   13.64 +  case PCAP_FORMAT_80211_PRISM:
   13.65 +    pcap->WriteWifiPrismHeader ();  
   13.66 +    break;
   13.67 +  }
   13.68 +  
   13.69    oss.str ("");
   13.70    oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid;
   13.71 -  oss << "/$ns3::WifiNetDevice/Phy/PromiscSniffer";
   13.72 -  Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapSnifferEvent, pcap));
   13.73 +  oss << "/$ns3::WifiNetDevice/Phy/PromiscSnifferTx";
   13.74 +  Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapSniffTxEvent, pcap));
   13.75 +
   13.76 +  oss.str ("");
   13.77 +  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid;
   13.78 +  oss << "/$ns3::WifiNetDevice/Phy/PromiscSnifferRx";
   13.79 +  Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PcapSniffRxEvent, pcap));  
   13.80  }
   13.81  
   13.82  void 
    14.1 --- a/src/helper/yans-wifi-helper.h	Wed Jun 03 10:04:51 2009 +0200
    14.2 +++ b/src/helper/yans-wifi-helper.h	Wed Jun 03 11:53:26 2009 +0200
    14.3 @@ -198,18 +198,45 @@
    14.4                            std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
    14.5  
    14.6    /**
    14.7 +   * PCAP formats 
    14.8 +   * 
    14.9 +   */
   14.10 +  enum PcapFormat {   
   14.11 +    PCAP_FORMAT_80211          = 1,
   14.12 +    PCAP_FORMAT_80211_PRISM    = 2,
   14.13 +    PCAP_FORMAT_80211_RADIOTAP = 3,
   14.14 +  };
   14.15 +  
   14.16 +  /** 
   14.17 +   * Set the format of PCAP traces to be used. This function has to be
   14.18 +   * called before EnablePcap(), so that the header of the pcap file
   14.19 +   * can be written correctly.
   14.20 +   *
   14.21 +   * In madwifi, this corresponds to setting
   14.22 +   * /proc/sys/net/ath0/dev_type to a particular value. See
   14.23 +   * http://madwifi-project.org/wiki/UserDocs/MonitorModeInterface for
   14.24 +   * more information.
   14.25 +   * 
   14.26 +   * @param format the PcapFormat to be used
   14.27 +   */
   14.28 +  void SetPcapFormat (enum PcapFormat format);
   14.29 +
   14.30 +  /**
   14.31     * \param filename filename prefix to use for pcap files.
   14.32     * \param nodeid the id of the node to generate pcap output for.
   14.33     * \param deviceid the id of the device to generate pcap output for.
   14.34     *
   14.35     * Generate a pcap file which contains the link-level data observed
   14.36     * by the specified deviceid within the specified nodeid. The pcap
   14.37 -   * data is stored in the file prefix-nodeid-deviceid.pcap.
   14.38 +   * data is stored in the file prefix-nodeid-deviceid.pcap. By
   14.39 +   * default, no PHY layer information is provided. An optional header
   14.40 +   * with PHY layer information, such as the radiotap or the prism
   14.41 +   * header, can be used by invoking SetPcapFormat().
   14.42     *
   14.43     * This method should be invoked after the network topology has 
   14.44     * been fully constructed.
   14.45     */
   14.46 -  static void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid);
   14.47 +  void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid);
   14.48  
   14.49    /**
   14.50     * \param filename filename prefix to use for pcap files.
   14.51 @@ -218,7 +245,7 @@
   14.52     * Enable pcap output on each input device which is of the
   14.53     * ns3::WifiNetDevice type.
   14.54     */
   14.55 -  static void EnablePcap (std::string filename, Ptr<NetDevice> nd);
   14.56 +   void EnablePcap (std::string filename, Ptr<NetDevice> nd);
   14.57  
   14.58    /**
   14.59     * \param filename filename prefix to use for pcap files.
   14.60 @@ -227,7 +254,7 @@
   14.61     * Enable pcap output on each input device which is of the
   14.62     * ns3::WifiNetDevice type.
   14.63     */
   14.64 -  static void EnablePcap (std::string filename, std::string ndName);
   14.65 +   void EnablePcap (std::string filename, std::string ndName);
   14.66  
   14.67    /**
   14.68     * \param filename filename prefix to use for pcap files.
   14.69 @@ -236,7 +263,7 @@
   14.70     * Enable pcap output on each input device which is of the
   14.71     * ns3::WifiNetDevice type.
   14.72     */
   14.73 -  static void EnablePcap (std::string filename, NetDeviceContainer d);
   14.74 +   void EnablePcap (std::string filename, NetDeviceContainer d);
   14.75  
   14.76    /**
   14.77     * \param filename filename prefix to use for pcap files.
   14.78 @@ -246,7 +273,7 @@
   14.79     * ns3::WifiNetDevice type and which is located in one of the 
   14.80     * input nodes.
   14.81     */
   14.82 -  static void EnablePcap (std::string filename, NodeContainer n);
   14.83 +   void EnablePcap (std::string filename, NodeContainer n);
   14.84  
   14.85    /**
   14.86     * \param filename filename prefix to use for pcap files.
   14.87 @@ -254,7 +281,7 @@
   14.88     * Enable pcap output on each device which is of the
   14.89     * ns3::WifiNetDevice type
   14.90     */
   14.91 -  static void EnablePcapAll (std::string filename);
   14.92 +   void EnablePcapAll (std::string filename);
   14.93  
   14.94    /**
   14.95     * \param os output stream
   14.96 @@ -311,6 +338,7 @@
   14.97    ObjectFactory m_phy;
   14.98    ObjectFactory m_errorRateModel;
   14.99    Ptr<YansWifiChannel> m_channel;
  14.100 +  enum PcapFormat m_pcapFormat;
  14.101  };
  14.102  
  14.103  } // namespace ns3