View | Details | Raw Unified | Return to bug 279
Collapse All | Expand All

(-)a/examples/mixed-wireless.cc (-2 lines)
 Lines 116-123   main (int argc, char *argv[]) Link Here 
116
  //
116
  //
117
  cmd.Parse (argc, argv);
117
  cmd.Parse (argc, argv);
118
118
119
  // The metadata system (off by default) is used by ascii tracing below
120
  Packet::EnableMetadata ();
121
119
122
  /////////////////////////////////////////////////////////////////////////// 
120
  /////////////////////////////////////////////////////////////////////////// 
123
  //                                                                       //
121
  //                                                                       //
(-)a/examples/wifi-ap.cc (-1 / +1 lines)
 Lines 110-116   AdvancePosition (Ptr<Node> node) Link Here 
110
110
111
int main (int argc, char *argv[])
111
int main (int argc, char *argv[])
112
{
112
{
113
  Packet::EnableMetadata ();
113
  Packet::EnablePrinting ();
114
114
115
  // enable rts cts all the time.
115
  // enable rts cts all the time.
116
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0"));
116
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0"));
(-)a/src/common/packet-metadata.cc (-4 / +28 lines)
 Lines 32-37   namespace ns3 { Link Here 
32
namespace ns3 {
32
namespace ns3 {
33
33
34
bool PacketMetadata::m_enable = false;
34
bool PacketMetadata::m_enable = false;
35
bool PacketMetadata::m_enableChecking = false;
35
bool PacketMetadata::m_metadataSkipped = false;
36
bool PacketMetadata::m_metadataSkipped = false;
36
uint32_t PacketMetadata::m_maxSize = 0;
37
uint32_t PacketMetadata::m_maxSize = 0;
37
uint16_t PacketMetadata::m_chunkUid = 0;
38
uint16_t PacketMetadata::m_chunkUid = 0;
 Lines 57-62   PacketMetadata::Enable (void) Link Here 
57
                 "to call ns3::PacketMetadata::Enable () near the beginning of"
58
                 "to call ns3::PacketMetadata::Enable () near the beginning of"
58
                 " the program, before any packets are sent.");
59
                 " the program, before any packets are sent.");
59
  m_enable = true;
60
  m_enable = true;
61
}
62
63
void 
64
PacketMetadata::EnableChecking (void)
65
{
66
  Enable ();
67
  m_enableChecking = true;
60
}
68
}
61
69
62
void
70
void
 Lines 630-642   PacketMetadata::RemoveHeader (const Head Link Here 
630
  if ((item.typeUid & 0xfffffffe) != uid ||
638
  if ((item.typeUid & 0xfffffffe) != uid ||
631
      item.size != size)
639
      item.size != size)
632
    {
640
    {
633
      NS_FATAL_ERROR ("Removing unexpected header.");
641
      if (m_enableChecking)
642
        {
643
          NS_FATAL_ERROR ("Removing unexpected header.");
644
        }
645
      return;
634
    }
646
    }
635
  else if (item.typeUid != uid &&
647
  else if (item.typeUid != uid &&
636
           (extraItem.fragmentStart != 0 ||
648
           (extraItem.fragmentStart != 0 ||
637
            extraItem.fragmentEnd != size))
649
            extraItem.fragmentEnd != size))
638
    {
650
    {
639
      NS_FATAL_ERROR ("Removing incomplete header.");
651
      if (m_enableChecking)
652
        {
653
          NS_FATAL_ERROR ("Removing incomplete header.");
654
        }
655
      return;
640
    }
656
    }
641
  if (m_head + read == m_used)
657
  if (m_head + read == m_used)
642
    {
658
    {
 Lines 688-700   PacketMetadata::RemoveTrailer (const Tra Link Here 
688
  if ((item.typeUid & 0xfffffffe) != uid ||
704
  if ((item.typeUid & 0xfffffffe) != uid ||
689
      item.size != size)
705
      item.size != size)
690
    {
706
    {
691
      NS_FATAL_ERROR ("Removing unexpected trailer.");
707
      if (m_enableChecking)
708
        {
709
          NS_FATAL_ERROR ("Removing unexpected trailer.");
710
        }
711
      return;
692
    }
712
    }
693
  else if (item.typeUid != uid &&
713
  else if (item.typeUid != uid &&
694
           (extraItem.fragmentStart != 0 ||
714
           (extraItem.fragmentStart != 0 ||
695
            extraItem.fragmentEnd != size))
715
            extraItem.fragmentEnd != size))
696
    {
716
    {
697
      NS_FATAL_ERROR ("Removing incomplete trailer.");
717
      if (m_enableChecking)
718
        {
719
          NS_FATAL_ERROR ("Removing incomplete trailer.");
720
        }
721
      return;
698
    }
722
    }
699
  if (m_tail + read == m_used)
723
  if (m_tail + read == m_used)
700
    {
724
    {
(-)a/src/common/packet-metadata.h (+2 lines)
 Lines 125-130   public: Link Here 
125
  };
125
  };
126
126
127
  static void Enable (void);
127
  static void Enable (void);
128
  static void EnableChecking (void);
128
129
129
  inline PacketMetadata (uint32_t uid, uint32_t size);
130
  inline PacketMetadata (uint32_t uid, uint32_t size);
130
  inline PacketMetadata (PacketMetadata const &o);
131
  inline PacketMetadata (PacketMetadata const &o);
 Lines 279-284   private: Link Here 
279
  
280
  
280
  static DataFreeList m_freeList;
281
  static DataFreeList m_freeList;
281
  static bool m_enable;
282
  static bool m_enable;
283
  static bool m_enableChecking;
282
284
283
  // set to true when adding metadata to a packet is skipped because
285
  // set to true when adding metadata to a packet is skipped because
284
  // m_enable is false; used to detect enabling of metadata in the
286
  // m_enable is false; used to detect enabling of metadata in the
(-)a/src/common/packet.cc (+14 lines)
 Lines 459-465   Packet::EnableMetadata (void) Link Here 
459
Packet::EnableMetadata (void)
459
Packet::EnableMetadata (void)
460
{
460
{
461
  NS_LOG_FUNCTION_NOARGS ();
461
  NS_LOG_FUNCTION_NOARGS ();
462
  EnableChecking ();
463
}
464
465
void
466
Packet::EnablePrinting (void)
467
{
468
  NS_LOG_FUNCTION_NOARGS ();
462
  PacketMetadata::Enable ();
469
  PacketMetadata::Enable ();
470
}
471
472
void
473
Packet::EnableChecking (void)
474
{
475
  NS_LOG_FUNCTION_NOARGS ();
476
  PacketMetadata::EnableChecking ();
463
}
477
}
464
478
465
Buffer 
479
Buffer 
(-)a/src/common/packet.h (-2 / +7 lines)
 Lines 30-35    Link Here 
30
#include "ns3/callback.h"
30
#include "ns3/callback.h"
31
#include "ns3/assert.h"
31
#include "ns3/assert.h"
32
#include "ns3/ptr.h"
32
#include "ns3/ptr.h"
33
#include "ns3/deprecated.h"
33
34
34
namespace ns3 {
35
namespace ns3 {
35
36
 Lines 310-322   public: Link Here 
310
311
311
  PacketMetadata::ItemIterator BeginItem (void) const;
312
  PacketMetadata::ItemIterator BeginItem (void) const;
312
313
314
  static void EnableMetadata (void) NS_DEPRECATED;
315
313
  /**
316
  /**
314
   * By default, packets do not keep around enough metadata to
317
   * By default, packets do not keep around enough metadata to
315
   * perform the operations requested by the Print methods. If you
318
   * perform the operations requested by the Print methods. If you
316
   * want to be able to invoke any of the two ::Print methods, 
319
   * want to be able to invoke any of the two ::Print methods, 
317
   * you need to invoke this method at least once during the 
320
   * you need to invoke this method at least once during the 
318
   * simulation setup and before any packet is created.
321
   * simulation setup and before any packet is created.
319
   *
322
   */
323
  static void EnablePrinting (void);
324
  /**
320
   * The packet metadata is also used to perform extensive
325
   * The packet metadata is also used to perform extensive
321
   * sanity checks at runtime when performing operations on a 
326
   * sanity checks at runtime when performing operations on a 
322
   * Packet. For example, this metadata is used to verify that
327
   * Packet. For example, this metadata is used to verify that
 Lines 324-330   public: Link Here 
324
   * was actually present at the front of the packet. These
329
   * was actually present at the front of the packet. These
325
   * errors will be detected and will abort the program.
330
   * errors will be detected and will abort the program.
326
   */
331
   */
327
  static void EnableMetadata (void);
332
  static void EnableChecking (void);
328
333
329
  /**
334
  /**
330
   * \returns a byte buffer
335
   * \returns a byte buffer
(-)a/src/helper/csma-helper.cc (-1 / +1 lines)
 Lines 122-128   void Link Here 
122
void 
122
void 
123
CsmaHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
123
CsmaHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
124
{
124
{
125
  Packet::EnableMetadata ();
125
  Packet::EnablePrinting ();
126
  std::ostringstream oss;
126
  std::ostringstream oss;
127
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/Rx";
127
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/Rx";
128
  Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiRxEvent, &os));
128
  Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiRxEvent, &os));
(-)a/src/helper/point-to-point-helper.cc (-1 / +1 lines)
 Lines 122-128   void Link Here 
122
void 
122
void 
123
PointToPointHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
123
PointToPointHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
124
{
124
{
125
  Packet::EnableMetadata ();
125
  Packet::EnablePrinting ();
126
  std::ostringstream oss;
126
  std::ostringstream oss;
127
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/Rx";
127
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/Rx";
128
  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiRxEvent, &os));
128
  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiRxEvent, &os));
(-)a/src/helper/wifi-helper.cc (-1 / +1 lines)
 Lines 193-199   void Link Here 
193
void 
193
void 
194
WifiHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
194
WifiHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
195
{
195
{
196
    Packet::EnableMetadata ();
196
  Packet::EnablePrinting ();
197
  std::ostringstream oss;
197
  std::ostringstream oss;
198
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/RxOk";
198
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/RxOk";
199
  Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os));
199
  Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os));
(-)a/utils/bench-packets.cc (-1 / +1 lines)
 Lines 282-288   int main (int argc, char *argv[]) Link Here 
282
  runBench (&benchC, n, "c");
282
  runBench (&benchC, n, "c");
283
  runBench (&benchD, n, "d");
283
  runBench (&benchD, n, "d");
284
284
285
  Packet::EnableMetadata ();
285
  Packet::EnablePrinting ();
286
  runBench (&benchA, n, "meta-a");
286
  runBench (&benchA, n, "meta-a");
287
  runBench (&benchB, n, "meta-b");
287
  runBench (&benchB, n, "meta-b");
288
  runBench (&benchC, n, "meta-c");
288
  runBench (&benchC, n, "meta-c");

Return to bug 279