Adding PacketBB (RFC 5444) library, along with test.
authorTom Wambold <tom5760@gmail.com>
Thu, 13 Aug 2009 23:30:03 -0400
changeset 4775 5b3efd4b3884
parent 4716 055af17f7225
child 4776 6ef853626f2a
Adding PacketBB (RFC 5444) library, along with test.
src/contrib/packetbb.cc
src/contrib/packetbb.h
src/contrib/test-packetbb.cc
src/contrib/wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/contrib/packetbb.cc	Thu Aug 13 23:30:03 2009 -0400
@@ -0,0 +1,2676 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* vim: set noai ts=2 sw=2 expandtab: */
+/* 
+ * Copyright (c) 2009 Drexel University
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ * Author: Tom Wambold <tom5760@gmail.com>
+ */
+/* TODO:
+ * - Check style
+ * - Check copy constructors
+ */
+
+#include "ns3/ipv4-address.h"
+#include "ns3/ipv6-address.h"
+
+#include "packetbb.h"
+
+static const uint8_t VERSION = 0;
+/* Packet flags */
+static const uint8_t PHAS_SEQ_NUM = 0x8;
+static const uint8_t PHAS_TLV = 0x4;
+
+/* Message flags */
+static const uint8_t MHAS_ORIG = 0x80;
+static const uint8_t MHAS_HOP_LIMIT = 0x40;
+static const uint8_t MHAS_HOP_COUNT = 0x20;
+static const uint8_t MHAS_SEQ_NUM = 0x10;
+
+/* Address block flags */
+static const uint8_t AHAS_HEAD = 0x80;
+static const uint8_t AHAS_FULL_TAIL = 0x40;
+static const uint8_t AHAS_ZERO_TAIL = 0x20;
+static const uint8_t AHAS_SINGLE_PRE_LEN = 0x10;
+static const uint8_t AHAS_MULTI_PRE_LEN = 0x08;
+
+/* TLV Flags */
+static const uint8_t THAS_TYPE_EXT = 0x80;
+static const uint8_t THAS_SINGLE_INDEX = 0x40;
+static const uint8_t THAS_MULTI_INDEX = 0x20;
+static const uint8_t THAS_VALUE = 0x10;
+static const uint8_t THAS_EXT_LEN = 0x08;
+static const uint8_t TIS_MULTIVALUE = 0x04;
+
+namespace ns3 {
+
+namespace pbb {
+
+NS_OBJECT_ENSURE_REGISTERED (PacketBB);
+
+TlvBlock::Iterator
+TlvBlock::Begin (void)
+{
+  return m_tlvList.begin ();
+}
+
+TlvBlock::ConstIterator
+TlvBlock::Begin (void) const
+{
+  return m_tlvList.begin ();
+}
+
+TlvBlock::Iterator
+TlvBlock::End (void)
+{
+  return m_tlvList.end ();
+}
+
+TlvBlock::ConstIterator
+TlvBlock::End (void) const
+{
+  return m_tlvList.end ();
+}
+
+int
+TlvBlock::Size (void) const
+{
+  return m_tlvList.size ();
+}
+
+bool
+TlvBlock::Empty (void) const
+{
+  return m_tlvList.empty ();
+}
+
+Ptr<Tlv>
+TlvBlock::Front (void) const
+{
+  return m_tlvList.front ();
+}
+
+Ptr<Tlv>
+TlvBlock::Back (void) const
+{
+  return m_tlvList.back ();
+}
+
+void
+TlvBlock::PushFront (Ptr<Tlv> tlv)
+{
+  //Ptr<Tlv> * newptr = new Ptr<Tlv> (GetPointer<Tlv> (tlv));
+  m_tlvList.push_front (tlv);
+}
+
+void
+TlvBlock::PopFront (void)
+{
+  m_tlvList.pop_front ();
+}
+
+void
+TlvBlock::PushBack (Ptr<Tlv> tlv)
+{
+  //Ptr<Tlv> * newptr = new Ptr<Tlv> (GetPointer<Tlv> (tlv));
+  m_tlvList.push_back (tlv);
+}
+
+void
+TlvBlock::PopBack (void)
+{
+  m_tlvList.pop_back ();
+}
+
+TlvBlock::Iterator
+TlvBlock::Insert (TlvBlock::Iterator position, const Ptr<Tlv> tlv)
+{
+  return m_tlvList.insert (position, tlv);
+}
+
+TlvBlock::Iterator
+TlvBlock::Erase (TlvBlock::Iterator position)
+{
+  return m_tlvList.erase (position);
+}
+
+TlvBlock::Iterator
+TlvBlock::Erase (TlvBlock::Iterator first, TlvBlock::Iterator last)
+{
+  return m_tlvList.erase (first, last);
+}
+
+void
+TlvBlock::Clear (void)
+{
+  m_tlvList.clear ();
+}
+
+uint32_t
+TlvBlock::GetSerializedSize (void) const
+{
+  /* tlv size */
+  uint32_t size = 2;
+  for (ConstIterator iter = Begin (); iter != End (); iter++)
+  {
+    size += (*iter)->GetSerializedSize ();
+  }
+  return size;
+}
+
+void
+TlvBlock::Serialize (Buffer::Iterator &start) const
+{
+  if (Empty ())
+  {
+    start.WriteHtonU16 (0);
+    return;
+  }
+
+  /* We need to write the size of the TLV block in front, so save its
+   * position. */
+  Buffer::Iterator tlvsize = start;
+  start.Next (2);
+  for (ConstIterator iter = Begin (); iter != End (); iter++)
+  {
+    (*iter)->Serialize (start);
+  }
+  /* - 2 to not include the size field */
+  uint16_t size = start.GetDistanceFrom (tlvsize) - 2;
+  tlvsize.WriteHtonU16 (size);
+}
+
+void
+TlvBlock::Deserialize (Buffer::Iterator &start)
+{
+  uint16_t size = start.ReadNtohU16 ();
+
+  Buffer::Iterator tlvstart = start;
+  if (size > 0)
+  {
+    while (start.GetDistanceFrom (tlvstart) < size)
+    {
+      Ptr<Tlv> newtlv = Create<Tlv> ();
+      //Tlv * newtlv = new Tlv ();
+      newtlv->Deserialize (start);
+
+      //Ptr<Tlv> * newptr = new Ptr<Tlv> (newtlv);
+      PushBack (newtlv);
+    }
+  }
+}
+
+void
+TlvBlock::Print (std::ostream &os) const
+{
+  Print (os, 0);
+}
+
+void
+TlvBlock::Print (std::ostream &os, int level) const
+{
+  std::string prefix = "";
+  for (int i = 0; i < level; i++)
+    prefix.append("\t");
+
+  os << prefix << "TLV Block {" << std::endl;
+  os << prefix << "\tsize = " << Size () << std::endl;
+  os << prefix << "\tmembers [" << std::endl;
+  for (ConstIterator iter = Begin (); iter != End (); iter++)
+  {
+    (*iter)->Print (os, level+2);
+  }
+  os << prefix << "\t]" << std::endl;
+  os << prefix << "}" << std::endl;
+}
+
+bool
+TlvBlock::operator== (const TlvBlock &other) const
+{
+  if (Size () != other.Size ())
+    return false;
+
+  ConstIterator ti, oi;
+  for (ti = Begin (), oi = other.Begin ();
+      ti != End () && oi != other.End ();
+      ti++, oi++)
+  {
+    if (**ti != **oi)
+      return false;
+  }
+  return true;
+}
+
+bool
+TlvBlock::operator!= (const TlvBlock &other) const
+{
+  return !(*this == other);
+}
+
+/* End TlvBlock class */
+
+AddressTlvBlock::Iterator
+AddressTlvBlock::Begin (void)
+{
+  return m_tlvList.begin ();
+}
+
+AddressTlvBlock::ConstIterator
+AddressTlvBlock::Begin (void) const
+{
+  return m_tlvList.begin ();
+}
+
+AddressTlvBlock::Iterator
+AddressTlvBlock::End (void)
+{
+  return m_tlvList.end ();
+}
+
+AddressTlvBlock::ConstIterator
+AddressTlvBlock::End (void) const
+{
+  return m_tlvList.end ();
+}
+
+int
+AddressTlvBlock::Size (void) const
+{
+  return m_tlvList.size ();
+}
+
+bool
+AddressTlvBlock::Empty (void) const
+{
+  return m_tlvList.empty ();
+}
+
+Ptr<AddressTlv>
+AddressTlvBlock::Front (void) const
+{
+  return m_tlvList.front ();
+}
+
+Ptr<AddressTlv>
+AddressTlvBlock::Back (void) const
+{
+  return m_tlvList.back ();
+}
+
+void
+AddressTlvBlock::PushFront (Ptr<AddressTlv> tlv)
+{
+  m_tlvList.push_front (tlv);
+}
+
+void
+AddressTlvBlock::PopFront (void)
+{
+  m_tlvList.pop_front ();
+}
+
+void
+AddressTlvBlock::PushBack (Ptr<AddressTlv> tlv)
+{
+  m_tlvList.push_back (tlv);
+}
+
+void
+AddressTlvBlock::PopBack (void)
+{
+  m_tlvList.pop_back ();
+}
+
+AddressTlvBlock::Iterator
+AddressTlvBlock::Insert (AddressTlvBlock::Iterator position, const Ptr<AddressTlv> tlv)
+{
+  return m_tlvList.insert (position, tlv);
+}
+
+AddressTlvBlock::Iterator
+AddressTlvBlock::Erase (AddressTlvBlock::Iterator position)
+{
+  return m_tlvList.erase (position);
+}
+
+AddressTlvBlock::Iterator
+AddressTlvBlock::Erase (AddressTlvBlock::Iterator first, AddressTlvBlock::Iterator last)
+{
+  return m_tlvList.erase (first, last);
+}
+
+void
+AddressTlvBlock::Clear (void)
+{
+  m_tlvList.clear ();
+}
+
+uint32_t
+AddressTlvBlock::GetSerializedSize (void) const
+{
+  /* tlv size */
+  uint32_t size = 2;
+  for (ConstIterator iter = Begin (); iter != End (); iter++)
+  {
+    size += (*iter)->GetSerializedSize ();
+  }
+  return size;
+}
+
+void
+AddressTlvBlock::Serialize (Buffer::Iterator &start) const
+{
+  if (Empty ())
+  {
+    start.WriteHtonU16 (0);
+    return;
+  }
+
+  /* We need to write the size of the TLV block in front, so save its
+   * position. */
+  Buffer::Iterator tlvsize = start;
+  start.Next (2);
+  for (ConstIterator iter = Begin (); iter != End (); iter++)
+  {
+    (*iter)->Serialize (start);
+  }
+  /* - 2 to not include the size field */
+  uint16_t size = start.GetDistanceFrom (tlvsize) - 2;
+  tlvsize.WriteHtonU16 (size);
+}
+
+void
+AddressTlvBlock::Deserialize (Buffer::Iterator &start)
+{
+  uint16_t size = start.ReadNtohU16 ();
+
+  Buffer::Iterator tlvstart = start;
+  if (size > 0)
+  {
+    while (start.GetDistanceFrom (tlvstart) < size)
+    {
+      Ptr<AddressTlv> newtlv = Create<AddressTlv> ();
+      //AddressTlv * newtlv = new AddressTlv ();
+      newtlv->Deserialize (start);
+
+      //Ptr<AddressTlv> * newptr = new Ptr<AddressTlv> (newtlv);
+      PushBack (newtlv);
+    }
+  }
+}
+
+void
+AddressTlvBlock::Print (std::ostream &os) const
+{
+  Print (os, 0);
+}
+
+void
+AddressTlvBlock::Print (std::ostream &os, int level) const
+{
+  std::string prefix = "";
+  for (int i = 0; i < level; i++)
+    prefix.append("\t");
+
+  os << prefix << "TLV Block {" << std::endl;
+  os << prefix << "\tsize = " << Size () << std::endl;
+  os << prefix << "\tmembers [" << std::endl;
+  for (ConstIterator iter = Begin (); iter != End (); iter++)
+  {
+    (*iter)->Print (os, level+2);
+  }
+  os << prefix << "\t]" << std::endl;
+  os << prefix << "}" << std::endl;
+}
+
+bool
+AddressTlvBlock::operator== (const AddressTlvBlock &other) const
+{
+  if (Size () != other.Size ())
+    return false;
+
+  ConstIterator it, ot;
+  for (it = Begin (), ot = other.Begin ();
+      it != End () && ot != other.End ();
+      it++, ot++)
+  {
+    if (**it != **ot)
+      return false;
+  }
+  return true;
+}
+
+bool
+AddressTlvBlock::operator!= (const AddressTlvBlock &other) const
+{
+  return !(*this == other);
+}
+
+
+/* End AddressTlvBlock Class */
+
+PacketBB::PacketBB (void)
+{
+  m_refCount = 1;
+  m_version = VERSION;
+  m_hasseqnum = false;
+}
+
+uint8_t
+PacketBB::GetVersion (void) const
+{
+  return m_version;
+}
+
+void
+PacketBB::SetSequenceNumber (uint16_t number)
+{
+  m_seqnum = number;
+  m_hasseqnum = true;
+}
+
+uint16_t
+PacketBB::GetSequenceNumber (void) const throw (PacketBBError)
+{
+  if (!HasSequenceNumber ())
+  {
+    throw PacketBBError ("Packet has no sequence number.");
+  }
+  return m_seqnum;
+}
+
+bool
+PacketBB::HasSequenceNumber (void) const
+{
+  return m_hasseqnum;
+}
+
+/* Manipulating Packet TLVs */
+
+PacketBB::TlvIterator
+PacketBB::TlvBegin (void)
+{
+  return m_tlvList.Begin ();
+}
+
+PacketBB::ConstTlvIterator
+PacketBB::TlvBegin (void) const
+{
+  return m_tlvList.Begin ();
+}
+
+PacketBB::TlvIterator
+PacketBB::TlvEnd (void)
+{
+  return m_tlvList.End ();
+}
+
+PacketBB::ConstTlvIterator
+PacketBB::TlvEnd (void) const
+{
+  return m_tlvList.End ();
+}
+
+int
+PacketBB::TlvSize (void) const
+{
+  return m_tlvList.Size ();
+}
+
+bool
+PacketBB::TlvEmpty (void) const
+{
+  return m_tlvList.Empty ();
+}
+
+Ptr<Tlv>
+PacketBB::TlvFront (void)
+{
+  return m_tlvList.Front ();
+}
+
+const Ptr<Tlv>
+PacketBB::TlvFront (void) const
+{
+  return m_tlvList.Front ();
+}
+
+Ptr<Tlv>
+PacketBB::TlvBack (void)
+{
+  return m_tlvList.Back ();
+}
+
+const Ptr<Tlv>
+PacketBB::TlvBack (void) const
+{
+  return m_tlvList.Back ();
+}
+
+void
+PacketBB::TlvPushFront (Ptr<Tlv> tlv)
+{
+  m_tlvList.PushFront (tlv);
+}
+
+void
+PacketBB::TlvPopFront (void)
+{
+  m_tlvList.PopFront ();
+}
+
+void
+PacketBB::TlvPushBack (Ptr<Tlv> tlv)
+{
+  m_tlvList.PushBack (tlv);
+}
+
+void
+PacketBB::TlvPopBack (void)
+{
+  m_tlvList.PopBack ();
+}
+
+PacketBB::TlvIterator
+PacketBB::Erase (PacketBB::TlvIterator position)
+{
+  return m_tlvList.Erase (position);
+}
+
+PacketBB::TlvIterator
+PacketBB::Erase (PacketBB::TlvIterator first, PacketBB::TlvIterator last)
+{
+  return m_tlvList.Erase (first, last);
+}
+
+void
+PacketBB::TlvClear (void)
+{
+  m_tlvList.Clear ();
+}
+
+/* Manipulating Packet Messages */
+
+PacketBB::MessageIterator
+PacketBB::MessageBegin (void)
+{
+  return m_messageList.begin ();
+}
+
+PacketBB::ConstMessageIterator
+PacketBB::MessageBegin (void) const
+{
+  return m_messageList.begin ();
+}
+
+PacketBB::MessageIterator
+PacketBB::MessageEnd (void)
+{
+  return m_messageList.end ();
+}
+
+PacketBB::ConstMessageIterator
+PacketBB::MessageEnd (void) const
+{
+  return m_messageList.end ();
+}
+
+int
+PacketBB::MessageSize (void) const
+{
+  return m_messageList.size ();
+}
+
+bool
+PacketBB::MessageEmpty (void) const
+{
+  return m_messageList.empty ();
+}
+
+Ptr<Message>
+PacketBB::MessageFront (void)
+{
+  return m_messageList.front ();
+}
+
+const Ptr<Message>
+PacketBB::MessageFront (void) const
+{
+  return m_messageList.front ();
+}
+
+Ptr<Message>
+PacketBB::MessageBack (void)
+{
+  return m_messageList.back ();
+}
+
+const Ptr<Message>
+PacketBB::MessageBack (void) const
+{
+  return m_messageList.back ();
+}
+
+void
+PacketBB::MessagePushFront (Ptr<Message> tlv)
+{
+  m_messageList.push_front (tlv);
+}
+
+void
+PacketBB::MessagePopFront (void)
+{
+  m_messageList.pop_front ();
+}
+
+void
+PacketBB::MessagePushBack (Ptr<Message> tlv)
+{
+  m_messageList.push_back (tlv);
+}
+
+void
+PacketBB::MessagePopBack (void)
+{
+  m_messageList.pop_back ();
+}
+
+PacketBB::MessageIterator
+PacketBB::Erase (PacketBB::MessageIterator position)
+{
+  return m_messageList.erase (position);
+}
+
+PacketBB::MessageIterator
+PacketBB::Erase (PacketBB::MessageIterator first,
+    PacketBB::MessageIterator last)
+{
+  return m_messageList.erase (first, last);
+}
+
+void
+PacketBB::MessageClear (void)
+{
+  m_messageList.clear ();
+}
+
+void
+PacketBB::Ref (void) const
+{
+  m_refCount++;
+}
+
+void
+PacketBB::Unref (void) const
+{
+  m_refCount--;
+  if (m_refCount == 0)
+  {
+    delete this;
+  }
+}
+
+TypeId
+PacketBB::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("PacketBB")
+    .SetParent<Header> ()
+    .AddConstructor<PacketBB> ()
+  ;
+  return tid;
+}
+
+TypeId
+PacketBB::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
+uint32_t
+PacketBB::GetSerializedSize (void) const
+{
+  /* Version number + flags */
+  uint32_t size = 1;
+
+  if (HasSequenceNumber())
+  {
+    size += 2;
+  }
+
+  if (!TlvEmpty ())
+    size += m_tlvList.GetSerializedSize ();
+
+  for (ConstMessageIterator iter = MessageBegin (); iter != MessageEnd ();
+      iter++)
+  {
+    size += (*iter)->GetSerializedSize ();
+  }
+
+  return size;
+}
+
+void
+PacketBB::Serialize (Buffer::Iterator start) const
+{
+  /* We remember the start, so we can write the flags after we check for a
+   * sequence number and TLV. */
+  Buffer::Iterator bufref = start;
+  start.Next ();
+
+  uint8_t flags = VERSION;
+  /* Make room for 4 bit flags */
+  flags <<= 4;
+
+  if (HasSequenceNumber ())
+  {
+    flags |= PHAS_SEQ_NUM;
+    start.WriteHtonU16 (GetSequenceNumber ());
+  }
+
+  if (!TlvEmpty ())
+  {
+    flags |= PHAS_TLV;
+    m_tlvList.Serialize (start);
+  }
+
+  bufref.WriteU8(flags);
+
+  for (ConstMessageIterator iter = MessageBegin ();
+      iter != MessageEnd ();
+      iter++)
+  {
+    (*iter)->Serialize (start);
+  }
+}
+
+uint32_t
+PacketBB::Deserialize (Buffer::Iterator start)
+{
+  Buffer::Iterator begin = start;
+
+  uint8_t flags = start.ReadU8 ();
+
+  if (flags & PHAS_SEQ_NUM)
+    SetSequenceNumber (start.ReadNtohU16 ());
+
+  if (flags & PHAS_TLV)
+    m_tlvList.Deserialize (start);
+
+  while (!start.IsEnd())
+  {
+    Ptr<Message> newmsg = Message::DeserializeMessage (start);
+    //Message * newmsg = Message::DeserializeMessage (start);
+    //Ptr<Message> * newptr = new Ptr<Message> (newmsg);
+    MessagePushBack (newmsg);
+  }
+
+  flags >>= 4;
+  m_version = flags;
+
+  return start.GetDistanceFrom (begin);
+}
+
+void
+PacketBB::Print (std::ostream &os) const
+{
+  os << "PacketBB {" << std::endl;
+
+  if (HasSequenceNumber ())
+    os << "\tsequence number = " << GetSequenceNumber ();
+
+  os << std::endl;
+
+  m_tlvList.Print (os, 1);
+
+  for (ConstMessageIterator iter = MessageBegin ();
+      iter != MessageEnd ();
+      iter++)
+  {
+    (*iter)->Print (os, 1);
+  }
+
+  os << "}" << std::endl;
+}
+
+bool
+PacketBB::operator== (const PacketBB &other) const
+{
+  if (GetVersion () != other.GetVersion ())
+    return false;
+
+  if (HasSequenceNumber () != other.HasSequenceNumber ())
+    return false;
+
+  if (HasSequenceNumber ())
+  {
+    if (GetSequenceNumber () != other.GetSequenceNumber ())
+      return false;
+  }
+
+  if (m_tlvList != other.m_tlvList)
+    return false;
+
+  if (MessageSize () != other.MessageSize ())
+      return false;
+
+  ConstMessageIterator tmi, omi;
+  for (tmi = MessageBegin (), omi = other.MessageBegin ();
+    tmi != MessageEnd () && omi != other.MessageEnd ();
+    tmi++, omi++)
+  {
+    if (**tmi != **omi)
+      return false;
+  }
+  return true;
+}
+
+bool
+PacketBB::operator!= (const PacketBB &other) const
+{
+  return !(*this == other);
+}
+
+/* End PacketBB class */
+
+Message::Message (void)
+{
+  m_refCount = 1;
+  /* Default to IPv4 */
+  m_addrSize = IPV4;
+  m_hasOriginatorAddress = false;
+  m_hasHopLimit = false;
+  m_hasHopCount = false;
+  m_hasSequenceNumber = false;
+}
+
+void
+Message::SetType (uint8_t type)
+{
+  m_type = type;
+}
+
+uint8_t
+Message::GetType (void) const
+{
+  return m_type;
+}
+
+AddressLength
+Message::GetAddressLength (void) const
+{
+  return m_addrSize;
+}
+
+void
+Message::SetOriginatorAddress (Address address)
+{
+  m_originatorAddress = address;
+  m_hasOriginatorAddress = true;
+}
+
+Address
+Message::GetOriginatorAddress (void) const throw (PacketBBError)
+{
+  if (!HasOriginatorAddress()) 
+  {
+    throw PacketBBError ("Message has no originator address.");
+  }
+  return m_originatorAddress;
+}
+
+bool
+Message::HasOriginatorAddress (void) const
+{
+  return m_hasOriginatorAddress;
+}
+
+void
+Message::SetHopLimit (uint8_t hopLimit)
+{
+  m_hopLimit = hopLimit;
+  m_hasHopLimit = true;
+}
+
+uint8_t
+Message::GetHopLimit (void) const throw (PacketBBError)
+{
+  if (!HasHopLimit())
+  {
+    throw PacketBBError ("Message has no hop limit.");
+  }
+  return m_hopLimit;
+}
+
+bool
+Message::HasHopLimit (void) const
+{
+  return m_hasHopLimit;
+}
+
+void
+Message::SetHopCount (uint8_t hopCount)
+{
+  m_hopCount = hopCount;
+  m_hasHopCount = true;
+}
+
+uint8_t
+Message::GetHopCount (void) const throw (PacketBBError)
+{
+  if (!HasHopCount())
+  {
+    throw PacketBBError ("Message has no hop count.");
+  }
+  return m_hopCount;
+}
+
+bool
+Message::HasHopCount (void) const
+{
+  return m_hasHopCount;
+}
+
+void
+Message::SetSequenceNumber (uint16_t sequenceNumber)
+{
+  m_sequenceNumber = sequenceNumber;
+  m_hasSequenceNumber = true;
+}
+
+uint16_t
+Message::GetSequenceNumber (void) const throw (PacketBBError)
+{
+  if (!HasSequenceNumber())
+  {
+    throw PacketBBError ("Message has no sequence number.");
+  }
+  return m_sequenceNumber;
+}
+
+bool
+Message::HasSequenceNumber (void) const
+{
+  return m_hasSequenceNumber;
+}
+
+/* Manipulating Message TLVs */
+
+Message::TlvIterator
+Message::TlvBegin (void)
+{
+  return m_tlvList.Begin();
+}
+
+Message::ConstTlvIterator
+Message::TlvBegin (void) const
+{
+  return m_tlvList.Begin();
+}
+
+Message::TlvIterator
+Message::TlvEnd (void)
+{
+  return m_tlvList.End();
+}
+
+Message::ConstTlvIterator
+Message::TlvEnd (void) const
+{
+  return m_tlvList.End();
+}
+
+int
+Message::TlvSize (void) const
+{
+  return m_tlvList.Size();
+}
+
+bool
+Message::TlvEmpty (void) const
+{
+  return m_tlvList.Empty();
+}
+
+Ptr<Tlv>
+Message::TlvFront (void)
+{
+  return m_tlvList.Front();
+}
+
+const Ptr<Tlv>
+Message::TlvFront (void) const
+{
+  return m_tlvList.Front();
+}
+
+Ptr<Tlv>
+Message::TlvBack (void)
+{
+  return m_tlvList.Back();
+}
+
+const Ptr<Tlv>
+Message::TlvBack (void) const
+{
+  return m_tlvList.Back();
+}
+
+void
+Message::TlvPushFront (Ptr<Tlv> tlv)
+{
+  m_tlvList.PushFront(tlv);
+}
+
+void
+Message::TlvPopFront (void)
+{
+  m_tlvList.PopFront();
+}
+
+void
+Message::TlvPushBack (Ptr<Tlv> tlv)
+{
+  m_tlvList.PushBack(tlv);
+}
+
+void
+Message::TlvPopBack (void)
+{
+  m_tlvList.PopBack();
+}
+
+Message::TlvIterator
+Message::TlvErase (Message::TlvIterator position)
+{
+  return m_tlvList.Erase(position);
+}
+
+Message::TlvIterator
+Message::TlvErase (Message::TlvIterator first, Message::TlvIterator last)
+{
+  return m_tlvList.Erase(first, last);
+}
+
+void
+Message::TlvClear (void)
+{
+  return m_tlvList.Clear();
+}
+
+/* Manipulating Address Block and Address TLV pairs */
+
+Message::AddressBlockIterator
+Message::AddressBlockBegin (void)
+{
+  return m_addressBlockList.begin();
+}
+
+Message::ConstAddressBlockIterator
+Message::AddressBlockBegin (void) const
+{
+  return m_addressBlockList.begin();
+}
+
+Message::AddressBlockIterator
+Message::AddressBlockEnd (void)
+{
+  return m_addressBlockList.end();
+}
+
+Message::ConstAddressBlockIterator
+Message::AddressBlockEnd (void) const
+{
+  return m_addressBlockList.end();
+}
+
+int
+Message::AddressBlockSize (void) const
+{
+  return m_addressBlockList.size();
+}
+
+bool
+Message::AddressBlockEmpty (void) const
+{
+  return m_addressBlockList.empty();
+}
+
+Ptr<AddressBlock>
+Message::AddressBlockFront (void)
+{
+  return m_addressBlockList.front();
+}
+
+const Ptr<AddressBlock>
+Message::AddressBlockFront (void) const
+{
+  return m_addressBlockList.front();
+}
+
+Ptr<AddressBlock>
+Message::AddressBlockBack (void)
+{
+  return m_addressBlockList.back();
+}
+
+const Ptr<AddressBlock>
+Message::AddressBlockBack (void) const
+{
+  return m_addressBlockList.back();
+}
+
+void
+Message::AddressBlockPushFront (Ptr<AddressBlock> tlv)
+{
+  m_addressBlockList.push_front(tlv);
+}
+
+void
+Message::AddressBlockPopFront (void)
+{
+  m_addressBlockList.pop_front();
+}
+
+void
+Message::AddressBlockPushBack (Ptr<AddressBlock> tlv)
+{
+  m_addressBlockList.push_back(tlv);
+}
+
+void
+Message::AddressBlockPopBack (void)
+{
+  m_addressBlockList.pop_back();
+}
+
+Message::AddressBlockIterator
+Message::AddressBlockErase (Message::AddressBlockIterator position)
+{
+  return m_addressBlockList.erase(position);
+}
+
+Message::AddressBlockIterator
+Message::AddressBlockErase (Message::AddressBlockIterator first,
+    Message::AddressBlockIterator last)
+{
+  return m_addressBlockList.erase(first, last);
+}
+
+void
+Message::AddressBlockClear (void)
+{
+  return m_addressBlockList.clear();
+}
+
+void
+Message::Ref (void) const
+{
+  m_refCount++;
+}
+
+void
+Message::Unref (void) const
+{
+  m_refCount--;
+  if (m_refCount == 0)
+  {
+    delete this;
+  }
+}
+
+uint32_t
+Message::GetSerializedSize (void) const
+{
+  /* msg-type + (msg-flags + msg-addr-length) + 2msg-size */
+  uint32_t size = 4;
+
+  if (HasOriginatorAddress())
+    size += GetAddressLength() + 1;
+
+  if (HasHopLimit())
+    size++;
+
+  if (HasHopCount())
+    size++;
+
+  if (HasSequenceNumber())
+    size += 2;
+
+  size += m_tlvList.GetSerializedSize ();
+
+  for (ConstAddressBlockIterator iter = AddressBlockBegin ();
+      iter != AddressBlockEnd ();
+      iter++)
+  {
+    size += (*iter)->GetSerializedSize ();
+  }
+
+  return size;
+}
+
+void
+Message::Serialize (Buffer::Iterator &start) const
+{
+  Buffer::Iterator front = start;
+
+  start.WriteU8 (GetType());
+
+  /* Save a reference to the spot where we will later write the flags */
+  Buffer::Iterator bufref = start;
+  start.Next (1);
+
+  uint8_t flags = 0;
+
+  flags = GetAddressLength ();
+
+  Buffer::Iterator sizeref = start;
+  start.Next (2);
+
+  if (HasOriginatorAddress ())
+  {
+    flags |= MHAS_ORIG;
+    SerializeOriginatorAddress (start);
+  }
+
+  if (HasHopLimit ())
+  {
+    flags |= MHAS_HOP_LIMIT;
+    start.WriteU8 (GetHopLimit ());
+  }
+
+  if (HasHopCount ())
+  {
+    flags |= MHAS_HOP_COUNT;
+    start.WriteU8 (GetHopCount ());
+  }
+
+  if (HasSequenceNumber ())
+  {
+    flags |= MHAS_SEQ_NUM;
+    start.WriteHtonU16 (GetSequenceNumber ());
+  }
+
+  bufref.WriteU8(flags);
+
+  m_tlvList.Serialize (start);
+
+  for (ConstAddressBlockIterator iter = AddressBlockBegin ();
+      iter != AddressBlockEnd ();
+      iter++)
+  {
+    (*iter)->Serialize (start);
+  }
+
+  sizeref.WriteHtonU16 (front.GetDistanceFrom (start));
+}
+
+Ptr<Message>
+Message::DeserializeMessage (Buffer::Iterator &start) throw (PacketBBError)
+{
+  /* We need to read the msg-addr-len field to determine what kind of object to
+   * construct. */
+  start.Next ();
+  uint8_t addrlen = start.ReadU8 ();
+  start.Prev (2); /* Go back to the start */
+
+  /* The first four bytes of the flag is the address length.  Set the last four
+   * bytes to 0 to read it. */
+  addrlen = (addrlen & 0xf);
+
+  Ptr<Message> newmsg;
+
+  switch (addrlen)
+  {
+    case 0:
+    case IPV4:
+      newmsg = Create<MessageIpv4> ();
+      break;
+    case IPV6:
+      newmsg = Create<MessageIpv6> ();
+      break;
+    default:
+      throw PacketBBError ("Message deserialization has invalid address size.");
+      break;
+  }
+  newmsg->Deserialize (start);
+  return newmsg;
+}
+
+void
+Message::Deserialize (Buffer::Iterator &start)
+{
+  Buffer::Iterator front = start;
+  SetType (start.ReadU8 ());
+  uint8_t flags = start.ReadU8 ();
+
+  uint16_t size = start.ReadNtohU16 ();
+
+  if (flags & MHAS_ORIG)
+    SetOriginatorAddress (DeserializeOriginatorAddress (start));
+
+  if (flags & MHAS_HOP_LIMIT)
+    SetHopLimit (start.ReadU8 ());
+
+  if (flags & MHAS_HOP_COUNT)
+    SetHopCount (start.ReadU8 ());
+
+  if (flags & MHAS_SEQ_NUM)
+    SetSequenceNumber (start.ReadNtohU16 ());
+
+  m_tlvList.Deserialize (start);
+
+  if (size > 0)
+  {
+    while (start.GetDistanceFrom(front) < size)
+    {
+      Ptr<AddressBlock> newab = AddressBlockDeserialize (start);
+      //AddressBlock * newab = AddressBlockDeserialize (start);
+      //Ptr<AddressBlock> * newptr = new Ptr<AddressBlock> (newab);
+      AddressBlockPushBack (newab);
+    }
+  }
+}
+
+void
+Message::Print (std::ostream &os) const
+{
+  Print (os, 0);
+}
+
+void
+Message::Print (std::ostream &os, int level) const
+{
+  std::string prefix = "";
+  for (int i = 0; i < level; i++)
+    prefix.append ("\t");
+
+  os << prefix << "Message {" << std::endl;
+
+  os << prefix << "\tmessage type = " << (int)GetType () << std::endl;
+  os << prefix << "\taddress size = " << GetAddressLength () << std::endl;
+
+  if (HasOriginatorAddress ())
+  {
+    os << prefix << "\toriginator address = ";
+    PrintOriginatorAddress (os);
+    os << std::endl;
+  }
+
+  if (HasHopLimit ())
+    os << prefix << "\thop limit = " << (int)GetHopLimit () << std::endl;
+
+  if (HasHopCount ())
+    os << prefix << "\thop count = " << (int)GetHopCount () << std::endl;
+
+  if (HasSequenceNumber ())
+    os << prefix << "\tseqnum = " << GetSequenceNumber () << std::endl;
+
+  m_tlvList.Print (os, level+1);
+
+  for (ConstAddressBlockIterator iter = AddressBlockBegin ();
+      iter != AddressBlockEnd ();
+      iter++)
+  {
+    (*iter)->Print (os, level+1);
+  }
+  os << prefix << "}" << std::endl;
+}
+
+bool
+Message::operator== (const Message &other) const
+{
+  if (GetAddressLength () != other.GetAddressLength ())
+    return false;
+
+  if (GetType () != other.GetType ())
+    return false;
+
+  if (HasOriginatorAddress () != other.HasOriginatorAddress ())
+    return false;
+
+  if (HasOriginatorAddress ())
+  {
+    if (GetOriginatorAddress () != other.GetOriginatorAddress ())
+      return false;
+  }
+
+  if (HasHopLimit () != other.HasHopLimit ())
+    return false;
+
+  if (HasHopLimit ())
+  {
+    if (GetHopLimit () != other.GetHopLimit ())
+      return false;
+  }
+
+  if (HasHopCount () != other.HasHopCount ())
+    return false;
+
+  if (HasHopCount ())
+  {
+    if (GetHopCount () != other.GetHopCount ())
+      return false;
+  }
+
+  if (HasSequenceNumber () != other.HasSequenceNumber ())
+    return false;
+
+  if (HasSequenceNumber ())
+  {
+    if (GetSequenceNumber () != other.GetSequenceNumber ())
+      return false;
+  }
+
+  if (m_tlvList != other.m_tlvList)
+    return false;
+
+  if (AddressBlockSize () != other.AddressBlockSize ())
+    return false;
+
+  ConstAddressBlockIterator tai, oai;
+  for (tai = AddressBlockBegin (), oai = other.AddressBlockBegin ();
+      tai != AddressBlockEnd () && oai != other.AddressBlockEnd ();
+      tai++, oai++)
+  {
+    if (**tai != **oai)
+      return false;
+  }
+  return true;
+}
+
+bool
+Message::operator!= (const Message &other) const
+{
+  return !(*this == other);
+}
+
+/* End Message Class */
+
+AddressLength
+MessageIpv4::GetAddressLength (void) const
+{
+  return IPV4;
+}
+
+void
+MessageIpv4::SerializeOriginatorAddress (Buffer::Iterator &start) const
+{
+  uint8_t buffer[GetAddressLength () + 1];
+  Ipv4Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer);
+  start.Write (buffer, GetAddressLength () + 1);
+}
+
+Address
+MessageIpv4::DeserializeOriginatorAddress (Buffer::Iterator &start) const
+{
+  uint8_t buffer[GetAddressLength () + 1];
+  start.Read(buffer, GetAddressLength () + 1);
+  return Ipv4Address::Deserialize (buffer);
+}
+
+void
+MessageIpv4::PrintOriginatorAddress (std::ostream &os) const
+{
+  Ipv4Address::ConvertFrom (GetOriginatorAddress ()).Print (os);
+}
+
+Ptr<AddressBlock>
+MessageIpv4::AddressBlockDeserialize (Buffer::Iterator &start) const
+{
+  Ptr<AddressBlock> newab = Create<AddressBlockIpv4> ();
+  newab->Deserialize (start);
+  return newab;
+}
+
+/* End MessageIpv4 Class */
+
+AddressLength
+MessageIpv6::GetAddressLength (void) const
+{
+  return IPV6;
+}
+
+void
+MessageIpv6::SerializeOriginatorAddress (Buffer::Iterator &start) const
+{
+  uint8_t buffer[GetAddressLength () + 1];
+  Ipv6Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer);
+  start.Write (buffer, GetAddressLength () + 1);
+}
+
+Address
+MessageIpv6::DeserializeOriginatorAddress (Buffer::Iterator &start) const
+{
+  uint8_t buffer[GetAddressLength () + 1];
+  start.Read(buffer, GetAddressLength () + 1);
+  return Ipv6Address::Deserialize (buffer);
+}
+
+void
+MessageIpv6::PrintOriginatorAddress (std::ostream &os) const
+{
+  Ipv6Address::ConvertFrom (GetOriginatorAddress ()).Print (os);
+}
+
+Ptr<AddressBlock>
+MessageIpv6::AddressBlockDeserialize (Buffer::Iterator &start) const
+{
+  Ptr<AddressBlock> newab = Create<AddressBlockIpv6> ();
+  newab->Deserialize (start);
+  return newab;
+}
+
+/* End MessageIpv6 Class */
+
+AddressBlock::AddressBlock ()
+{
+  m_refCount = 1;
+}
+
+/* Manipulating the address block */
+
+AddressBlock::AddressIterator
+AddressBlock::AddressBegin (void)
+{
+  return m_addressList.begin();
+}
+
+AddressBlock::ConstAddressIterator
+AddressBlock::AddressBegin (void) const
+{
+  return m_addressList.begin();
+}
+
+AddressBlock::AddressIterator
+AddressBlock::AddressEnd (void)
+{
+  return m_addressList.end();
+}
+
+AddressBlock::ConstAddressIterator
+AddressBlock::AddressEnd (void) const
+{
+  return m_addressList.end();
+}
+
+int
+AddressBlock::AddressSize (void) const
+{
+  return m_addressList.size();
+}
+
+bool
+AddressBlock::AddressEmpty (void) const
+{
+  return m_addressList.empty();
+}
+
+Address
+AddressBlock::AddressFront (void) const
+{
+  return m_addressList.front();
+}
+
+Address
+AddressBlock::AddressBack (void) const
+{
+  return m_addressList.back();
+}
+
+void
+AddressBlock::AddressPushFront (Address tlv)
+{
+  m_addressList.push_front(tlv);
+}
+
+void
+AddressBlock::AddressPopFront (void)
+{
+  m_addressList.pop_front();
+}
+
+void
+AddressBlock::AddressPushBack (Address tlv)
+{
+  m_addressList.push_back(tlv);
+}
+
+void
+AddressBlock::AddressPopBack (void)
+{
+  m_addressList.pop_back();
+}
+
+AddressBlock::AddressIterator
+AddressBlock::AddressErase (AddressBlock::AddressIterator position)
+{
+  return m_addressList.erase(position);
+}
+
+AddressBlock::AddressIterator
+AddressBlock::AddressErase (AddressBlock::AddressIterator first,
+    AddressBlock::AddressIterator last)
+{
+  return m_addressList.erase(first, last);
+}
+
+  void
+AddressBlock::AddressClear (void)
+{
+  return m_addressList.clear();
+}
+
+/* Manipulating the prefix list */
+
+AddressBlock::PrefixIterator
+AddressBlock::PrefixBegin (void)
+{
+  return m_prefixList.begin ();
+}
+
+AddressBlock::ConstPrefixIterator
+AddressBlock::PrefixBegin (void) const
+{
+  return m_prefixList.begin ();
+}
+
+AddressBlock::PrefixIterator
+AddressBlock::PrefixEnd (void)
+{
+  return m_prefixList.end ();
+}
+
+AddressBlock::ConstPrefixIterator
+AddressBlock::PrefixEnd (void) const
+{
+  return m_prefixList.end ();
+}
+
+int
+AddressBlock::PrefixSize (void) const
+{
+  return m_prefixList.size ();
+}
+
+bool
+AddressBlock::PrefixEmpty (void) const
+{
+  return m_prefixList.empty ();
+}
+
+uint8_t
+AddressBlock::PrefixFront (void) const
+{
+  return m_prefixList.front ();
+}
+
+uint8_t
+AddressBlock::PrefixBack (void) const
+{
+  return m_prefixList.back ();
+}
+
+void
+AddressBlock::PrefixPushFront (uint8_t prefix)
+{
+  m_prefixList.push_front (prefix);
+}
+
+void
+AddressBlock::PrefixPopFront (void)
+{
+  m_prefixList.pop_front ();
+}
+
+void
+AddressBlock::PrefixPushBack (uint8_t prefix)
+{
+  m_prefixList.push_back (prefix);
+}
+
+void
+AddressBlock::PrefixPopBack (void)
+{
+  m_prefixList.pop_back ();
+}
+
+AddressBlock::PrefixIterator
+AddressBlock::PrefixInsert (AddressBlock::PrefixIterator position, const uint8_t value)
+{
+  return m_prefixList.insert (position, value);
+}
+
+AddressBlock::PrefixIterator
+AddressBlock::PrefixErase (AddressBlock::PrefixIterator position)
+{
+  return m_prefixList.erase (position);
+}
+
+AddressBlock::PrefixIterator
+AddressBlock::PrefixErase (AddressBlock::PrefixIterator first, AddressBlock::PrefixIterator last)
+{
+  return m_prefixList.erase (first, last);
+}
+
+void
+AddressBlock::PrefixClear (void)
+{
+  m_prefixList.clear ();
+}
+
+/* Manipulating the TLV block */
+
+AddressBlock::TlvIterator
+AddressBlock::TlvBegin (void)
+{
+  return m_addressTlvList.Begin();
+}
+
+AddressBlock::ConstTlvIterator
+AddressBlock::TlvBegin (void) const
+{
+  return m_addressTlvList.Begin();
+}
+
+AddressBlock::TlvIterator
+AddressBlock::TlvEnd (void)
+{
+  return m_addressTlvList.End();
+}
+
+AddressBlock::ConstTlvIterator
+AddressBlock::TlvEnd (void) const
+{
+  return m_addressTlvList.End();
+}
+
+int
+AddressBlock::TlvSize (void) const
+{
+  return m_addressTlvList.Size();
+}
+
+bool
+AddressBlock::TlvEmpty (void) const
+{
+  return m_addressTlvList.Empty();
+}
+
+Ptr<AddressTlv>
+AddressBlock::TlvFront (void)
+{
+  return m_addressTlvList.Front();
+}
+
+const Ptr<AddressTlv>
+AddressBlock::TlvFront (void) const
+{
+  return m_addressTlvList.Front();
+}
+
+Ptr<AddressTlv>
+AddressBlock::TlvBack (void)
+{
+  return m_addressTlvList.Back();
+}
+
+const Ptr<AddressTlv>
+AddressBlock::TlvBack (void) const
+{
+  return m_addressTlvList.Back();
+}
+
+void
+AddressBlock::TlvPushFront (Ptr<AddressTlv> tlv)
+{
+  m_addressTlvList.PushFront(tlv);
+}
+
+void
+AddressBlock::TlvPopFront (void)
+{
+  m_addressTlvList.PopFront();
+}
+
+void
+AddressBlock::TlvPushBack (Ptr<AddressTlv> tlv)
+{
+  m_addressTlvList.PushBack(tlv);
+}
+
+void
+AddressBlock::TlvPopBack (void)
+{
+  m_addressTlvList.PopBack();
+}
+
+AddressBlock::TlvIterator
+AddressBlock::TlvErase (AddressBlock::TlvIterator position)
+{
+  return m_addressTlvList.Erase(position);
+}
+
+AddressBlock::TlvIterator
+AddressBlock::TlvErase (AddressBlock::TlvIterator first,
+    AddressBlock::TlvIterator last)
+{
+  return m_addressTlvList.Erase(first, last);
+}
+
+void
+AddressBlock::TlvClear (void)
+{
+  return m_addressTlvList.Clear();
+}
+
+void
+AddressBlock::Ref (void) const
+{
+  m_refCount++;
+}
+
+void
+AddressBlock::Unref (void) const
+{
+  m_refCount--;
+  if (m_refCount == 0)
+  {
+    delete this;
+  }
+}
+
+uint32_t
+AddressBlock::GetSerializedSize (void) const
+{
+  /* num-addr + flags */
+  uint32_t size = 2;
+
+  if (AddressSize () == 1)
+  {
+    size += GetAddressLength () + PrefixSize();
+  }
+  else if (AddressSize () > 0)
+  {
+    uint8_t head[GetAddressLength ()];
+    uint8_t headlen = 0;
+    uint8_t tail[GetAddressLength ()];
+    uint8_t taillen = 0;
+
+    GetHeadTail (head, headlen, tail, taillen);
+
+    if (headlen > 0)
+      size += 1 + headlen;
+
+    if (taillen > 0)
+    {
+      size++;
+      if (!HasZeroTail (tail, taillen))
+        size += taillen;
+    }
+
+    /* mid size */
+    size += (GetAddressLength () - headlen - taillen) * AddressSize ();
+
+    size += PrefixSize ();
+  }
+
+  size += m_addressTlvList.GetSerializedSize ();
+
+  return size;
+}
+
+void
+AddressBlock::Serialize (Buffer::Iterator &start) const
+{
+  start.WriteU8 (AddressSize ());
+
+  if (AddressSize () == 1) {
+    start.WriteU8 (0);
+
+    uint8_t buf[GetAddressLength ()];
+    SerializeAddress (buf, AddressBegin ());
+    start.Write (buf, GetAddressLength ());
+
+    if (PrefixSize () == 1)
+      start.WriteU8 (PrefixFront ());
+  }
+  else if (AddressSize () > 0)
+  {
+    Buffer::Iterator bufref = start;
+    uint8_t flags = 0;
+    start.Next ();
+
+    uint8_t head[GetAddressLength ()];
+    uint8_t tail[GetAddressLength ()];
+    uint8_t headlen = 0;
+    uint8_t taillen = 0;
+
+    GetHeadTail (head, headlen, tail, taillen);
+
+    if (headlen > 0)
+    {
+      flags |= AHAS_HEAD;
+      start.WriteU8 (headlen);
+      start.Write (head, headlen);
+    }
+
+    if (taillen > 0)
+    {
+      start.WriteU8 (taillen);
+
+      if (HasZeroTail (tail, taillen))
+      {
+        flags |= AHAS_ZERO_TAIL;
+      }
+      else
+      {
+        flags |= AHAS_FULL_TAIL;
+        start.Write (tail, taillen);
+      }
+    }
+
+    if (headlen + taillen < GetAddressLength ())
+    {
+      uint8_t mid[GetAddressLength ()];
+      for (AddressBlock::ConstAddressIterator iter = AddressBegin ();
+          iter != AddressEnd ();
+          iter++)
+      {
+        SerializeAddress (mid, iter);
+        start.Write (mid + headlen, GetAddressLength () - headlen - taillen);
+      }
+    }
+
+    flags |= GetPrefixFlags ();
+    bufref.WriteU8 (flags);
+
+    for (ConstPrefixIterator iter = PrefixBegin ();
+        iter != PrefixEnd ();
+        iter++)
+    {
+      start.WriteU8 (*iter);
+    }
+  }
+  
+  m_addressTlvList.Serialize (start);
+}
+
+void
+AddressBlock::Deserialize (Buffer::Iterator &start)
+{
+  uint8_t numaddr = start.ReadU8 ();
+  uint8_t flags = start.ReadU8 ();
+
+  if (numaddr > 0)
+  {
+    uint8_t headlen = 0;
+    uint8_t taillen = 0;
+    uint8_t addrtmp[GetAddressLength ()];
+    memset(addrtmp, 0, GetAddressLength ());
+
+    if (flags & AHAS_HEAD)
+    {
+      headlen = start.ReadU8 ();
+      start.Read (addrtmp, headlen);
+    }
+
+    if ((flags & AHAS_FULL_TAIL) ^ (flags & AHAS_ZERO_TAIL))
+    {
+      taillen = start.ReadU8 ();
+      
+      if (flags & AHAS_FULL_TAIL)
+      {
+        start.Read (addrtmp + GetAddressLength () - taillen, taillen);
+      }
+    }
+
+    for (int i = 0; i < numaddr; i++)
+    {
+      start.Read (addrtmp + headlen, GetAddressLength () - headlen - taillen);
+      AddressPushBack (DeserializeAddress (addrtmp));
+    }
+
+    if (flags & AHAS_SINGLE_PRE_LEN)
+    {
+      PrefixPushBack (start.ReadU8 ());
+    }
+    else if (flags & AHAS_MULTI_PRE_LEN)
+    {
+      for (int i = 0; i < numaddr; i++)
+      {
+        PrefixPushBack (start.ReadU8 ());
+      }
+    }
+  }
+
+  m_addressTlvList.Deserialize (start);
+}
+
+void
+AddressBlock::Print (std::ostream &os) const
+{
+  Print (os, 0);
+}
+
+void
+AddressBlock::Print (std::ostream &os, int level) const
+{
+  std::string prefix = "";
+  for (int i = 0; i < level; i++)
+    prefix.append ("\t");
+
+  os << prefix << "AddressBlock {" << std::endl;
+  os << prefix << "\taddresses = " << std::endl;
+  for (ConstAddressIterator iter = AddressBegin ();
+      iter != AddressEnd ();
+      iter++)
+  {
+    os << prefix << "\t\t";
+    PrintAddress(os, iter);
+    os << std::endl;
+  }
+
+  os << prefix << "\tprefixes = " << std::endl;
+  for (ConstPrefixIterator iter = PrefixBegin ();
+      iter != PrefixEnd ();
+      iter++)
+  {
+    os << prefix << "\t\t" << (int)(*iter) << std::endl;
+  }
+
+  m_addressTlvList.Print (os, level+1);
+}
+
+bool
+AddressBlock::operator== (const AddressBlock &other) const
+{
+  if (AddressSize () != other.AddressSize ())
+    return false;
+
+  ConstAddressIterator tai, oai;
+  for (tai = AddressBegin (), oai = other.AddressBegin ();
+      tai != AddressEnd () && oai != other.AddressEnd ();
+      tai++, oai++)
+  {
+    if (*tai != *oai)
+      return false;
+  }
+
+  if (PrefixSize () != other.PrefixSize ())
+    return false;
+
+  ConstPrefixIterator tpi, opi;
+  for (tpi = PrefixBegin (), opi = other.PrefixBegin ();
+      tpi != PrefixEnd () && opi != other.PrefixEnd ();
+      tpi++, opi++)
+  {
+    if (*tpi != *opi)
+      return false;
+  }
+
+  if (m_addressTlvList != other.m_addressTlvList)
+    return false;
+
+  return true;
+}
+
+bool
+AddressBlock::operator!= (const AddressBlock &other) const
+{
+  return !(*this == other);
+}
+
+uint8_t
+AddressBlock::GetPrefixFlags (void) const
+{
+  switch (PrefixSize ())
+  {
+    case 0:
+      return 0;
+      break;
+    case 1:
+      return AHAS_SINGLE_PRE_LEN;
+      break;
+    default:
+      return AHAS_MULTI_PRE_LEN;
+      break;
+  }
+}
+
+void
+AddressBlock::GetHeadTail (uint8_t *head, uint8_t &headlen,
+    uint8_t *tail, uint8_t &taillen) const
+{
+  headlen = GetAddressLength ();
+  taillen = headlen;
+
+  /* Temporary automatic buffers to store serialized addresses */
+  uint8_t * buflast = new uint8_t[GetAddressLength ()];
+  uint8_t * bufcur = new uint8_t[GetAddressLength ()];
+  uint8_t * tmp;
+
+  SerializeAddress (buflast, AddressBegin ());
+
+  /* Skip the first item */
+  for (AddressBlock::ConstAddressIterator iter = AddressBegin ()++;
+      iter != AddressEnd ();
+      iter++)
+  {
+    SerializeAddress (bufcur, iter);
+
+    int i;
+    for (i = 0; i < headlen; i++)
+    {
+      if (buflast[i] != bufcur[i])
+      {
+        headlen = i;
+        break;
+      }
+    }
+
+    /* If headlen == fulllen - 1, then tail is 0 */
+    if (headlen <= GetAddressLength () - 1)
+    {
+      for (i = GetAddressLength () - 1;
+          GetAddressLength () - 1 - i <= taillen && i > headlen;
+          i--)
+      {
+        if (buflast[i] != bufcur[i])
+          break;
+      }
+      taillen = GetAddressLength () - 1 - i;
+    }
+    else if (headlen == 0)
+    {
+      taillen = 0;
+      break;
+    }
+
+    tmp = buflast;
+    buflast = bufcur;
+    bufcur = tmp;
+  }
+
+  memcpy(head, bufcur, headlen);
+  memcpy(tail, bufcur + (GetAddressLength () - taillen), taillen);
+
+  delete[] buflast;
+  delete[] bufcur;
+}
+
+bool
+AddressBlock::HasZeroTail (const uint8_t *tail, uint8_t taillen) const
+{
+  int i;
+  for (i = 0; i < taillen; i++)
+  {
+    if (tail[i] != 0)
+      break;
+  }
+  return i == taillen;
+}
+
+/* End AddressBlock Class */
+
+uint8_t
+AddressBlockIpv4::GetAddressLength (void) const
+{
+  return 4;
+}
+
+void
+AddressBlockIpv4::SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const
+{
+  Ipv4Address::ConvertFrom (*iter).Serialize (buffer);
+}
+
+Address
+AddressBlockIpv4::DeserializeAddress (uint8_t *buffer) const
+{
+  return Ipv4Address::Deserialize (buffer);
+}
+
+void
+AddressBlockIpv4::PrintAddress (std::ostream &os, ConstAddressIterator iter) const
+{
+  Ipv4Address::ConvertFrom (*iter).Print (os);
+}
+
+/* End AddressBlockIpv4 Class */
+
+uint8_t
+AddressBlockIpv6::GetAddressLength (void) const
+{
+  return 16;
+}
+
+void
+AddressBlockIpv6::SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const
+{
+  Ipv6Address::ConvertFrom (*iter).Serialize (buffer);
+}
+
+Address
+AddressBlockIpv6::DeserializeAddress (uint8_t *buffer) const
+{
+  return Ipv6Address::Deserialize (buffer);
+}
+
+void
+AddressBlockIpv6::PrintAddress (std::ostream &os, ConstAddressIterator iter) const
+{
+  Ipv6Address::ConvertFrom (*iter).Print (os);
+}
+
+/* End AddressBlockIpv6 Class */
+
+Tlv::Tlv (void)
+{
+  m_refCount = 1;
+  m_hasTypeExt = false;
+  m_hasIndexStart = false;
+  m_hasIndexStop = false;
+  m_isMultivalue = false;
+  m_hasValue = false;
+}
+
+void
+Tlv::SetType (uint8_t type)
+{
+  m_type = type;
+}
+
+uint8_t
+Tlv::GetType (void) const
+{
+  return m_type;
+}
+
+void
+Tlv::SetTypeExt (uint8_t typeExt)
+{
+  m_typeExt = typeExt;
+  m_hasTypeExt = true;
+}
+
+uint8_t
+Tlv::GetTypeExt (void) const throw (PacketBBError)
+{
+  if (!HasTypeExt())
+  {
+    throw PacketBBError ("TLV has no type extension.");
+  }
+  return m_typeExt;
+}
+
+bool
+Tlv::HasTypeExt (void) const
+{
+  return m_hasTypeExt;
+}
+
+void
+Tlv::SetIndexStart (uint8_t index)
+{
+  m_indexStart = index;
+  m_hasIndexStart = true;
+}
+
+uint8_t
+Tlv::GetIndexStart (void) const throw (PacketBBError)
+{
+  if (!HasIndexStart())
+  {
+    throw PacketBBError ("TLV has no start index.");
+  }
+  return m_indexStart;
+}
+
+bool
+Tlv::HasIndexStart (void) const
+{
+  return m_hasIndexStart;
+}
+
+void
+Tlv::SetIndexStop (uint8_t index)
+{
+  m_indexStop = index;
+  m_hasIndexStop = true;
+}
+
+uint8_t
+Tlv::GetIndexStop (void) const throw (PacketBBError)
+{
+  if (!HasIndexStop())
+  {
+    throw PacketBBError ("TLV has no stop index.");
+  }
+  return m_indexStop;
+}
+
+bool
+Tlv::HasIndexStop (void) const
+{
+  return m_hasIndexStop;
+}
+
+void
+Tlv::SetMultivalue (bool isMultivalue)
+{
+  m_isMultivalue = isMultivalue;
+}
+
+bool
+Tlv::IsMultivalue (void) const
+{
+  return m_isMultivalue;
+}
+
+void
+Tlv::SetValue (Buffer start)
+{
+  m_hasValue = true;
+  m_value = start;
+}
+
+void
+Tlv::SetValue (const uint8_t * buffer, uint32_t size)
+{
+  Buffer value;
+  value.AddAtStart (size);
+  value.Begin ().Write (buffer, size);
+  SetValue (value);
+}
+
+Buffer
+Tlv::GetValue (void) const throw (PacketBBError)
+{
+  if (!HasValue ())
+  {
+    throw PacketBBError ("TLV has no value.");
+  }
+  return m_value;
+}
+
+bool
+Tlv::HasValue (void) const
+{
+  return m_hasValue;
+}
+
+void
+Tlv::Ref (void) const
+{
+  m_refCount++;
+}
+
+void
+Tlv::Unref (void) const
+{
+  m_refCount--;
+  if (m_refCount == 0)
+  {
+    delete this;
+  }
+}
+
+uint32_t
+Tlv::GetSerializedSize (void) const
+{
+  /* type + flags */
+  uint32_t size = 2;
+
+  if (HasTypeExt ()) {
+    size++;
+  }
+
+  if (HasIndexStart ()) {
+    size++;
+  }
+
+  if (HasIndexStop ()) {
+    size++;
+  }
+
+  if (HasValue ())
+  {
+    if (GetValue ().GetSize () > 255) {
+      size += 2;
+    } else {
+      size++;
+    }
+    size += GetValue ().GetSize ();
+  }
+
+  return size;
+}
+
+void
+Tlv::Serialize (Buffer::Iterator &start) const
+{
+  start.WriteU8 (GetType ());
+
+  Buffer::Iterator bufref = start;
+  uint8_t flags = 0;
+  start.Next();
+
+  if (HasTypeExt())
+  {
+    flags |= THAS_TYPE_EXT;
+    start.WriteU8 (GetTypeExt ());
+  }
+
+  if (HasIndexStart ())
+  {
+    start.WriteU8 (GetIndexStart ());
+
+    if (HasIndexStop ())
+    {
+      flags |= THAS_MULTI_INDEX;
+      start.WriteU8 (GetIndexStop ());
+    } 
+    else
+    {
+      flags |= THAS_SINGLE_INDEX;
+    }
+  }
+
+  if (HasValue ()) {
+    flags |= THAS_VALUE;
+
+    uint32_t size = GetValue ().GetSize ();
+    if (size > 255)
+    {
+      flags |= THAS_EXT_LEN;
+      start.WriteHtonU16 (size);
+    }
+    else
+    {
+      start.WriteU8 (size);
+    }
+
+    if (IsMultivalue ())
+      flags |= TIS_MULTIVALUE;
+
+    start.Write(GetValue ().Begin (), GetValue ().End ());
+  }
+
+  bufref.WriteU8 (flags);
+}
+
+void
+Tlv::Deserialize (Buffer::Iterator &start)
+{
+  SetType (start.ReadU8 ());
+
+  uint8_t flags = start.ReadU8 ();
+
+  if (flags & THAS_TYPE_EXT)
+    SetTypeExt (start.ReadU8 ());
+
+  if (flags & THAS_MULTI_INDEX)
+  {
+    SetIndexStart (start.ReadU8 ());
+    SetIndexStop (start.ReadU8 ());
+  }
+  else if (flags & THAS_SINGLE_INDEX)
+  {
+    SetIndexStart (start.ReadU8 ());
+  }
+
+  if (flags & THAS_VALUE)
+  {
+    uint16_t len = 0;
+
+    if (flags & THAS_EXT_LEN)
+      len = start.ReadNtohU16 ();
+    else
+      len = start.ReadU8 ();
+
+    m_value.AddAtStart (len);
+
+    Buffer::Iterator valueStart = start;
+    start.Next (len);
+    m_value.Begin ().Write (valueStart, start);
+    m_hasValue = true;
+  }
+}
+
+void
+Tlv::Print (std::ostream &os) const
+{
+  Print (os, 0);
+}
+
+void
+Tlv::Print (std::ostream &os, int level) const
+{
+  std::string prefix = "";
+  for (int i = 0; i < level; i++)
+    prefix.append ("\t");
+
+  os << prefix << "Tlv {" << std::endl;
+  os << prefix << "\ttype = " << (int)GetType () << std::endl;
+
+  if (HasTypeExt ())
+    os << prefix << "\ttypeext = " << (int)GetTypeExt () << std::endl;
+
+  if (HasIndexStart ())
+    os << prefix << "\tindexStart = " << (int)GetIndexStart () << std::endl;
+
+  if (HasIndexStop ())
+    os << prefix << "\tindexStop = " << (int)GetIndexStop () << std::endl;
+
+  os << prefix << "\tisMultivalue = " << IsMultivalue () << std::endl;
+
+  if (HasValue ())
+    os << prefix << "\thas value; size = " << GetValue (). GetSize () << std::endl;
+
+  os << prefix << "}" << std::endl;
+}
+
+bool
+Tlv::operator== (const Tlv &other) const
+{
+  if (GetType () != other.GetType ())
+    return false;
+
+  if (HasTypeExt () != other.HasTypeExt ())
+    return false;
+
+  if (HasTypeExt ())
+  {
+    if (GetTypeExt () != other.GetTypeExt ())
+      return false;
+  }
+
+  if (HasValue () != other.HasValue ())
+    return false;
+
+  if (HasValue ())
+  {
+    Buffer tv = GetValue ();
+    Buffer ov = other.GetValue ();
+    if (tv.GetSize () != ov.GetSize ())
+      return false;
+
+    /* The docs say I probably shouldn't use Buffer::PeekData, but I think it
+     * is justified in this case. */
+    if (memcmp (tv.PeekData (), ov.PeekData (), tv.GetSize ()) != 0)
+      return false;
+  }
+  return true;
+}
+
+bool
+Tlv::operator!= (const Tlv &other) const
+{
+  return !(*this == other);
+}
+
+/* End Tlv Class */
+
+void 
+AddressTlv::SetIndexStart (uint8_t index)
+{
+  Tlv::SetIndexStart (index);
+}
+
+uint8_t
+AddressTlv::GetIndexStart (void) const throw (PacketBBError)
+{
+  return Tlv::GetIndexStart ();
+}
+
+bool
+AddressTlv::HasIndexStart (void) const
+{
+  return Tlv::HasIndexStart ();
+}
+
+void 
+AddressTlv::SetIndexStop (uint8_t index)
+{
+  Tlv::SetIndexStop (index);
+}
+
+uint8_t
+AddressTlv::GetIndexStop (void) const throw (PacketBBError)
+{
+  return Tlv::GetIndexStop ();
+}
+
+bool
+AddressTlv::HasIndexStop (void) const
+{
+  return Tlv::HasIndexStop ();
+}
+
+void
+AddressTlv::SetMultivalue (bool isMultivalue)
+{
+  Tlv::SetMultivalue (isMultivalue);
+}
+
+bool
+AddressTlv::IsMultivalue (void) const
+{
+  return Tlv::IsMultivalue ();
+}
+
+} /* namespace pbb */
+
+} /* namespace ns3 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/contrib/packetbb.h	Thu Aug 13 23:30:03 2009 -0400
@@ -0,0 +1,617 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* vim: set ts=2 sw=2 expandtab: */
+/* 
+ * Copyright (c) 2009 Drexel University
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ * Author: Tom Wambold <tom5760@gmail.com>
+ */
+/* These classes implement RFC 5444 - The Generalized Mobile Ad Hoc Network
+ * (MANET) Packet/Message Format
+ * See: http://tools.ietf.org/html/rfc5444 for details */
+
+#ifndef PACKETBB_H
+#define PACKETBB_H
+
+#include <stdexcept>
+#include <list>
+
+#include "ns3/ptr.h"
+#include "ns3/address.h"
+#include "ns3/header.h"
+#include "ns3/buffer.h"
+
+namespace ns3 {
+
+namespace pbb {
+
+/* Forward declare objects */
+class PacketBB;
+class Message;
+class AddressBlock;
+class TlvBlock;
+class AddressTlvBlock;
+class Tlv;
+class AddressTlv;
+
+enum AddressLength {
+  IPV4 = 3,
+  IPV6 = 15,
+};
+
+class PacketBBError : public std::runtime_error {
+public:
+  PacketBBError(const std::string &arg) : std::runtime_error(arg) {}
+};
+
+class TlvBlock
+{
+public:
+  typedef std::list< Ptr<Tlv> >::iterator Iterator;
+  typedef std::list< Ptr<Tlv> >::const_iterator ConstIterator;
+
+  Iterator Begin (void);
+  ConstIterator Begin (void) const;
+  Iterator End (void);
+  ConstIterator End (void) const;
+
+  int Size (void) const;
+  bool Empty (void) const;
+
+  Ptr<Tlv> Front (void) const;
+  Ptr<Tlv> Back (void) const;
+
+  void PushFront (Ptr<Tlv> tlv);
+  void PopFront (void);
+
+  void PushBack (Ptr<Tlv> tlv);
+  void PopBack (void);
+
+  Iterator Insert (Iterator position, const Ptr<Tlv> tlv);
+
+  Iterator Erase (Iterator position);
+  Iterator Erase (Iterator first, Iterator last);
+
+  void Clear (void);
+
+  uint32_t GetSerializedSize (void) const;
+  void Serialize (Buffer::Iterator &start) const;
+  void Deserialize (Buffer::Iterator &start);
+  void Print (std::ostream &os) const;
+  void Print (std::ostream &os, int level) const;
+
+  bool operator== (const TlvBlock &other) const;
+  bool operator!= (const TlvBlock &other) const;
+
+private:
+  std::list< Ptr<Tlv> > m_tlvList;
+};
+
+class AddressTlvBlock
+{
+public:
+  typedef std::list< Ptr<AddressTlv> >::iterator Iterator;
+  typedef std::list< Ptr<AddressTlv> >::const_iterator ConstIterator;
+
+  Iterator Begin (void);
+  ConstIterator Begin (void) const;
+  Iterator End (void);
+  ConstIterator End (void) const;
+
+  int Size (void) const;
+  bool Empty (void) const;
+
+  Ptr<AddressTlv> Front (void) const;
+  Ptr<AddressTlv> Back (void) const;
+
+  void PushFront (Ptr<AddressTlv> tlv);
+  void PopFront (void);
+
+  void PushBack (Ptr<AddressTlv> tlv);
+  void PopBack (void);
+
+  Iterator Insert (Iterator position, const Ptr<AddressTlv> tlv);
+
+  Iterator Erase (Iterator position);
+  Iterator Erase (Iterator first, Iterator last);
+
+  void Clear (void);
+
+  uint32_t GetSerializedSize (void) const;
+  void Serialize (Buffer::Iterator &start) const;
+  void Deserialize (Buffer::Iterator &start);
+  void Print (std::ostream &os) const;
+  void Print (std::ostream &os, int level) const;
+
+  bool operator== (const AddressTlvBlock &other) const;
+  bool operator!= (const AddressTlvBlock &other) const;
+
+private:
+  std::list< Ptr<AddressTlv> > m_tlvList;
+};
+
+/** Top level PacketBB packet object */
+class PacketBB : public Header
+{
+public:
+  typedef std::list< Ptr<Tlv> >::iterator TlvIterator;
+  typedef std::list< Ptr<Tlv> >::const_iterator ConstTlvIterator;
+  typedef std::list< Ptr<Message> >::iterator MessageIterator;
+  typedef std::list< Ptr<Message> >::const_iterator ConstMessageIterator;
+
+  PacketBB (void);
+
+  uint8_t GetVersion (void) const;
+
+  void SetSequenceNumber (uint16_t number);
+  uint16_t GetSequenceNumber (void) const throw (PacketBBError);
+  bool HasSequenceNumber (void) const;
+
+  /* Manipulating Packet TLVs */
+
+  TlvIterator TlvBegin (void);
+  ConstTlvIterator TlvBegin (void) const;
+  TlvIterator TlvEnd (void);
+  ConstTlvIterator TlvEnd (void) const;
+
+  int TlvSize (void) const;
+  bool TlvEmpty (void) const;
+
+  Ptr<Tlv> TlvFront (void);
+  const Ptr<Tlv> TlvFront (void) const;
+  Ptr<Tlv> TlvBack (void);
+  const Ptr<Tlv> TlvBack (void) const;
+
+  void TlvPushFront (Ptr<Tlv>);
+  void TlvPopFront (void);
+  void TlvPushBack (Ptr<Tlv>);
+  void TlvPopBack (void);
+
+  TlvIterator Erase (TlvIterator position);
+  TlvIterator Erase (TlvIterator first, TlvIterator last);
+  void TlvClear (void);
+
+  /* Manipulating Packet Messages */
+
+  MessageIterator MessageBegin (void);
+  ConstMessageIterator MessageBegin (void) const;
+  MessageIterator MessageEnd (void);
+  ConstMessageIterator MessageEnd (void) const;
+
+  int MessageSize (void) const;
+  bool MessageEmpty (void) const;
+
+  Ptr<Message> MessageFront (void);
+  const Ptr<Message> MessageFront (void) const;
+  Ptr<Message> MessageBack (void);
+  const Ptr<Message> MessageBack (void) const;
+
+  void MessagePushFront (Ptr<Message> message);
+  void MessagePopFront (void);
+  void MessagePushBack (Ptr<Message> message);
+  void MessagePopBack (void);
+
+  MessageIterator Erase (MessageIterator position);
+  MessageIterator Erase (MessageIterator first, MessageIterator last);
+  void MessageClear (void);
+
+  /* Smart pointer methods */
+  void Ref (void) const;
+  void Unref (void) const;
+
+  /* Methods implemented by all headers */
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
+  virtual void Print (std::ostream &os) const;
+
+  bool operator== (const PacketBB &other) const;
+  bool operator!= (const PacketBB &other) const;
+
+protected:
+  void SerializePacketTlv (Buffer::Iterator &start) const;
+
+private:
+  TlvBlock m_tlvList;
+  std::list< Ptr<Message> > m_messageList;
+
+  uint8_t m_version;
+
+  bool m_hasseqnum;
+  uint16_t m_seqnum;
+
+  mutable uint32_t m_refCount;
+};
+
+class Message
+{
+public:
+  typedef std::list< Ptr<Tlv> >::iterator TlvIterator;
+  typedef std::list< Ptr<Tlv> >::const_iterator ConstTlvIterator;
+  typedef std::list< Ptr<AddressBlock> >::iterator AddressBlockIterator;
+  typedef std::list< Ptr<AddressBlock> >::const_iterator ConstAddressBlockIterator;
+
+  Message (void);
+
+  void SetType (uint8_t type);
+  uint8_t GetType (void) const;
+
+  void SetOriginatorAddress (Address address);
+  Address GetOriginatorAddress (void) const throw (PacketBBError);
+  bool HasOriginatorAddress (void) const;
+
+  void SetHopLimit (uint8_t hoplimit);
+  uint8_t GetHopLimit (void) const throw (PacketBBError);
+  bool HasHopLimit (void) const;
+
+  void SetHopCount (uint8_t hopcount);
+  uint8_t GetHopCount (void) const throw (PacketBBError);
+  bool HasHopCount (void) const;
+
+  void SetSequenceNumber (uint16_t seqnum);
+  uint16_t GetSequenceNumber (void) const throw (PacketBBError);
+  bool HasSequenceNumber (void) const;
+
+  /* Manipulating Message TLVs */
+
+  TlvIterator TlvBegin ();
+  ConstTlvIterator TlvBegin () const;
+  TlvIterator TlvEnd ();
+  ConstTlvIterator TlvEnd () const;
+
+  int TlvSize (void) const;
+  bool TlvEmpty (void) const;
+
+  Ptr<Tlv> TlvFront (void);
+  const Ptr<Tlv> TlvFront (void) const;
+  Ptr<Tlv> TlvBack (void);
+  const Ptr<Tlv> TlvBack (void) const;
+
+  void TlvPushFront (Ptr<Tlv> tlv);
+  void TlvPopFront (void);
+  void TlvPushBack (Ptr<Tlv> tlv);
+  void TlvPopBack (void);
+
+  TlvIterator TlvErase (TlvIterator position);
+  TlvIterator TlvErase (TlvIterator first, TlvIterator last);
+  void TlvClear (void);
+
+  /* Manipulating Address Block and Address TLV pairs */
+
+  AddressBlockIterator AddressBlockBegin ();
+  ConstAddressBlockIterator AddressBlockBegin () const;
+  AddressBlockIterator AddressBlockEnd ();
+  ConstAddressBlockIterator AddressBlockEnd () const;
+
+  int AddressBlockSize (void) const;
+  bool AddressBlockEmpty (void) const;
+
+  Ptr<AddressBlock> AddressBlockFront (void);
+  const Ptr<AddressBlock> AddressBlockFront (void) const;
+  Ptr<AddressBlock> AddressBlockBack (void);
+  const Ptr<AddressBlock> AddressBlockBack (void) const;
+
+  void AddressBlockPushFront (Ptr<AddressBlock> block);
+  void AddressBlockPopFront (void);
+  void AddressBlockPushBack (Ptr<AddressBlock> block);
+  void AddressBlockPopBack (void);
+
+  AddressBlockIterator AddressBlockErase (AddressBlockIterator position);
+  AddressBlockIterator AddressBlockErase (AddressBlockIterator first,
+      AddressBlockIterator last);
+  void AddressBlockClear (void);
+
+  /* Smart pointer methods */
+  void Ref (void) const;
+  void Unref (void) const;
+
+  static Ptr<Message> DeserializeMessage (Buffer::Iterator &start) throw (PacketBBError);
+  uint32_t GetSerializedSize (void) const;
+  void Serialize (Buffer::Iterator &start) const;
+  void Deserialize (Buffer::Iterator &start);
+  void Print (std::ostream &os) const;
+  void Print (std::ostream &os, int level) const;
+
+  bool operator== (const Message &other) const;
+  bool operator!= (const Message &other) const;
+
+protected:
+  /* Message size in bytes - 1.
+   *
+   * IPv4 = 4 - 1 = 3, IPv6 = 16 - 1 = 15
+   */
+  virtual AddressLength GetAddressLength (void) const = 0;
+
+  virtual void SerializeOriginatorAddress (Buffer::Iterator &start) const = 0;
+  virtual Address DeserializeOriginatorAddress (Buffer::Iterator &start) const = 0;
+  virtual void PrintOriginatorAddress (std::ostream &os) const = 0;
+
+  virtual Ptr<AddressBlock> AddressBlockDeserialize (Buffer::Iterator &start) const = 0;
+
+private:
+  TlvBlock m_tlvList;
+  std::list< Ptr<AddressBlock> > m_addressBlockList;
+
+  uint8_t m_type;
+  AddressLength m_addrSize;
+
+  bool m_hasOriginatorAddress;
+  Address m_originatorAddress;
+
+  bool m_hasHopLimit;
+  uint8_t m_hopLimit;
+
+  bool m_hasHopCount;
+  uint8_t m_hopCount;
+
+  bool m_hasSequenceNumber;
+  uint16_t m_sequenceNumber;
+
+  mutable uint32_t m_refCount;
+};
+
+class MessageIpv4 : public Message {
+protected:
+  virtual AddressLength GetAddressLength (void) const;
+
+  virtual void SerializeOriginatorAddress (Buffer::Iterator &start) const;
+  virtual Address DeserializeOriginatorAddress (Buffer::Iterator &start) const;
+  virtual void PrintOriginatorAddress (std::ostream &os) const;
+
+  virtual Ptr<AddressBlock> AddressBlockDeserialize (Buffer::Iterator &start) const;
+};
+
+class MessageIpv6 : public Message {
+protected:
+  virtual AddressLength GetAddressLength (void) const;
+
+  virtual void SerializeOriginatorAddress (Buffer::Iterator &start) const;
+  virtual Address DeserializeOriginatorAddress (Buffer::Iterator &start) const;
+  virtual void PrintOriginatorAddress (std::ostream &os) const;
+
+  virtual Ptr<AddressBlock> AddressBlockDeserialize (Buffer::Iterator &start) const;
+};
+
+/** This combines address blocks with their associated TLVs */
+class AddressBlock
+{
+public:
+  typedef std::list< Address >::iterator AddressIterator;
+  typedef std::list< Address >::const_iterator ConstAddressIterator;
+
+  typedef std::list<uint8_t>::iterator PrefixIterator;
+  typedef std::list<uint8_t>::const_iterator ConstPrefixIterator;
+
+  typedef AddressTlvBlock::Iterator TlvIterator;
+  typedef AddressTlvBlock::ConstIterator ConstTlvIterator;
+
+  AddressBlock ();
+
+  /* Manipulating the address block */
+
+  AddressIterator AddressBegin (void);
+  ConstAddressIterator AddressBegin (void) const;
+  AddressIterator AddressEnd (void);
+  ConstAddressIterator AddressEnd (void) const;
+
+  int AddressSize (void) const;
+  bool AddressEmpty (void) const;
+
+  Address AddressFront (void) const;
+  Address AddressBack (void) const;
+
+  void AddressPushFront (Address address);
+  void AddressPopFront (void);
+
+  void AddressPushBack (Address address);
+  void AddressPopBack (void);
+
+  AddressIterator AddressInsert (AddressIterator position,
+      const Address value);
+
+  AddressIterator AddressErase (AddressIterator position);
+  AddressIterator AddressErase (AddressIterator first, AddressIterator last);
+
+  void AddressClear (void);
+
+  /* Prefix methods */
+  PrefixIterator PrefixBegin (void);
+  ConstPrefixIterator PrefixBegin (void) const;
+  PrefixIterator PrefixEnd (void);
+  ConstPrefixIterator PrefixEnd (void) const;
+
+  int PrefixSize (void) const;
+  bool PrefixEmpty (void) const;
+
+  uint8_t PrefixFront (void) const;
+  uint8_t PrefixBack (void) const;
+
+  void PrefixPushFront (uint8_t prefix);
+  void PrefixPopFront (void);
+
+  void PrefixPushBack (uint8_t prefix);
+  void PrefixPopBack (void);
+
+  PrefixIterator PrefixInsert (PrefixIterator position, const uint8_t value);
+
+  PrefixIterator PrefixErase (PrefixIterator position);
+  PrefixIterator PrefixErase (PrefixIterator first, PrefixIterator last);
+
+  void PrefixClear (void);
+
+  /* Manipulating the TLV block */
+  TlvIterator TlvBegin (void);
+  ConstTlvIterator TlvBegin (void) const;
+  TlvIterator TlvEnd (void);
+  ConstTlvIterator TlvEnd (void) const;
+
+  int TlvSize (void) const;
+  bool TlvEmpty (void) const;
+
+  Ptr<AddressTlv> TlvFront (void);
+  const Ptr<AddressTlv> TlvFront (void) const;
+  Ptr<AddressTlv> TlvBack (void);
+  const Ptr<AddressTlv> TlvBack (void) const;
+
+  void TlvPushFront (Ptr<AddressTlv> address);
+  void TlvPopFront (void);
+
+  void TlvPushBack (Ptr<AddressTlv> address);
+  void TlvPopBack (void);
+
+  TlvIterator TlvInsert (TlvIterator position, const Ptr<Tlv> value);
+
+  TlvIterator TlvErase (TlvIterator position);
+  TlvIterator TlvErase (TlvIterator first, TlvIterator last);
+
+  void TlvClear (void);
+
+  /* Smart pointer methods */
+  void Ref (void) const;
+  void Unref (void) const;
+
+  uint32_t GetSerializedSize (void) const;
+  void Serialize (Buffer::Iterator &start) const;
+  void Deserialize (Buffer::Iterator &start);
+  void Print (std::ostream &os) const;
+  void Print (std::ostream &os, int level) const;
+
+  bool operator== (const AddressBlock &other) const;
+  bool operator!= (const AddressBlock &other) const;
+
+protected:
+  virtual uint8_t GetAddressLength (void) const = 0;
+
+  virtual void SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const = 0;
+  virtual Address DeserializeAddress (uint8_t *buffer) const = 0;
+  virtual void PrintAddress (std::ostream &os, ConstAddressIterator iter) const = 0;
+
+private:
+  uint8_t GetPrefixFlags (void) const;
+  void GetHeadTail (uint8_t *head, uint8_t &headlen,
+      uint8_t *tail, uint8_t &taillen) const;
+  bool HasZeroTail (const uint8_t *tail, uint8_t taillen) const;
+
+  std::list<Address> m_addressList;
+  std::list<uint8_t> m_prefixList;
+  AddressTlvBlock m_addressTlvList;
+
+  mutable uint32_t m_refCount;
+};
+
+class AddressBlockIpv4 : public AddressBlock
+{
+protected:
+  virtual uint8_t GetAddressLength (void) const;
+
+  virtual void SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const;
+  virtual Address DeserializeAddress (uint8_t *buffer) const;
+  virtual void PrintAddress (std::ostream &os, ConstAddressIterator iter) const;
+};
+
+class AddressBlockIpv6 : public AddressBlock
+{
+protected:
+  virtual uint8_t GetAddressLength (void) const;
+
+  virtual void SerializeAddress (uint8_t *buffer, ConstAddressIterator iter) const;
+  virtual Address DeserializeAddress (uint8_t *buffer) const;
+  virtual void PrintAddress (std::ostream &os, ConstAddressIterator iter) const;
+};
+
+/** A packet or message TLV */
+class Tlv
+{
+public:
+  Tlv (void);
+
+  void SetType (uint8_t type);
+  uint8_t GetType (void) const;
+
+  void SetTypeExt (uint8_t type);
+  uint8_t GetTypeExt (void) const throw (PacketBBError);
+  bool HasTypeExt (void) const;
+
+  void SetValue (Buffer start);
+  void SetValue (const uint8_t * buffer, uint32_t size);
+  Buffer GetValue (void) const throw (PacketBBError);
+  bool HasValue (void) const;
+
+  /* Smart pointer methods */
+  void Ref (void) const;
+  void Unref (void) const;
+
+  uint32_t GetSerializedSize (void) const;
+  void Serialize (Buffer::Iterator &start) const;
+  void Deserialize (Buffer::Iterator &start);
+  void Print (std::ostream &os) const;
+  void Print (std::ostream &os, int level) const;
+
+  bool operator== (const Tlv &other) const;
+  bool operator!= (const Tlv &other) const;
+
+protected:
+  void SetIndexStart (uint8_t index);
+  uint8_t GetIndexStart (void) const throw (PacketBBError);
+  bool HasIndexStart (void) const;
+
+  void SetIndexStop (uint8_t index);
+  uint8_t GetIndexStop (void) const throw (PacketBBError);
+  bool HasIndexStop (void) const;
+
+  void SetMultivalue (bool isMultivalue);
+  bool IsMultivalue (void) const;
+
+private:
+  uint8_t m_type;
+
+  bool m_hasTypeExt;
+  uint8_t m_typeExt;
+
+  bool m_hasIndexStart;
+  uint8_t m_indexStart;
+
+  bool m_hasIndexStop;
+  uint8_t m_indexStop;
+
+  bool m_isMultivalue;
+  bool m_hasValue;
+  Buffer m_value;
+
+  mutable uint32_t m_refCount;
+};
+
+class AddressTlv : public Tlv
+{
+public:
+  void SetIndexStart (uint8_t index);
+  uint8_t GetIndexStart (void) const throw (PacketBBError);
+  bool HasIndexStart (void) const;
+
+  void SetIndexStop (uint8_t index);
+  uint8_t GetIndexStop (void) const throw (PacketBBError);
+  bool HasIndexStop (void) const;
+
+  void SetMultivalue (bool isMultivalue);
+  bool IsMultivalue (void) const;
+};
+
+} /* namespace pbb */
+
+} /* namespace ns3 */
+
+#endif /* PACKETBB_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/contrib/test-packetbb.cc	Thu Aug 13 23:30:03 2009 -0400
@@ -0,0 +1,3861 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* vim: set ts=2 sw=2 expandtab: */
+/* 
+ * Copyright (c) 2009 Drexel University
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ * Author: Tom Wambold <tom5760@gmail.com>
+ */
+/** TODO: Find out why msg-addr-length is set to 0 in tests */
+
+#include <iostream>
+
+#include "ns3/ptr.h"
+#include "ns3/ipv4-address.h"
+#include "ns3/ipv6-address.h"
+#include "ns3/packetbb.h"
+
+using namespace std;
+using namespace ns3;
+using namespace ns3::pbb;
+
+class PacketBBTester
+{
+public:
+  PacketBBTester (int testnum, PacketBB &reference, const uint8_t * buffer, uint32_t size) :
+    m_refPacket(reference)
+  {
+    m_refBuffer.AddAtStart (size);
+    m_refBuffer.Begin ().Write (buffer, size);
+
+    cout << "Test " << testnum << " - ";
+    Test ();
+  }
+
+  void Test (void)
+  {
+    if (TestSerialize ())
+      cout << "Serialize Pass, ";
+    else
+      cout << "Serialize Fail, ";
+
+    if (TestDeserialize ())
+      cout << "Deserialize Pass, ";
+    else
+      cout << "Deserialize Fail, ";
+
+    if (TestConsistency ())
+      cout << "Consistency Pass" << endl;
+    else
+      cout << "Consistency Fail" << endl;
+  }
+
+  bool TestSerialize (void)
+  {
+    Buffer newBuffer;
+    try
+    {
+      newBuffer.AddAtStart (m_refPacket.GetSerializedSize ());
+      m_refPacket.Serialize (newBuffer.Begin ());
+    } 
+    catch (PacketBBError &e)
+    {
+      cout << endl << "Exception: " << e.what () << endl;
+      return false;
+    }
+    return CompareBuffers (m_refBuffer, newBuffer);
+  }
+
+  bool TestDeserialize (void)
+  {
+    PacketBB newPacket;
+    try
+    {
+      newPacket.Deserialize (m_refBuffer.Begin ());
+    } 
+    catch (PacketBBError &e)
+    {
+      cout << endl << "Exception: " << e.what () << endl;
+      return false;
+    }
+    return m_refPacket == newPacket;
+  }
+
+  bool TestConsistency (void)
+  {
+    Buffer newBuffer;
+    PacketBB newPacket;
+    try
+    {
+      newBuffer.AddAtStart (m_refPacket.GetSerializedSize ());
+      m_refPacket.Serialize (newBuffer.Begin ());
+      newPacket.Deserialize (newBuffer.Begin ());
+    } 
+    catch (PacketBBError &e)
+    {
+      cout << endl << "Exception: " << e.what () << endl;
+      return false;
+    }
+    return m_refPacket == newPacket;
+  }
+
+
+private:
+  static bool CompareBuffers (Buffer a, Buffer b)
+  {
+    const uint8_t * abuf = a.PeekData ();
+    const uint8_t * bbuf = b.PeekData ();
+
+    for (unsigned int i = 0; i < a.GetSize (); i++)
+    {
+      if (abuf[i] != bbuf[i])
+        cout << "Difference - [" << i << "] - " << (int)abuf[i] << " - " << (int)bbuf[i] << endl;
+    }
+
+    if (a.GetSize () != b.GetSize ())
+    {
+      cout << "Buffers differ in size: " << a.GetSize () << ", " << b.GetSize() << endl;
+      return false;
+    }
+
+    if (memcmp (a.PeekData (), b.PeekData (), a.GetSize ()) != 0)
+    {
+      return false;
+    }
+
+    return true;
+  }
+
+  Buffer m_refBuffer;
+  PacketBB &m_refPacket;
+};
+
+int main (void)
+{
+  /* These tests are from:
+   * http://interop08.thomasclausen.org/packets-and-dumps.txt
+   */
+  int testnum = 1;
+
+  /* Test 1
+   * 	,------------------
+   * 	|  PACKET
+   * 	|------------------
+   * 	| * Packet version:    0
+   * 	| * Packet flags:  0
+   * 	`------------------
+   */
+  {
+    PacketBB packet;
+    uint8_t buffer[] = {0x00};
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 2
+   * ,------------------
+   * |  PACKET
+   * |------------------
+   * | * Packet version:    0
+   * | * Packet flags:  8
+   * | * Packet seq number: 2
+   * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (2);
+    uint8_t buffer[] = {0x08, 0x00, 0x02};
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 3
+   * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 3
+	 * `------------------
+   * This test has the phastlv flag set to 1 with no tlvs.
+   * I'll come back to this one later.
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (3);
+    uint8_t buffer[] = {0x0c, 0x00, 0x03, 0x00, 0x00};
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+   */
+  std::cout << "Skipping test " << testnum++ << std::endl;
+
+  /* Test 4
+   * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 4
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (4);
+
+    Ptr<Tlv> tlv = Create<Tlv>();
+    tlv->SetType (1);
+
+    packet.TlvPushBack (tlv);
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x04, 0x00,
+      0x02, 0x01, 0x00
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 5
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 5
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    |     - TLV
+	 * |    |         Flags = 128
+	 * |    |         Type = 2; Type ext. = 100; Value = (warning: parameter is NULL)
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (5);
+
+    Ptr<Tlv> tlv1 = Create<Tlv>();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<Tlv> tlv2 = Create<Tlv>();
+    tlv2->SetType (2);
+    tlv2->SetTypeExt (100);
+    packet.TlvPushBack (tlv2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x05, 0x00,
+      0x05, 0x01, 0x00, 0x02,
+      0x80, 0x64
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 6
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 6
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    |     - TLV
+	 * |    |         Flags = 144
+	 * |    |         Type = 2; Type ext. = 100; Value = 01  02  03  04
+	 * |    |                                          
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (6);
+
+    Ptr<Tlv> tlv1 = Create<Tlv>();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<Tlv> tlv2 = Create<Tlv>();
+    tlv2->SetType (2);
+    tlv2->SetTypeExt (100);
+
+    uint8_t tlv2val[] = {1, 2, 3, 4};
+    tlv2->SetValue(tlv2val, sizeof(tlv2val));
+
+    packet.TlvPushBack (tlv2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x06, 0x00,
+      0x0a, 0x01, 0x00, 0x02,
+      0x90, 0x64, 0x04, 0x01,
+      0x02, 0x03, 0x04
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 7
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 7
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    |     - TLV
+	 * |    |         Flags = 152
+	 * |    |         Type = 2; Type ext. = 100; Value = 00  01  02  03
+	 * |    |                                          04  05  06  07
+	 * |    |                                          08  09  0a  0b
+	 * |    |                                          0c  0d  0e  0f
+	 * |    |                                          10  11  12  13
+	 * |    |                                          14  15  16  17
+	 * |    |                                          18  19  1a  1b
+	 * |    |                                          1c  1d  1e  1f
+	 * |    |                                          20  21  22  23
+	 * |    |                                          24  25  26  27
+	 * |    |                                          28  29  2a  2b
+	 * |    |                                          2c  2d  2e  2f
+	 * |    |                                          30  31  32  33
+	 * |    |                                          34  35  36  37
+	 * |    |                                          38  39  3a  3b
+	 * |    |                                          3c  3d  3e  3f
+	 * |    |                                          40  41  42  43
+	 * |    |                                          44  45  46  47
+	 * |    |                                          48  49  4a  4b
+	 * |    |                                          4c  4d  4e  4f
+	 * |    |                                          50  51  52  53
+	 * |    |                                          54  55  56  57
+	 * |    |                                          58  59  5a  5b
+	 * |    |                                          5c  5d  5e  5f
+	 * |    |                                          60  61  62  63
+	 * |    |                                          64  65  66  67
+	 * |    |                                          68  69  6a  6b
+	 * |    |                                          6c  6d  6e  6f
+	 * |    |                                          70  71  72  73
+	 * |    |                                          74  75  76  77
+	 * |    |                                          78  79  7a  7b
+	 * |    |                                          7c  7d  7e  7f
+	 * |    |                                          80  81  82  83
+	 * |    |                                          84  85  86  87
+	 * |    |                                          88  89  8a  8b
+	 * |    |                                          8c  8d  8e  8f
+	 * |    |                                          90  91  92  93
+	 * |    |                                          94  95  96  97
+	 * |    |                                          98  99  9a  9b
+	 * |    |                                          9c  9d  9e  9f
+	 * |    |                                          a0  a1  a2  a3
+	 * |    |                                          a4  a5  a6  a7
+	 * |    |                                          a8  a9  aa  ab
+	 * |    |                                          ac  ad  ae  af
+	 * |    |                                          b0  b1  b2  b3
+	 * |    |                                          b4  b5  b6  b7
+	 * |    |                                          b8  b9  ba  bb
+	 * |    |                                          bc  bd  be  bf
+	 * |    |                                          c0  c1  c2  c3
+	 * |    |                                          c4  c5  c6  c7
+	 * |    |                                          c8  c9  ca  cb
+	 * |    |                                          cc  cd  ce  cf
+	 * |    |                                          d0  d1  d2  d3
+	 * |    |                                          d4  d5  d6  d7
+	 * |    |                                          d8  d9  da  db
+	 * |    |                                          dc  dd  de  df
+	 * |    |                                          e0  e1  e2  e3
+	 * |    |                                          e4  e5  e6  e7
+	 * |    |                                          e8  e9  ea  eb
+	 * |    |                                          ec  ed  ee  ef
+	 * |    |                                          f0  f1  f2  f3
+	 * |    |                                          f4  f5  f6  f7
+	 * |    |                                          f8  f9  fa  fb
+	 * |    |                                          fc  fd  fe  00
+	 * |    |                                          01  02  03  04
+	 * |    |                                          05  06  07  08
+	 * |    |                                          09  0a  0b  0c
+	 * |    |                                          0d  0e  0f  10
+	 * |    |                                          11  12  13  14
+	 * |    |                                          15  16  17  18
+	 * |    |                                          19  1a  1b  1c
+	 * |    |                                          1d  1e  1f  20
+	 * |    |                                          21  22  23  24
+	 * |    |                                          25  26  27  28
+	 * |    |                                          29  2a  2b  2c
+	 * |    |                                          
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (7);
+
+    Ptr<Tlv> tlv1 = Create<Tlv>();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<Tlv> tlv2 = Create<Tlv>();
+    tlv2->SetType (2);
+    tlv2->SetTypeExt (100);
+
+    uint8_t tlv2val[] = {
+      0x00, 0x01, 0x02, 0x03,
+      0x04, 0x05, 0x06, 0x07,
+      0x08, 0x09, 0x0a, 0x0b,
+      0x0c, 0x0d, 0x0e, 0x0f,
+      0x10, 0x11, 0x12, 0x13,
+      0x14, 0x15, 0x16, 0x17,
+      0x18, 0x19, 0x1a, 0x1b,
+      0x1c, 0x1d, 0x1e, 0x1f,
+      0x20, 0x21, 0x22, 0x23,
+      0x24, 0x25, 0x26, 0x27,
+      0x28, 0x29, 0x2a, 0x2b,
+      0x2c, 0x2d, 0x2e, 0x2f,
+      0x30, 0x31, 0x32, 0x33,
+      0x34, 0x35, 0x36, 0x37,
+      0x38, 0x39, 0x3a, 0x3b,
+      0x3c, 0x3d, 0x3e, 0x3f,
+      0x40, 0x41, 0x42, 0x43,
+      0x44, 0x45, 0x46, 0x47,
+      0x48, 0x49, 0x4a, 0x4b,
+      0x4c, 0x4d, 0x4e, 0x4f,
+      0x50, 0x51, 0x52, 0x53,
+      0x54, 0x55, 0x56, 0x57,
+      0x58, 0x59, 0x5a, 0x5b,
+      0x5c, 0x5d, 0x5e, 0x5f,
+      0x60, 0x61, 0x62, 0x63,
+      0x64, 0x65, 0x66, 0x67,
+      0x68, 0x69, 0x6a, 0x6b,
+      0x6c, 0x6d, 0x6e, 0x6f,
+      0x70, 0x71, 0x72, 0x73,
+      0x74, 0x75, 0x76, 0x77,
+      0x78, 0x79, 0x7a, 0x7b,
+      0x7c, 0x7d, 0x7e, 0x7f,
+      0x80, 0x81, 0x82, 0x83,
+      0x84, 0x85, 0x86, 0x87,
+      0x88, 0x89, 0x8a, 0x8b,
+      0x8c, 0x8d, 0x8e, 0x8f,
+      0x90, 0x91, 0x92, 0x93,
+      0x94, 0x95, 0x96, 0x97,
+      0x98, 0x99, 0x9a, 0x9b,
+      0x9c, 0x9d, 0x9e, 0x9f,
+      0xa0, 0xa1, 0xa2, 0xa3,
+      0xa4, 0xa5, 0xa6, 0xa7,
+      0xa8, 0xa9, 0xaa, 0xab,
+      0xac, 0xad, 0xae, 0xaf,
+      0xb0, 0xb1, 0xb2, 0xb3,
+      0xb4, 0xb5, 0xb6, 0xb7,
+      0xb8, 0xb9, 0xba, 0xbb,
+      0xbc, 0xbd, 0xbe, 0xbf,
+      0xc0, 0xc1, 0xc2, 0xc3,
+      0xc4, 0xc5, 0xc6, 0xc7,
+      0xc8, 0xc9, 0xca, 0xcb,
+      0xcc, 0xcd, 0xce, 0xcf,
+      0xd0, 0xd1, 0xd2, 0xd3,
+      0xd4, 0xd5, 0xd6, 0xd7,
+      0xd8, 0xd9, 0xda, 0xdb,
+      0xdc, 0xdd, 0xde, 0xdf,
+      0xe0, 0xe1, 0xe2, 0xe3,
+      0xe4, 0xe5, 0xe6, 0xe7,
+      0xe8, 0xe9, 0xea, 0xeb,
+      0xec, 0xed, 0xee, 0xef,
+      0xf0, 0xf1, 0xf2, 0xf3,
+      0xf4, 0xf5, 0xf6, 0xf7,
+      0xf8, 0xf9, 0xfa, 0xfb,
+      0xfc, 0xfd, 0xfe, 0x00,
+      0x01, 0x02, 0x03, 0x04,
+      0x05, 0x06, 0x07, 0x08,
+      0x09, 0x0a, 0x0b, 0x0c,
+      0x0d, 0x0e, 0x0f, 0x10,
+      0x11, 0x12, 0x13, 0x14,
+      0x15, 0x16, 0x17, 0x18,
+      0x19, 0x1a, 0x1b, 0x1c,
+      0x1d, 0x1e, 0x1f, 0x20,
+      0x21, 0x22, 0x23, 0x24,
+      0x25, 0x26, 0x27, 0x28,
+      0x29, 0x2a, 0x2b, 0x2c
+    };
+    tlv2->SetValue(tlv2val, sizeof(tlv2val));
+
+    packet.TlvPushBack (tlv2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x07, 0x01,
+      0x33, 0x01, 0x00, 0x02,
+      0x98, 0x64, 0x01, 0x2c,
+      0x00, 0x01, 0x02, 0x03,
+      0x04, 0x05, 0x06, 0x07,
+      0x08, 0x09, 0x0a, 0x0b,
+      0x0c, 0x0d, 0x0e, 0x0f,
+      0x10, 0x11, 0x12, 0x13,
+      0x14, 0x15, 0x16, 0x17,
+      0x18, 0x19, 0x1a, 0x1b,
+      0x1c, 0x1d, 0x1e, 0x1f,
+      0x20, 0x21, 0x22, 0x23,
+      0x24, 0x25, 0x26, 0x27,
+      0x28, 0x29, 0x2a, 0x2b,
+      0x2c, 0x2d, 0x2e, 0x2f,
+      0x30, 0x31, 0x32, 0x33,
+      0x34, 0x35, 0x36, 0x37,
+      0x38, 0x39, 0x3a, 0x3b,
+      0x3c, 0x3d, 0x3e, 0x3f,
+      0x40, 0x41, 0x42, 0x43,
+      0x44, 0x45, 0x46, 0x47,
+      0x48, 0x49, 0x4a, 0x4b,
+      0x4c, 0x4d, 0x4e, 0x4f,
+      0x50, 0x51, 0x52, 0x53,
+      0x54, 0x55, 0x56, 0x57,
+      0x58, 0x59, 0x5a, 0x5b,
+      0x5c, 0x5d, 0x5e, 0x5f,
+      0x60, 0x61, 0x62, 0x63,
+      0x64, 0x65, 0x66, 0x67,
+      0x68, 0x69, 0x6a, 0x6b,
+      0x6c, 0x6d, 0x6e, 0x6f,
+      0x70, 0x71, 0x72, 0x73,
+      0x74, 0x75, 0x76, 0x77,
+      0x78, 0x79, 0x7a, 0x7b,
+      0x7c, 0x7d, 0x7e, 0x7f,
+      0x80, 0x81, 0x82, 0x83,
+      0x84, 0x85, 0x86, 0x87,
+      0x88, 0x89, 0x8a, 0x8b,
+      0x8c, 0x8d, 0x8e, 0x8f,
+      0x90, 0x91, 0x92, 0x93,
+      0x94, 0x95, 0x96, 0x97,
+      0x98, 0x99, 0x9a, 0x9b,
+      0x9c, 0x9d, 0x9e, 0x9f,
+      0xa0, 0xa1, 0xa2, 0xa3,
+      0xa4, 0xa5, 0xa6, 0xa7,
+      0xa8, 0xa9, 0xaa, 0xab,
+      0xac, 0xad, 0xae, 0xaf,
+      0xb0, 0xb1, 0xb2, 0xb3,
+      0xb4, 0xb5, 0xb6, 0xb7,
+      0xb8, 0xb9, 0xba, 0xbb,
+      0xbc, 0xbd, 0xbe, 0xbf,
+      0xc0, 0xc1, 0xc2, 0xc3,
+      0xc4, 0xc5, 0xc6, 0xc7,
+      0xc8, 0xc9, 0xca, 0xcb,
+      0xcc, 0xcd, 0xce, 0xcf,
+      0xd0, 0xd1, 0xd2, 0xd3,
+      0xd4, 0xd5, 0xd6, 0xd7,
+      0xd8, 0xd9, 0xda, 0xdb,
+      0xdc, 0xdd, 0xde, 0xdf,
+      0xe0, 0xe1, 0xe2, 0xe3,
+      0xe4, 0xe5, 0xe6, 0xe7,
+      0xe8, 0xe9, 0xea, 0xeb,
+      0xec, 0xed, 0xee, 0xef,
+      0xf0, 0xf1, 0xf2, 0xf3,
+      0xf4, 0xf5, 0xf6, 0xf7,
+      0xf8, 0xf9, 0xfa, 0xfb,
+      0xfc, 0xfd, 0xfe, 0x00,
+      0x01, 0x02, 0x03, 0x04,
+      0x05, 0x06, 0x07, 0x08,
+      0x09, 0x0a, 0x0b, 0x0c,
+      0x0d, 0x0e, 0x0f, 0x10,
+      0x11, 0x12, 0x13, 0x14,
+      0x15, 0x16, 0x17, 0x18,
+      0x19, 0x1a, 0x1b, 0x1c,
+      0x1d, 0x1e, 0x1f, 0x20,
+      0x21, 0x22, 0x23, 0x24,
+      0x25, 0x26, 0x27, 0x28,
+      0x29, 0x2a, 0x2b, 0x2c
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 8
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 8
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    `-------------------
+	 * |
+	 * `------------------
+  */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (8);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+    packet.MessagePushBack (msg1);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x06, 0x00,
+      0x00
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 9
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 9
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  128
+	 * |    | * Originator address: 10.0.0.1
+	 * |    `-------------------
+	 * |
+	 * `------------------
+  */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (9);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1"));
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x09, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x06, 0x00,
+      0x00, 0x02, 0x83, 0x00,   /* [14] used to be 0x80 */
+      0x0a, 0x0a, 0x00, 0x00,
+      0x01, 0x00, 0x00
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 10
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 10
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  160
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop count:          1
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (10);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1"));
+    msg2->SetHopCount (1);
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x0a, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x06, 0x00,
+      0x00, 0x02, 0xa3, 0x00,     /* [14] used to be 0xa0 */
+      0x0b, 0x0a, 0x00, 0x00,
+      0x01, 0x01, 0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 11
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 11
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  224
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (11);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x0b, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x06, 0x00,
+      0x00, 0x02, 0xe3, 0x00,   /* [14] used to be 0xe0 */
+      0x0c, 0x0a, 0x00, 0x00,
+      0x01, 0xff, 0x01, 0x00,
+      0x00
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 12
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 12
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (12);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x0c, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x06, 0x00,
+      0x00, 0x02, 0xf3, 0x00,   /* [14] - 0xf0 */
+      0x0e, 0x0a, 0x00, 0x00,
+      0x01, 0xff, 0x01, 0x30,
+      0x39, 0x00, 0x00
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 13
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 13
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (13);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x0d, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x06, 0x00,
+      0x00, 0x02, 0xf3, 0x00,   /* [14] - 0xf0 */
+      0x0e, 0x0a, 0x00, 0x00,
+      0x01, 0xff, 0x01, 0x30,
+      0x39, 0x00, 0x00
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 14
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 14
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (14);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x0e, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x0e, 0x0a,  /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 15
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 15
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (1 addresses)
+	 * |    |     - 0.0.0.0/32
+	 * |    |     - Flags = 0
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (15);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("0.0.0.0"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x0f, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x16, 0x0a,    /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x01, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 16
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 16
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (1 addresses)
+	 * |    |     - 255.255.255.255/32
+	 * |    |     - Flags = 0
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (16);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("255.255.255.255"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x10, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x16, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x01, 0x00, 0xff,
+      0xff, 0xff, 0xff, 0x00,
+      0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 17
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 17
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (1 addresses)
+	 * |    |     - 0.0.0.1/32
+	 * |    |     - Flags = 0
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (17);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("0.0.0.1"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x11, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x16, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x01, 0x00, 0x00,
+      0x00, 0x00, 0x01, 0x00,
+      0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 18
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 18
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (1 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - Flags = 0
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (18);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x12, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x16, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x01, 0x00, 0x0a,
+      0x00, 0x00, 0x00, 0x00,
+      0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 19
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 19
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (1 addresses)
+	 * |    |     - 10.0.0.1/32
+	 * |    |     - Flags = 0
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (19);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.1"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x13, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x16, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x01, 0x00, 0x0a,
+      0x00, 0x00, 0x01, 0x00,
+      0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 20
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 20
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.1/32
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - Flags = 128
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (20);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.1"));
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x14, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x18, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0x80, 0x03,
+      0x0a, 0x00, 0x00, 0x01,
+      0x02, 0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 21
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 21
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (21);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    msg2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x15, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x1a, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 22
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 22
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - 11.0.0.0/32
+	 * |    |     - Flags = 32
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (22);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    msg2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    Ptr<AddressBlockIpv4> msg2a2 = Create<AddressBlockIpv4> ();
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("11.0.0.0"));
+    msg2->AddressBlockPushBack (msg2a2);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x16, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x21, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00, 0x02, 0x20, 0x03,
+      0x0a, 0x0b, 0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 23
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 23
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - 11.0.0.0/32
+	 * |    |     - 10.0.0.5/16
+	 * |    |     - 10.0.0.6/24
+	 * |    |     - Flags = 8
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (23);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    msg2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    Ptr<AddressBlockIpv4> msg2a2 = Create<AddressBlockIpv4> ();
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("11.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.5"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.6"));
+
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (16);
+    msg2a2->PrefixPushBack (24);
+
+    msg2->AddressBlockPushBack (msg2a2);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x17, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x32, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00, 0x04, 0x08, 0x0a,
+      0x00, 0x00, 0x00, 0x0b,
+      0x00, 0x00, 0x00, 0x0a,
+      0x00, 0x00, 0x05, 0x0a,
+      0x00, 0x00, 0x06, 0x20,
+      0x20, 0x10, 0x18, 0x00,
+      0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 24
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 24
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - 11.0.0.0/32
+	 * |    |     - 10.0.0.5/16
+	 * |    |     - 10.0.0.6/24
+	 * |    |     - Flags = 8
+	 * |    | - ADDRESS TLV block (1 TLVs)
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (24);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    msg2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    Ptr<AddressBlockIpv4> msg2a2 = Create<AddressBlockIpv4> ();
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("11.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.5"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.6"));
+
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (16);
+    msg2a2->PrefixPushBack (24);
+
+    Ptr<AddressTlv> msg2a2tlv1 = Create<AddressTlv> ();
+    msg2a2tlv1->SetType (1);
+    msg2a2->TlvPushBack (msg2a2tlv1);
+
+    msg2->AddressBlockPushBack (msg2a2);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x18, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x34, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00, 0x04, 0x08, 0x0a,
+      0x00, 0x00, 0x00, 0x0b,
+      0x00, 0x00, 0x00, 0x0a,
+      0x00, 0x00, 0x05, 0x0a,
+      0x00, 0x00, 0x06, 0x20,
+      0x20, 0x10, 0x18, 0x00,
+      0x02, 0x01, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 25
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 25
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - 11.0.0.0/32
+	 * |    |     - 10.0.0.5/16
+	 * |    |     - 10.0.0.6/24
+	 * |    |     - Flags = 8
+	 * |    | - ADDRESS TLV block (1 TLVs)
+	 * |    |     - TLV
+	 * |    |         Flags = 64
+	 * |    |         Index-start = 1
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (25);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    msg2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    Ptr<AddressBlockIpv4> msg2a2 = Create<AddressBlockIpv4> ();
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("11.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.5"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.6"));
+
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (16);
+    msg2a2->PrefixPushBack (24);
+
+    Ptr<AddressTlv> msg2a2tlv1 = Create<AddressTlv> ();
+    msg2a2tlv1->SetType (1);
+    msg2a2tlv1->SetIndexStart (1);
+    msg2a2->TlvPushBack (msg2a2tlv1);
+
+    msg2->AddressBlockPushBack (msg2a2);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x19, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x35, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00, 0x04, 0x08, 0x0a,
+      0x00, 0x00, 0x00, 0x0b,
+      0x00, 0x00, 0x00, 0x0a,
+      0x00, 0x00, 0x05, 0x0a,
+      0x00, 0x00, 0x06, 0x20,
+      0x20, 0x10, 0x18, 0x00,
+      0x03, 0x01, 0x40, 0x01,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 26
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 26
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - 11.0.0.0/32
+	 * |    |     - 10.0.0.5/16
+	 * |    |     - 10.0.0.6/24
+	 * |    |     - Flags = 8
+	 * |    | - ADDRESS TLV block (1 TLVs)
+	 * |    |     - TLV
+	 * |    |         Flags = 32
+	 * |    |         Index-start = 1
+	 * |    |         Index-stop = 3
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (26);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    msg2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    Ptr<AddressBlockIpv4> msg2a2 = Create<AddressBlockIpv4> ();
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("11.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.5"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.6"));
+
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (16);
+    msg2a2->PrefixPushBack (24);
+
+    Ptr<AddressTlv> msg2a2tlv1 = Create<AddressTlv> ();
+    msg2a2tlv1->SetType (1);
+    msg2a2tlv1->SetIndexStart (1);
+    msg2a2tlv1->SetIndexStop (3);
+    msg2a2->TlvPushBack (msg2a2tlv1);
+
+    msg2->AddressBlockPushBack (msg2a2);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x1a, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x36, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00, 0x04, 0x08, 0x0a,
+      0x00, 0x00, 0x00, 0x0b,
+      0x00, 0x00, 0x00, 0x0a,
+      0x00, 0x00, 0x05, 0x0a,
+      0x00, 0x00, 0x06, 0x20,
+      0x20, 0x10, 0x18, 0x00,
+      0x04, 0x01, 0x20, 0x01,
+      0x03,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 27
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 27
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - 11.0.0.0/32
+	 * |    |     - 10.0.0.5/16
+	 * |    |     - 10.0.0.6/24
+	 * |    |     - Flags = 8
+	 * |    | - ADDRESS TLV block (1 TLVs)
+	 * |    |     - TLV
+	 * |    |         Flags = 52
+	 * |    |         Index-start = 1
+	 * |    |         Index-stop = 3
+	 * |    |         Type = 1; Value = 01  02  03
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (27);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    msg2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    Ptr<AddressBlockIpv4> msg2a2 = Create<AddressBlockIpv4> ();
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("11.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.5"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.6"));
+
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (16);
+    msg2a2->PrefixPushBack (24);
+
+    Ptr<AddressTlv> msg2a2tlv1 = Create<AddressTlv> ();
+    msg2a2tlv1->SetType (1);
+    msg2a2tlv1->SetIndexStart (1);
+    msg2a2tlv1->SetIndexStop (3);
+
+    uint8_t value[] = {1, 2, 3};
+    msg2a2tlv1->SetValue(value, sizeof (value));
+    msg2a2tlv1->SetMultivalue (true);
+
+    msg2a2->TlvPushBack (msg2a2tlv1);
+
+    msg2->AddressBlockPushBack (msg2a2);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x1b, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x00, 0x3a, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00, 0x04, 0x08, 0x0a,
+      0x00, 0x00, 0x00, 0x0b,
+      0x00, 0x00, 0x00, 0x0a,
+      0x00, 0x00, 0x05, 0x0a,
+      0x00, 0x00, 0x06, 0x20,
+      0x20, 0x10, 0x18, 0x00,
+      0x08, 0x01, 0x34, 0x01,
+      0x03, 0x03, 0x01, 0x02,
+      0x03,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 28
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 28
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - 11.0.0.0/32
+	 * |    |     - 10.0.0.5/16
+	 * |    |     - 10.0.0.6/24
+	 * |    |     - Flags = 8
+	 * |    | - ADDRESS TLV block (1 TLVs)
+	 * |    |     - TLV
+	 * |    |         Flags = 56
+	 * |    |         Index-start = 1
+	 * |    |         Index-stop = 3
+	 * |    |         Type = 1; Value = 00  01  02  03
+	 * |    |                                          04  05  06  07
+	 * |    |                                          08  09  0a  0b
+	 * |    |                                          0c  0d  0e  0f
+	 * |    |                                          10  11  12  13
+	 * |    |                                          14  15  16  17
+	 * |    |                                          18  19  1a  1b
+	 * |    |                                          1c  1d  1e  1f
+	 * |    |                                          20  21  22  23
+	 * |    |                                          24  25  26  27
+	 * |    |                                          28  29  2a  2b
+	 * |    |                                          2c  2d  2e  2f
+	 * |    |                                          30  31  32  33
+	 * |    |                                          34  35  36  37
+	 * |    |                                          38  39  3a  3b
+	 * |    |                                          3c  3d  3e  3f
+	 * |    |                                          40  41  42  43
+	 * |    |                                          44  45  46  47
+	 * |    |                                          48  49  4a  4b
+	 * |    |                                          4c  4d  4e  4f
+	 * |    |                                          50  51  52  53
+	 * |    |                                          54  55  56  57
+	 * |    |                                          58  59  5a  5b
+	 * |    |                                          5c  5d  5e  5f
+	 * |    |                                          60  61  62  63
+	 * |    |                                          64  65  66  67
+	 * |    |                                          68  69  6a  6b
+	 * |    |                                          6c  6d  6e  6f
+	 * |    |                                          70  71  72  73
+	 * |    |                                          74  75  76  77
+	 * |    |                                          78  79  7a  7b
+	 * |    |                                          7c  7d  7e  7f
+	 * |    |                                          80  81  82  83
+	 * |    |                                          84  85  86  87
+	 * |    |                                          88  89  8a  8b
+	 * |    |                                          8c  8d  8e  8f
+	 * |    |                                          90  91  92  93
+	 * |    |                                          94  95  96  97
+	 * |    |                                          98  99  9a  9b
+	 * |    |                                          9c  9d  9e  9f
+	 * |    |                                          a0  a1  a2  a3
+	 * |    |                                          a4  a5  a6  a7
+	 * |    |                                          a8  a9  aa  ab
+	 * |    |                                          ac  ad  ae  af
+	 * |    |                                          b0  b1  b2  b3
+	 * |    |                                          b4  b5  b6  b7
+	 * |    |                                          b8  b9  ba  bb
+	 * |    |                                          bc  bd  be  bf
+	 * |    |                                          c0  c1  c2  c3
+	 * |    |                                          c4  c5  c6  c7
+	 * |    |                                          c8  c9  ca  cb
+	 * |    |                                          cc  cd  ce  cf
+	 * |    |                                          d0  d1  d2  d3
+	 * |    |                                          d4  d5  d6  d7
+	 * |    |                                          d8  d9  da  db
+	 * |    |                                          dc  dd  de  df
+	 * |    |                                          e0  e1  e2  e3
+	 * |    |                                          e4  e5  e6  e7
+	 * |    |                                          e8  e9  ea  eb
+	 * |    |                                          ec  ed  ee  ef
+	 * |    |                                          f0  f1  f2  f3
+	 * |    |                                          f4  f5  f6  f7
+	 * |    |                                          f8  f9  fa  fb
+	 * |    |                                          fc  fd  fe  00
+	 * |    |                                          01  02  03  04
+	 * |    |                                          05  06  07  08
+	 * |    |                                          09  0a  0b  0c
+	 * |    |                                          0d  0e  0f  10
+	 * |    |                                          11  12  13  14
+	 * |    |                                          15  16  17  18
+	 * |    |                                          19  1a  1b  1c
+	 * |    |                                          1d  1e  1f  20
+	 * |    |                                          21  22  23  24
+	 * |    |                                          25  26  27  28
+	 * |    |                                          29  2a  2b  2c
+	 * |    |                                          
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (28);
+
+    Ptr<Tlv> tlv1 = Create<Tlv> ();
+    tlv1->SetType (1);
+    packet.TlvPushBack (tlv1);
+
+    Ptr<MessageIpv4> msg1 = Create<MessageIpv4> ();
+    msg1->SetType (1);
+
+    Ptr<Tlv> msg1tlv1 = Create<Tlv> ();
+    msg1tlv1->SetType (1);
+    msg1->TlvPushBack (msg1tlv1);
+
+    packet.MessagePushBack (msg1);
+
+    Ptr<MessageIpv4> msg2 = Create<MessageIpv4> ();
+    msg2->SetType (2);
+    msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    msg2->SetHopLimit (255);
+    msg2->SetHopCount (1);
+    msg2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> msg2a1 = Create<AddressBlockIpv4> ();
+    msg2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    msg2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    msg2->AddressBlockPushBack (msg2a1);
+
+    Ptr<AddressBlockIpv4> msg2a2 = Create<AddressBlockIpv4> ();
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("11.0.0.0"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.5"));
+    msg2a2->AddressPushBack (Ipv4Address ("10.0.0.6"));
+
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (32);
+    msg2a2->PrefixPushBack (16);
+    msg2a2->PrefixPushBack (24);
+
+    Ptr<AddressTlv> msg2a2tlv1 = Create<AddressTlv> ();
+    msg2a2tlv1->SetType (1);
+    msg2a2tlv1->SetIndexStart (1);
+    msg2a2tlv1->SetIndexStop (3);
+
+    uint8_t value[] = {
+      0x00, 0x01, 0x02, 0x03,
+      0x04, 0x05, 0x06, 0x07,
+      0x08, 0x09, 0x0a, 0x0b,
+      0x0c, 0x0d, 0x0e, 0x0f,
+      0x10, 0x11, 0x12, 0x13,
+      0x14, 0x15, 0x16, 0x17,
+      0x18, 0x19, 0x1a, 0x1b,
+      0x1c, 0x1d, 0x1e, 0x1f,
+      0x20, 0x21, 0x22, 0x23,
+      0x24, 0x25, 0x26, 0x27,
+      0x28, 0x29, 0x2a, 0x2b,
+      0x2c, 0x2d, 0x2e, 0x2f,
+      0x30, 0x31, 0x32, 0x33,
+      0x34, 0x35, 0x36, 0x37,
+      0x38, 0x39, 0x3a, 0x3b,
+      0x3c, 0x3d, 0x3e, 0x3f,
+      0x40, 0x41, 0x42, 0x43,
+      0x44, 0x45, 0x46, 0x47,
+      0x48, 0x49, 0x4a, 0x4b,
+      0x4c, 0x4d, 0x4e, 0x4f,
+      0x50, 0x51, 0x52, 0x53,
+      0x54, 0x55, 0x56, 0x57,
+      0x58, 0x59, 0x5a, 0x5b,
+      0x5c, 0x5d, 0x5e, 0x5f,
+      0x60, 0x61, 0x62, 0x63,
+      0x64, 0x65, 0x66, 0x67,
+      0x68, 0x69, 0x6a, 0x6b,
+      0x6c, 0x6d, 0x6e, 0x6f,
+      0x70, 0x71, 0x72, 0x73,
+      0x74, 0x75, 0x76, 0x77,
+      0x78, 0x79, 0x7a, 0x7b,
+      0x7c, 0x7d, 0x7e, 0x7f,
+      0x80, 0x81, 0x82, 0x83,
+      0x84, 0x85, 0x86, 0x87,
+      0x88, 0x89, 0x8a, 0x8b,
+      0x8c, 0x8d, 0x8e, 0x8f,
+      0x90, 0x91, 0x92, 0x93,
+      0x94, 0x95, 0x96, 0x97,
+      0x98, 0x99, 0x9a, 0x9b,
+      0x9c, 0x9d, 0x9e, 0x9f,
+      0xa0, 0xa1, 0xa2, 0xa3,
+      0xa4, 0xa5, 0xa6, 0xa7,
+      0xa8, 0xa9, 0xaa, 0xab,
+      0xac, 0xad, 0xae, 0xaf,
+      0xb0, 0xb1, 0xb2, 0xb3,
+      0xb4, 0xb5, 0xb6, 0xb7,
+      0xb8, 0xb9, 0xba, 0xbb,
+      0xbc, 0xbd, 0xbe, 0xbf,
+      0xc0, 0xc1, 0xc2, 0xc3,
+      0xc4, 0xc5, 0xc6, 0xc7,
+      0xc8, 0xc9, 0xca, 0xcb,
+      0xcc, 0xcd, 0xce, 0xcf,
+      0xd0, 0xd1, 0xd2, 0xd3,
+      0xd4, 0xd5, 0xd6, 0xd7,
+      0xd8, 0xd9, 0xda, 0xdb,
+      0xdc, 0xdd, 0xde, 0xdf,
+      0xe0, 0xe1, 0xe2, 0xe3,
+      0xe4, 0xe5, 0xe6, 0xe7,
+      0xe8, 0xe9, 0xea, 0xeb,
+      0xec, 0xed, 0xee, 0xef,
+      0xf0, 0xf1, 0xf2, 0xf3,
+      0xf4, 0xf5, 0xf6, 0xf7,
+      0xf8, 0xf9, 0xfa, 0xfb,
+      0xfc, 0xfd, 0xfe, 0x00,
+      0x01, 0x02, 0x03, 0x04,
+      0x05, 0x06, 0x07, 0x08,
+      0x09, 0x0a, 0x0b, 0x0c,
+      0x0d, 0x0e, 0x0f, 0x10,
+      0x11, 0x12, 0x13, 0x14,
+      0x15, 0x16, 0x17, 0x18,
+      0x19, 0x1a, 0x1b, 0x1c,
+      0x1d, 0x1e, 0x1f, 0x20,
+      0x21, 0x22, 0x23, 0x24,
+      0x25, 0x26, 0x27, 0x28,
+      0x29, 0x2a, 0x2b, 0x2c,
+    };
+    msg2a2tlv1->SetValue(value, sizeof (value));
+
+    msg2a2->TlvPushBack (msg2a2tlv1);
+
+    msg2->AddressBlockPushBack (msg2a2);
+
+    packet.MessagePushBack (msg2);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x1c, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x03, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x01, 0x64, 0x0a,   /* [16] - 0xf0 */
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00, 0x04, 0x08, 0x0a,
+      0x00, 0x00, 0x00, 0x0b,
+      0x00, 0x00, 0x00, 0x0a,
+      0x00, 0x00, 0x05, 0x0a,
+      0x00, 0x00, 0x06, 0x20,
+      0x20, 0x10, 0x18, 0x01,
+      0x32, 0x01, 0x38, 0x01,
+      0x03, 0x01, 0x2c, 0x00,
+      0x01, 0x02, 0x03, 0x04,
+      0x05, 0x06, 0x07, 0x08,
+      0x09, 0x0a, 0x0b, 0x0c,
+      0x0d, 0x0e, 0x0f, 0x10,
+      0x11, 0x12, 0x13, 0x14,
+      0x15, 0x16, 0x17, 0x18,
+      0x19, 0x1a, 0x1b, 0x1c,
+      0x1d, 0x1e, 0x1f, 0x20,
+      0x21, 0x22, 0x23, 0x24,
+      0x25, 0x26, 0x27, 0x28,
+      0x29, 0x2a, 0x2b, 0x2c,
+      0x2d, 0x2e, 0x2f, 0x30,
+      0x31, 0x32, 0x33, 0x34,
+      0x35, 0x36, 0x37, 0x38,
+      0x39, 0x3a, 0x3b, 0x3c,
+      0x3d, 0x3e, 0x3f, 0x40,
+      0x41, 0x42, 0x43, 0x44,
+      0x45, 0x46, 0x47, 0x48,
+      0x49, 0x4a, 0x4b, 0x4c,
+      0x4d, 0x4e, 0x4f, 0x50,
+      0x51, 0x52, 0x53, 0x54,
+      0x55, 0x56, 0x57, 0x58,
+      0x59, 0x5a, 0x5b, 0x5c,
+      0x5d, 0x5e, 0x5f, 0x60,
+      0x61, 0x62, 0x63, 0x64,
+      0x65, 0x66, 0x67, 0x68,
+      0x69, 0x6a, 0x6b, 0x6c,
+      0x6d, 0x6e, 0x6f, 0x70,
+      0x71, 0x72, 0x73, 0x74,
+      0x75, 0x76, 0x77, 0x78,
+      0x79, 0x7a, 0x7b, 0x7c,
+      0x7d, 0x7e, 0x7f, 0x80,
+      0x81, 0x82, 0x83, 0x84,
+      0x85, 0x86, 0x87, 0x88,
+      0x89, 0x8a, 0x8b, 0x8c,
+      0x8d, 0x8e, 0x8f, 0x90,
+      0x91, 0x92, 0x93, 0x94,
+      0x95, 0x96, 0x97, 0x98,
+      0x99, 0x9a, 0x9b, 0x9c,
+      0x9d, 0x9e, 0x9f, 0xa0,
+      0xa1, 0xa2, 0xa3, 0xa4,
+      0xa5, 0xa6, 0xa7, 0xa8,
+      0xa9, 0xaa, 0xab, 0xac,
+      0xad, 0xae, 0xaf, 0xb0,
+      0xb1, 0xb2, 0xb3, 0xb4,
+      0xb5, 0xb6, 0xb7, 0xb8,
+      0xb9, 0xba, 0xbb, 0xbc,
+      0xbd, 0xbe, 0xbf, 0xc0,
+      0xc1, 0xc2, 0xc3, 0xc4,
+      0xc5, 0xc6, 0xc7, 0xc8,
+      0xc9, 0xca, 0xcb, 0xcc,
+      0xcd, 0xce, 0xcf, 0xd0,
+      0xd1, 0xd2, 0xd3, 0xd4,
+      0xd5, 0xd6, 0xd7, 0xd8,
+      0xd9, 0xda, 0xdb, 0xdc,
+      0xdd, 0xde, 0xdf, 0xe0,
+      0xe1, 0xe2, 0xe3, 0xe4,
+      0xe5, 0xe6, 0xe7, 0xe8,
+      0xe9, 0xea, 0xeb, 0xec,
+      0xed, 0xee, 0xef, 0xf0,
+      0xf1, 0xf2, 0xf3, 0xf4,
+      0xf5, 0xf6, 0xf7, 0xf8,
+      0xf9, 0xfa, 0xfb, 0xfc,
+      0xfd, 0xfe, 0x00, 0x01,
+      0x02, 0x03, 0x04, 0x05,
+      0x06, 0x07, 0x08, 0x09,
+      0x0a, 0x0b, 0x0c, 0x0d,
+      0x0e, 0x0f, 0x10, 0x11,
+      0x12, 0x13, 0x14, 0x15,
+      0x16, 0x17, 0x18, 0x19,
+      0x1a, 0x1b, 0x1c, 0x1d,
+      0x1e, 0x1f, 0x20, 0x21,
+      0x22, 0x23, 0x24, 0x25,
+      0x26, 0x27, 0x28, 0x29,
+      0x2a, 0x2b, 0x2c
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 29
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  0
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  1
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+
+    Ptr<MessageIpv6> m1 = Create<MessageIpv6> ();
+    m1->SetType(1);
+
+    packet.MessagePushBack (m1);
+
+    uint8_t buffer[] = {
+      0x00, 0x01, 0x0f, 0x00,
+      0x06, 0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 30
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  0
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  129
+	 * |    | * Originator address: abcd::1
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+
+    Ptr<MessageIpv6> m1 = Create<MessageIpv6> ();
+    m1->SetType(1);
+    m1->SetOriginatorAddress (Ipv6Address("abcd::1"));
+
+    packet.MessagePushBack (m1);
+
+    uint8_t buffer[] = {
+      0x00, 0x01, 0x8f, 0x00,
+      0x16, 0xab, 0xcd, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x01, 0x00, 0x00
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 31
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  0
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  129
+	 * |    | * Originator address: abcd::1
+	 * |    | - Address block (1 addresses)
+	 * |    |     - 10::1/128
+	 * |    |     - Flags = 0
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+
+    Ptr<MessageIpv6> m1 = Create<MessageIpv6> ();
+    m1->SetType(1);
+    m1->SetOriginatorAddress (Ipv6Address("abcd::1"));
+
+    Ptr<AddressBlockIpv6> m1a1 = Create<AddressBlockIpv6> ();
+    m1a1->AddressPushBack (Ipv6Address ("10::1"));
+    m1->AddressBlockPushBack (m1a1);
+
+    packet.MessagePushBack (m1);
+
+    uint8_t buffer[] = {
+      0x00, 0x01, 0x8f, 0x00,
+      0x2a, 0xab, 0xcd, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x01, 0x00, 0x00, 0x01,
+      0x00, 0x00, 0x10, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x01, 0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 32
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  0
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  129
+	 * |    | * Originator address: abcd::1
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10::1/128
+	 * |    |     - 10::2/128
+	 * |    |     - Flags = 128
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+
+    Ptr<MessageIpv6> m1 = Create<MessageIpv6> ();
+    m1->SetType(1);
+    m1->SetOriginatorAddress (Ipv6Address("abcd::1"));
+
+    Ptr<AddressBlockIpv6> m1a1 = Create<AddressBlockIpv6> ();
+    m1a1->AddressPushBack (Ipv6Address ("10::1"));
+    m1a1->AddressPushBack (Ipv6Address ("10::2"));
+    m1->AddressBlockPushBack (m1a1);
+
+    packet.MessagePushBack (m1);
+
+    uint8_t buffer[] = {
+      0x00, 0x01, 0x8f, 0x00,
+      0x2c, 0xab, 0xcd, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x01, 0x00, 0x00, 0x02,
+      0x80, 0x0f, 0x00, 0x10,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x01, 0x02, 0x00,
+      0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 33
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  0
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  129
+	 * |    | * Originator address: abcd::1
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10::2/128
+	 * |    |     - 10::11:2/128
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+
+    Ptr<MessageIpv6> m1 = Create<MessageIpv6> ();
+    m1->SetType(1);
+    m1->SetOriginatorAddress (Ipv6Address("abcd::1"));
+
+    Ptr<AddressBlockIpv6> m1a1 = Create<AddressBlockIpv6> ();
+    m1a1->AddressPushBack (Ipv6Address ("10::2"));
+    m1a1->AddressPushBack (Ipv6Address ("10::11:2"));
+    m1->AddressBlockPushBack (m1a1);
+
+    packet.MessagePushBack (m1);
+
+    uint8_t buffer[] = {
+      0x00, 0x01, 0x8f, 0x00,
+      0x2d, 0xab, 0xcd, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x01, 0x00, 0x00, 0x02,
+      0xc0, 0x0d, 0x00, 0x10,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x02,
+      0x00, 0x02, 0x00, 0x11,
+      0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 34
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  0
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  129
+	 * |    | * Originator address: abcd::1
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10::2/128
+	 * |    |     - 10::11:2/128
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10::/128
+	 * |    |     - 11::/128
+	 * |    |     - Flags = 160
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+
+    Ptr<MessageIpv6> m1 = Create<MessageIpv6> ();
+    m1->SetType(1);
+    m1->SetOriginatorAddress (Ipv6Address("abcd::1"));
+
+    Ptr<AddressBlockIpv6> m1a1 = Create<AddressBlockIpv6> ();
+    m1a1->AddressPushBack (Ipv6Address ("10::2"));
+    m1a1->AddressPushBack (Ipv6Address ("10::11:2"));
+    m1->AddressBlockPushBack (m1a1);
+
+    Ptr<AddressBlockIpv6> m1a2 = Create<AddressBlockIpv6> ();
+    m1a2->AddressPushBack (Ipv6Address ("10::"));
+    m1a2->AddressPushBack (Ipv6Address ("11::"));
+    m1->AddressBlockPushBack (m1a2);
+
+    packet.MessagePushBack (m1);
+
+    uint8_t buffer[] = {
+      0x00, 0x01, 0x8f, 0x00,
+      0x36, 0xab, 0xcd, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x01, 0x00, 0x00, 0x02,
+      0xc0, 0x0d, 0x00, 0x10,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x02,
+      0x00, 0x02, 0x00, 0x11,
+      0x00, 0x00, 0x02, 0xa0,
+      0x01, 0x00, 0x0e, 0x10,
+      0x11, 0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 35
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  0
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  129
+	 * |    | * Originator address: abcd::1
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10::2/128
+	 * |    |     - 10::11:2/128
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10::/128
+	 * |    |     - 11::/128
+	 * |    |     - 10::5/64
+	 * |    |     - 10::6/48
+	 * |    |     - Flags = 136
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+
+    Ptr<MessageIpv6> m1 = Create<MessageIpv6> ();
+    m1->SetType(1);
+    m1->SetOriginatorAddress (Ipv6Address("abcd::1"));
+
+    Ptr<AddressBlockIpv6> m1a1 = Create<AddressBlockIpv6> ();
+    m1a1->AddressPushBack (Ipv6Address ("10::2"));
+    m1a1->AddressPushBack (Ipv6Address ("10::11:2"));
+    m1->AddressBlockPushBack (m1a1);
+
+    Ptr<AddressBlockIpv6> m1a2 = Create<AddressBlockIpv6> ();
+    m1a2->AddressPushBack (Ipv6Address ("10::"));
+    m1a2->AddressPushBack (Ipv6Address ("11::"));
+    m1a2->AddressPushBack (Ipv6Address ("10::5"));
+    m1a2->AddressPushBack (Ipv6Address ("10::6"));
+    m1a2->PrefixPushBack (128);
+    m1a2->PrefixPushBack (128);
+    m1a2->PrefixPushBack (64);
+    m1a2->PrefixPushBack (48);
+    m1->AddressBlockPushBack (m1a2);
+
+    packet.MessagePushBack (m1);
+
+    uint8_t buffer[] = {
+      0x00, 0x01, 0x8f, 0x00,
+      0x73, 0xab, 0xcd, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x01, 0x00, 0x00, 0x02,
+      0xc0, 0x0d, 0x00, 0x10,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x02,
+      0x00, 0x02, 0x00, 0x11,
+      0x00, 0x00, 0x04, 0x88,
+      0x01, 0x00, 0x10, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x11, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x10, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x05, 0x10,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x06, 0x80, 0x80,
+      0x40, 0x30, 0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 36
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 29
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - 11.0.0.0/32
+	 * |    |     - 10.0.0.5/16
+	 * |    |     - 10.0.0.6/24
+	 * |    |     - Flags = 8
+	 * |    | - ADDRESS TLV block (1 TLVs)
+	 * |    |     - TLV
+	 * |    |         Flags = 56
+	 * |    |         Index-start = 1
+	 * |    |         Index-stop = 3
+	 * |    |         Type = 1; Value = 00  01  02  03
+	 * |    |                                          04  05  06  07
+	 * |    |                                          08  09  0a  0b
+	 * |    |                                          0c  0d  0e  0f
+	 * |    |                                          10  11  12  13
+	 * |    |                                          14  15  16  17
+	 * |    |                                          18  19  1a  1b
+	 * |    |                                          1c  1d  1e  1f
+	 * |    |                                          20  21  22  23
+	 * |    |                                          24  25  26  27
+	 * |    |                                          28  29  2a  2b
+	 * |    |                                          2c  2d  2e  2f
+	 * |    |                                          30  31  32  33
+	 * |    |                                          34  35  36  37
+	 * |    |                                          38  39  3a  3b
+	 * |    |                                          3c  3d  3e  3f
+	 * |    |                                          40  41  42  43
+	 * |    |                                          44  45  46  47
+	 * |    |                                          48  49  4a  4b
+	 * |    |                                          4c  4d  4e  4f
+	 * |    |                                          50  51  52  53
+	 * |    |                                          54  55  56  57
+	 * |    |                                          58  59  5a  5b
+	 * |    |                                          5c  5d  5e  5f
+	 * |    |                                          60  61  62  63
+	 * |    |                                          64  65  66  67
+	 * |    |                                          68  69  6a  6b
+	 * |    |                                          6c  6d  6e  6f
+	 * |    |                                          70  71  72  73
+	 * |    |                                          74  75  76  77
+	 * |    |                                          78  79  7a  7b
+	 * |    |                                          7c  7d  7e  7f
+	 * |    |                                          80  81  82  83
+	 * |    |                                          84  85  86  87
+	 * |    |                                          88  89  8a  8b
+	 * |    |                                          8c  8d  8e  8f
+	 * |    |                                          90  91  92  93
+	 * |    |                                          94  95  96  97
+	 * |    |                                          98  99  9a  9b
+	 * |    |                                          9c  9d  9e  9f
+	 * |    |                                          a0  a1  a2  a3
+	 * |    |                                          a4  a5  a6  a7
+	 * |    |                                          a8  a9  aa  ab
+	 * |    |                                          ac  ad  ae  af
+	 * |    |                                          b0  b1  b2  b3
+	 * |    |                                          b4  b5  b6  b7
+	 * |    |                                          b8  b9  ba  bb
+	 * |    |                                          bc  bd  be  bf
+	 * |    |                                          c0  c1  c2  c3
+	 * |    |                                          c4  c5  c6  c7
+	 * |    |                                          c8  c9  ca  cb
+	 * |    |                                          cc  cd  ce  cf
+	 * |    |                                          d0  d1  d2  d3
+	 * |    |                                          d4  d5  d6  d7
+	 * |    |                                          d8  d9  da  db
+	 * |    |                                          dc  dd  de  df
+	 * |    |                                          e0  e1  e2  e3
+	 * |    |                                          e4  e5  e6  e7
+	 * |    |                                          e8  e9  ea  eb
+	 * |    |                                          ec  ed  ee  ef
+	 * |    |                                          f0  f1  f2  f3
+	 * |    |                                          f4  f5  f6  f7
+	 * |    |                                          f8  f9  fa  fb
+	 * |    |                                          fc  fd  fe  00
+	 * |    |                                          01  02  03  04
+	 * |    |                                          05  06  07  08
+	 * |    |                                          09  0a  0b  0c
+	 * |    |                                          0d  0e  0f  10
+	 * |    |                                          11  12  13  14
+	 * |    |                                          15  16  17  18
+	 * |    |                                          19  1a  1b  1c
+	 * |    |                                          1d  1e  1f  20
+	 * |    |                                          21  22  23  24
+	 * |    |                                          25  26  27  28
+	 * |    |                                          29  2a  2b  2c
+	 * |    |                                          
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  129
+	 * |    | * Originator address: abcd::1
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10::2/128
+	 * |    |     - 10::11:2/128
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10::/128
+	 * |    |     - 11::/128
+	 * |    |     - 10::5/64
+	 * |    |     - 10::6/48
+	 * |    |     - Flags = 136
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (29);
+
+    Ptr<Tlv> ptlv1 = Create<Tlv> ();
+    ptlv1->SetType (1);
+    packet.TlvPushBack (ptlv1);
+
+    Ptr<MessageIpv6> m1 = Create<MessageIpv6> ();
+    m1->SetType (1);
+
+    Ptr<Tlv> m1tlv1 = Create<Tlv> ();
+    m1tlv1->SetType (1);
+    m1->TlvPushBack (m1tlv1);
+    packet.MessagePushBack (m1);
+
+    Ptr<MessageIpv4> m2 = Create<MessageIpv4> ();
+    m2->SetType (2);
+    m2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    m2->SetHopLimit (255);
+    m2->SetHopCount (1);
+    m2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> m2a1 = Create<AddressBlockIpv4> ();
+    m2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    m2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    m2->AddressBlockPushBack (m2a1);
+
+    Ptr<AddressBlockIpv4> m2a2 = Create<AddressBlockIpv4> ();
+    m2a2->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    m2a2->AddressPushBack (Ipv4Address ("11.0.0.0"));
+    m2a2->AddressPushBack (Ipv4Address ("10.0.0.5"));
+    m2a2->AddressPushBack (Ipv4Address ("10.0.0.6"));
+    m2a2->PrefixPushBack (32);
+    m2a2->PrefixPushBack (32);
+    m2a2->PrefixPushBack (16);
+    m2a2->PrefixPushBack (24);
+
+    Ptr<AddressTlv> m2a2tlv1 = Create<AddressTlv> ();
+    m2a2tlv1->SetType (1);
+    m2a2tlv1->SetIndexStart (1);
+    m2a2tlv1->SetIndexStop (3);
+
+    uint8_t value[] = {
+      0x00, 0x01, 0x02, 0x03,
+      0x04, 0x05, 0x06, 0x07,
+      0x08, 0x09, 0x0a, 0x0b,
+      0x0c, 0x0d, 0x0e, 0x0f,
+      0x10, 0x11, 0x12, 0x13,
+      0x14, 0x15, 0x16, 0x17,
+      0x18, 0x19, 0x1a, 0x1b,
+      0x1c, 0x1d, 0x1e, 0x1f,
+      0x20, 0x21, 0x22, 0x23,
+      0x24, 0x25, 0x26, 0x27,
+      0x28, 0x29, 0x2a, 0x2b,
+      0x2c, 0x2d, 0x2e, 0x2f,
+      0x30, 0x31, 0x32, 0x33,
+      0x34, 0x35, 0x36, 0x37,
+      0x38, 0x39, 0x3a, 0x3b,
+      0x3c, 0x3d, 0x3e, 0x3f,
+      0x40, 0x41, 0x42, 0x43,
+      0x44, 0x45, 0x46, 0x47,
+      0x48, 0x49, 0x4a, 0x4b,
+      0x4c, 0x4d, 0x4e, 0x4f,
+      0x50, 0x51, 0x52, 0x53,
+      0x54, 0x55, 0x56, 0x57,
+      0x58, 0x59, 0x5a, 0x5b,
+      0x5c, 0x5d, 0x5e, 0x5f,
+      0x60, 0x61, 0x62, 0x63,
+      0x64, 0x65, 0x66, 0x67,
+      0x68, 0x69, 0x6a, 0x6b,
+      0x6c, 0x6d, 0x6e, 0x6f,
+      0x70, 0x71, 0x72, 0x73,
+      0x74, 0x75, 0x76, 0x77,
+      0x78, 0x79, 0x7a, 0x7b,
+      0x7c, 0x7d, 0x7e, 0x7f,
+      0x80, 0x81, 0x82, 0x83,
+      0x84, 0x85, 0x86, 0x87,
+      0x88, 0x89, 0x8a, 0x8b,
+      0x8c, 0x8d, 0x8e, 0x8f,
+      0x90, 0x91, 0x92, 0x93,
+      0x94, 0x95, 0x96, 0x97,
+      0x98, 0x99, 0x9a, 0x9b,
+      0x9c, 0x9d, 0x9e, 0x9f,
+      0xa0, 0xa1, 0xa2, 0xa3,
+      0xa4, 0xa5, 0xa6, 0xa7,
+      0xa8, 0xa9, 0xaa, 0xab,
+      0xac, 0xad, 0xae, 0xaf,
+      0xb0, 0xb1, 0xb2, 0xb3,
+      0xb4, 0xb5, 0xb6, 0xb7,
+      0xb8, 0xb9, 0xba, 0xbb,
+      0xbc, 0xbd, 0xbe, 0xbf,
+      0xc0, 0xc1, 0xc2, 0xc3,
+      0xc4, 0xc5, 0xc6, 0xc7,
+      0xc8, 0xc9, 0xca, 0xcb,
+      0xcc, 0xcd, 0xce, 0xcf,
+      0xd0, 0xd1, 0xd2, 0xd3,
+      0xd4, 0xd5, 0xd6, 0xd7,
+      0xd8, 0xd9, 0xda, 0xdb,
+      0xdc, 0xdd, 0xde, 0xdf,
+      0xe0, 0xe1, 0xe2, 0xe3,
+      0xe4, 0xe5, 0xe6, 0xe7,
+      0xe8, 0xe9, 0xea, 0xeb,
+      0xec, 0xed, 0xee, 0xef,
+      0xf0, 0xf1, 0xf2, 0xf3,
+      0xf4, 0xf5, 0xf6, 0xf7,
+      0xf8, 0xf9, 0xfa, 0xfb,
+      0xfc, 0xfd, 0xfe, 0x00,
+      0x01, 0x02, 0x03, 0x04,
+      0x05, 0x06, 0x07, 0x08,
+      0x09, 0x0a, 0x0b, 0x0c,
+      0x0d, 0x0e, 0x0f, 0x10,
+      0x11, 0x12, 0x13, 0x14,
+      0x15, 0x16, 0x17, 0x18,
+      0x19, 0x1a, 0x1b, 0x1c,
+      0x1d, 0x1e, 0x1f, 0x20,
+      0x21, 0x22, 0x23, 0x24,
+      0x25, 0x26, 0x27, 0x28,
+      0x29, 0x2a, 0x2b, 0x2c,
+    };
+    m2a2tlv1->SetValue (value, sizeof(value));
+    m2a2->TlvPushBack (m2a2tlv1);
+
+    m2->AddressBlockPushBack (m2a2);
+    packet.MessagePushBack (m2);
+
+    Ptr<MessageIpv6> m3 = Create<MessageIpv6> ();
+    m3->SetType (1);
+    m3->SetOriginatorAddress (Ipv6Address ("abcd::1"));
+
+    Ptr<AddressBlockIpv6> m3a1 = Create<AddressBlockIpv6> ();
+    m3a1->AddressPushBack (Ipv6Address ("10::2"));
+    m3a1->AddressPushBack (Ipv6Address ("10::11:2"));
+    m3->AddressBlockPushBack (m3a1);
+
+    Ptr<AddressBlockIpv6> m3a2 = Create<AddressBlockIpv6> ();
+    m3a2->AddressPushBack (Ipv6Address ("10::"));
+    m3a2->AddressPushBack (Ipv6Address ("11::"));
+    m3a2->AddressPushBack (Ipv6Address ("10::5"));
+    m3a2->AddressPushBack (Ipv6Address ("10::6"));
+    m3a2->PrefixPushBack (128);
+    m3a2->PrefixPushBack (128);
+    m3a2->PrefixPushBack (64);
+    m3a2->PrefixPushBack (48);
+
+    m3->AddressBlockPushBack (m3a2);
+    packet.MessagePushBack (m3);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x1d, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x0f, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x01, 0x64, 0x0a,
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00, 0x04, 0x08, 0x0a,
+      0x00, 0x00, 0x00, 0x0b,
+      0x00, 0x00, 0x00, 0x0a,
+      0x00, 0x00, 0x05, 0x0a,
+      0x00, 0x00, 0x06, 0x20,
+      0x20, 0x10, 0x18, 0x01,
+      0x32, 0x01, 0x38, 0x01,
+      0x03, 0x01, 0x2c, 0x00,
+      0x01, 0x02, 0x03, 0x04,
+      0x05, 0x06, 0x07, 0x08,
+      0x09, 0x0a, 0x0b, 0x0c,
+      0x0d, 0x0e, 0x0f, 0x10,
+      0x11, 0x12, 0x13, 0x14,
+      0x15, 0x16, 0x17, 0x18,
+      0x19, 0x1a, 0x1b, 0x1c,
+      0x1d, 0x1e, 0x1f, 0x20,
+      0x21, 0x22, 0x23, 0x24,
+      0x25, 0x26, 0x27, 0x28,
+      0x29, 0x2a, 0x2b, 0x2c,
+      0x2d, 0x2e, 0x2f, 0x30,
+      0x31, 0x32, 0x33, 0x34,
+      0x35, 0x36, 0x37, 0x38,
+      0x39, 0x3a, 0x3b, 0x3c,
+      0x3d, 0x3e, 0x3f, 0x40,
+      0x41, 0x42, 0x43, 0x44,
+      0x45, 0x46, 0x47, 0x48,
+      0x49, 0x4a, 0x4b, 0x4c,
+      0x4d, 0x4e, 0x4f, 0x50,
+      0x51, 0x52, 0x53, 0x54,
+      0x55, 0x56, 0x57, 0x58,
+      0x59, 0x5a, 0x5b, 0x5c,
+      0x5d, 0x5e, 0x5f, 0x60,
+      0x61, 0x62, 0x63, 0x64,
+      0x65, 0x66, 0x67, 0x68,
+      0x69, 0x6a, 0x6b, 0x6c,
+      0x6d, 0x6e, 0x6f, 0x70,
+      0x71, 0x72, 0x73, 0x74,
+      0x75, 0x76, 0x77, 0x78,
+      0x79, 0x7a, 0x7b, 0x7c,
+      0x7d, 0x7e, 0x7f, 0x80,
+      0x81, 0x82, 0x83, 0x84,
+      0x85, 0x86, 0x87, 0x88,
+      0x89, 0x8a, 0x8b, 0x8c,
+      0x8d, 0x8e, 0x8f, 0x90,
+      0x91, 0x92, 0x93, 0x94,
+      0x95, 0x96, 0x97, 0x98,
+      0x99, 0x9a, 0x9b, 0x9c,
+      0x9d, 0x9e, 0x9f, 0xa0,
+      0xa1, 0xa2, 0xa3, 0xa4,
+      0xa5, 0xa6, 0xa7, 0xa8,
+      0xa9, 0xaa, 0xab, 0xac,
+      0xad, 0xae, 0xaf, 0xb0,
+      0xb1, 0xb2, 0xb3, 0xb4,
+      0xb5, 0xb6, 0xb7, 0xb8,
+      0xb9, 0xba, 0xbb, 0xbc,
+      0xbd, 0xbe, 0xbf, 0xc0,
+      0xc1, 0xc2, 0xc3, 0xc4,
+      0xc5, 0xc6, 0xc7, 0xc8,
+      0xc9, 0xca, 0xcb, 0xcc,
+      0xcd, 0xce, 0xcf, 0xd0,
+      0xd1, 0xd2, 0xd3, 0xd4,
+      0xd5, 0xd6, 0xd7, 0xd8,
+      0xd9, 0xda, 0xdb, 0xdc,
+      0xdd, 0xde, 0xdf, 0xe0,
+      0xe1, 0xe2, 0xe3, 0xe4,
+      0xe5, 0xe6, 0xe7, 0xe8,
+      0xe9, 0xea, 0xeb, 0xec,
+      0xed, 0xee, 0xef, 0xf0,
+      0xf1, 0xf2, 0xf3, 0xf4,
+      0xf5, 0xf6, 0xf7, 0xf8,
+      0xf9, 0xfa, 0xfb, 0xfc,
+      0xfd, 0xfe, 0x00, 0x01,
+      0x02, 0x03, 0x04, 0x05,
+      0x06, 0x07, 0x08, 0x09,
+      0x0a, 0x0b, 0x0c, 0x0d,
+      0x0e, 0x0f, 0x10, 0x11,
+      0x12, 0x13, 0x14, 0x15,
+      0x16, 0x17, 0x18, 0x19,
+      0x1a, 0x1b, 0x1c, 0x1d,
+      0x1e, 0x1f, 0x20, 0x21,
+      0x22, 0x23, 0x24, 0x25,
+      0x26, 0x27, 0x28, 0x29,
+      0x2a, 0x2b, 0x2c, 0x01,
+      0x8f, 0x00, 0x73, 0xab,
+      0xcd, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x01, 0x00,
+      0x00, 0x02, 0xc0, 0x0d,
+      0x00, 0x10, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x02, 0x00, 0x02,
+      0x00, 0x11, 0x00, 0x00,
+      0x04, 0x88, 0x01, 0x00,
+      0x10, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x11,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x10, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x05, 0x10, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x06,
+      0x80, 0x80, 0x40, 0x30,
+      0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+
+  /* Test 37
+	 * ,------------------
+	 * |  PACKET
+	 * |------------------
+	 * | * Packet version:    0
+	 * | * Packet flags:  12
+	 * | * Packet seq number: 30
+	 * |    | * Packet TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  0
+	 * |    | * Message TLV Block
+	 * |    |     - TLV
+	 * |    |         Flags = 0
+	 * |    |         Type = 1; Value = (warning: parameter is NULL)
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       2
+	 * |    | * Message flags:  240
+	 * |    | * Originator address: 10.0.0.1
+	 * |    | * Hop limit:          255
+	 * |    | * Hop count:          1
+	 * |    | * Message seq number: 12345
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10.0.0.2/32
+	 * |    |     - 10.1.1.2/32
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10.0.0.0/32
+	 * |    |     - 11.0.0.0/32
+	 * |    |     - 10.0.0.5/16
+	 * |    |     - 10.0.0.6/24
+	 * |    |     - Flags = 8
+	 * |    | - ADDRESS TLV block (1 TLVs)
+	 * |    |     - TLV
+	 * |    |         Flags = 56
+	 * |    |         Index-start = 1
+	 * |    |         Index-stop = 3
+	 * |    |         Type = 1; Value = 00  01  02  03
+	 * |    |                                          04  05  06  07
+	 * |    |                                          08  09  0a  0b
+	 * |    |                                          0c  0d  0e  0f
+	 * |    |                                          10  11  12  13
+	 * |    |                                          14  15  16  17
+	 * |    |                                          18  19  1a  1b
+	 * |    |                                          1c  1d  1e  1f
+	 * |    |                                          20  21  22  23
+	 * |    |                                          24  25  26  27
+	 * |    |                                          28  29  2a  2b
+	 * |    |                                          2c  2d  2e  2f
+	 * |    |                                          30  31  32  33
+	 * |    |                                          34  35  36  37
+	 * |    |                                          38  39  3a  3b
+	 * |    |                                          3c  3d  3e  3f
+	 * |    |                                          40  41  42  43
+	 * |    |                                          44  45  46  47
+	 * |    |                                          48  49  4a  4b
+	 * |    |                                          4c  4d  4e  4f
+	 * |    |                                          50  51  52  53
+	 * |    |                                          54  55  56  57
+	 * |    |                                          58  59  5a  5b
+	 * |    |                                          5c  5d  5e  5f
+	 * |    |                                          60  61  62  63
+	 * |    |                                          64  65  66  67
+	 * |    |                                          68  69  6a  6b
+	 * |    |                                          6c  6d  6e  6f
+	 * |    |                                          70  71  72  73
+	 * |    |                                          74  75  76  77
+	 * |    |                                          78  79  7a  7b
+	 * |    |                                          7c  7d  7e  7f
+	 * |    |                                          80  81  82  83
+	 * |    |                                          84  85  86  87
+	 * |    |                                          88  89  8a  8b
+	 * |    |                                          8c  8d  8e  8f
+	 * |    |                                          90  91  92  93
+	 * |    |                                          94  95  96  97
+	 * |    |                                          98  99  9a  9b
+	 * |    |                                          9c  9d  9e  9f
+	 * |    |                                          a0  a1  a2  a3
+	 * |    |                                          a4  a5  a6  a7
+	 * |    |                                          a8  a9  aa  ab
+	 * |    |                                          ac  ad  ae  af
+	 * |    |                                          b0  b1  b2  b3
+	 * |    |                                          b4  b5  b6  b7
+	 * |    |                                          b8  b9  ba  bb
+	 * |    |                                          bc  bd  be  bf
+	 * |    |                                          c0  c1  c2  c3
+	 * |    |                                          c4  c5  c6  c7
+	 * |    |                                          c8  c9  ca  cb
+	 * |    |                                          cc  cd  ce  cf
+	 * |    |                                          d0  d1  d2  d3
+	 * |    |                                          d4  d5  d6  d7
+	 * |    |                                          d8  d9  da  db
+	 * |    |                                          dc  dd  de  df
+	 * |    |                                          e0  e1  e2  e3
+	 * |    |                                          e4  e5  e6  e7
+	 * |    |                                          e8  e9  ea  eb
+	 * |    |                                          ec  ed  ee  ef
+	 * |    |                                          f0  f1  f2  f3
+	 * |    |                                          f4  f5  f6  f7
+	 * |    |                                          f8  f9  fa  fb
+	 * |    |                                          fc  fd  fe  00
+	 * |    |                                          01  02  03  04
+	 * |    |                                          05  06  07  08
+	 * |    |                                          09  0a  0b  0c
+	 * |    |                                          0d  0e  0f  10
+	 * |    |                                          11  12  13  14
+	 * |    |                                          15  16  17  18
+	 * |    |                                          19  1a  1b  1c
+	 * |    |                                          1d  1e  1f  20
+	 * |    |                                          21  22  23  24
+	 * |    |                                          25  26  27  28
+	 * |    |                                          29  2a  2b  2c
+	 * |    |                                          
+	 * |    `-------------------
+	 * |
+	 * |    ,-------------------
+	 * |    |  MESSAGE  
+	 * |    |-------------------
+	 * |    | * Message type:       1
+	 * |    | * Message flags:  129
+	 * |    | * Originator address: abcd::1
+	 * |    | - Address block (2 addresses)
+	 * |    |     - 10::2/128
+	 * |    |     - 10::11:2/128
+	 * |    |     - Flags = 192
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    | - Address block (4 addresses)
+	 * |    |     - 10::/128
+	 * |    |     - 11::/128
+	 * |    |     - 10::5/64
+	 * |    |     - 10::6/48
+	 * |    |     - Flags = 136
+	 * |    | - ADDRESS TLV block (0 TLVs)
+	 * |    `-------------------
+	 * |
+	 * `------------------
+   */
+  {
+    PacketBB packet;
+    packet.SetSequenceNumber (30);
+
+    Ptr<Tlv> ptlv1 = Create<Tlv> ();
+    ptlv1->SetType (1);
+    packet.TlvPushBack (ptlv1);
+
+    Ptr<MessageIpv6> m1 = Create<MessageIpv6> ();
+    m1->SetType (1);
+
+    Ptr<Tlv> m1tlv1 = Create<Tlv> ();
+    m1tlv1->SetType (1);
+    m1->TlvPushBack (m1tlv1);
+    packet.MessagePushBack (m1);
+
+    Ptr<MessageIpv4> m2 = Create<MessageIpv4> ();
+    m2->SetType (2);
+    m2->SetOriginatorAddress (Ipv4Address ("10.0.0.1"));
+    m2->SetHopLimit (255);
+    m2->SetHopCount (1);
+    m2->SetSequenceNumber (12345);
+
+    Ptr<AddressBlockIpv4> m2a1 = Create<AddressBlockIpv4> ();
+    m2a1->AddressPushBack (Ipv4Address ("10.0.0.2"));
+    m2a1->AddressPushBack (Ipv4Address ("10.1.1.2"));
+    m2->AddressBlockPushBack (m2a1);
+
+    Ptr<AddressBlockIpv4> m2a2 = Create<AddressBlockIpv4> ();
+    m2a2->AddressPushBack (Ipv4Address ("10.0.0.0"));
+    m2a2->AddressPushBack (Ipv4Address ("11.0.0.0"));
+    m2a2->AddressPushBack (Ipv4Address ("10.0.0.5"));
+    m2a2->AddressPushBack (Ipv4Address ("10.0.0.6"));
+    m2a2->PrefixPushBack (32);
+    m2a2->PrefixPushBack (32);
+    m2a2->PrefixPushBack (16);
+    m2a2->PrefixPushBack (24);
+
+    Ptr<AddressTlv> m2a2tlv1 = Create<AddressTlv> ();
+    m2a2tlv1->SetType (1);
+    m2a2tlv1->SetIndexStart (1);
+    m2a2tlv1->SetIndexStop (3);
+
+    uint8_t value[] = {
+      0x00, 0x01, 0x02, 0x03,
+      0x04, 0x05, 0x06, 0x07,
+      0x08, 0x09, 0x0a, 0x0b,
+      0x0c, 0x0d, 0x0e, 0x0f,
+      0x10, 0x11, 0x12, 0x13,
+      0x14, 0x15, 0x16, 0x17,
+      0x18, 0x19, 0x1a, 0x1b,
+      0x1c, 0x1d, 0x1e, 0x1f,
+      0x20, 0x21, 0x22, 0x23,
+      0x24, 0x25, 0x26, 0x27,
+      0x28, 0x29, 0x2a, 0x2b,
+      0x2c, 0x2d, 0x2e, 0x2f,
+      0x30, 0x31, 0x32, 0x33,
+      0x34, 0x35, 0x36, 0x37,
+      0x38, 0x39, 0x3a, 0x3b,
+      0x3c, 0x3d, 0x3e, 0x3f,
+      0x40, 0x41, 0x42, 0x43,
+      0x44, 0x45, 0x46, 0x47,
+      0x48, 0x49, 0x4a, 0x4b,
+      0x4c, 0x4d, 0x4e, 0x4f,
+      0x50, 0x51, 0x52, 0x53,
+      0x54, 0x55, 0x56, 0x57,
+      0x58, 0x59, 0x5a, 0x5b,
+      0x5c, 0x5d, 0x5e, 0x5f,
+      0x60, 0x61, 0x62, 0x63,
+      0x64, 0x65, 0x66, 0x67,
+      0x68, 0x69, 0x6a, 0x6b,
+      0x6c, 0x6d, 0x6e, 0x6f,
+      0x70, 0x71, 0x72, 0x73,
+      0x74, 0x75, 0x76, 0x77,
+      0x78, 0x79, 0x7a, 0x7b,
+      0x7c, 0x7d, 0x7e, 0x7f,
+      0x80, 0x81, 0x82, 0x83,
+      0x84, 0x85, 0x86, 0x87,
+      0x88, 0x89, 0x8a, 0x8b,
+      0x8c, 0x8d, 0x8e, 0x8f,
+      0x90, 0x91, 0x92, 0x93,
+      0x94, 0x95, 0x96, 0x97,
+      0x98, 0x99, 0x9a, 0x9b,
+      0x9c, 0x9d, 0x9e, 0x9f,
+      0xa0, 0xa1, 0xa2, 0xa3,
+      0xa4, 0xa5, 0xa6, 0xa7,
+      0xa8, 0xa9, 0xaa, 0xab,
+      0xac, 0xad, 0xae, 0xaf,
+      0xb0, 0xb1, 0xb2, 0xb3,
+      0xb4, 0xb5, 0xb6, 0xb7,
+      0xb8, 0xb9, 0xba, 0xbb,
+      0xbc, 0xbd, 0xbe, 0xbf,
+      0xc0, 0xc1, 0xc2, 0xc3,
+      0xc4, 0xc5, 0xc6, 0xc7,
+      0xc8, 0xc9, 0xca, 0xcb,
+      0xcc, 0xcd, 0xce, 0xcf,
+      0xd0, 0xd1, 0xd2, 0xd3,
+      0xd4, 0xd5, 0xd6, 0xd7,
+      0xd8, 0xd9, 0xda, 0xdb,
+      0xdc, 0xdd, 0xde, 0xdf,
+      0xe0, 0xe1, 0xe2, 0xe3,
+      0xe4, 0xe5, 0xe6, 0xe7,
+      0xe8, 0xe9, 0xea, 0xeb,
+      0xec, 0xed, 0xee, 0xef,
+      0xf0, 0xf1, 0xf2, 0xf3,
+      0xf4, 0xf5, 0xf6, 0xf7,
+      0xf8, 0xf9, 0xfa, 0xfb,
+      0xfc, 0xfd, 0xfe, 0x00,
+      0x01, 0x02, 0x03, 0x04,
+      0x05, 0x06, 0x07, 0x08,
+      0x09, 0x0a, 0x0b, 0x0c,
+      0x0d, 0x0e, 0x0f, 0x10,
+      0x11, 0x12, 0x13, 0x14,
+      0x15, 0x16, 0x17, 0x18,
+      0x19, 0x1a, 0x1b, 0x1c,
+      0x1d, 0x1e, 0x1f, 0x20,
+      0x21, 0x22, 0x23, 0x24,
+      0x25, 0x26, 0x27, 0x28,
+      0x29, 0x2a, 0x2b, 0x2c,
+    };
+    m2a2tlv1->SetValue (value, sizeof(value));
+    m2a2->TlvPushBack (m2a2tlv1);
+
+    m2->AddressBlockPushBack (m2a2);
+    packet.MessagePushBack (m2);
+
+    Ptr<MessageIpv6> m3 = Create<MessageIpv6> ();
+    m3->SetType (1);
+    m3->SetOriginatorAddress (Ipv6Address ("abcd::1"));
+
+    Ptr<AddressBlockIpv6> m3a1 = Create<AddressBlockIpv6> ();
+    m3a1->AddressPushBack (Ipv6Address ("10::2"));
+    m3a1->AddressPushBack (Ipv6Address ("10::11:2"));
+    m3->AddressBlockPushBack (m3a1);
+
+    Ptr<AddressBlockIpv6> m3a2 = Create<AddressBlockIpv6> ();
+    m3a2->AddressPushBack (Ipv6Address ("10::"));
+    m3a2->AddressPushBack (Ipv6Address ("11::"));
+    m3a2->AddressPushBack (Ipv6Address ("10::5"));
+    m3a2->AddressPushBack (Ipv6Address ("10::6"));
+    m3a2->PrefixPushBack (128);
+    m3a2->PrefixPushBack (128);
+    m3a2->PrefixPushBack (64);
+    m3a2->PrefixPushBack (48);
+
+    m3->AddressBlockPushBack (m3a2);
+    packet.MessagePushBack (m3);
+
+    uint8_t buffer[] = {
+      0x0c, 0x00, 0x1e, 0x00,
+      0x02, 0x01, 0x00, 0x01,
+      0x0f, 0x00, 0x08, 0x00,
+      0x02, 0x01, 0x00, 0x02,
+      0xf3, 0x01, 0x64, 0x0a,
+      0x00, 0x00, 0x01, 0xff,
+      0x01, 0x30, 0x39, 0x00,
+      0x00, 0x02, 0xc0, 0x01,
+      0x0a, 0x01, 0x02, 0x00,
+      0x00, 0x01, 0x01, 0x00,
+      0x00, 0x04, 0x08, 0x0a,
+      0x00, 0x00, 0x00, 0x0b,
+      0x00, 0x00, 0x00, 0x0a,
+      0x00, 0x00, 0x05, 0x0a,
+      0x00, 0x00, 0x06, 0x20,
+      0x20, 0x10, 0x18, 0x01,
+      0x32, 0x01, 0x38, 0x01,
+      0x03, 0x01, 0x2c, 0x00,
+      0x01, 0x02, 0x03, 0x04,
+      0x05, 0x06, 0x07, 0x08,
+      0x09, 0x0a, 0x0b, 0x0c,
+      0x0d, 0x0e, 0x0f, 0x10,
+      0x11, 0x12, 0x13, 0x14,
+      0x15, 0x16, 0x17, 0x18,
+      0x19, 0x1a, 0x1b, 0x1c,
+      0x1d, 0x1e, 0x1f, 0x20,
+      0x21, 0x22, 0x23, 0x24,
+      0x25, 0x26, 0x27, 0x28,
+      0x29, 0x2a, 0x2b, 0x2c,
+      0x2d, 0x2e, 0x2f, 0x30,
+      0x31, 0x32, 0x33, 0x34,
+      0x35, 0x36, 0x37, 0x38,
+      0x39, 0x3a, 0x3b, 0x3c,
+      0x3d, 0x3e, 0x3f, 0x40,
+      0x41, 0x42, 0x43, 0x44,
+      0x45, 0x46, 0x47, 0x48,
+      0x49, 0x4a, 0x4b, 0x4c,
+      0x4d, 0x4e, 0x4f, 0x50,
+      0x51, 0x52, 0x53, 0x54,
+      0x55, 0x56, 0x57, 0x58,
+      0x59, 0x5a, 0x5b, 0x5c,
+      0x5d, 0x5e, 0x5f, 0x60,
+      0x61, 0x62, 0x63, 0x64,
+      0x65, 0x66, 0x67, 0x68,
+      0x69, 0x6a, 0x6b, 0x6c,
+      0x6d, 0x6e, 0x6f, 0x70,
+      0x71, 0x72, 0x73, 0x74,
+      0x75, 0x76, 0x77, 0x78,
+      0x79, 0x7a, 0x7b, 0x7c,
+      0x7d, 0x7e, 0x7f, 0x80,
+      0x81, 0x82, 0x83, 0x84,
+      0x85, 0x86, 0x87, 0x88,
+      0x89, 0x8a, 0x8b, 0x8c,
+      0x8d, 0x8e, 0x8f, 0x90,
+      0x91, 0x92, 0x93, 0x94,
+      0x95, 0x96, 0x97, 0x98,
+      0x99, 0x9a, 0x9b, 0x9c,
+      0x9d, 0x9e, 0x9f, 0xa0,
+      0xa1, 0xa2, 0xa3, 0xa4,
+      0xa5, 0xa6, 0xa7, 0xa8,
+      0xa9, 0xaa, 0xab, 0xac,
+      0xad, 0xae, 0xaf, 0xb0,
+      0xb1, 0xb2, 0xb3, 0xb4,
+      0xb5, 0xb6, 0xb7, 0xb8,
+      0xb9, 0xba, 0xbb, 0xbc,
+      0xbd, 0xbe, 0xbf, 0xc0,
+      0xc1, 0xc2, 0xc3, 0xc4,
+      0xc5, 0xc6, 0xc7, 0xc8,
+      0xc9, 0xca, 0xcb, 0xcc,
+      0xcd, 0xce, 0xcf, 0xd0,
+      0xd1, 0xd2, 0xd3, 0xd4,
+      0xd5, 0xd6, 0xd7, 0xd8,
+      0xd9, 0xda, 0xdb, 0xdc,
+      0xdd, 0xde, 0xdf, 0xe0,
+      0xe1, 0xe2, 0xe3, 0xe4,
+      0xe5, 0xe6, 0xe7, 0xe8,
+      0xe9, 0xea, 0xeb, 0xec,
+      0xed, 0xee, 0xef, 0xf0,
+      0xf1, 0xf2, 0xf3, 0xf4,
+      0xf5, 0xf6, 0xf7, 0xf8,
+      0xf9, 0xfa, 0xfb, 0xfc,
+      0xfd, 0xfe, 0x00, 0x01,
+      0x02, 0x03, 0x04, 0x05,
+      0x06, 0x07, 0x08, 0x09,
+      0x0a, 0x0b, 0x0c, 0x0d,
+      0x0e, 0x0f, 0x10, 0x11,
+      0x12, 0x13, 0x14, 0x15,
+      0x16, 0x17, 0x18, 0x19,
+      0x1a, 0x1b, 0x1c, 0x1d,
+      0x1e, 0x1f, 0x20, 0x21,
+      0x22, 0x23, 0x24, 0x25,
+      0x26, 0x27, 0x28, 0x29,
+      0x2a, 0x2b, 0x2c, 0x01,
+      0x8f, 0x00, 0x73, 0xab,
+      0xcd, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x01, 0x00,
+      0x00, 0x02, 0xc0, 0x0d,
+      0x00, 0x10, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x02, 0x00, 0x02,
+      0x00, 0x11, 0x00, 0x00,
+      0x04, 0x88, 0x01, 0x00,
+      0x10, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x11,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x10, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x05, 0x10, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x06,
+      0x80, 0x80, 0x40, 0x30,
+      0x00, 0x00,
+    };
+    PacketBBTester test(testnum++, packet, buffer, sizeof(buffer));
+  }
+}
--- a/src/contrib/wscript	Thu Aug 13 13:39:23 2009 +0200
+++ b/src/contrib/wscript	Thu Aug 13 23:30:03 2009 -0400
@@ -30,6 +30,7 @@
         'attribute-default-iterator.cc',
         'file-config.cc',
         'raw-text-config.cc',
+        'packetbb.cc',
         ]
 
     headers = bld.new_task_gen('ns3header')
@@ -41,6 +42,7 @@
         'file-config.h',
         'config-store.h',
         'flow-id-tag.h',
+        'packetbb.h',
         ]
 
     if bld.env['ENABLE_GTK_CONFIG_STORE']: