Undo whitespace-only changes, to ease review ptl
authorPeter D. Barnes, Jr. <barnes26@llnl.gov>
Wed, 14 Nov 2012 00:03:41 -0800
branchptl
changeset 9768 bee4f4bf5044
parent 9767 bcde2492d42b
child 9769 44c102578159
Undo whitespace-only changes, to ease review
src/lte/model/lte-radio-bearer-tag.cc
src/lte/model/lte-radio-bearer-tag.h
src/lte/model/lte-rlc-um.cc
src/lte/model/lte-rlc-um.h
src/network/model/byte-tag-list.h
src/network/model/packet-tag-list.h
src/network/model/packet.cc
src/network/model/packet.h
src/network/test/packet-test-suite.cc
--- a/src/network/model/byte-tag-list.h	Tue Nov 13 23:56:26 2012 -0800
+++ b/src/network/model/byte-tag-list.h	Wed Nov 14 00:03:41 2012 -0800
@@ -68,9 +68,10 @@
 class ByteTagList
 {
 public:
+
   class Iterator
   {
-  public:
+public:
     struct Item 
     {
       TypeId tid;
@@ -79,14 +80,14 @@
       int32_t end;
       TagBuffer buf;
       Item (TagBuffer buf);
-    private:
+private:
       friend class ByteTagList;
       friend class ByteTagList::Iterator;
     };
     bool HasNext (void) const;
     struct ByteTagList::Iterator::Item Next (void);
     uint32_t GetOffsetStart (void) const;
-  private:
+private:
     friend class ByteTagList;
     Iterator (uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd);
     void PrepareForNext (void);
@@ -157,7 +158,7 @@
   bool IsDirtyAtStart (int32_t prependOffset);
   ByteTagList::Iterator BeginAll (void) const;
 
-  struct ByteTagListData * Allocate (uint32_t size);
+  struct ByteTagListData *Allocate (uint32_t size);
   void Deallocate (struct ByteTagListData *data);
 
   uint16_t m_used;
--- a/src/network/model/packet-tag-list.h	Tue Nov 13 23:56:26 2012 -0800
+++ b/src/network/model/packet-tag-list.h	Wed Nov 14 00:03:41 2012 -0800
@@ -33,7 +33,6 @@
 
 class Tag;
 
-
 /**
  * \ingroup packet
  *
--- a/src/network/model/packet.cc	Tue Nov 13 23:56:26 2012 -0800
+++ b/src/network/model/packet.cc	Wed Nov 14 00:03:41 2012 -0800
@@ -71,8 +71,8 @@
 {
   ByteTagList::Iterator::Item i = m_current.Next ();
   return ByteTagIterator::Item (i.tid,
-                                i.start - m_current.GetOffsetStart (),
-                                i.end - m_current.GetOffsetStart (),
+                                i.start-m_current.GetOffsetStart (),
+                                i.end-m_current.GetOffsetStart (),
                                 i.buf);
 }
 ByteTagIterator::ByteTagIterator (ByteTagList::Iterator i)
@@ -373,7 +373,7 @@
   uint32_t newStart = m_buffer.GetCurrentStartOffset ();
  
   // Update tag offsets if buffer offsets were changed
-  const_cast<ByteTagList &> (m_byteTagList).AddAtStart (newStart - oldStart, newStart);
+  const_cast<ByteTagList &>(m_byteTagList).AddAtStart (newStart - oldStart, newStart);
   return data;
 }
 
@@ -434,8 +434,7 @@
       PacketMetadata::Item item = i.Next ();
       if (item.isFragment)
         {
-          switch (item.type)
-            {
+          switch (item.type) {
             case PacketMetadata::Item::PAYLOAD:
               os << "Payload";
               break;
@@ -444,13 +443,12 @@
               os << item.tid.GetName ();
               break;
             }
-          os << " Fragment [" << item.currentTrimedFromStart << ":"
+          os << " Fragment [" << item.currentTrimedFromStart<<":"
              << (item.currentTrimedFromStart + item.currentSize) << "]";
         }
       else
         {
-          switch (item.type)
-            {
+          switch (item.type) {
             case PacketMetadata::Item::PAYLOAD:
               os << "Payload (size=" << item.currentSize << ")";
               break;
@@ -489,8 +487,7 @@
       PacketMetadata::Item item = i.Next ();
       if (item.isFragment)
         {
-          switch (item.type)
-            {
+          switch (item.type) {
             case PacketMetadata::Item::PAYLOAD:
               os << "Payload";
               break;
@@ -499,13 +496,12 @@
               os << item.tid.GetName ();
               break;
             }
-          os << " Fragment [" << item.currentTrimedFromStart << ":"
+          os << " Fragment [" << item.currentTrimedFromStart<<":"
              << (item.currentTrimedFromStart + item.currentSize) << "]";
         }
       else
         {
-          switch (item.type)
-            {
+          switch (item.type) {
             case PacketMetadata::Item::PAYLOAD:
               os << "Payload (size=" << item.currentSize << ")";
               break;
@@ -633,7 +629,7 @@
             {
               // increment p by nixSize bytes
               // ensuring 4-byte boundary
-              p += ((nixSize + 3) & (~3)) / 4;
+              p += ((nixSize+3) & (~3)) / 4;
             }
           else
             {
@@ -681,7 +677,7 @@
         {
           // increment p by metaSize bytes
           // ensuring 4-byte boundary
-          p += ((metaSize + 3) & (~3)) / 4;
+          p += ((metaSize+3) & (~3)) / 4;
         }
       else
         {
@@ -710,7 +706,7 @@
         {
           // increment p by bufSize bytes
           // ensuring 4-byte boundary
-          p += ((bufSize + 3) & (~3)) / 4;
+          p += ((bufSize+3) & (~3)) / 4;
         }
       else 
         {
@@ -855,7 +851,6 @@
   bool found = m_packetTagList.Remove (tag);
   return found;
 }
-
 bool
 Packet::ReplacePacketTag (Tag &tag)
 {
--- a/src/network/model/packet.h	Tue Nov 13 23:56:26 2012 -0800
+++ b/src/network/model/packet.h	Wed Nov 14 00:03:41 2012 -0800
@@ -189,11 +189,6 @@
  * qos class id set by an application and processed by a lower-level MAC 
  * layer.
  *
- * - Packet tags must have unique types; repeated tags of a single type
- * (even with different values) can't be attached to a single packet.
- * Packet tags must serialize to a finite maximum size, see
- * PacketTagList::TagData.
- *
  * Implementing a new type of Header or Trailer for a new protocol is 
  * pretty easy and is a matter of creating a subclass of the ns3::Header 
  * or of the ns3::Trailer base class, and implementing the methods
@@ -208,6 +203,7 @@
 class Packet : public SimpleRefCount<Packet>
 {
 public:
+
   /**
    * Create an empty packet with a new uid (as returned
    * by getUid).
@@ -324,7 +320,7 @@
   void AddPaddingAtEnd (uint32_t size);
   /** 
    * Remove size bytes from the end of the current packet
-   * It is safe to remove more bytes than arepresent in
+   * It is safe to remove more bytes than are present in
    * the packet.
    *
    * \param size number of bytes from remove
@@ -350,7 +346,7 @@
    * an explicit copy.
    *
    */
-  uint8_t const * PeekData (void) const NS_DEPRECATED;
+  uint8_t const *PeekData (void) const NS_DEPRECATED;
 
   /**
    * Copy the packet contents to a byte buffer.
@@ -360,9 +356,7 @@
    * \param size the size of the byte buffer. 
    * \returns the number of bytes read from the packet
    *
-   * No more than \b size bytes will be copied by this function,
-   * even if the packet has more content.  Use GetSize"()" to
-   * to find the total size of the buffer needed.
+   * No more than \b size bytes will be copied by this function.
    */
   uint32_t CopyData (uint8_t *buffer, uint32_t size) const;
 
@@ -379,7 +373,7 @@
   /**
    * \returns a COW copy of the packet.
    *
-   * The returned packet will behave like an independent copy of
+   * The returns packet will behave like an independent copy of
    * the original packet, even though they both share the
    * same datasets internally.
    */
--- a/src/network/test/packet-test-suite.cc	Tue Nov 13 23:56:26 2012 -0800
+++ b/src/network/test/packet-test-suite.cc	Wed Nov 14 00:03:41 2012 -0800
@@ -24,6 +24,7 @@
 #include <string>
 #include <cstdarg>
 #include <iostream>
+#include <iomanip>
 #include <ctime>
 
 using namespace ns3;
@@ -457,12 +458,17 @@
   virtual ~PacketTagListTest ();
 private:
   void DoRun (void);
-  void CheckRef (PacketTagList & ref, ATestTagBase & t,
-                 const char * msg, bool miss = false);
-  void CheckRefList (PacketTagList & ref, const char * msg, int miss = 0);
-  int RemoveTime (const PacketTagList & ref, ATestTagBase & t,
-                   const char * msg);
-  int AddRemoveTime ();
+  void CheckRef (const PacketTagList & ref,
+                 ATestTagBase & t,
+                 const char * msg,
+                 bool miss = false);
+  void CheckRefList (const PacketTagList & ref,
+                     const char * msg,
+                     int miss = 0);
+  int RemoveTime (const PacketTagList & ref,
+                  ATestTagBase & t,
+                  const char * msg = 0);
+  int AddRemoveTime (const bool verbose = false);
 };
 
 PacketTagListTest::PacketTagListTest ()
@@ -475,8 +481,10 @@
 }
 
 void
