model: Returning back support for CCNb wire format

Refs #1008 (http://redmine.named-data.net/)
diff --git a/model/ndn-content-object.cc b/model/ndn-content-object.cc
index 81d92f0..ecf3197 100644
--- a/model/ndn-content-object.cc
+++ b/model/ndn-content-object.cc
@@ -120,6 +120,18 @@
 }
 
 void
+ContentObject::SetKeyLocator (Ptr<Name> keyLocator)
+{
+  m_keyLocator = keyLocator;
+}
+
+Ptr<const Name>
+ContentObject::GetKeyLocator () const
+{
+  return m_keyLocator;
+}
+
+void
 ContentObject::Print (std::ostream &os) const
 {
   os << "D: " << GetName ();
diff --git a/model/ndn-content-object.h b/model/ndn-content-object.h
index 6fa60dd..c79ddf9 100644
--- a/model/ndn-content-object.h
+++ b/model/ndn-content-object.h
@@ -122,6 +122,21 @@
   uint32_t
   GetSignature () const;
 
+  /**
+   * @brief Set key locator
+   * @param keyLocator name of the key
+   */
+  void
+  SetKeyLocator (Ptr<Name> keyLocator);
+
+  /**
+   * @brief Get key locator
+   *
+   * Note that only <KeyName> option for the key locator is supported
+   */
+  Ptr<const Name>
+  GetKeyLocator () const;
+  
   //////////////////////////////////////////////////////////////////
   /**
    * @brief Get payload of data packet
@@ -170,6 +185,7 @@
   Time m_timestamp;
   uint32_t m_signature; // 0, means no signature, any other value application dependent (not a real signature)
   Ptr<Packet> m_payload;
+  Ptr<Name> m_keyLocator;
 
   mutable Ptr<const Packet> m_wire;
 };
diff --git a/model/wire/ccnb.h b/model/wire/ccnb.h
new file mode 100644
index 0000000..893d481
--- /dev/null
+++ b/model/wire/ccnb.h
@@ -0,0 +1,94 @@
+/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/* 
+ * Copyright (c) 2013, Regents of the University of California
+ *                     Alexander Afanasyev
+ * 
+ * BSD license, See the doc/LICENSE file for more information
+ * 
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef NDN_WIRE_CCNB_H
+#define NDN_WIRE_CCNB_H
+
+#include "ns3/ndn-common.h"
+#include "ns3/ndn-interest.h"
+#include "ns3/ndn-content-object.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace ccnb {
+
+/**
+  * @brief Routines to serialize/deserialize NDN interest in ccnb format
+  *
+  * @see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+  **/
+class Interest : public Header
+{
+public:
+  Interest ();
+  Interest (Ptr<ndn::Interest> interest);
+
+  Ptr<ndn::Interest>
+  GetInterest ();
+
+  static Ptr<Packet>
+  ToWire (Ptr<const ndn::Interest> interest);
+
+  static Ptr<ndn::Interest>
+  FromWire (Ptr<Packet> packet);
+  
+  //////////////////////////////////////////////////////////////////
+  // from Header
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
+  virtual void Print (std::ostream &os) const;
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
+
+private:
+  Ptr<ndn::Interest> m_interest;
+};
+
+
+/**
+  * @brief Routines to serialize/deserialize NDN Data packet in ccnb format
+  *
+  * @see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+  **/
+class Data : public Header
+{
+public:
+  Data ();
+  Data (Ptr<ndn::ContentObject> data);
+
+  Ptr<ndn::ContentObject>
+  GetData ();
+
+  static Ptr<Packet>
+  ToWire (Ptr<const ndn::ContentObject> data);
+
+  static Ptr<ndn::ContentObject>
+  FromWire (Ptr<Packet> packet);
+  
+  // from Header
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
+  virtual void Print (std::ostream &os) const;
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
+
+private:
+  Ptr<ndn::ContentObject> m_data;  
+};
+
+} // ccnb
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // NDN_WIRE_CCNB_H
diff --git a/model/wire/ccnb/ccnb-parser/common.h b/model/wire/ccnb/ccnb-parser/common.h
new file mode 100644
index 0000000..aa3f68a
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/common.h
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_COMMON_H_
+#define _CCNB_PARSER_COMMON_H_
+
+#include "ns3/ndn-common.h"
+
+#ifndef NDN_NAMESPACE_BEGIN
+#error "dafaq"
+#endif
+
+NDN_NAMESPACE_BEGIN;
+
+namespace wire {
+
+/**
+ * \ingroup ndn
+ * \defgroup ndn-ccnb CCNB decoding routines
+ */
+/**
+ * \ingroup ndn-ccnb
+ * \brief Namespace for ccnb parer
+ */
+namespace CcnbParser {
+
+// forward declarations
+class Block;
+class Blob;
+class Udata;
+class Tag;
+class Attr;
+class Dtag;
+class Dattr;
+class Ext;
+
+
+/**
+ * \brief Exception thrown if there is a parsing error
+ *
+ * \todo inherit this class from some exception class and provide meaningful error messages
+ */
+class CcnbDecodingException {};
+
+/**
+ * \brief Type tag for a ccnb start marker.
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html
+ */
+enum ccn_tt {
+  CCN_EXT,        /**< starts composite extension - numval is subtype */
+  CCN_TAG,        /**< starts composite - numval is tagnamelen-1 */ 
+  CCN_DTAG,       /**< starts composite - numval is tagdict index (enum ccn_dtag) */
+  CCN_ATTR,       /**< attribute - numval is attrnamelen-1, value follows */
+  CCN_DATTR,      /**< attribute numval is attrdict index */
+  CCN_BLOB,       /**< opaque binary data - numval is byte count */
+  CCN_UDATA,      /**< UTF-8 encoded character data - numval is byte count */
+  CCN_NO_TOKEN    /**< should not occur in encoding */
+};
+
+/** \brief CCN_CLOSE terminates composites */
+enum {CCN_CLOSE = 0};
+
+/**
+ * \brief DTAG identifies ccnb-encoded elements.
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html
+ */
+enum ccn_dtag {
+  CCN_DTAG_Any = 13,
+  CCN_DTAG_Name = 14,
+  CCN_DTAG_Component = 15,
+  CCN_DTAG_Certificate = 16,
+  CCN_DTAG_Collection = 17,
+  CCN_DTAG_CompleteName = 18,
+  CCN_DTAG_Content = 19,
+  CCN_DTAG_SignedInfo = 20,
+  CCN_DTAG_ContentDigest = 21,
+  CCN_DTAG_ContentHash = 22,
+  CCN_DTAG_Count = 24,
+  CCN_DTAG_Header = 25,
+  CCN_DTAG_Interest = 26,	/* 20090915 */
+  CCN_DTAG_Key = 27,
+  CCN_DTAG_KeyLocator = 28,
+  CCN_DTAG_KeyName = 29,
+  CCN_DTAG_Length = 30,
+  CCN_DTAG_Link = 31,
+  CCN_DTAG_LinkAuthenticator = 32,
+  CCN_DTAG_NameComponentCount = 33,	/* DeprecatedInInterest */
+  CCN_DTAG_RootDigest = 36,
+  CCN_DTAG_Signature = 37,
+  CCN_DTAG_Start = 38,
+  CCN_DTAG_Timestamp = 39,
+  CCN_DTAG_Type = 40,
+  CCN_DTAG_Nonce = 41,
+  CCN_DTAG_Scope = 42,
+  CCN_DTAG_Exclude = 43,
+  CCN_DTAG_Bloom = 44,
+  CCN_DTAG_BloomSeed = 45,
+  CCN_DTAG_AnswerOriginKind = 47,
+  CCN_DTAG_InterestLifetime = 48,
+  CCN_DTAG_Witness = 53,
+  CCN_DTAG_SignatureBits = 54,
+  CCN_DTAG_DigestAlgorithm = 55,
+  CCN_DTAG_BlockSize = 56,
+  CCN_DTAG_FreshnessSeconds = 58,
+  CCN_DTAG_FinalBlockID = 59,
+  CCN_DTAG_PublisherPublicKeyDigest = 60,
+  CCN_DTAG_PublisherCertificateDigest = 61,
+  CCN_DTAG_PublisherIssuerKeyDigest = 62,
+  CCN_DTAG_PublisherIssuerCertificateDigest = 63,
+  CCN_DTAG_ContentObject = 64,	/* 20090915 */
+  CCN_DTAG_WrappedKey = 65,
+  CCN_DTAG_WrappingKeyIdentifier = 66,
+  CCN_DTAG_WrapAlgorithm = 67,
+  CCN_DTAG_KeyAlgorithm = 68,
+  CCN_DTAG_Label = 69,
+  CCN_DTAG_EncryptedKey = 70,
+  CCN_DTAG_EncryptedNonceKey = 71,
+  CCN_DTAG_WrappingKeyName = 72,
+  CCN_DTAG_Action = 73,
+  CCN_DTAG_FaceID = 74,
+  CCN_DTAG_IPProto = 75,
+  CCN_DTAG_Host = 76,
+  CCN_DTAG_Port = 77,
+  CCN_DTAG_MulticastInterface = 78,
+  CCN_DTAG_ForwardingFlags = 79,
+  CCN_DTAG_FaceInstance = 80,
+  CCN_DTAG_ForwardingEntry = 81,
+  CCN_DTAG_MulticastTTL = 82,
+  CCN_DTAG_MinSuffixComponents = 83,
+  CCN_DTAG_MaxSuffixComponents = 84,
+  CCN_DTAG_ChildSelector = 85,
+  CCN_DTAG_RepositoryInfo = 86,
+  CCN_DTAG_Version = 87,
+  CCN_DTAG_RepositoryVersion = 88,
+  CCN_DTAG_GlobalPrefix = 89,
+  CCN_DTAG_LocalName = 90,
+  CCN_DTAG_Policy = 91,
+  CCN_DTAG_Namespace = 92,
+  CCN_DTAG_GlobalPrefixName = 93,
+  CCN_DTAG_PolicyVersion = 94,
+  CCN_DTAG_KeyValueSet = 95,
+  CCN_DTAG_KeyValuePair = 96,
+  CCN_DTAG_IntegerValue = 97,
+  CCN_DTAG_DecimalValue = 98,
+  CCN_DTAG_StringValue = 99,
+  CCN_DTAG_BinaryValue = 100,
+  CCN_DTAG_NameValue = 101,
+  CCN_DTAG_Entry = 102,
+  CCN_DTAG_ACL = 103,
+  CCN_DTAG_ParameterizedName = 104,
+  CCN_DTAG_Prefix = 105,
+  CCN_DTAG_Suffix = 106,
+  CCN_DTAG_Root = 107,
+  CCN_DTAG_ProfileName = 108,
+  CCN_DTAG_Parameters = 109,
+  CCN_DTAG_InfoString = 110,
+  CCN_DTAG_StatusResponse = 112,
+  CCN_DTAG_StatusCode = 113,
+  CCN_DTAG_StatusText = 114,
+  CCN_DTAG_Nack = 200,
+  CCN_DTAG_SequenceNumber = 256,
+  CCN_DTAG_CCNProtocolDataUnit = 17702112
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_COMMON_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/attr.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/attr.cc
new file mode 100644
index 0000000..f661186
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/attr.cc
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "attr.h"
+#include "../common.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+// length length in octets of UTF-8 encoding of tag name - 1 (minimum tag name length is 1) 
+Attr::Attr (Buffer::Iterator &start, uint32_t length)
+{
+  m_attr.reserve (length+2); // extra byte for potential \0 at the end
+  uint32_t i = 0;
+  for (; !start.IsEnd () && i < (length+1); i++)
+    {
+      m_attr.push_back (start.ReadU8 ());
+    }
+  if (i < (length+1) && start.IsEnd ())
+    throw CcnbDecodingException ();
+  m_value = DynamicCast<Udata> (Block::ParseBlock (start));
+  if (m_value == 0)
+    throw CcnbDecodingException (); // "ATTR must be followed by UDATA field"
+}
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/attr.h b/model/wire/ccnb/ccnb-parser/syntax-tree/attr.h
new file mode 100644
index 0000000..37882ad
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/attr.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_ATTR_H_
+#define _CCNB_PARSER_ATTR_H_
+
+#include "base-attr.h"
+#include <string>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Class to represent ATTR ccnb-encoded node
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ */
+class Attr : public BaseAttr
+{
+public:
+  /**
+   * \brief Constructor that actually parsed ccnb-encoded ATTR block
+   *
+   * \param start  buffer iterator pointing to the first byte of ATTR block name
+   * \param length length of ATTR name (extracted from the value field)
+   *
+   * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+   */
+  Attr (Buffer::Iterator &start, uint32_t length);
+  
+  virtual void accept( VoidNoArguVisitor &v )               { v.visit( *this ); }
+  virtual void accept( VoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( NoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  std::string m_attr; ///< field holding name of the attribute
+};
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_ATTR_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/base-attr.h b/model/wire/ccnb/ccnb-parser/syntax-tree/base-attr.h
new file mode 100644
index 0000000..c2b2627
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/base-attr.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_BASE_ATTR_H_
+#define _CCNB_PARSER_BASE_ATTR_H_
+
+#include "udata.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Virtual base class providing a common storage for ATTR
+ * and DATTR ccnb-encoded blocks
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ */
+class BaseAttr : public Block
+{
+public:
+  Ptr<Udata> m_value; ///< \brief Value of the attribute
+};
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_BASE_ATTR_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/base-tag.h b/model/wire/ccnb/ccnb-parser/syntax-tree/base-tag.h
new file mode 100644
index 0000000..1449d9f
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/base-tag.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_BASE_TAG_H_
+#define _CCNB_PARSER_BASE_TAG_H_
+
+#include "block.h"
+#include <list>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Virtual base class providing a common storage for TAG
+ * and DTAG ccnb-encoded blocks
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ */
+class BaseTag : public Block
+{
+public:
+  std::list<Ptr<Block> > m_attrs;      ///< \brief List of attributes, associated with this tag
+  std::list<Ptr<Block> > m_nestedTags; ///< \brief List of nested tags
+  
+protected:
+  /**
+   * \brief Default constructor
+   */
+  BaseTag() { }
+};
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_BASE_TAG_H_
+
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/blob.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/blob.cc
new file mode 100644
index 0000000..6c2ab2e
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/blob.cc
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "blob.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+Blob::Blob (Buffer::Iterator &start, uint32_t length)
+{
+  m_blobSize = length;
+  m_blob = new char[length];
+  if (m_blob == 0 )
+    throw CcnbDecodingException (); // memory problem
+
+  uint32_t i = 0;
+  for (; !start.IsEnd () && i < length; i++)
+    {
+      m_blob[i] = start.ReadU8 ();
+    }
+  if (i < length && start.IsEnd ())
+    throw CcnbDecodingException ();
+  // Block::counter += length;
+}
+
+Blob::~Blob ()
+{
+  delete [] m_blob;
+}
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/blob.h b/model/wire/ccnb/ccnb-parser/syntax-tree/blob.h
new file mode 100644
index 0000000..2b480ca
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/blob.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_BLOB_H_
+#define _CCNB_PARSER_BLOB_H_
+
+#include "block.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Class to represent BLOB ccnb-encoded node
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ */
+class Blob : public Block
+{
+public:
+  /**
+   * \brief Constructor that actually parsed ccnb-encoded BLOB block
+   *
+   * \param start  buffer iterator pointing to the first byte of BLOB data in ccnb-encoded block 
+   * \param length length of data in BLOB block (extracted from the value field)
+   *
+   * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+   */
+  Blob (Buffer::Iterator &start, uint32_t length);
+  ~Blob ();
+  
+  virtual void accept( VoidNoArguVisitor &v )               { v.visit( *this ); }
+  virtual void accept( VoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( NoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  char* m_blob; ///< \brief field holding a parsed BLOB value of the block
+  uint32_t  m_blobSize; ///< @brief field representing size of the BLOB field stored
+};
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_BLOB_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/block.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/block.cc
new file mode 100644
index 0000000..06c8e2c
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/block.cc
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "block.h"
+
+#include "blob.h"
+#include "udata.h"
+#include "tag.h"
+#include "dtag.h"
+#include "attr.h"
+#include "dattr.h"
+#include "ext.h"
+
+#include "ns3/log.h"
+
+NS_LOG_COMPONENT_DEFINE ("ndn.CcnbParser.Block");
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/// @cond include_hidden
+const uint8_t CCN_TT_BITS = 3;
+const uint8_t CCN_TT_MASK = ((1 << CCN_TT_BITS) - 1);
+const uint8_t CCN_MAX_TINY= ((1 << (7-CCN_TT_BITS)) - 1);
+const uint8_t CCN_TT_HBIT = ((uint8_t)(1 << 7));
+/// @endcond
+
+// int Block::counter = 0;
+
+Ptr<Block> Block::ParseBlock (Buffer::Iterator &start)
+{
+  // std::cout << "<< pos: " << counter << "\n";
+  uint32_t value = 0;
+
+  // We will have problems if length field is more than 32 bits. Though it's really impossible
+  uint8_t byte = 0;
+  while (!start.IsEnd() && !(byte & CCN_TT_HBIT))
+    {
+      value <<= 8;
+      value += byte;
+      byte = start.ReadU8 ();
+      // Block::counter ++;
+    }
+  if (start.IsEnd())
+    CcnbDecodingException ();
+  
+  value <<= 4;
+  value += ( (byte&(~CCN_TT_HBIT)) >> 3);
+  
+  /**
+   * Huh. After fighting with NS-3, it became apparent that Create<T>(...) construct
+   * doesn't work with references.  Just simply doesn't work.  wtf?
+   */
+  switch (byte & CCN_TT_MASK)
+    {
+    case CCN_BLOB:
+      return Ptr<Blob> (new Blob(start, value), false);
+    case CCN_UDATA:
+      return Ptr<Udata> (new Udata(start, value), false);
+    case CCN_TAG:
+      return Ptr<Tag> (new Tag(start, value), false);
+    case CCN_ATTR:
+      return Ptr<Attr> (new Attr(start, value), false);
+    case CCN_DTAG:
+      return Ptr<Dtag> (new Dtag(start, value), false);
+    case CCN_DATTR:
+      return Ptr<Dattr> (new Dattr(start, value), false);
+    case CCN_EXT:
+      return Ptr<Ext> (new Ext(start, value), false);
+    default:
+      throw CcnbDecodingException ();
+    }
+}
+
+Block::~Block ()
+{
+}
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/block.h b/model/wire/ccnb/ccnb-parser/syntax-tree/block.h
new file mode 100644
index 0000000..caf227f
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/block.h
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_BLOCK_H_
+#define _CCNB_PARSER_BLOCK_H_
+
+#include "ns3/simple-ref-count.h"
+#include "ns3/buffer.h"
+#include "ns3/ptr.h"
+
+// visitors
+#include "../visitors/void-no-argu-visitor.h"
+#include "../visitors/void-visitor.h"
+#include "../visitors/no-argu-visitor.h"
+#include "../visitors/visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Base class for ccnb-encoded node
+ *
+ * This class provides a static method to create a new block
+ * (recursively) from the stream
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ */
+class Block : public SimpleRefCount<Block>
+{
+public:
+  // static int counter;
+  /**
+   * \brief Parsing stream (recursively) and creating a parsed BLOCK
+   * object
+   *
+   * \param start buffer iterator pointing to the start position for parsing 
+   * \returns parsed ccnb-encoded block, that could contain more block inside
+   */
+  static Ptr<Block>
+  ParseBlock (Buffer::Iterator &start);
+
+  virtual ~Block ();
+  
+  virtual void accept( VoidNoArguVisitor &v )               = 0; ///< @brief Accept visitor void(*)()
+  virtual void accept( VoidVisitor &v, boost::any param )   = 0; ///< @brief Accept visitor void(*)(boost::any)
+  virtual boost::any accept( NoArguVisitor &v )             = 0; ///< @brief Accept visitor boost::any(*)()
+  virtual boost::any accept( Visitor &v, boost::any param ) = 0; ///< @brief Accept visitor boost::any(*)(boost::any)
+};
+
+/**
+ * @brief Necessary until Buffer::Iterator gets PeekU8 call
+ * @param i buffer iterator
+ * @return peeked uint8_t value
+ */
+inline
+uint8_t
+BufferIteratorPeekU8 (Buffer::Iterator &i)
+{
+  uint8_t ret = i.ReadU8 ();
+  i.Prev ();
+  return ret;
+}
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_BLOCK_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.cc
new file mode 100644
index 0000000..a37db84
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.cc
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "dattr.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+// dictionary attributes are not used (yet?) in CCNx 
+Dattr::Dattr (Buffer::Iterator &start, uint32_t dattr)
+{
+  m_dattr = dattr;
+  m_value = DynamicCast<Udata> (Block::ParseBlock (start));
+  if (m_value == 0)
+    throw CcnbDecodingException (); // "ATTR must be followed by UDATA field"
+}
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.h b/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.h
new file mode 100644
index 0000000..3728d6e
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_DATTR_H_
+#define _CCNB_PARSER_DATTR_H_
+
+#include "base-attr.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Class to represent DATTR ccnb-encoded node
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ */
+class Dattr : public BaseAttr
+{
+public:
+  /**
+   * \brief Constructor that actually parsed ccnb-encoded DATTR block
+   *
+   * \param start buffer iterator pointing to the first byte of attribute value (UDATA block)
+   * \param dattr dictionary code of DATTR (extracted from the value field)
+   *
+   * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+   */
+  Dattr (Buffer::Iterator &start, uint32_t dattr);
+
+  virtual void accept( VoidNoArguVisitor &v )               { v.visit( *this ); }
+  virtual void accept( VoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( NoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  uint32_t m_dattr; ///< \brief Dictionary code of DATTR
+};
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_DATTR_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.cc
new file mode 100644
index 0000000..b7af79b
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.cc
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "dtag.h"
+
+#include "base-attr.h"
+#include "base-tag.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+Dtag::Dtag (Buffer::Iterator &start, uint32_t dtag)
+{
+  m_dtag = dtag;
+  // std::cout << m_dtag << ", position: " << Block::counter << "\n";  
+  /**
+   * Hack
+   *
+   * Stop processing after encountering "Content" dtag.  Actual
+   * content (including virtual payload) will be stored in Packet
+   * buffer
+   */
+  if (dtag == CCN_DTAG_Content)
+    return; // hack #1. Do not process nesting block for <Content>
+  
+  // parse attributes until first nested block reached
+  while (!start.IsEnd () && BufferIteratorPeekU8 (start)!=CCN_CLOSE)
+    {
+      Ptr<Block> block = Block::ParseBlock (start);
+      if (DynamicCast<BaseAttr> (block)!=0)
+		m_attrs.push_back (block);
+	  else
+		{
+		  m_nestedTags.push_back (block);
+		  break;
+		}
+	}
+
+  // parse the rest of nested blocks
+  while (!start.IsEnd () && BufferIteratorPeekU8 (start)!=CCN_CLOSE)
+    {
+      // hack #2. Stop processing nested blocks if last block was <Content>
+      if (m_dtag == CCN_DTAG_ContentObject && // we are in <ContentObject>
+          DynamicCast<Dtag> (m_nestedTags.back())!=0 && // last block is DTAG
+          DynamicCast<Dtag> (m_nestedTags.back())->m_dtag == CCN_DTAG_Content) 
+        {
+          return; 
+        }
+
+      m_nestedTags.push_back (Block::ParseBlock (start));
+    }
+
+  // hack #3. Stop processing when last tag was <ContentObject>
+  if (m_dtag == CCN_DTAG_ContentObject && // we are in <ContentObject>
+      DynamicCast<Dtag> (m_nestedTags.back())!=0 && // last block is DTAG
+      DynamicCast<Dtag> (m_nestedTags.back())->m_dtag == CCN_DTAG_Content) 
+    {
+      return; 
+    }
+
+  if (start.IsEnd ())
+      throw CcnbDecodingException ();
+
+  start.ReadU8 (); // read CCN_CLOSE
+  // std::cout << "closer, position = " << Block::counter << "\n";
+  // Block::counter ++;
+}
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.h b/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.h
new file mode 100644
index 0000000..0d00f50
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.h
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_DTAG_H_
+#define _CCNB_PARSER_DTAG_H_
+
+#include "base-tag.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Class to represent DTAG ccnb-encoded node
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ */
+class Dtag : public BaseTag
+{
+public:
+  /**
+   * \brief Constructor that actually parsed ccnb-encoded DTAG block
+   *
+   * \param start buffer iterator pointing to the first nesting block or closing tag
+   * \param dtag  dictionary code of DTAG (extracted from the value field)
+   *
+   * DTAG parsing is slightly hacked to provide memory optimization
+   * for NS-3 simulations.  Parsing will be stopped after encountering
+   * "Content" dtag.  Actual content (including virtual payload) will
+   * be stored in Packet buffer
+   *
+   * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+   */
+  Dtag (Buffer::Iterator &start, uint32_t dtag);
+
+  virtual void accept( VoidNoArguVisitor &v )               { v.visit( *this ); }
+  virtual void accept( VoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( NoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  uint32_t m_dtag; ///< \brief Dictionary code for DTAG
+};
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_DTAG_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/ext.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/ext.cc
new file mode 100644
index 0000000..79ac738
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/ext.cc
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ext.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+Ext::Ext (Buffer::Iterator &start, uint32_t extSubtype)
+{
+  m_extSubtype = extSubtype;
+}
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/ext.h b/model/wire/ccnb/ccnb-parser/syntax-tree/ext.h
new file mode 100644
index 0000000..532eb87
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/ext.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_EXT_H_
+#define _CCNB_PARSER_EXT_H_
+
+#include "block.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Class to represent EXT ccnb-encoded node
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ */
+class Ext : public Block
+{
+public:
+  /**
+   * \brief Constructor that actually parsed ccnb-encoded DTAG block
+   *
+   * \param start buffer iterator pointing to the next byte past EXT block
+   * \param extSubtype extension type (extracted from the value field)
+   *
+   * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+   */
+  Ext (Buffer::Iterator &start, uint32_t extSubtype);
+
+  virtual void accept( VoidNoArguVisitor &v )               { v.visit( *this ); }
+  virtual void accept( VoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( NoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  uint64_t m_extSubtype; ///< \brief Extension type
+};
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_EXT_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/tag.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/tag.cc
new file mode 100644
index 0000000..8cd7fd1
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/tag.cc
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "tag.h"
+
+#include "base-attr.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+Tag::Tag (Buffer::Iterator &start, uint32_t length)
+{
+  m_tag.reserve (length+2); // extra byte for potential \0 at the end
+  uint32_t i = 0;
+  for (; !start.IsEnd () && i < (length+1); i++)
+    {
+      m_tag.push_back (start.ReadU8 ());
+    }
+  if (i < (length+1) && start.IsEnd ())
+    throw CcnbDecodingException ();
+  
+  // parse attributes until first nested block reached
+  while (!start.IsEnd () && BufferIteratorPeekU8 (start)!=CCN_CLOSE)
+    {
+      Ptr<Block> block = Block::ParseBlock (start);
+      if (DynamicCast<BaseAttr> (block)!=0)
+		m_attrs.push_back (block);
+	  else
+		{
+		  m_nestedTags.push_back (block);
+		  break;
+		}
+	}
+
+  // parse the rest of nested blocks
+  while (!start.IsEnd () && BufferIteratorPeekU8 (start)!=CCN_CLOSE)
+    {
+      Ptr<Block> block = Block::ParseBlock (start);
+	  m_nestedTags.push_back (block);
+    }
+  
+  if (start.IsEnd ()) //should not be the end
+      throw CcnbDecodingException ();
+
+  start.ReadU8 (); // read CCN_CLOSE
+}
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/tag.h b/model/wire/ccnb/ccnb-parser/syntax-tree/tag.h
new file mode 100644
index 0000000..8949119
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/tag.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_TAG_H_
+#define _CCNB_PARSER_TAG_H_
+
+#include "base-tag.h"
+#include <string>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Class to represent TAG ccnb-encoded node
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ */
+class Tag : public BaseTag
+{
+public:
+  /**
+   * \brief Constructor that actually parsed ccnb-encoded TAG block
+   *
+   * \param start  buffer iterator pointing to the first byte of TAG block name
+   * \param length length of TAG name - 1 byte (i.e., minimum tag name is 1 byte)
+   *
+   * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+   */
+  Tag (Buffer::Iterator &start, uint32_t length);
+
+  virtual void accept( VoidNoArguVisitor &v )               { v.visit( *this ); }
+  virtual void accept( VoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( NoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  std::string m_tag; ///< \brief Name of TAG block
+};
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_TAG_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/udata.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/udata.cc
new file mode 100644
index 0000000..9d3c8df
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/udata.cc
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "udata.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+Udata::Udata (Buffer::Iterator &start, uint32_t length)
+{
+  // Ideally, the code should look like this. Unfortunately, we don't have normal compatible iterators
+  // Buffer::Iterator realStart = start;
+  // start.Next (length); // advancing forward
+  // m_udata.assign (realStart, start/*actually, it is the end*/);
+
+  m_udata.reserve (length+1); //just in case we will need \0 at the end later
+  // this is actually the way Read method is implemented in network/src/buffer.cc
+  uint32_t i = 0;
+  for (; !start.IsEnd () && i < length; i++)
+    {
+      m_udata.push_back (start.ReadU8 ());
+    }
+
+  if (i < length && start.IsEnd ())
+    throw CcnbDecodingException ();
+}
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/udata.h b/model/wire/ccnb/ccnb-parser/syntax-tree/udata.h
new file mode 100644
index 0000000..463898f
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/syntax-tree/udata.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_UDATA_H_
+#define _CCNB_PARSER_UDATA_H_
+
+#include "block.h"
+#include <string>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Class to represent UDATA ccnb-encoded node
+ */
+class Udata : public Block
+{
+public:
+  /**
+   * \brief Constructor that actually parsed ccnb-encoded UDATA block
+   *
+   * \param start  buffer iterator pointing to the first byte of string in ccnb-encoded block 
+   * \param length length of data in UDATA block (extracted from the value field)
+   *
+   * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+   */
+  Udata (Buffer::Iterator &start, uint32_t length);
+  
+  virtual void accept( VoidNoArguVisitor &v )               { v.visit( *this ); }
+  virtual void accept( VoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( NoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  std::string m_udata; ///< \brief field holding a parsed UDATA value of the block
+};
+
+} // namespace CcnbParser
+} // namespace wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_UDATA_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.cc
new file mode 100644
index 0000000..91112da
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.cc
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "content-type-visitor.h"
+#include "../syntax-tree/blob.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+boost::any
+ContentTypeVisitor::visit (Blob &n) 
+{
+  // Buffer n.m_blob;
+  if (n.m_blobSize != 3)
+    throw CcnbDecodingException ();
+
+  uint32_t type =
+    (n.m_blob [0] << 16) |
+    (n.m_blob [1] << 8 ) |
+    (n.m_blob [2]      );
+    
+  return boost::any (type);
+}
+
+boost::any
+ContentTypeVisitor::visit (Udata &n)
+{
+  // std::string n.m_udata;
+  throw CcnbDecodingException ();
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.h
new file mode 100644
index 0000000..aa9abbf
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
+#define _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
+
+#include "no-argu-depth-first-visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain nonce value from BLOB block
+ *
+ * Note, only first 32 bits will be actually parsed into nonce. If
+ * original Nonce contains more, the rest will be ignored
+ *
+ * Will return empty boost::any() if called on anything except BLOB block
+ */
+class ContentTypeVisitor : public NoArguDepthFirstVisitor
+{
+public:
+  virtual boost::any visit (Blob &n); 
+  virtual boost::any visit (Udata &n); ///< Throws parsing error if BLOB object is encountered
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.cc
new file mode 100644
index 0000000..b82b140
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.cc
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "depth-first-visitor.h"
+
+#include "../syntax-tree/blob.h"
+#include "../syntax-tree/udata.h"
+#include "../syntax-tree/tag.h"
+#include "../syntax-tree/dtag.h"
+#include "../syntax-tree/attr.h"
+#include "../syntax-tree/dattr.h"
+#include "../syntax-tree/ext.h"
+
+#include <boost/foreach.hpp>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+boost::any
+DepthFirstVisitor::visit (Blob &n, boost::any param)
+{
+  // Buffer n.m_blob;
+  return n.m_blob;
+}
+ 
+boost::any
+DepthFirstVisitor::visit (Udata &n, boost::any param)
+{
+  // std::string n.m_udata;
+  return n.m_udata;
+}
+ 
+boost::any
+DepthFirstVisitor::visit (Tag &n, boost::any param)
+{
+  // std::string n.m_tag;
+  // std::list<Ptr<Block> > n.m_attrs;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+    {
+      block->accept (*this, param);
+    }
+  BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+    {
+      block->accept (*this, param);
+    }
+  return boost::any();
+}
+
+boost::any
+DepthFirstVisitor::visit (Dtag &n, boost::any param)
+{
+  // std::string n.m_tag;
+  // std::list<Ptr<Block> > n.m_attrs;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+    {
+      block->accept (*this, param);
+    }
+  BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+    {
+      block->accept (*this, param);
+    }
+  return boost::any ();
+}
+
+boost::any
+DepthFirstVisitor::visit (Attr &n, boost::any param)
+{
+  // std::string n.m_attr;
+  // Ptr<Udata> n.m_value;
+  return boost::any ();
+}
+
+boost::any
+DepthFirstVisitor::visit (Dattr &n, boost::any param)
+{
+  // uint32_t n.m_dattr;
+  // Ptr<Udata> n.m_value;
+  return boost::any ();
+}
+ 
+boost::any
+DepthFirstVisitor::visit (Ext &n, boost::any param)
+{
+  // uint64_t n.m_extSubtype;
+  return n.m_extSubtype;
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.h
new file mode 100644
index 0000000..be701b1
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
+
+#include "visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Depth-first visitor that takes boot::any as argument and returns boost::any value
+ */
+class DepthFirstVisitor : public Visitor
+{
+public:
+  virtual boost::any visit (Blob&,  boost::any);
+  virtual boost::any visit (Udata&, boost::any);
+  virtual boost::any visit (Tag&,   boost::any);
+  virtual boost::any visit (Attr&,  boost::any);
+  virtual boost::any visit (Dtag&,  boost::any);
+  virtual boost::any visit (Dattr&, boost::any);
+  virtual boost::any visit (Ext&,   boost::any);
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/name-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/name-visitor.cc
new file mode 100644
index 0000000..13043d3
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/name-visitor.cc
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "name-visitor.h"
+
+#include "string-visitor.h"
+#include "../syntax-tree/dtag.h"
+
+#include "ns3/ndn-name.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+void
+NameVisitor::visit (Dtag &n, boost::any param/*should be Name* */)
+{
+  // uint32_t n.m_dtag;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  static StringVisitor stringVisitor; 
+ 
+  Name &components = *(boost::any_cast<Name*> (param));
+
+  switch (n.m_dtag)
+    {
+    case CCN_DTAG_Component:
+      if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnbDecodingException ();
+      components.Add (
+                      boost::any_cast<std::string> ((*n.m_nestedTags.begin())->accept(
+                                                                                      stringVisitor
+                                                                                      )));
+      break;
+    default:
+      // ignore any other components
+      // when parsing Exclude, there could be <Any /> and <Bloom /> tags
+      break;
+    }
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/name-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/name-visitor.h
new file mode 100644
index 0000000..f71e202
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/name-visitor.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
+#define _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
+
+#include "void-depth-first-visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain fill CcnxName object with name components
+ */
+class NameVisitor : public VoidDepthFirstVisitor
+{
+public:
+  virtual void visit (Dtag &n, boost::any param/*should be Name* */);
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
+
diff --git a/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.cc
new file mode 100644
index 0000000..6393e7e
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.cc
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "no-argu-depth-first-visitor.h"
+
+#include "../syntax-tree/blob.h"
+#include "../syntax-tree/udata.h"
+#include "../syntax-tree/tag.h"
+#include "../syntax-tree/dtag.h"
+#include "../syntax-tree/attr.h"
+#include "../syntax-tree/dattr.h"
+#include "../syntax-tree/ext.h"
+
+#include <boost/foreach.hpp>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+boost::any
+NoArguDepthFirstVisitor::visit (Blob &n)
+{
+  // Buffer n.m_blob;
+  return n.m_blob;
+}
+ 
+boost::any
+NoArguDepthFirstVisitor::visit (Udata &n)
+{
+  // std::string n.m_udata;
+  return n.m_udata;
+}
+ 
+boost::any
+NoArguDepthFirstVisitor::visit (Tag &n)
+{
+  // uint32_t n.m_dtag;
+  // std::list<Ptr<Block> > n.m_attrs;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+    {
+      block->accept (*this);
+    }
+  BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+    {
+      block->accept (*this);
+    }
+  return boost::any ();
+}
+ 
+boost::any
+NoArguDepthFirstVisitor::visit (Dtag &n)
+{
+  // uint32_t n.m_dtag;
+  // std::list<Ptr<Block> > n.m_attrs;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+    {
+      block->accept (*this);
+    }
+  BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+    {
+      block->accept (*this);
+    }
+  return boost::any();
+}
+ 
+boost::any
+NoArguDepthFirstVisitor::visit (Attr &n)
+{
+  // std::string n.m_attr;
+  // Ptr<Udata> n.m_value;
+  return boost::any ();
+}
+ 
+boost::any
+NoArguDepthFirstVisitor::visit (Dattr &n)
+{
+  // uint32_t n.m_dattr;
+  // Ptr<Udata> n.m_value;
+  return boost::any ();
+}
+ 
+boost::any
+NoArguDepthFirstVisitor::visit (Ext &n)
+{
+  // uint64_t n.m_extSubtype;
+  return n.m_extSubtype;
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.h
new file mode 100644
index 0000000..c400083
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+
+#include "no-argu-visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Depth-first visitor that takes no arguments and returns boost::any value
+ */
+class NoArguDepthFirstVisitor : public NoArguVisitor
+{
+public:
+  virtual boost::any visit (Blob& );
+  virtual boost::any visit (Udata&);
+  virtual boost::any visit (Tag&  );
+  virtual boost::any visit (Attr& );
+  virtual boost::any visit (Dtag& );
+  virtual boost::any visit (Dattr&);
+  virtual boost::any visit (Ext&  );
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/no-argu-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/no-argu-visitor.h
new file mode 100644
index 0000000..d603a0a
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/no-argu-visitor.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_NO_ARGU_VISITOR_H_
+#define _CCNB_PARSER_NO_ARGU_VISITOR_H_
+
+#include "../common.h"
+#include <boost/any.hpp>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor interface that takes no arguments and returns boost::any
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ * for ccnb encoding format help
+ */
+class NoArguVisitor
+{
+public:
+  virtual boost::any visit (Blob& )=0; ///< \brief Method accepting BLOB block  
+  virtual boost::any visit (Udata&)=0; ///< \brief Method accepting UDATA block 
+  virtual boost::any visit (Tag&  )=0; ///< \brief Method accepting TAG block   
+  virtual boost::any visit (Attr& )=0; ///< \brief Method accepting ATTR block  
+  virtual boost::any visit (Dtag& )=0; ///< \brief Method accepting DTAG block  
+  virtual boost::any visit (Dattr&)=0; ///< \brief Method accepting DATTR block 
+  virtual boost::any visit (Ext&  )=0; ///< \brief Method accepting EXT block
+
+  virtual ~NoArguVisitor () { }
+};
+  
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_NO_ARGU_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.cc
new file mode 100644
index 0000000..9c2fee3
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.cc
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "non-negative-integer-visitor.h"
+
+#include "../syntax-tree/blob.h"
+#include "../syntax-tree/udata.h"
+#include <sstream>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+boost::any
+NonNegativeIntegerVisitor::visit (Blob &n) //to throw parsing error
+{
+  // Buffer n.m_blob;
+  throw CcnbDecodingException ();
+}
+
+boost::any
+NonNegativeIntegerVisitor::visit (Udata &n)
+{
+  // std::string n.m_udata;
+  std::istringstream is (n.m_udata);
+  int32_t value;
+  is >> value;
+  if (value<0) // value should be non-negative
+    throw CcnbDecodingException ();
+
+  return static_cast<uint32_t> (value);
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.h
new file mode 100644
index 0000000..027e0eb
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
+#define _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
+
+#include "no-argu-depth-first-visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain non-negative integer value from UDATA block
+ *
+ * Will return empty boost::any() if called on anything except UDATA block
+ */
+class NonNegativeIntegerVisitor : public NoArguDepthFirstVisitor
+{
+public:
+  virtual boost::any visit (Blob &n); ///< Throws an exception if BLOB object is encountered
+  virtual boost::any visit (Udata &n);
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/string-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/string-visitor.cc
new file mode 100644
index 0000000..5c41779
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/string-visitor.cc
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "string-visitor.h"
+#include "../syntax-tree/udata.h"
+#include "../syntax-tree/blob.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+boost::any
+StringVisitor::visit (Blob &n) 
+{
+  // Buffer n.m_blob;
+  return std::string (n.m_blob, n.m_blobSize);
+}
+
+boost::any
+StringVisitor::visit (Udata &n)
+{
+  // std::string n.m_udata;
+  return n.m_udata;
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/string-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/string-visitor.h
new file mode 100644
index 0000000..b6a74fd
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/string-visitor.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_STRING_VISITOR_H_
+#define _CCNB_PARSER_STRING_VISITOR_H_
+
+#include "no-argu-depth-first-visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain string value from UDATA block
+ *
+ * Will return empty boost::any() if called on anything except UDATA block
+ */
+class StringVisitor : public NoArguDepthFirstVisitor
+{
+public:
+  virtual boost::any visit (Blob &n);
+  virtual boost::any visit (Udata &n);
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_STRING_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.cc
new file mode 100644
index 0000000..efea82a
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.cc
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "timestamp-visitor.h"
+#include "../syntax-tree/blob.h"
+
+#include "ns3/nstime.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+boost::any/*Time*/
+TimestampVisitor::visit (Blob &n) 
+{
+  // Buffer n.m_blob;
+  if (n.m_blobSize < 2)
+    throw CcnbDecodingException ();
+
+  const char *start = n.m_blob;
+  
+  intmax_t seconds = 0;
+  intmax_t nanoseconds = 0;
+
+  for (uint32_t i=0; i < n.m_blobSize-2; i++)
+    {
+      seconds = (seconds << 8) | (uint8_t)start[i];
+    }
+  uint8_t combo = start[n.m_blobSize-2]; // 4 most significant bits hold 4 least significant bits of number of seconds
+  seconds = (seconds << 4) | (combo >> 4);
+
+  nanoseconds = combo & 0x0F; /*00001111*/ // 4 least significant bits hold 4 most significant bits of number of
+  nanoseconds = (nanoseconds << 8) | start[n.m_blobSize-1];
+  nanoseconds = (intmax_t) ((nanoseconds / 4096.0/*2^12*/) * 1000000 /*up-convert useconds*/);
+
+  return boost::any (Time::FromInteger (seconds, Time::S) + Time::FromInteger (nanoseconds, Time::US));
+}
+
+boost::any
+TimestampVisitor::visit (Udata &n)
+{
+  // std::string n.m_udata;
+  throw CcnbDecodingException ();
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.h
new file mode 100644
index 0000000..a5ad224
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_TIMESTAMP_VISITOR_H_
+#define _CCNB_PARSER_TIMESTAMP_VISITOR_H_
+
+#include "no-argu-depth-first-visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain timestamp value from BLOB block
+ *
+ * Will return empty boost::any() if called on anything except BLOB block
+ */
+class TimestampVisitor : public NoArguDepthFirstVisitor
+{
+public:
+  virtual boost::any visit (Blob &n); 
+  virtual boost::any/*Time*/ visit (Udata &n); ///< Throws parsing error if UDATA object is encountered
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_TIMESTAMP_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.cc
new file mode 100644
index 0000000..f5620ae
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.cc
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "uint32t-blob-visitor.h"
+#include "../syntax-tree/blob.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+boost::any
+Uint32tBlobVisitor::visit (Blob &n) 
+{
+  // Buffer n.m_blob;
+  if (n.m_blobSize < 4)
+    throw CcnbDecodingException ();
+     
+  return boost::any (*(reinterpret_cast<uint32_t*> (n.m_blob)));
+}
+
+boost::any
+Uint32tBlobVisitor::visit (Udata &n)
+{
+  // std::string n.m_udata;
+  throw CcnbDecodingException ();
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.h
new file mode 100644
index 0000000..5d30405
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
+#define _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
+
+#include "no-argu-depth-first-visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain nonce value from BLOB block
+ *
+ * Note, only first 32 bits will be actually parsed into nonce. If
+ * original Nonce contains more, the rest will be ignored
+ *
+ * Will return empty boost::any() if called on anything except BLOB block
+ */
+class Uint32tBlobVisitor : public NoArguDepthFirstVisitor
+{
+public:
+  virtual boost::any visit (Blob &n); 
+  virtual boost::any visit (Udata &n); ///< Throws parsing error if BLOB object is encountered
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/visitor.h b/model/wire/ccnb/ccnb-parser/visitors/visitor.h
new file mode 100644
index 0000000..ee9f831
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/visitor.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VISITOR_H_
+#define _CCNB_PARSER_VISITOR_H_
+
+#include "../common.h"
+#include <boost/any.hpp>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor interface that takes one boost::any argument and returns boost::any
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ * for ccnb encoding format help
+ */
+class Visitor
+{
+public:
+  virtual boost::any visit (Blob&,  boost::any)=0; ///< \brief Method accepting BLOB block  
+  virtual boost::any visit (Udata&, boost::any)=0; ///< \brief Method accepting UDATA block 
+  virtual boost::any visit (Tag&,   boost::any)=0; ///< \brief Method accepting TAG block   
+  virtual boost::any visit (Attr&,  boost::any)=0; ///< \brief Method accepting ATTR block  
+  virtual boost::any visit (Dtag&,  boost::any)=0; ///< \brief Method accepting DTAG block  
+  virtual boost::any visit (Dattr&, boost::any)=0; ///< \brief Method accepting DATTR block 
+  virtual boost::any visit (Ext&,   boost::any)=0; ///< \brief Method accepting EXT block
+
+  virtual ~Visitor () { }
+};                                                
+                                                  
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+                                                  
+#endif // _CCNB_PARSER_VISITOR_H_                             
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.cc
new file mode 100644
index 0000000..8a8adde
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.cc
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "void-depth-first-visitor.h"
+
+#include "../syntax-tree/blob.h"
+#include "../syntax-tree/udata.h"
+#include "../syntax-tree/tag.h"
+#include "../syntax-tree/dtag.h"
+#include "../syntax-tree/attr.h"
+#include "../syntax-tree/dattr.h"
+#include "../syntax-tree/ext.h"
+
+#include <boost/foreach.hpp>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+void
+VoidDepthFirstVisitor::visit (Blob &n, boost::any param)
+{
+  // Buffer n.m_blob;
+}
+ 
+void
+VoidDepthFirstVisitor::visit (Udata &n, boost::any param)
+{
+  // std::string n.m_udata;
+}
+ 
+void
+VoidDepthFirstVisitor::visit (Tag &n, boost::any param)
+{
+  // std::string n.m_tag;
+  // std::list<Ptr<Block> > n.m_attrs;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+    {
+      block->accept (*this, param);
+    }
+  BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+    {
+      block->accept (*this, param);
+    }
+}
+ 
+void
+VoidDepthFirstVisitor::visit (Dtag &n, boost::any param)
+{
+  // std::string n.m_tag;
+  // std::list<Ptr<Block> > n.m_attrs;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+    {
+      block->accept (*this, param);
+    }
+  BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+    {
+      block->accept (*this, param);
+    }
+}
+ 
+void
+VoidDepthFirstVisitor::visit (Attr &n, boost::any param)
+{
+  // std::string n.m_attr;
+  // Ptr<Udata> n.m_value;
+}
+ 
+void
+VoidDepthFirstVisitor::visit (Dattr &n, boost::any param)
+{
+  // uint32_t n.m_dattr;
+  // Ptr<Udata> n.m_value;
+}
+ 
+void
+VoidDepthFirstVisitor::visit (Ext &n, boost::any param)
+{
+  // uint64_t n.m_extSubtype;
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.h
new file mode 100644
index 0000000..96f8b6f
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
+
+#include "void-visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Depth-first visitor that takes one argument and returns nothing
+ */
+class VoidDepthFirstVisitor : public VoidVisitor
+{
+public:
+  virtual void visit (Blob&,  boost::any);
+  virtual void visit (Udata&, boost::any);
+  virtual void visit (Tag&,   boost::any);
+  virtual void visit (Attr&,  boost::any);
+  virtual void visit (Dtag&,  boost::any);
+  virtual void visit (Dattr&, boost::any);
+  virtual void visit (Ext&,   boost::any);
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.cc
new file mode 100644
index 0000000..5bcecb8
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.cc
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "void-no-argu-depth-first-visitor.h"
+
+#include "../syntax-tree/blob.h"
+#include "../syntax-tree/udata.h"
+#include "../syntax-tree/tag.h"
+#include "../syntax-tree/dtag.h"
+#include "../syntax-tree/attr.h"
+#include "../syntax-tree/dattr.h"
+#include "../syntax-tree/ext.h"
+
+#include <boost/foreach.hpp>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+void
+VoidNoArguDepthFirstVisitor::visit (Blob &n)
+{
+  // Buffer n.m_blob;
+}
+ 
+void
+VoidNoArguDepthFirstVisitor::visit (Udata &n)
+{
+  // std::string n.m_udata;
+}
+ 
+void
+VoidNoArguDepthFirstVisitor::visit (Tag &n)
+{
+  // std::string n.m_tag;
+  // std::list<Ptr<Block> > n.m_attrs;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+    {
+      block->accept (*this);
+    }
+  BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+    {
+      block->accept (*this);
+    }
+}
+ 
+void
+VoidNoArguDepthFirstVisitor::visit (Dtag &n)
+{
+  // uint32_t n.m_dtag;
+  // std::list<Ptr<Block> > n.m_attrs;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
+    {
+      block->accept (*this);
+    }
+  BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
+    {
+      block->accept (*this);
+    }
+}
+ 
+void
+VoidNoArguDepthFirstVisitor::visit (Attr &n)
+{
+  // std::string n.m_attr;
+  // Ptr<Udata> n.m_value;
+}
+ 
+void
+VoidNoArguDepthFirstVisitor::visit (Dattr &n)
+{
+  // uint32_t n.m_dattr;
+  // Ptr<Udata> n.m_value;
+}
+ 
+void
+VoidNoArguDepthFirstVisitor::visit (Ext &n)
+{
+  // uint64_t n.m_extSubtype;
+}
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.h
new file mode 100644
index 0000000..59b59d7
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+
+#include "void-no-argu-visitor.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Depth-first visitor that takes no arguments and returns nothing
+ */
+class VoidNoArguDepthFirstVisitor : public VoidNoArguVisitor
+{
+public:
+  virtual void visit (Blob& );
+  virtual void visit (Udata&);
+  virtual void visit (Tag&  );
+  virtual void visit (Attr& );
+  virtual void visit (Dtag& );
+  virtual void visit (Dattr&);
+  virtual void visit (Ext&  );
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-visitor.h
new file mode 100644
index 0000000..a98d933
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-visitor.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
+#define _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
+
+#include "../common.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ndn-ccnb
+ * \brief Visitor interface that takes no arguments and returns nothing
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ * for ccnb encoding format help
+ */
+class VoidNoArguVisitor
+{
+public:
+  virtual void visit (Blob& )=0; ///< \brief Method accepting BLOB block
+  virtual void visit (Udata&)=0; ///< \brief Method accepting UDATA block
+  virtual void visit (Tag&  )=0; ///< \brief Method accepting TAG block
+  virtual void visit (Attr& )=0; ///< \brief Method accepting ATTR block
+  virtual void visit (Dtag& )=0; ///< \brief Method accepting DTAG block
+  virtual void visit (Dattr&)=0; ///< \brief Method accepting DATTR block
+  virtual void visit (Ext&  )=0; ///< \brief Method accepting EXT block
+
+  virtual ~VoidNoArguVisitor () { }
+};
+  
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/void-visitor.h
new file mode 100644
index 0000000..8c51e21
--- /dev/null
+++ b/model/wire/ccnb/ccnb-parser/visitors/void-visitor.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef _CCNB_PARSER_VOID_VISITOR_H_
+#define _CCNB_PARSER_VOID_VISITOR_H_
+
+#include "../common.h"
+#include <boost/any.hpp>
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace CcnbParser {
+
+/**
+ * \ingroup ndn-ccnb
+ * \brief Visitor interface that takes one boost::any argument and returns nothing
+ *
+ * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
+ * for ccnb encoding format help
+ */
+class VoidVisitor
+{
+public:
+  virtual void visit (Blob&,  boost::any)=0; ///< \brief Method accepting BLOB block  
+  virtual void visit (Udata&, boost::any)=0; ///< \brief Method accepting UDATA block 
+  virtual void visit (Tag&,   boost::any)=0; ///< \brief Method accepting TAG block   
+  virtual void visit (Attr&,  boost::any)=0; ///< \brief Method accepting ATTR block  
+  virtual void visit (Dtag&,  boost::any)=0; ///< \brief Method accepting DTAG block  
+  virtual void visit (Dattr&, boost::any)=0; ///< \brief Method accepting DATTR block 
+  virtual void visit (Ext&,   boost::any)=0; ///< \brief Method accepting EXT block
+
+  virtual ~VoidVisitor () { }
+};
+
+} // CcnbParser
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // _CCNB_PARSER_VOID_VISITOR_H_
diff --git a/model/wire/ccnb/wire-ccnb-data.cc b/model/wire/ccnb/wire-ccnb-data.cc
new file mode 100644
index 0000000..767d57b
--- /dev/null
+++ b/model/wire/ccnb/wire-ccnb-data.cc
@@ -0,0 +1,505 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "../ccnb.h"
+
+#include "wire-ccnb.h"
+
+#include "ns3/log.h"
+
+#include "ccnb-parser/common.h"
+#include "ccnb-parser/visitors/void-depth-first-visitor.h"
+#include "ccnb-parser/visitors/name-visitor.h"
+#include "ccnb-parser/visitors/non-negative-integer-visitor.h"
+#include "ccnb-parser/visitors/timestamp-visitor.h"
+#include "ccnb-parser/visitors/string-visitor.h"
+#include "ccnb-parser/visitors/uint32t-blob-visitor.h"
+#include "ccnb-parser/visitors/content-type-visitor.h"
+
+#include "ccnb-parser/syntax-tree/block.h"
+#include "ccnb-parser/syntax-tree/dtag.h"
+
+#include <boost/foreach.hpp>
+
+NS_LOG_COMPONENT_DEFINE ("ndn.wire.Ccnb.Data");
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace ccnb {
+
+// const std::string DefaultDigestAlgorithm = "2.16.840.1.101.3.4.2.1";
+
+class DataTrailer : public Trailer
+{
+public:
+  DataTrailer ()
+  {
+  }
+
+  static TypeId GetTypeId ()
+  {
+    static TypeId tid = TypeId ("ns3::ndn::Data::Ccnb::Closer")
+      .SetGroupName ("Ndn")
+      .SetParent<Trailer> ()
+      .AddConstructor<DataTrailer> ()
+      ;
+    return tid;
+  }
+
+  virtual TypeId GetInstanceTypeId (void) const
+  {
+    return GetTypeId ();
+  }
+
+  virtual void Print (std::ostream &os) const
+  {
+  }
+
+  virtual uint32_t GetSerializedSize (void) const
+  {
+    return 2;
+  }
+
+  virtual void Serialize (Buffer::Iterator end) const
+  {
+    Buffer::Iterator i = end;
+    i.Prev (2); // Trailer interface requires us to go backwards
+
+    i.WriteU8 (0x00); // </Content>
+    i.WriteU8 (0x00); // </ContentObject>
+  }
+
+  virtual uint32_t Deserialize (Buffer::Iterator end)
+  {
+    Buffer::Iterator i = end;
+    i.Prev (2); // Trailer interface requires us to go backwards
+
+    uint8_t closing_tag_content = i.ReadU8 ();
+    NS_ASSERT_MSG (closing_tag_content==0, "Should be a closing tag </Content> (0x00)");
+
+    uint8_t closing_tag_content_object = i.ReadU8 ();
+    NS_ASSERT_MSG (closing_tag_content_object==0, "Should be a closing tag </ContentObject> (0x00)");
+
+    return 2;
+  }
+};
+
+NS_OBJECT_ENSURE_REGISTERED (Data);
+NS_OBJECT_ENSURE_REGISTERED (DataTrailer);
+
+TypeId
+Data::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::ndn::Data::Ccnb")
+    .SetGroupName ("Ndn")
+    .SetParent<Header> ()
+    .AddConstructor<Data> ()
+    ;
+  return tid;
+}
+
+TypeId
+Data::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
+Data::Data ()
+  : m_data (Create<ndn::ContentObject> ())
+{
+}
+
+Data::Data (Ptr<ndn::ContentObject> data)
+  : m_data (data)
+{
+}
+
+Ptr<ndn::ContentObject>
+Data::GetData ()
+{
+  return m_data;
+}
+
+Ptr<Packet>
+Data::ToWire (Ptr<const ndn::ContentObject> data)
+{
+  static DataTrailer trailer;
+
+  Ptr<const Packet> p = data->GetWire ();
+  if (!p)
+    {
+      Ptr<Packet> packet = Create<Packet> (*data->GetPayload ());
+      Data wireEncoding (ConstCast<ndn::ContentObject> (data));
+      packet->AddHeader (wireEncoding);
+      packet->AddTrailer (trailer);
+      data->SetWire (packet);
+
+      p = packet;
+    }
+
+  return p->Copy ();
+}
+
+Ptr<ndn::ContentObject>
+Data::FromWire (Ptr<Packet> packet)
+{
+  static DataTrailer trailer;
+
+  Ptr<ndn::ContentObject> data = Create<ndn::ContentObject> ();
+  data->SetWire (packet->Copy ());
+
+  Data wireEncoding (data);
+  packet->RemoveHeader (wireEncoding);
+  packet->RemoveTrailer (trailer);
+
+  data->SetPayload (packet);
+
+  return data;
+}
+
+void
+Data::Serialize (Buffer::Iterator start) const
+{
+  Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_ContentObject, CcnbParser::CCN_DTAG); // <ContentObject>
+
+  // fake signature
+  Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Signature, CcnbParser::CCN_DTAG); // <Signature>
+  // Signature ::= √DigestAlgorithm?
+  //               Witness?
+  //               √SignatureBits
+  // if (GetSignature ().GetDigestAlgorithm () != Signature::DefaultDigestAlgorithm)
+  //   {
+  //     Ccnb::AppendString (start, CcnbParser::CCN_DTAG_DigestAlgorithm, GetSignature ().GetDigestAlgorithm ());
+  //   }
+  Ccnb::AppendTaggedBlob (start, CcnbParser::CCN_DTAG_SignatureBits, m_data->GetSignature ()); // <SignatureBits />
+  Ccnb::AppendCloser (start);                                    // </Signature>
+
+  Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG);    // <Name>
+  Ccnb::AppendName (start, m_data->GetName()); //   <Component>...</Component>...
+  Ccnb::AppendCloser (start);                                  // </Name>
+
+  // fake signature
+  Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_SignedInfo, CcnbParser::CCN_DTAG); // <SignedInfo>
+  // SignedInfo ::= √PublisherPublicKeyDigest
+  //                √Timestamp
+  //                √Type?
+  //                √FreshnessSeconds?
+  //                FinalBlockID?
+  //                KeyLocator?
+  // Ccnb::AppendTaggedBlob (start, CcnbParser::CCN_DTAG_PublisherPublicKeyDigest,         // <PublisherPublicKeyDigest>...
+  //                         GetSignedInfo ().GetPublisherPublicKeyDigest ());
+
+  Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Timestamp, CcnbParser::CCN_DTAG);            // <Timestamp>...
+  Ccnb::AppendTimestampBlob (start, m_data->GetTimestamp ());
+  Ccnb::AppendCloser (start);
+
+  // if (GetSignedInfo ().GetContentType () != DATA)
+  //   {
+  //     uint8_t type[3];
+  //     type[0] = (GetSignedInfo ().GetContentType () >> 16) & 0xFF;
+  //     type[1] = (GetSignedInfo ().GetContentType () >> 8 ) & 0xFF;
+  //     type[2] = (GetSignedInfo ().GetContentType ()      ) & 0xFF;
+
+  //     Ccnb::AppendTaggedBlob (start, CCN_DTAG_Type, type, 3);
+  //   }
+  if (m_data->GetFreshness () > Seconds(0))
+    {
+      Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_FreshnessSeconds, CcnbParser::CCN_DTAG);
+      Ccnb::AppendNumber (start, m_data->GetFreshness ().ToInteger (Time::S));
+      Ccnb::AppendCloser (start);
+    }
+  if (m_data->GetKeyLocator () != 0)
+    {
+      Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_KeyLocator, CcnbParser::CCN_DTAG); // <KeyLocator>
+      {
+        Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_KeyName, CcnbParser::CCN_DTAG);    // <KeyName>
+        {
+          Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG);       // <Name>
+          Ccnb::AppendName (start, *m_data->GetKeyLocator ());   //   <Component>...</Component>...
+          Ccnb::AppendCloser (start);                                     // </Name>
+        }
+        Ccnb::AppendCloser (start);                                     // </KeyName>
+      }
+      Ccnb::AppendCloser (start);                                     // </KeyLocator>
+    }
+
+  Ccnb::AppendCloser (start);                                     // </SignedInfo>
+
+  Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Content, CcnbParser::CCN_DTAG); // <Content>
+
+  // there are no closing tags !!!
+  // The closing tag is handled by ContentObjectTail
+}
+
+uint32_t
+Data::GetSerializedSize () const
+{
+  size_t written = 0;
+  written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_ContentObject); // <ContentObject>
+
+  // fake signature
+  written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Signature); // <Signature>
+  // Signature ::= DigestAlgorithm?
+  //               Witness?
+  //               SignatureBits
+  // if (GetSignature ().GetDigestAlgorithm () != Signature::DefaultDigestAlgorithm)
+  //   {
+  //     written += Ccnb::EstimateString (CcnbParser::CCN_DTAG_DigestAlgorithm, GetSignature ().GetDigestAlgorithm ());
+  //   }
+  written += Ccnb::EstimateTaggedBlob (CcnbParser::CCN_DTAG_SignatureBits,
+                                       sizeof (m_data->GetSignature ()));      // <SignatureBits />
+  written += 1;                                    // </Signature>
+
+  written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name);    // <Name>
+  written += Ccnb::EstimateName (m_data->GetName ()); //   <Component>...</Component>...
+  written += 1;                                  // </Name>
+
+  // fake signature
+  written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_SignedInfo); // <SignedInfo>
+  // SignedInfo ::= √PublisherPublicKeyDigest
+  //                √Timestamp
+  //                √Type?
+  //                √FreshnessSeconds?
+  //                FinalBlockID?
+  //                KeyLocator?
+
+  // written += Ccnb::EstimateTaggedBlob (CCN_DTAG_PublisherPublicKeyDigest,                          // <PublisherPublicKeyDigest>...
+  //                                      sizeof (GetSignedInfo ().GetPublisherPublicKeyDigest ()));
+
+  written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Timestamp);                  // <Timestamp>...
+  written += Ccnb::EstimateTimestampBlob (m_data->GetTimestamp ());
+  written += 1;
+
+  // if (GetSignedInfo ().GetContentType () != DATA)
+  //   {
+  //     written += Ccnb::EstimateTaggedBlob (CcnbParser::CCN_DTAG_Type, 3);
+  //   }
+  if (m_data->GetFreshness () > Seconds(0))
+    {
+      written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_FreshnessSeconds);
+      written += Ccnb::EstimateNumber (m_data->GetFreshness ().ToInteger (Time::S));
+      written += 1;
+    }
+
+  if (m_data->GetKeyLocator () != 0)
+    {
+      written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_KeyLocator); // <KeyLocator>
+      {
+        written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_KeyName);    // <KeyName>
+        {
+          written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name);       // <Name>
+          written += Ccnb::EstimateName (*m_data->GetKeyLocator ());        //   <Component>...</Component>...
+          written += 1;                                               // </Name>
+        }
+        written += 1;                                               // </KeyName>
+      }
+      written += 1;                                               // </KeyLocator>
+    }
+
+  written += 1; // </SignedInfo>
+
+  written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Content); // <Content>
+
+  // there are no closing tags !!!
+  // The closing tag is handled by ContentObjectTail
+  return written;
+}
+
+class ContentObjectVisitor : public CcnbParser::VoidDepthFirstVisitor
+{
+public:
+  virtual void visit (CcnbParser::Dtag &n, boost::any param/*should be ContentObject* */)
+  {
+    // uint32_t n.m_dtag;
+    // std::list< Ptr<CcnbParser::Block> > n.m_nestedBlocks;
+    static CcnbParser::NameVisitor nameVisitor;
+    static CcnbParser::NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
+    static CcnbParser::TimestampVisitor          timestampVisitor;
+    static CcnbParser::StringVisitor      stringVisitor;
+    static CcnbParser::Uint32tBlobVisitor uint32tBlobVisitor;
+    static CcnbParser::ContentTypeVisitor contentTypeVisitor;
+
+    ndn::ContentObject &contentObject = *(boost::any_cast<ndn::ContentObject*> (param));
+
+    switch (n.m_dtag)
+      {
+      case CcnbParser::CCN_DTAG_ContentObject:
+        // process nested blocks
+        BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
+          {
+            block->accept (*this, param);
+          }
+        break;
+      case CcnbParser::CCN_DTAG_Name:
+        {
+          // process name components
+          Ptr<Name> name = Create<Name> ();
+
+          BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
+            {
+              block->accept (nameVisitor, &(*name));
+            }
+          contentObject.SetName (name);
+          break;
+        }
+
+      case CcnbParser::CCN_DTAG_Signature:
+        // process nested blocks
+        BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
+          {
+            block->accept (*this, param);
+          }
+        break;
+
+      // case CCN_DTAG_DigestAlgorithm:
+      //   NS_LOG_DEBUG ("DigestAlgorithm");
+      //   if (n.m_nestedTags.size ()!=1) // should be exactly one UDATA inside this tag
+      //     throw CcnbParser::CcnbDecodingException ();
+
+      //   contentObject.GetSignature ().SetDigestAlgorithm
+      //     (boost::any_cast<std::string> ((*n.m_nestedTags.begin())->accept
+      //                                    (stringVisitor)));
+      //   break;
+
+      case CcnbParser::CCN_DTAG_SignatureBits:
+        NS_LOG_DEBUG ("SignatureBits");
+        if (n.m_nestedTags.size ()!=1) // should be only one nested tag
+          throw CcnbParser::CcnbDecodingException ();
+
+        contentObject.SetSignature
+          (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
+                                      (uint32tBlobVisitor)));
+        break;
+
+      case CcnbParser::CCN_DTAG_SignedInfo:
+        // process nested blocks
+        BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
+          {
+            block->accept (*this, param);
+          }
+        break;
+
+      // case CCN_DTAG_PublisherPublicKeyDigest:
+      //   NS_LOG_DEBUG ("PublisherPublicKeyDigest");
+      //   if (n.m_nestedTags.size ()!=1) // should be only one nested tag
+      //     throw CcnbParser::CcnbDecodingException ();
+
+      //   contentObject.GetSignedInfo ().SetPublisherPublicKeyDigest
+      //     (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
+      //                                 (uint32tBlobVisitor)));
+      //   break;
+
+      case CcnbParser::CCN_DTAG_Timestamp:
+        NS_LOG_DEBUG ("Timestamp");
+        if (n.m_nestedTags.size()!=1) // should be exactly one nested tag
+          throw CcnbParser::CcnbDecodingException ();
+
+        contentObject.SetTimestamp
+          (boost::any_cast<Time> ((*n.m_nestedTags.begin())->accept
+                                  (timestampVisitor)));
+        break;
+
+      // case CCN_DTAG_Type:
+      //   NS_LOG_DEBUG ("Type");
+      //   if (n.m_nestedTags.size ()!=1) // should be only one nested tag
+      //     throw CcnbParser::CcnbDecodingException ();
+
+      //   contentObject.GetSignedInfo ().SetContentType
+      //     (static_cast<Data::ContentType>
+      //      (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
+      //                                  (contentTypeVisitor))));
+      //   break;
+
+      case CcnbParser::CCN_DTAG_FreshnessSeconds:
+        NS_LOG_DEBUG ("FreshnessSeconds");
+
+        if (n.m_nestedTags.size()!=1) // should be exactly one nested tag
+          throw CcnbParser::CcnbDecodingException ();
+
+        contentObject.SetFreshness
+          (Seconds
+           (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
+                                       (nonNegativeIntegerVisitor))));
+        break;
+
+      case CcnbParser::CCN_DTAG_KeyLocator:
+        // process nested blocks
+        BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
+          {
+            block->accept (*this, param);
+          }
+        break;
+
+      case CcnbParser::CCN_DTAG_KeyName:
+        {
+          if (n.m_nestedTags.size ()!=1) // should be exactly one nested tag
+            throw CcnbParser::CcnbDecodingException ();
+
+          Ptr<CcnbParser::BaseTag> nameTag = DynamicCast<CcnbParser::BaseTag>(n.m_nestedTags.front ());
+          if (nameTag == 0)
+            throw CcnbParser::CcnbDecodingException ();
+
+          // process name components
+          Ptr<Name> name = Create<Name> ();
+
+          BOOST_FOREACH (Ptr<CcnbParser::Block> block, nameTag->m_nestedTags)
+            {
+              block->accept (nameVisitor, &(*name));
+            }
+          contentObject.SetKeyLocator (name);
+          break;
+        }
+
+      case CcnbParser::CCN_DTAG_Content: // !!! HACK
+        // This hack was necessary for memory optimizations (i.e., content is virtual payload)
+        NS_ASSERT_MSG (n.m_nestedTags.size() == 0, "Parser should have stopped just after processing <Content> tag");
+        break;
+
+      default: // ignore all other stuff
+        break;
+      }
+  }
+};
+
+uint32_t
+Data::Deserialize (Buffer::Iterator start)
+{
+  static ContentObjectVisitor contentObjectVisitor;
+
+  Buffer::Iterator i = start;
+  Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
+  root->accept (contentObjectVisitor, GetPointer (m_data));
+
+  return i.GetDistanceFrom (start);
+}
+
+void
+Data::Print (std::ostream &os) const
+{
+  os << "D: " << m_data->GetName ();
+  // os << "<ContentObject><Name>" << GetName () << "</Name><Content>";
+}
+
+} // ccnb
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/wire-ccnb-interest.cc b/model/wire/ccnb/wire-ccnb-interest.cc
new file mode 100644
index 0000000..8a0ec3b
--- /dev/null
+++ b/model/wire/ccnb/wire-ccnb-interest.cc
@@ -0,0 +1,451 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "../ccnb.h"
+
+#include "wire-ccnb.h"
+
+#include "ns3/log.h"
+#include "ns3/unused.h"
+#include "ns3/packet.h"
+
+#include "ccnb-parser/visitors/name-visitor.h"
+#include "ccnb-parser/visitors/non-negative-integer-visitor.h"
+#include "ccnb-parser/visitors/timestamp-visitor.h"
+#include "ccnb-parser/visitors/uint32t-blob-visitor.h"
+
+#include "ccnb-parser/syntax-tree/block.h"
+#include "ccnb-parser/syntax-tree/dtag.h"
+
+#include <boost/foreach.hpp>
+
+NS_LOG_COMPONENT_DEFINE ("ndn.wire.Ccnb.Interest");
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+namespace ccnb {
+
+NS_OBJECT_ENSURE_REGISTERED (Interest);
+
+TypeId
+Interest::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::ndn::Interest::Ccnb")
+    .SetGroupName ("Ndn")
+    .SetParent<Header> ()
+    .AddConstructor<Interest> ()
+    ;
+  return tid;
+}
+
+TypeId
+Interest::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
+Interest::Interest ()
+  : m_interest (Create<ndn::Interest> ())
+{
+}
+
+Interest::Interest (Ptr<ndn::Interest> interest)
+  : m_interest (interest)
+{
+}
+
+Ptr<ndn::Interest>
+Interest::GetInterest ()
+{
+  return m_interest;
+}
+
+Ptr<Packet>
+Interest::ToWire (Ptr<const ndn::Interest> interest)
+{
+  Ptr<const Packet> p = interest->GetWire ();
+  if (!p)
+    {
+      Ptr<Packet> packet = Create<Packet> (*interest->GetPayload ());
+      Interest wireEncoding (ConstCast<ndn::Interest> (interest));
+      packet->AddHeader (wireEncoding);
+      interest->SetWire (packet);
+
+      p = packet;
+    }
+  
+  return p->Copy ();
+}
+
+Ptr<ndn::Interest>
+Interest::FromWire (Ptr<Packet> packet)
+{
+  Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
+  interest->SetWire (packet->Copy ());
+
+  Interest wireEncoding (interest);
+  packet->RemoveHeader (wireEncoding);
+
+  interest->SetPayload (packet);
+
+  return interest;
+}
+
+void
+Interest::Serialize (Buffer::Iterator start) const
+{
+  Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Interest, CcnbParser::CCN_DTAG); // <Interest>
+  
+  Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
+  Ccnb::AppendName (start, m_interest->GetName());                // <Component>...</Component>...
+  Ccnb::AppendCloser (start);                               // </Name>
+
+  // if (m_interest->GetMinSuffixComponents() >= 0)
+  //   {
+  //     Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_MinSuffixComponents, CcnbParser::CCN_DTAG);
+  //     Ccnb::AppendNumber (start, m_interest->GetMinSuffixComponents ());
+  //     Ccnb::AppendCloser (start);
+  //   }
+  // if (m_interest->GetMaxSuffixComponents() >= 0)
+  //   {
+  //     Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_MaxSuffixComponents, CcnbParser::CCN_DTAG);
+  //     Ccnb::AppendNumber (start, m_interest->GetMaxSuffixComponents ());
+  //     Ccnb::AppendCloser (start);
+  //   }
+  // if (m_interest->IsEnabledExclude() && m_interest->GetExclude().size() > 0)
+  //   {
+  //     Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Exclude, CcnbParser::CCN_DTAG); // <Exclude>
+  //     Ccnb::AppendName (start, m_interest->GetExclude());                // <Component>...</Component>...
+  //     Ccnb::AppendCloser (start);                                  // </Exclude>
+  //   }
+  // if (m_interest->IsEnabledChildSelector())
+  //   {
+  //     Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_ChildSelector, CcnbParser::CCN_DTAG);
+  //     Ccnb::AppendNumber (start, 1);
+  //     Ccnb::AppendCloser (start);
+  //   }
+  // if (m_interest->IsEnabledAnswerOriginKind())
+  //   {
+  //     Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_AnswerOriginKind, CcnbParser::CCN_DTAG);
+  //     Ccnb::AppendNumber (start, 1);
+  //     Ccnb::AppendCloser (start);
+  //   }
+  if (m_interest->GetScope() >= 0)
+    {
+      Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Scope, CcnbParser::CCN_DTAG);
+      Ccnb::AppendNumber (start, m_interest->GetScope ());
+      Ccnb::AppendCloser (start);
+    }
+  if (!m_interest->GetInterestLifetime().IsZero())
+    {
+      Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_InterestLifetime, CcnbParser::CCN_DTAG);
+      Ccnb::AppendTimestampBlob (start, m_interest->GetInterestLifetime ());
+      Ccnb::AppendCloser (start);
+    }
+  if (m_interest->GetNonce()>0)
+    {
+      uint32_t nonce = m_interest->GetNonce();
+      Ccnb::AppendTaggedBlob (start, CcnbParser::CCN_DTAG_Nonce, nonce);
+    }
+    
+  if (m_interest->GetNack ()>0)
+    {
+      Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Nack, CcnbParser::CCN_DTAG);
+      Ccnb::AppendNumber (start, m_interest->GetNack ());
+      Ccnb::AppendCloser (start);
+    }
+  Ccnb::AppendCloser (start); // </Interest>
+}
+
+uint32_t
+Interest::GetSerializedSize () const
+{
+  size_t written = 0;
+  written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Interest); // <Interest>
+  
+  written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
+  written += Ccnb::EstimateName (m_interest->GetName()); // <Component>...</Component>...
+  written += 1; // </Name>
+
+  // if (m_interest->GetMinSuffixComponents() >= 0)
+  //   {
+  //     written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_MinSuffixComponents);
+  //     written += Ccnb::EstimateNumber (m_interest->GetMinSuffixComponents ());
+  //     written += 1;
+  //   }
+  // if (m_interest->GetMaxSuffixComponents() >= 0)
+  //   {
+  //     written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_MaxSuffixComponents);
+  //     written += Ccnb::EstimateNumber (m_interest->GetMaxSuffixComponents ());
+  //     written += 1;
+  //   }
+  // if (m_interest->IsEnabledExclude() && m_interest->GetExclude().size() > 0)
+  //   {
+  //     written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Exclude);
+  //     written += Ccnb::EstimateName (m_interest->GetExclude());                // <Component>...</Component>...
+  //     written += 1;                                  // </Exclude>
+  //   }
+  // if (m_interest->IsEnabledChildSelector())
+  //   {
+  //     written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_ChildSelector);
+  //     written += Ccnb::EstimateNumber (1);
+  //     written += 1;
+  //   }
+  // if (m_interest->IsEnabledAnswerOriginKind())
+  //   {
+  //     written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_AnswerOriginKind);
+  //     written += Ccnb::EstimateNumber (1);
+  //     written += 1;
+  //   }
+  if (m_interest->GetScope() >= 0)
+    {
+      written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Scope);
+      written += Ccnb::EstimateNumber (m_interest->GetScope ());
+      written += 1;
+    }
+  if (!m_interest->GetInterestLifetime().IsZero())
+    {
+      written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_InterestLifetime);
+      written += Ccnb::EstimateTimestampBlob (m_interest->GetInterestLifetime());
+      written += 1;
+    }
+  if (m_interest->GetNonce()>0)
+    {
+      written += Ccnb::EstimateTaggedBlob (CcnbParser::CCN_DTAG_Nonce, sizeof(uint32_t));
+    }
+  if (m_interest->GetNack ()>0)
+    {
+        written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Nack);
+        written += Ccnb::EstimateNumber (m_interest->GetNack ());
+        written += 1;
+    }
+
+  written += 1; // </Interest>
+
+  return written;
+}
+
+class InterestVisitor : public CcnbParser::VoidDepthFirstVisitor
+{
+public:
+  virtual void visit (CcnbParser::Dtag &n, boost::any param/*should be CcnxInterest* */);
+};
+
+// We don't care about any other fields
+void
+InterestVisitor::visit (CcnbParser::Dtag &n, boost::any param/*should be Interest* */)
+{
+  // uint32_t n.m_dtag;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+
+  static CcnbParser::NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
+  static CcnbParser::NameVisitor               nameVisitor;
+  static CcnbParser::TimestampVisitor          timestampVisitor;
+  static CcnbParser::Uint32tBlobVisitor        nonceVisitor;
+  
+  ndn::Interest &interest = *(boost::any_cast<ndn::Interest*> (param));
+
+  switch (n.m_dtag)
+    {
+    case CcnbParser::CCN_DTAG_Interest:
+      NS_LOG_DEBUG ("Interest");
+  
+      // process nested blocks
+      BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
+        {
+          block->accept (*this, param);
+        }
+      break;
+    case CcnbParser::CCN_DTAG_Name:
+      {
+        NS_LOG_DEBUG ("Name");
+
+        // process name components
+        Ptr<Name> name = Create<Name> ();
+        
+        BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
+          {
+            block->accept (nameVisitor, &(*name));
+          }
+        interest.SetName (name);
+        break;
+      }
+    // case CcnbParser::CCN_DTAG_MinSuffixComponents:
+    //   NS_LOG_DEBUG ("MinSuffixComponents");
+    //   if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
+    //     throw CcnbParser::CcnbDecodingException ();
+    //   interest.SetMinSuffixComponents (
+    //            boost::any_cast<uint32_t> (
+    //                                       (*n.m_nestedTags.begin())->accept(
+    //                                                                        nonNegativeIntegerVisitor
+    //                                                                        )));
+    //   break;
+    // case CcnbParser::CCN_DTAG_MaxSuffixComponents:
+    //   NS_LOG_DEBUG ("MaxSuffixComponents");
+    //   if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
+    //     throw CcnbParser::CcnbDecodingException ();
+    //   interest.SetMaxSuffixComponents (
+    //            boost::any_cast<uint32_t> (
+    //                                       (*n.m_nestedTags.begin())->accept(
+    //                                                                        nonNegativeIntegerVisitor
+    //                                                                        )));
+    //   break;
+    // case CcnbParser::CCN_DTAG_Exclude:
+    //   {
+    //     NS_LOG_DEBUG ("Exclude");
+    //     // process exclude components
+    //     Ptr<Name> exclude = Create<Name> ();
+        
+    //     BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
+    //       {
+    //         block->accept (nameVisitor, &(*exclude));
+    //       }
+    //     interest.SetExclude (exclude);
+    //     break;
+    //   }
+    // case CcnbParser::CCN_DTAG_ChildSelector:
+    //   NS_LOG_DEBUG ("ChildSelector");
+    //   if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
+    //     throw CcnbParser::CcnbDecodingException ();
+
+    //   interest.SetChildSelector (
+    //            1 == boost::any_cast<uint32_t> (
+    //                                       (*n.m_nestedTags.begin())->accept(
+    //                                                                        nonNegativeIntegerVisitor
+    //                                                                        )));
+    //   break;
+    // case CCN_DTAG_AnswerOriginKind:
+    //   NS_LOG_DEBUG ("AnswerOriginKind");
+    //   if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
+    //     throw CcnbParser::CcnbDecodingException ();
+    //   interest.SetAnswerOriginKind (
+    //            1 == boost::any_cast<uint32_t> (
+    //                                       (*n.m_nestedTags.begin())->accept(
+    //                                                                        nonNegativeIntegerVisitor
+    //                                                                        )));
+    //   break;
+    case CcnbParser::CCN_DTAG_Scope: 
+      NS_LOG_DEBUG ("Scope");
+      if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnbParser::CcnbDecodingException ();
+      interest.SetScope (
+               boost::any_cast<uint32_t> (
+                                          (*n.m_nestedTags.begin())->accept(
+                                                                           nonNegativeIntegerVisitor
+                                                                           )));
+      break;
+    case CcnbParser::CCN_DTAG_InterestLifetime:
+      NS_LOG_DEBUG ("InterestLifetime");
+      if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnbParser::CcnbDecodingException ();
+
+      interest.SetInterestLifetime (
+               boost::any_cast<Time> (
+                                      (*n.m_nestedTags.begin())->accept(
+                                                                        timestampVisitor
+                                                                        )));
+      break;
+    case CcnbParser::CCN_DTAG_Nonce:
+      NS_LOG_DEBUG ("Nonce");
+      if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnbParser::CcnbDecodingException ();
+
+      interest.SetNonce (
+               boost::any_cast<uint32_t> (
+                                          (*n.m_nestedTags.begin())->accept(
+                                                                           nonceVisitor
+                                                                           )));
+      break;
+    
+            
+    case CcnbParser::CCN_DTAG_Nack:
+      NS_LOG_DEBUG ("Nack");
+      if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnbParser::CcnbDecodingException ();
+            
+      interest.SetNack (
+               boost::any_cast<uint32_t> (
+                                          (*n.m_nestedTags.begin())->accept(nonNegativeIntegerVisitor)));
+      break;
+    }
+}
+
+
+uint32_t
+Interest::Deserialize (Buffer::Iterator start)
+{
+  static InterestVisitor interestVisitor;
+
+  Buffer::Iterator i = start;
+  Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
+  root->accept (interestVisitor, GetPointer (m_interest));
+  
+  return i.GetDistanceFrom (start);
+}
+
+void
+Interest::Print (std::ostream &os) const
+{
+  os << "I: " << m_interest->GetName ();
+  
+  return;
+  // os << "<Interest>\n  <Name>" << GetName () << "</Name>\n";
+  // if (GetNack ()>0)
+  //   {
+  //     os << "  <NACK>";
+  //     switch (GetNack ())
+  //       {
+  //       case NACK_LOOP:
+  //         os << "loop";
+  //         break;
+  //       case NACK_CONGESTION:
+  //         os << "congestion";
+  //         break;
+  //       default:
+  //         os << "unknown";
+  //         break;
+  //       }
+  //     os << "</NACK>\n";
+  //   }
+  // if (GetMinSuffixComponents () >= 0)
+  //   os << "  <MinSuffixComponents>" << GetMinSuffixComponents () << "</MinSuffixComponents>\n";
+  // if (GetMaxSuffixComponents () >= 0)
+  //   os << "  <MaxSuffixComponents>" << m_maxSuffixComponents << "</MaxSuffixComponents>\n";
+  // if (IsEnabledExclude () && GetExclude ().size()>0)
+  //   os << "  <Exclude>" << GetExclude () << "</Exclude>\n";
+  // if (IsEnabledChildSelector ())
+  //   os << "  <ChildSelector />\n";
+  // if (IsEnabledAnswerOriginKind ())
+  //   os << "  <AnswerOriginKind />\n";
+  // if (GetScope () >= 0)
+  //   os << "  <Scope>" << GetScope () << "</Scope>\n";
+  // if ( !GetInterestLifetime ().IsZero() )
+  //   os << "  <InterestLifetime>" << GetInterestLifetime () << "</InterestLifetime>\n";
+  // if (GetNonce ()>0)
+  //   os << "  <Nonce>" << GetNonce () << "</Nonce>\n";
+  // os << "</Interest>";
+}
+
+} // ccnb
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/wire-ccnb.cc b/model/wire/ccnb/wire-ccnb.cc
new file mode 100644
index 0000000..4f4f695
--- /dev/null
+++ b/model/wire/ccnb/wire-ccnb.cc
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu> 
+ */
+
+#include "wire-ccnb.h"
+
+#include <sstream>
+#include <boost/foreach.hpp>
+#include "ccnb-parser/common.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+
+//////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////
+
+#define CCN_TT_BITS 3
+#define CCN_TT_MASK ((1 << CCN_TT_BITS) - 1)
+#define CCN_MAX_TINY ((1 << (7-CCN_TT_BITS)) - 1)
+#define CCN_TT_HBIT ((unsigned char)(1 << 7))
+
+size_t
+Ccnb::AppendBlockHeader (Buffer::Iterator &start, size_t val, uint32_t tt)
+{
+  unsigned char buf[1+8*((sizeof(val)+6)/7)];
+  unsigned char *p = &(buf[sizeof(buf)-1]);
+  size_t n = 1;
+  p[0] = (CCN_TT_HBIT & ~CcnbParser::CCN_CLOSE) |
+  ((val & CCN_MAX_TINY) << CCN_TT_BITS) |
+  (CCN_TT_MASK & tt);
+  val >>= (7-CCN_TT_BITS);
+  while (val != 0) {
+    (--p)[0] = (((unsigned char)val) & ~CCN_TT_HBIT) | CcnbParser::CCN_CLOSE;
+    n++;
+    val >>= 7;
+  }
+  start.Write (p,n);
+  return n;
+}
+
+size_t
+Ccnb::EstimateBlockHeader (size_t value)
+{
+  value >>= (7-CCN_TT_BITS);
+  size_t n = 1;
+  while (value>0)
+    {
+      value >>= 7;
+      n++;
+    }
+  return n;
+}
+
+size_t
+Ccnb::AppendNumber (Buffer::Iterator &start, uint32_t number)
+{
+  std::ostringstream os;
+  os << number;
+
+  size_t written = 0;
+  written += AppendBlockHeader (start, os.str().size(), CcnbParser::CCN_UDATA);
+  written += os.str().size();
+  start.Write (reinterpret_cast<const unsigned char*>(os.str().c_str()), os.str().size());
+
+  return written;
+}
+
+size_t
+Ccnb::EstimateNumber (uint32_t number)
+{
+  std::ostringstream os;
+  os << number;
+  return EstimateBlockHeader (os.str ().size ()) + os.str ().size ();
+}
+  
+size_t
+Ccnb::AppendCloser (Buffer::Iterator &start)
+{
+  start.WriteU8 (CcnbParser::CCN_CLOSE);
+  return 1;
+}
+
+size_t
+Ccnb::AppendName (Buffer::Iterator &start, const Name &name)
+{
+  size_t written = 0;
+  BOOST_FOREACH (const std::string &component, name.GetComponents())
+    {
+      written += AppendTaggedBlob (start, CcnbParser::CCN_DTAG_Component,
+                                   reinterpret_cast<const uint8_t*>(component.c_str()), component.size());
+    }
+  return written;
+}
+
+size_t
+Ccnb::EstimateName (const Name &name)
+{
+  size_t written = 0;
+  BOOST_FOREACH (const std::string &component, name.GetComponents())
+    {
+      written += EstimateTaggedBlob (CcnbParser::CCN_DTAG_Component, component.size());
+    }
+  return written;
+}
+
+size_t
+Ccnb::AppendTimestampBlob (Buffer::Iterator &start, const Time &time)
+{
+  // the original function implements Markers... thought not sure what are these markers for...
+
+  // Determine miminal number of bytes required to store the timestamp
+  int required_bytes = 2; // 12 bits for fractions of a second, 4 bits left for seconds. Sometimes it is enough
+  intmax_t ts = time.ToInteger (Time::S) >> 4;
+  for (;  required_bytes < 7 && ts != 0; ts >>= 8) // not more than 6 bytes?
+     required_bytes++;
+  
+  size_t len = AppendBlockHeader(start, required_bytes, CcnbParser::CCN_BLOB);
+
+  // write part with seconds
+  ts = time.ToInteger (Time::S) >> 4;
+  for (int i = 0; i < required_bytes - 2; i++)
+    start.WriteU8 ( ts >> (8 * (required_bytes - 3 - i)) );
+
+  /* arithmetic contortions are to avoid overflowing 31 bits */
+  ts = ((time.ToInteger (Time::S) & 15) << 12) +
+       (((time.ToInteger (Time::NS) % 1000000000) / 5 * 8 + 195312) / 390625);
+  for (int i = required_bytes - 2; i < required_bytes; i++)
+    start.WriteU8 ( ts >> (8 * (required_bytes - 1 - i)) );
+  
+  return len + required_bytes;
+}
+
+size_t
+Ccnb::EstimateTimestampBlob (const Time &time)
+{
+  int required_bytes = 2; // 12 bits for fractions of a second, 4 bits left for seconds. Sometimes it is enough
+  intmax_t ts = time.ToInteger (Time::S) >> 4;
+  for (;  required_bytes < 7 && ts != 0; ts >>= 8) // not more than 6 bytes?
+     required_bytes++;
+
+  return EstimateBlockHeader (required_bytes) + required_bytes;
+}
+
+size_t
+Ccnb::AppendTaggedBlob (Buffer::Iterator &start, uint32_t dtag,
+                  const uint8_t *data, size_t size)
+{
+  size_t written = AppendBlockHeader (start, dtag, CcnbParser::CCN_DTAG);
+  /* 2 */
+  if (size>0)
+    {
+      written += AppendBlockHeader (start, size, CcnbParser::CCN_BLOB);
+      start.Write (data, size);
+      written += size;
+      /* size */
+    }
+  written += AppendCloser (start);
+  /* 1 */
+
+  return written;
+}
+
+size_t
+Ccnb::EstimateTaggedBlob (uint32_t dtag, size_t size)
+{
+  if (size>0)
+    return EstimateBlockHeader (dtag) + EstimateBlockHeader (size) + size + 1;
+  else
+    return EstimateBlockHeader (dtag) + 1;
+}
+
+size_t
+Ccnb::AppendString (Buffer::Iterator &start, uint32_t dtag,
+                                  const std::string &string)
+{
+  size_t written = AppendBlockHeader (start, dtag, CcnbParser::CCN_DTAG);
+  {
+    written += AppendBlockHeader (start, string.size (), CcnbParser::CCN_UDATA);
+    start.Write (reinterpret_cast<const uint8_t*> (string.c_str ()), string.size ());
+    written += string.size ();
+  }
+  written += AppendCloser (start);
+
+  return written;
+}
+
+size_t
+Ccnb::EstimateString (uint32_t dtag, const std::string &string)
+{
+  return EstimateBlockHeader (dtag) + EstimateBlockHeader (string.size ()) + string.size () + 1;
+}
+
+} // wire
+
+NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/wire-ccnb.h b/model/wire/ccnb/wire-ccnb.h
new file mode 100644
index 0000000..42764c4
--- /dev/null
+++ b/model/wire/ccnb/wire-ccnb.h
@@ -0,0 +1,204 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2011-2013 University of California, Los Angeles
+ *
+ * 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef NDN_WIRE_CCNB_SYNTAX_H
+#define NDN_WIRE_CCNB_SYNTAX_H
+
+#include "ns3/ptr.h"
+#include "ns3/nstime.h"
+#include "ns3/buffer.h"
+
+#include "ns3/ndn-common.h"
+#include "ns3/ndn-name.h"
+
+NDN_NAMESPACE_BEGIN
+
+namespace wire {
+
+/**
+ * \brief Helper to encode CCNb blocks
+ */
+class Ccnb
+{
+public:
+  /**
+   * @brief Append CCNB block header
+   * @param start Buffer to store serialized
+   * @param value dictionary id of the block header
+   * @param block_type Type of CCNB block
+   *
+   * @returns written length
+   */
+  static size_t
+  AppendBlockHeader (Buffer::Iterator &start, size_t value, uint32_t block_type);
+
+  /**
+   * @brief Estimate size of the CCNB block header
+   * @param value dictionary id of the block header
+   * @returns estimated length
+   */
+  static size_t
+  EstimateBlockHeader (size_t value);
+
+  /**
+   * @brief Add number in CCNB encoding
+   * @param start Buffer to store serialized NdnInterest
+   * @param number Number to be written
+   *
+   * @returns written length
+   */
+  static size_t
+  AppendNumber (Buffer::Iterator &start, uint32_t number);
+
+  /**
+   * @brief Estimate size of the number in CCNB encoding
+   * @param number Number to be written
+   * @returns estimated length
+   */
+  static size_t
+  EstimateNumber (uint32_t number);
+
+  /**
+   * @brief Append CCNB closer tag (estimated size is 1)
+   * @param start Buffer to store serialized Interest
+   *
+   * @returns written length
+   */
+  static size_t
+  AppendCloser (Buffer::Iterator &start);
+
+  /**
+   * @brief Append Name in CCNB encoding
+   * @param start Buffer to store serialized Interest
+   * @param name constant reference to Name object
+   *
+   * @returns written length
+   */
+  static size_t
+  AppendName (Buffer::Iterator &start, const Name &name);
+
+  /**
+   * @brief Estimate size of Name in CCNB encoding
+   * @param name constant reference to Name object
+   * @returns estimated length
+   */
+  static size_t
+  EstimateName (const Name &name);
+
+  /**
+   * Append a binary timestamp as a BLOB using the ccn binary
+   * Timestamp representation (12-bit fraction).
+   *
+   * @param start start iterator of  the buffer to append to.
+   * @param time - Time object
+   *
+   * @returns written length
+   */
+  static size_t
+  AppendTimestampBlob (Buffer::Iterator &start, const Time &time);
+
+  /**
+   * @brief Estimate size of a binary timestamp as a BLOB using CCNB enconding
+   * @param time - Time object
+   * @returns estimated length
+   */
+  static size_t
+  EstimateTimestampBlob (const Time &time);
+
+  /**
+   * Append a tagged BLOB
+   *
+   * This is a ccnb-encoded element with containing the BLOB as content
+   *
+   * @param start start iterator of  the buffer to append to.
+   * @param dtag is the element's dtab
+   * @param data points to the binary data
+   * @param size is the size of the data, in bytes
+   *
+   * @returns written length
+   */
+  static size_t
+  AppendTaggedBlob (Buffer::Iterator &start, uint32_t dtag,
+                    const uint8_t *data, size_t size);
+  
+  /**
+   * @brief Estimate size of a tagged BLOB in CCNB enconding
+   * @param dtag is the element's dtab
+   * @param size is the size of the data, in bytes
+   * @returns estimated length
+   */
+  static size_t
+  EstimateTaggedBlob (uint32_t dtag, size_t size);
+
+  /**
+   * Append value as a tagged BLOB (templated version)
+   *
+   * This is a ccnb-encoded element with containing the BLOB as content
+   *
+   * Data will be reinterpret_cast<const uint8_t*> and size will be obtained using sizeof
+   *
+   * @param start start iterator of  the buffer to append to.
+   * @param dtag is the element's dtab
+   * @param data a value to add
+   *
+   * @returns written length
+   */
+  template<class T>
+  static inline size_t
+  AppendTaggedBlob (Buffer::Iterator &start, uint32_t dtag, const T &data);
+
+  /**
+   * Append a tagged string (should be a valid UTF-8 coded string)
+   *
+   * This is a ccnb-encoded element with containing UDATA as content
+   *
+   * @param start start iterator of  the buffer to append to.
+   * @param dtag is the element's dtab
+   * @param string UTF-8 string to be written
+   *
+   * @returns written length
+   */
+  static size_t
+  AppendString (Buffer::Iterator &start, uint32_t dtag,
+                const std::string &string);
+
+  /**
+   * @brief Estimate size of the string in CCNB encoding
+   * @param dtag is the element's dtab
+   * @param string UTF-8 string to be written
+   * @returns estimated length
+   */
+  static size_t
+  EstimateString (uint32_t dtag, const std::string &string);
+}; // Ccnb
+
+
+template<class T>
+size_t
+Ccnb::AppendTaggedBlob (Buffer::Iterator &start, uint32_t dtag, const T &data)
+{
+  return AppendTaggedBlob (start, dtag, reinterpret_cast<const uint8_t*> (&data), sizeof (data));
+}
+
+} // wire
+
+NDN_NAMESPACE_END
+
+#endif // NDN_WIRE_CCNB_SYNTAX_H
diff --git a/model/wire/ndnsim.h b/model/wire/ndnsim.h
index b46dba9..5e50a32 100644
--- a/model/wire/ndnsim.h
+++ b/model/wire/ndnsim.h
@@ -11,7 +11,7 @@
 #ifndef NDN_WIRE_NDNSIM_H
 #define NDN_WIRE_NDNSIM_H
 
-#include "../ndn-common.h"
+#include "ns3/ndn-common.h"
 #include "ns3/ndn-interest.h"
 #include "ns3/ndn-content-object.h"