-PacketTagListTest::CheckRef (PacketTagList & ref, ATestTagBase & t,
-                             const char * msg, bool miss)
+PacketTagListTest::CheckRef (const PacketTagList & ref,
+                             ATestTagBase & t,
+                             const char * msg,
+                             bool miss)
 {
   int expect = t.GetData ();  // the value we should find
   bool found = ref.Peek (t); // rewrites t with actual value
@@ -491,7 +499,7 @@
 }
 
   // A set of tags with data value 1, to check COW
-#define MAKE_REF_TAGS \
+#define MAKE_TEST_TAGS \
   ATestTag<1> t1 (1); \
   ATestTag<2> t2 (1); \
   ATestTag<3> t3 (1); \
@@ -501,23 +509,24 @@
   ATestTag<7> t7 (1)
   
 void
-PacketTagListTest::CheckRefList (PacketTagList & ref,
+PacketTagListTest::CheckRefList (const PacketTagList & ptl,
                                  const char * msg,
                                  int miss /* = 0 */)
 {
-  MAKE_REF_TAGS ;
-  CheckRef (ref, t1, msg, miss == 1);
-  CheckRef (ref, t2, msg, miss == 2);
-  CheckRef (ref, t3, msg, miss == 3);
-  CheckRef (ref, t4, msg, miss == 4);
-  CheckRef (ref, t5, msg, miss == 5);
-  CheckRef (ref, t6, msg, miss == 6);
-  CheckRef (ref, t7, msg, miss == 7);
+  MAKE_TEST_TAGS ;
+  CheckRef (ptl, t1, msg, miss == 1);
+  CheckRef (ptl, t2, msg, miss == 2);
+  CheckRef (ptl, t3, msg, miss == 3);
+  CheckRef (ptl, t4, msg, miss == 4);
+  CheckRef (ptl, t5, msg, miss == 5);
+  CheckRef (ptl, t6, msg, miss == 6);
+  CheckRef (ptl, t7, msg, miss == 7);
 }
   
 int
-PacketTagListTest::RemoveTime (const PacketTagList & ref, ATestTagBase & t,
-                               const char * msg)
+PacketTagListTest::RemoveTime (const PacketTagList & ref,
+                               ATestTagBase & t,
+                               const char * msg /* = 0 */)
 {
   const int reps = 10000;
   std::vector< PacketTagList > ptv(reps, ref);
@@ -527,37 +536,21 @@
   }
   int stop = clock ();
   int delta = stop - start;
-  std::cout << GetName () << "remove time: " << msg << ": "
-            << delta << " ticks"
+  if (msg) {
+    std::cout << GetName () << "remove time: " << msg << ": " << std::setw (8)
+              << delta      << " ticks to remove "
+              << reps       << " times"
             << std::endl;
+  }
   return delta;
 }
 
 int
-PacketTagListTest::AddRemoveTime ()
+PacketTagListTest::AddRemoveTime (const bool verbose /* = false */)
 {
-  /*  old free list priming
-  const int nfree = 1000 - 10;
-
-  // get some stuff on the free list
-  std::cout << GetName () << "free list: initial: "
-            << PacketTagList::GetNFree ();
-  std::vector< PacketTagList > ptv;
-  for (int i = 0; i < nfree; ++i) {
-    PacketTagList p;
-    p.Add (ATestTag <1> (i));
-    ptv.push_back (p);
-  }
-  ptv.clear ();
-  std::cout << ", now: " 
-            << PacketTagList::GetNFree ()
-            << std::endl;
-  */
-
-  // timing
   const int reps = 100000;
   PacketTagList ptl;
-  ATestTag <2> t;
+  ATestTag <2> t(2);
   int start = clock ();
   for (int i = 0; i < reps; ++i) {
     ptl.Add (t);
@@ -565,9 +558,12 @@
   }
   int stop = clock ();
   int delta = stop - start;
-  std::cout << GetName () << "freelist time: "
-            << delta << " ticks"
+  if (verbose) {
+    std::cout << GetName () << "add/remove time: " << std::setw (8)
+              << delta      << " ticks to add+remove "
+              << reps       << " times"
             << std::endl;
+  }
   return delta;
 }
 
@@ -576,7 +572,7 @@
 {
   std::cout << GetName () << "begin" << std::endl;
 
-  MAKE_REF_TAGS ;
+  MAKE_TEST_TAGS ;
   
   PacketTagList ref;  // empty list
   ref.Add (t1);       // last
@@ -587,85 +583,129 @@
   ref.Add (t6);       // pre-merge
   ref.Add (t7);       // first
   
-  std::cout << GetName () << "missing tag" << std::endl;;
-  ATestTag<10> t10;
-  NS_TEST_EXPECT_MSG_EQ (ref.Peek (t10), false, "missing tag");
-
-  std::cout << GetName () << "copy and assignment" << std::endl;
-  { PacketTagList ptl (ref);
-    CheckRefList (ref, "copy ctor orig");
-    CheckRefList (ptl, "copy ctor copy");
-  }
-  { PacketTagList ptl = ref;
-    CheckRefList (ref, "assignment orig");
-    CheckRefList (ptl, "assignment copy");
-  }
-  
-  std::cout << GetName () << "remove" << std::endl;
-#define RemoveCheck(n)                                  \
-  { PacketTagList p ## n = ref;                         \
-    p ## n .Remove ( t ## n );                          \
-    CheckRefList (ref,     "remove " #n " orig");      \
-    CheckRefList (p ## n, "remove " #n " copy", n);   \
-  }
-  
-  RemoveCheck (1);
-  RemoveCheck (2);
-  RemoveCheck (3);
-  RemoveCheck (4);
-  RemoveCheck (5);
-  RemoveCheck (6);
-  RemoveCheck (7);
-
-  std::cout << GetName () << "replace" << std::endl;
-#define ReplaceCheck(n)                                         \
-  t ## n .m_data = 2;                                           \
-  { PacketTagList p ## n = ref;                                 \
-    p ## n .Replace ( t ## n );                                 \
-    CheckRefList (ref,     "replace " #n " orig");             \
-    CheckRef     (p ## n, t ## n, "replace " #n " copy");      \
+  { // Peek
+    std::cout << GetName () << "check Peek (missing tag) returns false"
+              << std::endl;;
+    ATestTag<10> t10;
+    NS_TEST_EXPECT_MSG_EQ (ref.Peek (t10), false, "missing tag");
   }
 
-  ReplaceCheck (1);
-  ReplaceCheck (2);
-  ReplaceCheck (3);
-  ReplaceCheck (4);
-  ReplaceCheck (5);
-  ReplaceCheck (6);
-  ReplaceCheck (7);
-
-  std::cout << GetName () << "freelist timing" << std::endl;
-  int flm = std::numeric_limits<int>::max ();
-  for (int i = 0; i < 100; ++i) {
-    int now = AddRemoveTime ();
-    if (now < flm) flm = now;
-  }
-  std::cout << GetName () << "min freelist time: "
-            << flm << " ticks" << std::endl;
-  
-  std::cout << GetName () << "remove timing" << std::endl;
-  std::vector <int> rmn (7, std::numeric_limits<int>::max ());
-  for (int i = 0; i < 100; ++i) {
-    for (int j = 1; j < 8; ++j) {
-      int now = 0;
-      switch (j) {
-        case 7:  now = RemoveTime (ref, t7, "t7");  break;
-        case 6:  now = RemoveTime (ref, t6, "t6");  break;
-        case 5:  now = RemoveTime (ref, t5, "t5");  break;
-        case 4:  now = RemoveTime (ref, t4, "t4");  break;
-        case 3:  now = RemoveTime (ref, t3, "t3");  break;
-        case 2:  now = RemoveTime (ref, t2, "t2");  break;
-        case 1:  now = RemoveTime (ref, t1, "t1");  break;
-      }  // switch
-
-      if (now < rmn[j]) rmn[j] = now;
-    } // for tag j
-  } // for iteration i
-  for (int j = 7; j > 0; --j) {
-    std::cout << GetName () << "min remove time: t"
-              << j << ": " << rmn[j] << std::endl;
+  { // Copy ctor, assignment
+    std::cout << GetName () << "check copy and assignment" << std::endl;
+    { PacketTagList ptl (ref);
+      CheckRefList (ref, "copy ctor orig");
+      CheckRefList (ptl, "copy ctor copy");
+    }
+    { PacketTagList ptl = ref;
+      CheckRefList (ref, "assignment orig");
+      CheckRefList (ptl, "assignment copy");
+    }
   }
   
+  { // Removal
+#   define RemoveCheck(n)                               \
+    { PacketTagList p ## n = ref;			\
+      p ## n .Remove ( t ## n );			\
+      CheckRefList (ref,     "remove " #n " orig");	\
+      CheckRefList (p ## n, "remove " #n " copy", n);   \
+    }
+    
+    { // Remove single tags from list
+      std::cout << GetName () << "check removal of each tag" << std::endl;
+      RemoveCheck (1);
+      RemoveCheck (2);
+      RemoveCheck (3);
+      RemoveCheck (4);
+      RemoveCheck (5);
+      RemoveCheck (6);
+      RemoveCheck (7);
+    }
+    
+    { // Remove in the presence of a merge
+      std::cout << GetName () << "check removal doesn't disturb merge "
+                << std::endl;
+      PacketTagList ptl = ref;
+      ptl.Remove (t7);
+      ptl.Remove (t6);
+      ptl.Remove (t5);
+      
+      PacketTagList mrg = ptl;  // merged list
+      ATestTag<8> m5 (1);
+      mrg.Add (m5);             // ptl and mrg differ
+      ptl.Add (t5);
+      ptl.Add (t6);
+      ptl.Add (t7);
+
+      CheckRefList (ref, "post merge, orig");
+      CheckRefList (ptl, "post merge, long chain");
+      const char * msg = "post merge, short chain";
+      CheckRef (mrg, t1, msg, false);
+      CheckRef (mrg, t2, msg, false);
+      CheckRef (mrg, t3, msg, false);
+      CheckRef (mrg, t4, msg, false);
+      CheckRef (mrg, m5, msg, false);
+    }
+#   undef RemoveCheck
+  }  // Removal
+
+  { // Replace
+
+    std::cout << GetName () << "check replacing each tag" << std::endl;
+      
+#   define ReplaceCheck(n)					\
+    t ## n .m_data = 2;						\
+    { PacketTagList p ## n = ref;				\
+      p ## n .Replace ( t ## n );				\
+      CheckRefList (ref,     "replace " #n " orig");		\
+      CheckRef     (p ## n, t ## n, "replace " #n " copy");	\
+    }
+    
+    ReplaceCheck (1);
+    ReplaceCheck (2);
+    ReplaceCheck (3);
+    ReplaceCheck (4);
+    ReplaceCheck (5);
+    ReplaceCheck (6);
+    ReplaceCheck (7);
+  }
+  
+  { // Timing
+    std::cout << GetName () << "add+remove timing" << std::endl;
+    int flm = std::numeric_limits<int>::max ();
+    for (int i = 0; i < 100; ++i) {
+      int now = AddRemoveTime ();
+      if (now < flm) flm = now;
+    }
+    std::cout << GetName () << "min add+remove time: "
+              << std::setw (8) << flm        << " ticks"
+              << std::endl;
+    
+    std::cout << GetName () << "remove timing" << std::endl;
+    std::vector <int> rmn (7, std::numeric_limits<int>::max ());
+    for (int i = 0; i < 100; ++i) {
+      for (int j = 1; j < 8; ++j) {
+	int now = 0;
+	switch (j) {
+        case 7:  now = RemoveTime (ref, t7);  break;
+        case 6:  now = RemoveTime (ref, t6);  break;
+        case 5:  now = RemoveTime (ref, t5);  break;
+        case 4:  now = RemoveTime (ref, t4);  break;
+        case 3:  now = RemoveTime (ref, t3);  break;
+        case 2:  now = RemoveTime (ref, t2);  break;
+        case 1:  now = RemoveTime (ref, t1);  break;
+	}  // switch
+	
+	if (now < rmn[j]) rmn[j] = now;
+      } // for tag j
+    } // for iteration i
+    for (int j = 7; j > 0; --j) {
+      std::cout << GetName () << "min remove time: t"
+		<< j          << ": "
+		<< std::setw (8) << rmn[j]     << " ticks"
+                << std::endl;
+    }
+  }  // Timing
+    
 }
 
 //-----------------------------------------------------------------------------