Checkpoint. Reorganizing ccnb parsing into many small files.
diff --git a/helper/ccnb-parser/ccnb-parser-commoh.h b/helper/ccnb-parser/ccnb-parser-commoh.h
new file mode 100644
index 0000000..2dc092c
--- /dev/null
+++ b/helper/ccnb-parser/ccnb-parser-commoh.h
@@ -0,0 +1,178 @@
+/* -*- 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_
+
+namespace ns3 {
+
+/**
+ * \ingroup ccnx
+ * \defgroup ccnx-ccnb CCNB decoding routines
+ */
+/**
+ * \ingroup ccnx-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 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_SequenceNumber = 256,
+  CCN_DTAG_CCNProtocolDataUnit = 17702112
+};
+
+/**
+ * \brief Exception thrown if there is a parsing error
+ *
+ * \todo inherit this class from some exception class and provide meaningful error messages
+ */
+class CcnbDecodingException {};
+
+} // namespace CcnxParser
+
+} // namespace ns3
+
+#endif // _CCNB_PARSER_COMMON_H_
diff --git a/helper/ccnb-parser/ccnx-decoding-helper.h b/helper/ccnb-parser/ccnx-decoding-helper.h
new file mode 100644
index 0000000..375a57a
--- /dev/null
+++ b/helper/ccnb-parser/ccnx-decoding-helper.h
@@ -0,0 +1,46 @@
+/* -*- 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 _CCNX_DECODING_HELPER_H_
+#define _CCNX_DECODING_HELPER_H_
+
+namespace ns3 {
+
+class CcnxInterestHeader;
+class CcnxContentObjectHeader;
+
+/**
+ * \brief Helper class to decode ccnb formatted CCNx message
+ */
+class CcnxDecodingHelper
+{
+public:
+  static size_t
+  Deserialize (Buffer::Iterator start, const CcnxInterestHeader &interest);
+
+  static size_t
+  Deserialize (Buffer::Iterator start, const CcnxContentObjectHeader &contentObject);
+  
+private:
+};
+
+} // namespace ns3
+
+#endif // _CCNX_DECODING_HELPER_H_
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-attr.cc b/helper/ccnb-parser/syntax-tree/ccnb-parser-attr.cc
new file mode 100644
index 0000000..3fe986e
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-attr.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 "ccnb-parser-attr.h"
+
+namespace ns3 {
+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
+  for (uint32_t i = 0; i < (length+1); i++)
+    {
+      m_attr.push_back (start.ReadU8 ());
+    }
+  m_value = DynamicCast<Udata> (Block::ParseBlock (start));
+  if (m_value == 0)
+    throw CcnxDecodingException (); // "ATTR must be followed by UDATA field"
+}
+
+}
+}
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-attr.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-attr.h
new file mode 100644
index 0000000..7864459
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-attr.h
@@ -0,0 +1,60 @@
+/* -*- 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 "ccnb-parser-base-attr.h"
+#include <string>
+
+namespace ns3 {
+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( Visitor &v )                           { v.visit( *this ); }
+  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  std::string m_attr; ///< field holding name of the attribute
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_ATTR_H_
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-base-attr.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-base-attr.h
new file mode 100644
index 0000000..f83f77e
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-base-attr.h
@@ -0,0 +1,46 @@
+/* -*- 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 "ccnb-parser-block.h"
+#include "ccnb-parser-udata.h"
+
+namespace ns3 {
+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
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_BASE_ATTR_H_
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-base-tag.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-base-tag.h
new file mode 100644
index 0000000..bfd1f5b
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-base-tag.h
@@ -0,0 +1,51 @@
+/* -*- 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 "ccnb-parser-block.h"
+#include <list>
+
+namespace ns3 {
+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() { }
+};
+
+#endif // _CCNB_PARSER_BASE_TAG_H_
+
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-blob.cc b/helper/ccnb-parser/syntax-tree/ccnb-parser-blob.cc
new file mode 100644
index 0000000..0928eb8
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-blob.cc
@@ -0,0 +1,32 @@
+/* -*- 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 "ccnb-parser-blob.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+Blob::Blob (Buffer::Iterator &start, uint32_t length)
+{
+  start.Read (m_blob.Begin (), length);
+}
+
+}
+}
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-blob.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-blob.h
new file mode 100644
index 0000000..1693fbe
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-blob.h
@@ -0,0 +1,59 @@
+/* -*- 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 "ccnb-parser-block.h"
+
+namespace ns3 {
+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);
+  
+  virtual void accept( Visitor &v )                           { v.visit( *this ); }
+  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  Buffer m_blob; ///< \brief field holding a parsed BLOB value of the block
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_BLOCK_H_
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-block.cc b/helper/ccnb-parser/syntax-tree/ccnb-parser-block.cc
new file mode 100644
index 0000000..81d137f
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-block.cc
@@ -0,0 +1,69 @@
+/* -*- 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 "ccnb-parser-block.h"
+#include "ns3/ccnb-parser-common.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+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));
+
+Ptr<Block> Block::ParseBlock (Buffer::Iterator &start)
+{
+  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 (!(byte & CCN_TT_HBIT))
+    {
+      value <<= 8;
+      value += byte;
+      byte = start.ReadU8 ();
+    }
+  value <<= 4;
+  value += ( (byte&(~CCN_TT_HBIT)) >> 3);
+
+  switch (byte & CCN_TT_MASK)
+    {
+    case CCN_BLOB:
+      return Create<Blob> (start, value);
+    case CCN_UDATA:
+      return Create<Udata> (start, value);
+    case CCN_TAG:
+      return Create<Tag> (start, value);
+    case CCN_ATTR:
+      return Create<Attr> (start, value);
+    case CCN_DTAG:
+      return Create<Dtag> (start, value);
+    case CCN_DATTR:
+      return Create<Dattr> (start, value);
+    case CCN_EXT:
+      return Create<Ext> (start, value);
+    default:
+      throw CcnxDecodingException ();
+    }
+}
+
+}
+}
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-block.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-block.h
new file mode 100644
index 0000000..6cbb6b3
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-block.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_BLOCK_H_
+#define _CCNB_PARSER_BLOCK_H_
+
+#include "ns3/simple-ref-count.h"
+#include "ns3/buffer.h"
+#include "ns3/ptr.h"
+
+// visitors
+#include "ns3/ccnb-parser-void-no-argu-visitor.h"
+#include "ns3/ccnb-parser-void-visitor.h"
+#include "ns3/ccnb-parser-no-argu-visitor.h"
+#include "ns3/ccnb-parser-visitor.h"
+
+namespace ns3 {
+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:
+  /**
+   * \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 void accept (VoidNoArguVisitor &v )               =0; ///< \brief Method to dispatch VoidNoArguVisitor
+  virtual void accept (VoidVisitor &v, boost::any param)    =0; ///< \brief Method to dispatch VoidVisitor
+  virtual boost::any accept (NoArguVisitor &v )             =0; ///< \brief Method to dispatch NoArguVisitor 
+  virtual boost::any accept (Visitor &v, boost::any param ) =0; ///< \brief Method to dispatch Visitor
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_BLOCK_H_
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-dattr.cc b/helper/ccnb-parser/syntax-tree/ccnb-parser-dattr.cc
new file mode 100644
index 0000000..b8ef685
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-dattr.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 "ccnb-parser-dattr.h"
+
+namespace ns3 {
+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 CcnxDecodingException (); // "ATTR must be followed by UDATA field"
+}
+
+}
+}
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-dattr.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-dattr.h
new file mode 100644
index 0000000..42de5f6
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-dattr.h
@@ -0,0 +1,59 @@
+/* -*- 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 "ccnb-parser-base-attr.h"
+
+namespace ns3 {
+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( Visitor &v )                           { v.visit( *this ); }
+  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  uint32_t m_dattr; ///< \brief Dictionary code of DATTR
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_DATTR_H_
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-dtag.cc b/helper/ccnb-parser/syntax-tree/ccnb-parser-dtag.cc
new file mode 100644
index 0000000..0cfe4bd
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-dtag.cc
@@ -0,0 +1,74 @@
+/* -*- 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 "ccnb-parser-dtag.h"
+#include "ns3/ccnb-parser-common.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+Dtag::Dtag (Buffer::Iterator &start, uint32_t dtag)
+{
+  m_dtag = dtag;
+
+  /**
+   * Hack
+   *
+   * Stop processing after encountering <Content> dtag.  Actual
+   * content (including virtual payload) will be stored in Packet
+   * buffer
+   */
+  if (dtag == Ccnx::CCN_DTAG_Content)
+    return; // hack #1. Do not process nesting block for <Content>
+  
+  // parse attributes until first nested block reached
+  while (!start.IsEnd () && start.PeekU8 ()!=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 () && start.PeekU8 ()!=CCN_CLOSE)
+    {
+      // hack #2. Stop processing nested blocks if last block was <Content>
+      if (m_dtag == Ccnx::CCN_DTAG_ContentObject && // we are in <ContentObject>
+          DynamicCast<Dtag> (m_nestedBlocks.back())!=0 && // last block is DTAG
+          DynamicCast<Dtag> (m_nestedBlocks.back())->m_dtag == CCN_DTAG_Content) 
+        {
+          return; 
+        }
+
+      m_nestedBlocks.push_back (Block::ParseBlock (start));
+    }
+  if (start.IsEnd ())
+      throw CcnxDecodingException ();
+
+  start.ReadU8 (); // read CCN_CLOSE
+}
+
+}
+}
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-dtag.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-dtag.h
new file mode 100644
index 0000000..65a84f5
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-dtag.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_DTAG_H_
+#define _CCNB_PARSER_DTAG_H_
+
+#include "ccnb-parser-base-tag.h"
+
+namespace ns3 {
+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( Visitor &v )                           { v.visit( *this ); }
+  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  uint32_t m_dtag; ///< \brief Dictionary code for DTAG
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_DTAG_H_
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-ext.cc b/helper/ccnb-parser/syntax-tree/ccnb-parser-ext.cc
new file mode 100644
index 0000000..7d90019
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-ext.cc
@@ -0,0 +1,32 @@
+/* -*- 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 "ccnb-parser-ext.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+Ext::Ext (Buffer::Iterator &start, uint32_t extSubtype)
+{
+  m_extSubtype = extSubtype;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-ext.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-ext.h
new file mode 100644
index 0000000..9a2f2c8
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-ext.h
@@ -0,0 +1,59 @@
+/* -*- 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 "ccnb-parser-ext.h"
+
+namespace ns3 {
+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( Visitor &v )                           { v.visit( *this ); }
+  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  uint64_t m_extSubtype; ///< \brief Extension type
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_EXT_H_
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-tag.cc b/helper/ccnb-parser/syntax-tree/ccnb-parser-tag.cc
new file mode 100644
index 0000000..f045d55
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-tag.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 "ccnb-parser-tag.h"
+#include "ns3/ccnb-parser-common.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+Tag::Tag (Buffer::Iterator &start, uint32_t length)
+{
+  m_tag.reserve (length+2); // extra byte for potential \0 at the end
+  for (uint32_t i = 0; i < (length+1); i++)
+    {
+      m_tag.push_back (start.ReadU8 ());
+    }
+  
+  // parse attributes until first nested block reached
+  while (!start.IsEnd () && start.PeekU8 ()!=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 () && start.PeekU8 ()!=CCN_CLOSE)
+    {
+      Ptr<Block> block = Block::ParseBlock (start);
+	  m_nestedTags.push_back (block);
+    }
+  
+  if (start.IsEnd ()) //should not be the end
+      throw CcnxDecodingException ();
+
+  start.ReadU8 (); // read CCN_CLOSE
+}
+
+}
+}
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-tag.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-tag.h
new file mode 100644
index 0000000..aea0bcc
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-tag.h
@@ -0,0 +1,60 @@
+/* -*- 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 "ccnb-parser-base-tag.h"
+#include <string>
+
+namespace ns3 {
+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( Visitor &v )                           { v.visit( *this ); }
+  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  std::string m_tag; ///< \brief Name of TAG block
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_TAG_H_
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-udata.cc b/helper/ccnb-parser/syntax-tree/ccnb-parser-udata.cc
new file mode 100644
index 0000000..39217fd
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-udata.cc
@@ -0,0 +1,42 @@
+/* -*- 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 "ccnb-parser-udata.h"
+
+namespace ns3 {
+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
+  for (uint32_t i = 0; i < length; i++)
+    {
+      m_udata.push_back (start.ReadU8 ());
+    }
+}
+
+}
+}
diff --git a/helper/ccnb-parser/syntax-tree/ccnb-parser-udata.h b/helper/ccnb-parser/syntax-tree/ccnb-parser-udata.h
new file mode 100644
index 0000000..c75fc9d
--- /dev/null
+++ b/helper/ccnb-parser/syntax-tree/ccnb-parser-udata.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_UDATA_H_
+#define _CCNB_PARSER_UDATA_H_
+
+#include "ccnb-parser-block.h"
+#include <string>
+
+namespace ns3 {
+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( Visitor &v )                           { v.visit( *this ); }
+  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
+  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
+  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
+
+  std::string m_udata; ///< \brief field holding a parsed UDATA value of the block
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_UDATA_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc
new file mode 100644
index 0000000..64f7d0b
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.cc
@@ -0,0 +1,75 @@
+/* -*- 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 "ccnb-parser-content-object-visitor.h"
+#include "ccnb-parser-name-components-visitor.h"
+
+#include "ns3/ccnb-parser-block.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/name-components.h"
+#include "ns3/assert.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+// We don't really care about any other fields
+void
+ContentObjectVisitor::visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader&*/)
+{
+  // uint32_t n.m_dtag;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  static NameComponentsVisitor m_nameComponentsVisitor;
+  
+  CcnxContentObjectHeader &contentObject = boost::any_cast<CcnxContentObjectHeader&> (param);
+  
+  switch (n.m_dtag)
+    {
+    case CCN_DTAG_ContentObject:
+      // process nested blocks
+      BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+        {
+          block->accept (*this, param);
+        }
+      break;
+    case CCN_DTAG_Name:
+      {
+        // process name components
+        Ptr<Name::Components> name = Create<Name::Components> ();
+        
+        BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+          {
+            block->accept (nameComponentsVisitor, *name);
+          }
+        contentObject.SetName (name);
+        break;
+      }
+    case CCN_DTAG_Signature: // ignoring
+      break;
+    case CCN_DTAG_SignedInfo: // ignoring
+      break;
+    case CCN_DTAG_Content: // !!! HACK
+      // This hack was necessary for memory optimizations (i.e., content is virtual payload)
+      NS_ASSERT_MSG (n.m_nestedBlocks.size() == 0, "Parser should have stopped just after processing <Content> tag");
+      break;
+    }
+}
+
+} // namespace CcnbParser
+} // namespace ns3
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h
new file mode 100644
index 0000000..e15e290
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-content-object-visitor.h
@@ -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>
+ */
+
+#ifndef _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
+#define _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
+
+#include "ccnb-parser-void-depth-first-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor that fills fields in CcnxContentObjectHeader
+ *
+ * Usage example:
+ * \code
+ *   Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
+ *   Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
+ *   ContentObjectVisitor visitor;
+ *   root->accept (visitor, *header); 
+ * \endcode
+ */
+class ContentObjectVisitor : public VoidDepthFirstVisitor
+{
+public:
+  virtual void visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader&*/);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_CONTENT_OBJECT_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.cc
new file mode 100644
index 0000000..aa78e85
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.cc
@@ -0,0 +1,108 @@
+/* -*- 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 "ccnb-parser-depth-first-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include "ns3/ccnb-parser-tag.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/ccnb-parser-attr.h"
+#include "ns3/ccnb-parser-dattr.h"
+#include "ns3/ccnb-parser-ext.h"
+
+#include <boost/foreach.hpp>
+
+namespace ns3 {
+namespace CcnbParser {
+
+boost::any
+GJDepthFirstVisitor::visit (Blob &n, boost::any param)
+{
+  // Buffer n.m_blob;
+  return n.m_blob;
+}
+ 
+boost::any
+GJDepthFirstVisitor::visit (Udata &n, boost::any param)
+{
+  // std::string n.m_udata;
+  return n.m_udata;
+}
+ 
+boost::any
+GJDepthFirstVisitor::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_nestedBlocks)
+    {
+      block->accept (*this, param);
+    }
+  return boost::any();
+}
+
+boost::any
+GJDepthFirstVisitor::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_nestedBlocks)
+    {
+      block->accept (*this, param);
+    }
+  return boost::any ();
+}
+
+boost::any
+GJDepthFirstVisitor::visit (Attr &n, boost::any param)
+{
+  // std::string n.m_attr;
+  // Ptr<Udata> n.m_value;
+  return boost::any ();
+}
+
+boost::any
+GJDepthFirstVisitor::visit (Dattr &n, boost::any param)
+{
+  // uint32_t n.m_dattr;
+  // Ptr<Udata> n.m_value;
+  return boost::any ();
+}
+ 
+boost::any
+GJDepthFirstVisitor::visit (Ext &n, boost::any param)
+{
+  // uint64_t n.m_extSubtype;
+  return n.m_extSubtype;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.h
new file mode 100644
index 0000000..d68b4ad
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-depth-first-visitor.h
@@ -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>
+ */
+
+#ifndef _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
+
+#include "ccnb-parser-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingrou 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);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
new file mode 100644
index 0000000..d33b2b0
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.cc
@@ -0,0 +1,133 @@
+/* -*- 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 "ccnb-parser-interest-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+// We don't care about any other fields
+void
+InterestVisitor::visit (Dtag &n, boost::any param/*should be CcnxInterestHeader&*/)
+{
+  // uint32_t n.m_dtag;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+
+  static NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
+  static NameComponentsVisitor     m_nameComponentsVisitor;
+  
+  CcnxInterestHeader &interest = boost::any_cast<CcnxInterestHeader&> (param);
+  
+  switch (n.m_dtag)
+    {
+    case CCN_DTAG_Interest:
+      // process nested blocks
+      BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+        {
+          block->accept (*this, param);
+        }
+      break;
+    case CCN_DTAG_Name:
+      {
+        // process name components
+        Ptr<Name::Components> name = Create<Name::Components> ();
+        
+        BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+          {
+            block->accept (nameComponentsVisitor, *name);
+          }
+        interest.SetName (name);
+        break;
+      }
+    case CCN_DTAG_MinSuffixComponents:
+      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnxDecodingException ();
+      interest.SetMinSuffixComponents (
+               boost::any_cast<uint32_t> (
+                                          (*n.m_nestedBlocks.begin())->accept(
+                                                                           nonNegativeIntegerVisitor
+                                                                           )));
+      break;
+    case CCN_DTAG_MaxSuffixComponents:
+      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnxDecodingException ();
+      interest.SetMaxSuffixComponents (
+               boost::any_cast<uint32_t> (
+                                          (*n.m_nestedBlocks.begin())->accept(
+                                                                           nonNegativeIntegerVisitor
+                                                                           )));
+      break;
+    case CCN_DTAG_Exclude:
+      {
+        // process exclude components
+        Ptr<Name::Components> exclude = Create<Name::Components> ();
+        
+        BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
+          {
+            block->accept (nameComponentsVisitor, *exclude);
+          }
+        interest.SetExclude (exclude);
+        break;
+      }
+    case CCN_DTAG_ChildSelector:
+      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnxDecodingException ();
+
+      interest.SetChildSelector (
+               1 == boost::any_cast<uint32_t> (
+                                          (*n.m_nestedBlocks.begin())->accept(
+                                                                           nonNegativeIntegerVisitor
+                                                                           )));
+      break;
+    case CCN_DTAG_AnswerOriginKind:
+      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnxDecodingException ();
+      interest.SetAnswerOriginKind (
+               1 == boost::any_cast<uint32_t> (
+                                          (*n.m_nestedBlocks.begin())->accept(
+                                                                           nonNegativeIntegerVisitor
+                                                                           )));
+      break;
+    case CCN_DTAG_Scope: 
+      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnxDecodingException ();
+      interest.SetScope (
+               boost::any_cast<uint32_t> (
+                                          (*n.m_nestedBlocks.begin())->accept(
+                                                                           nonNegativeIntegerVisitor
+                                                                           )));
+      break;
+    case CCN_DTAG_InterestLifetime:
+      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnxDecodingException ();
+
+      /// \todo Decode InterestLifetime
+      break;
+    case CCN_DTAG_Nonce:
+      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnxDecodingException ();
+
+      /// \todo Decode Nonce
+      break;
+    }
+}
+
+} // namespace CcnbParser
+} // namespace ns3
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-interest-visitor.h
new file mode 100644
index 0000000..e2cc574
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-interest-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_INTEREST_VISITOR_H_
+#define _CCNB_PARSER_INTEREST_VISITOR_H_
+
+#include "ccnb-parser-void-depth-first-visitor.h"
+#include "ccnb-parser-name-components-visitor.h"
+#include "ccnb-parser-non-negative-integer-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor that fills fields in CcnxInterestHeader
+ *
+ * Usage example:
+ * \code
+ *   Ptr<CcnxInterestHeader> header = Create<CcnxInterestHeader> ();
+ *   Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
+ *   InterestVisitor visitor;
+ *   root->accept (visitor, *header); 
+ * \endcode
+ */
+class InterestVisitor : public VoidDepthFirstVisitor
+{
+public:
+  virtual void visit (Dtag &n, boost::any param/*should be CcnxInterestHeader&*/);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_INTEREST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.cc
new file mode 100644
index 0000000..5ffd71f
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.cc
@@ -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>
+ */
+
+#include "ccnb-parser-name-components-visitor.h"
+
+#include "ccnb-parser-string-visitor.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/name-components.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+void
+NameComponentsVisitor::visit (Dtag &n, boost::any param/*should be Name::Components&*/)
+{
+  // uint32_t n.m_dtag;
+  // std::list<Ptr<Block> > n.m_nestedBlocks;
+  static StringVisitor stringVisitor; 
+ 
+  Name::Components &components = boost::any_cast<Name::Components&> (param);
+
+  switch (n.m_dtag)
+    {
+    case CCN_DTAG_Component:
+      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
+        throw CcnxDecodingException ();
+      components.Add (
+                      boost::any_cast<std::string> ((*n.m_nestedBlocks.begin())->accept(
+                                                                                        stringVisitor
+                                                                                        )));
+      break;
+    default:
+      // ignore any other components
+      // when parsing Exclude, there could be <Any /> and <Bloom /> tags
+      break;
+    }
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.h
new file mode 100644
index 0000000..c68eb56
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-name-components-visitor.h
@@ -0,0 +1,43 @@
+/* -*- 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 "ccnb-parser-void-depth-first-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-ccnb
+ * \brief Visitor to obtain fill Name::Components object with name components
+ */
+class NameComponentsVisitor : public VoidDepthFirstVisitor
+{
+public:
+  virtual void visit (Dtag &n, boost::any param/*should be Name::Components&*/);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
+
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.cc
new file mode 100644
index 0000000..6cd9aac
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.cc
@@ -0,0 +1,108 @@
+/* -*- 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 "ccnb-parser-no-argu-depth-first-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include "ns3/ccnb-parser-tag.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/ccnb-parser-attr.h"
+#include "ns3/ccnb-parser-dattr.h"
+#include "ns3/ccnb-parser-ext.h"
+
+#include <boost/foreach.hpp>
+
+namespace ns3 {
+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_nestedBlocks)
+    {
+      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_nestedBlocks)
+    {
+      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;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.h
new file mode 100644
index 0000000..1990d87
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-depth-first-visitor.h
@@ -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>
+ */
+
+#ifndef _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+
+#include "ccnb-parser-no-argu-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingrou 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&  );
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-no-argu-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-visitor.h
new file mode 100644
index 0000000..ea3b56b
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-no-argu-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_VISITOR_H_
+#define _CCNB_PARSER_NO_ARGU_VISITOR_H_
+
+#include "ccnb-parser-commoh.h"
+#include <boost/any.hpp>
+
+namespace ns3 {
+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
+};
+  
+}
+}
+
+#endif // _CCNB_PARSER_NO_ARGU_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.cc
new file mode 100644
index 0000000..319eefa
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.cc
@@ -0,0 +1,51 @@
+/* -*- 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 "ccnb-parser-non-negative-integer-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include <sstream>
+
+namespace ns3 {
+namespace CcnbParser {
+
+boost::any
+NonNegativeIntegerVisitor::visit (Blob &n) //to throw parsing error
+{
+  // Buffer n.m_blob;
+  throw CcnxDecodingException ();
+}
+
+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 CcnxDecodingException ();
+
+  return static_cast<uint32_t> (value);
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.h
new file mode 100644
index 0000000..7ecc3a9
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-non-negative-integer-visitor.h
@@ -0,0 +1,45 @@
+/* -*- 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 "ccnb-parser-no-argu-depth-first-visitor.h"
+
+namespace ns3 {
+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);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.cc
new file mode 100644
index 0000000..078b326
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.cc
@@ -0,0 +1,41 @@
+/* -*- 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 "ccnb-parser-string-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+boost::any
+StringVisitor::visit (Blob &n) 
+{
+  // Buffer n.m_blob;
+  throw CcnxDecodingException ();
+}
+
+boost::any
+StringVisitor::visit (Udata &n)
+{
+  // std::string n.m_udata;
+  return n.m_udata;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.h
new file mode 100644
index 0000000..b2a2a29
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-string-visitor.h
@@ -0,0 +1,45 @@
+/* -*- 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 "ccnb-parser-no-argu-depth-first-visitor.h"
+
+namespace ns3 {
+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); ///< Throws parsing error if BLOB object is encountered
+  virtual boost::any visit (Udata &n);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_STRING_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-visitor.h
new file mode 100644
index 0000000..d098c3e
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-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_VISITOR_H_
+#define _CCNB_PARSER_VISITOR_H_
+
+#include "ccnb-parser-commoh.h"
+#include <boost/any.hpp>
+
+namespace ns3 {
+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
+};                                                
+                                                  
+}                                                 
+}                                                 
+                                                  
+#endif // _CCNB_PARSER_VISITOR_H_                             
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.cc
new file mode 100644
index 0000000..c2b8401
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.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 "ccnb-parser-void-depth-first-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include "ns3/ccnb-parser-tag.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/ccnb-parser-attr.h"
+#include "ns3/ccnb-parser-dattr.h"
+#include "ns3/ccnb-parser-ext.h"
+
+#include <boost/foreach.hpp>
+
+namespace ns3 {
+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_nestedBlocks)
+    {
+      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_nestedBlocks)
+    {
+      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;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.h
new file mode 100644
index 0000000..f2b78e3
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-depth-first-visitor.h
@@ -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>
+ */
+
+#ifndef _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
+
+#include "ccnb-parser-void-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingrou 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);
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.cc b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.cc
new file mode 100644
index 0000000..7f8e6de
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.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 "ccnb-parser-void-no-argu-depth-first-visitor.h"
+
+#include "ns3/ccnb-parser-blob.h"
+#include "ns3/ccnb-parser-udata.h"
+#include "ns3/ccnb-parser-tag.h"
+#include "ns3/ccnb-parser-dtag.h"
+#include "ns3/ccnb-parser-attr.h"
+#include "ns3/ccnb-parser-dattr.h"
+#include "ns3/ccnb-parser-ext.h"
+
+#include <boost/foreach.hpp>
+
+namespace ns3 {
+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_nestedBlocks)
+    {
+      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_nestedBlocks)
+    {
+      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;
+}
+
+}
+}
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.h
new file mode 100644
index 0000000..9237c2c
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-depth-first-visitor.h
@@ -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>
+ */
+
+#ifndef _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+#define _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
+
+#include "ccnb-parser-void-no-argu-visitor.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingrou 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&  );
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-visitor.h
new file mode 100644
index 0000000..ef45c98
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-no-argu-visitor.h
@@ -0,0 +1,51 @@
+/* -*- 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 "ccnb-parser-commoh.h"
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-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
+};
+  
+}
+}
+
+#endif // _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
diff --git a/helper/ccnb-parser/visitors/ccnb-parser-void-visitor.h b/helper/ccnb-parser/visitors/ccnb-parser-void-visitor.h
new file mode 100644
index 0000000..7f412c2
--- /dev/null
+++ b/helper/ccnb-parser/visitors/ccnb-parser-void-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_VISITOR_H_
+#define _CCNB_PARSER_VOID_VISITOR_H_
+
+#include "ccnb-parser-commoh.h"
+#include <boost/any.hpp>
+
+namespace ns3 {
+namespace CcnbParser {
+
+/**
+ * \ingroup ccnx-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
+};
+
+}
+}
+
+#endif // _CCNB_PARSER_VOID_VISITOR_H_
diff --git a/helper/ccnx-decoding-helper.cc b/helper/ccnx-decoding-helper.cc
index 0dabb66..553beb3 100644
--- a/helper/ccnx-decoding-helper.cc
+++ b/helper/ccnx-decoding-helper.cc
@@ -20,25 +20,19 @@
 
 #include "ccnx-decoding-helper.h"
 
-#include "ns3/ccnx.h"
-#include "ns3/name-components.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-content-object-header.h"
-
-#include <sstream>
-#include <boost/foreach.hpp>
+// #include "ns3/ccnx-interest-header.h"
+// #include "ns3/ccnx-content-object-header.h"
 
 namespace ns3 {
 
-CcnxParser::InterestVisitor CcnxDecodingHelper::m_interestVisitor;
-CcnxParser::ContentObjectVisitor CcnxDecodingHelper::m_contentObjectVisitor;
-
 size_t
 CcnxDecodingHelper::Deserialize (Buffer::Iterator start, const CcnxInterestHeader &interest)
 {
+  static InterestVisitor interestVisitor;
+
   Buffer::Iterator i = start;
   Ptr<CcnxParser::Block> root = CcnxParser::Block::ParseBlock (i);
-  root->accept (m_interestVisitor, interest);
+  root->accept (interestVisitor, interest);
 
   return i.GetDistanceFrom (start);
 }
@@ -46,622 +40,13 @@
 size_t
 CcnxDecodingHelper::Deserialize (Buffer::Iterator start, const CcnxContentObjectHeader &contentObject)
 {
+  static ContentObjectVisitor contentObjectVisitor;
+
   Buffer::Iterator i = start;
   Ptr<CcnxParser::Block> root = CcnxParser::Block::ParseBlock (i);
-  root->accept (m_contentObjectVisitor, contentObject);
+  root->accept (contentObjectVisitor, contentObject);
 
   return i.GetDistanceFrom (start);
 }
 
-
-//////////////////////////////////////////////////////////////////////
-
-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));
-
-namespace CcnxParser {
-
-Ptr<Block> Block::ParseBlock (Buffer::Iterator &start)
-{
-  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 (!(byte & CCN_TT_HBIT))
-    {
-      value <<= 8;
-      value += byte;
-      byte = start.ReadU8 ();
-    }
-  value <<= 4;
-  value += ( (byte&(~CCN_TT_HBIT)) >> 3);
-
-  switch (byte & CCN_TT_MASK)
-    {
-    case Ccnx::CCN_BLOB:
-      return Create<Blob> (start, value);
-    case Ccnx::CCN_UDATA:
-      return Create<Udata> (start, value);
-    case Ccnx::CCN_TAG:
-      return Create<Tag> (start, value);
-    case Ccnx::CCN_ATTR:
-      return Create<Attr> (start, value);
-    case Ccnx::CCN_DTAG:
-      return Create<Dtag> (start, value);
-    case Ccnx::CCN_DATTR:
-      return Create<Dattr> (start, value);
-    case Ccnx::CCN_EXT:
-      return Create<Ext> (start, value);
-    default:
-      throw CcnxDecodingException ();
-    }
-}
-
-Blob::Blob (Buffer::Iterator &start, uint32_t length)
-{
-  start.Read (m_blob.Begin (), length);
-}
-
-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
-  for (uint32_t i = 0; i < length; i++)
-    {
-      m_udata.push_back (start.ReadU8 ());
-    }
-}
-
-// length length in octets of UTF-8 encoding of tag name - 1 (minimum tag name length is 1) 
-Tag::Tag (Buffer::Iterator &start, uint32_t length)
-{
-  m_tag.reserve (length+2); // extra byte for potential \0 at the end
-  for (uint32_t i = 0; i < (length+1); i++)
-    {
-      m_tag.push_back (start.ReadU8 ());
-    }
-  
-  while (!start.IsEnd () && start.PeekU8 ()!=Ccnx::CCN_CLOSE)
-    {
-      m_nestedBlocks.push_back (Block::ParseBlock (start));
-    }
-  if (start.IsEnd ())
-      throw CcnxDecodingException ();
-
-  start.ReadU8 (); // read CCN_CLOSE
-}
-
-// 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
-  for (uint32_t i = 0; i < (length+1); i++)
-    {
-      m_attr.push_back (start.ReadU8 ());
-    }
-  m_value = DynamicCast<Udata> (Block::ParseBlock (start));
-  if (m_value == 0)
-    throw CcnxDecodingException (); // "ATTR must be followed by UDATA field"
-}
-
-Dtag::Dtag (Buffer::Iterator &start, uint32_t dtag)
-{
-  m_dtag = dtag;
-
-  /**
-   * Hack
-   *
-   * Stop processing after encountering <Content> dtag.  Actual
-   * content (including virtual payload) will be stored in Packet
-   * buffer
-   */
-  if (dtag == Ccnx::CCN_DTAG_Content)
-    return; // hack #1. Do not process nesting block for <Content>
-  
-  while (!start.IsEnd () && start.PeekU8 ()!=Ccnx::CCN_CLOSE)
-    {
-      m_nestedBlocks.push_back (Block::ParseBlock (start));
-
-      // hack #2. Stop processing nested blocks if last block was <Content>
-      if (m_dtag == Ccnx::CCN_DTAG_ContentObject && // we are in <ContentObject>
-          DynamicCast<Dtag> (m_nestedBlocks.back())!=0 && // last block is DTAG
-          DynamicCast<Dtag> (m_nestedBlocks.back())->m_dtag == Ccnx::CCN_DTAG_Content) 
-        {
-          return; 
-        }
-    }
-  if (start.IsEnd ())
-      throw CcnxDecodingException ();
-
-  start.ReadU8 (); // read CCN_CLOSE
-}
-
-// 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 CcnxDecodingException (); // "ATTR must be followed by UDATA field"
-}
-
-Ext::Ext (Buffer::Iterator &start, uint32_t extSubtype)
-{
-  m_extSubtype = extSubtype;
-}
-
-void
-DepthFirstVisitor::visit (Blob &n)
-{
-  // Buffer n.m_blob;
-}
- 
-void
-DepthFirstVisitor::visit (Udata &n)
-{
-  // std::string n.m_udata;
-}
- 
-void
-DepthFirstVisitor::visit (Tag &n)
-{
-  // std::string n.m_tag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-    {
-      block->accept (*this);
-    }
-}
- 
-void
-DepthFirstVisitor::visit (Attr &n)
-{
-  // std::string n.m_attr;
-  // Ptr<Udata> n.m_value;
-}
- 
-void
-DepthFirstVisitor::visit (Dtag &n)
-{
-  // uint32_t n.m_dtag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-    {
-      block->accept (*this);
-    }
-}
- 
-void
-DepthFirstVisitor::visit (Dattr &n)
-{
-  // uint32_t n.m_dattr;
-  // Ptr<Udata> n.m_value;
-}
- 
-void
-DepthFirstVisitor::visit (Ext &n)
-{
-  // uint64_t n.m_extSubtype;
-}
-
-//////////////////////////////////////////////////////////////////////
- 
-boost::any
-GJNoArguDepthFirstVisitor::visit (Blob &n)
-{
-  // Buffer n.m_blob;
-  return n.m_blob;
-}
- 
-boost::any
-GJNoArguDepthFirstVisitor::visit (Udata &n)
-{
-  // std::string n.m_udata;
-  return n.m_udata;
-}
- 
-boost::any
-GJNoArguDepthFirstVisitor::visit (Tag &n)
-{
-  // std::string n.m_tag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-    {
-      block->accept (*this);
-    }
-  return boost::any();
-}
- 
-boost::any
-GJNoArguDepthFirstVisitor::visit (Attr &n)
-{
-  // std::string n.m_attr;
-  // Ptr<Udata> n.m_value;
-  return boost::any(
-                    std::pair<std::string,std::string> (
-                                                        n.m_attr,
-                                                        boost::any_cast<std::string> (n.m_value->accept (*this))
-                                                        ));
-}
- 
-boost::any
-GJNoArguDepthFirstVisitor::visit (Dtag &n)
-{
-  // uint32_t n.m_dtag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-    {
-      block->accept (*this);
-    }
-  return boost::any();
-}
- 
-boost::any
-GJNoArguDepthFirstVisitor::visit (Dattr &n)
-{
-  // uint32_t n.m_dattr;
-  // Ptr<Udata> n.m_value;
-  return boost::any(
-                    std::pair<uint32_t,std::string> (
-                                                     n.m_dattr,
-                                                     boost::any_cast<std::string> (n.m_value->accept (*this))
-                                                     ));
-}
- 
-boost::any
-GJNoArguDepthFirstVisitor::visit (Ext &n)
-{
-  // uint64_t n.m_extSubtype;
-  return n.m_extSubtype;
-}
-
-//////////////////////////////////////////////////////////////////////
-
-void
-GJVoidDepthFirstVisitor::visit (Blob &n, boost::any param)
-{
-  // Buffer n.m_blob;
-}
- 
-void
-GJVoidDepthFirstVisitor::visit (Udata &n, boost::any param)
-{
-  // std::string n.m_udata;
-}
- 
-void
-GJVoidDepthFirstVisitor::visit (Tag &n, boost::any param)
-{
-  // std::string n.m_tag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-    {
-      block->accept (*this, param);
-    }
-}
- 
-void
-GJVoidDepthFirstVisitor::visit (Attr &n, boost::any param)
-{
-  // std::string n.m_attr;
-  // Ptr<Udata> n.m_value;
-}
- 
-void
-GJVoidDepthFirstVisitor::visit (Dtag &n, boost::any param)
-{
-  // uint32_t n.m_dtag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-    {
-      block->accept (*this, param);
-    }
-}
- 
-void
-GJVoidDepthFirstVisitor::visit (Dattr &n, boost::any param)
-{
-  // uint32_t n.m_dattr;
-  // Ptr<Udata> n.m_value;
-}
- 
-void
-GJVoidDepthFirstVisitor::visit (Ext &n, boost::any param)
-{
-  // uint64_t n.m_extSubtype;
-}
-
-//////////////////////////////////////////////////////////////////////
- 
-boost::any
-GJDepthFirstVisitor::visit (Blob &n, boost::any param)
-{
-  // Buffer n.m_blob;
-  return n.m_blob;
-}
- 
-boost::any
-GJDepthFirstVisitor::visit (Udata &n, boost::any param)
-{
-  // std::string n.m_udata;
-  return n.m_udata;
-}
- 
-boost::any
-GJDepthFirstVisitor::visit (Tag &n, boost::any param)
-{
-  // std::string n.m_tag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-    {
-      block->accept (*this, param);
-    }
-  return boost::any();
-}
- 
-boost::any
-GJDepthFirstVisitor::visit (Attr &n, boost::any param)
-{
-  // std::string n.m_attr;
-  // Ptr<Udata> n.m_value;
-  return boost::any(
-                    std::pair<std::string,std::string> (
-                                                        n.m_attr,
-                                                        boost::any_cast<std::string> (n.m_value->accept (*this,param))
-                                                        ));
-}
- 
-boost::any
-GJDepthFirstVisitor::visit (Dtag &n, boost::any param)
-{
-  // uint32_t n.m_dtag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-    {
-      block->accept (*this, param);
-    }
-  return boost::any();
-}
- 
-boost::any
-GJDepthFirstVisitor::visit (Dattr &n, boost::any param)
-{
-  // uint32_t n.m_dattr;
-  // Ptr<Udata> n.m_value;
-  return boost::any(
-                    std::pair<uint32_t,std::string> (
-                                                     n.m_dattr,
-                                                     boost::any_cast<std::string> (n.m_value->accept (*this,param))
-                                                     ));
-}
- 
-boost::any
-GJDepthFirstVisitor::visit (Ext &n, boost::any param)
-{
-  // uint64_t n.m_extSubtype;
-  return n.m_extSubtype;
-}
-
-//////////////////////////////////////////////////////////////////////
-
-boost::any
-NonNegativeIntegerVisitor::visit (Blob &n) //to throw parsing error
-{
-  // Buffer n.m_blob;
-  throw CcnxDecodingException ();
-}
-
-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 CcnxDecodingException ();
-
-  return static_cast<uint32_t> (value);
-}
-
-
-//////////////////////////////////////////////////////////////////////
-
-boost::any
-StringVisitor::visit (Blob &n) //to throw parsing error
-{
-  // Buffer n.m_blob;
-  throw CcnxDecodingException ();
-}
-
-boost::any
-StringVisitor::visit (Udata &n)
-{
-  // std::string n.m_udata;
-  return n.m_udata;
-}
-
-//////////////////////////////////////////////////////////////////////
-
-StringVisitor NameComponentsVisitor::m_stringVisitor; 
-
-void
-NameComponentsVisitor::visit (Dtag &n, boost::any param/*should be Name::Components&*/)
-{
-  // uint32_t n.m_dtag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  Name::Components &components = boost::any_cast<Name::Components&> (param);
-
-  switch (n.m_dtag)
-    {
-    case Ccnx::CCN_DTAG_Component:
-      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnxDecodingException ();
-      components.Add (
-                      boost::any_cast<std::string> ((*n.m_nestedBlocks.begin())->accept(
-                                                                                        m_stringVisitor
-                                                                                        )));
-      break;
-    default:
-      // ignore any other components
-      // when parsing Exclude, there could be <Any /> and <Bloom /> tags
-      break;
-    }
-}
- 
-//////////////////////////////////////////////////////////////////////
-
-NonNegativeIntegerVisitor InterestVisitor::m_nonNegativeIntegerVisitor;
-NameComponentsVisitor     InterestVisitor::m_nameComponentsVisitor;
-
-// We don't really care about any other fields
-void
-InterestVisitor::visit (Dtag &n, boost::any param/*should be CcnxInterestHeader&*/)
-{
-  // uint32_t n.m_dtag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  CcnxInterestHeader &interest = boost::any_cast<CcnxInterestHeader&> (param);
-  
-  switch (n.m_dtag)
-    {
-    case Ccnx::CCN_DTAG_Interest:
-      // process nested blocks
-      BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-        {
-          block->accept (*this, param);
-        }
-      break;
-    case Ccnx::CCN_DTAG_Name:
-      {
-        // process name components
-        Ptr<Name::Components> name = Create<Name::Components> ();
-        
-        BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-          {
-            block->accept (m_nameComponentsVisitor, *name);
-          }
-        interest.SetName (name);
-        break;
-      }
-    case Ccnx::CCN_DTAG_MinSuffixComponents:
-      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnxDecodingException ();
-      interest.SetMinSuffixComponents (
-               boost::any_cast<uint32_t> (
-                                          (*n.m_nestedBlocks.begin())->accept(
-                                                                           m_nonNegativeIntegerVisitor
-                                                                           )));
-      break;
-    case Ccnx::CCN_DTAG_MaxSuffixComponents:
-      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnxDecodingException ();
-      interest.SetMaxSuffixComponents (
-               boost::any_cast<uint32_t> (
-                                          (*n.m_nestedBlocks.begin())->accept(
-                                                                           m_nonNegativeIntegerVisitor
-                                                                           )));
-      break;
-    case Ccnx::CCN_DTAG_Exclude:
-      {
-        // process exclude components
-        Ptr<Name::Components> exclude = Create<Name::Components> ();
-        
-        BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-          {
-            block->accept (m_nameComponentsVisitor, *exclude);
-          }
-        interest.SetExclude (exclude);
-        break;
-      }
-    case Ccnx::CCN_DTAG_ChildSelector:
-      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnxDecodingException ();
-
-      interest.SetChildSelector (
-               1 == boost::any_cast<uint32_t> (
-                                          (*n.m_nestedBlocks.begin())->accept(
-                                                                           m_nonNegativeIntegerVisitor
-                                                                           )));
-      break;
-    case Ccnx::CCN_DTAG_AnswerOriginKind:
-      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnxDecodingException ();
-      interest.SetAnswerOriginKind (
-               1 == boost::any_cast<uint32_t> (
-                                          (*n.m_nestedBlocks.begin())->accept(
-                                                                           m_nonNegativeIntegerVisitor
-                                                                           )));
-      break;
-    case Ccnx::CCN_DTAG_Scope: 
-      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnxDecodingException ();
-      interest.SetScope (
-               boost::any_cast<uint32_t> (
-                                          (*n.m_nestedBlocks.begin())->accept(
-                                                                           m_nonNegativeIntegerVisitor
-                                                                           )));
-      break;
-    case Ccnx::CCN_DTAG_InterestLifetime:
-      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnxDecodingException ();
-      break;
-    case Ccnx::CCN_DTAG_Nonce:
-      if (n.m_nestedBlocks.size()!=1) // should be exactly one UDATA inside this tag
-        throw CcnxDecodingException ();
-      break;
-    }
-}
-
-//////////////////////////////////////////////////////////////////////
-
-NameComponentsVisitor ContentObjectVisitor::m_nameComponentsVisitor;
-
-// We don't really care about any other fields
-void
-ContentObjectVisitor::visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader&*/)
-{
-  // uint32_t n.m_dtag;
-  // std::list<Ptr<Block> > n.m_nestedBlocks;
-  CcnxContentObjectHeader &contentObject = boost::any_cast<CcnxContentObjectHeader&> (param);
-  
-  switch (n.m_dtag)
-    {
-    case Ccnx::CCN_DTAG_ContentObject:
-      // process nested blocks
-      BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-        {
-          block->accept (*this, param);
-        }
-      break;
-    case Ccnx::CCN_DTAG_Name:
-      {
-        // process name components
-        Ptr<Name::Components> name = Create<Name::Components> ();
-        
-        BOOST_FOREACH (Ptr<Block> block, n.m_nestedBlocks)
-          {
-            block->accept (m_nameComponentsVisitor, *name);
-          }
-        contentObject.SetName (name);
-        break;
-      }
-    case Ccnx::CCN_DTAG_Signature: // ignoring
-      break;
-    case Ccnx::CCN_DTAG_SignedInfo: // ignoring
-      break;
-    case Ccnx::CCN_DTAG_Content: // !!! HACK
-      // This hack was necessary for memory optimizations (i.e., content is virtual payload)
-      NS_ASSERT_MSG (n.m_nestedBlocks.size() == 0, "Parser should have stopped just after processing <Content> tag");
-      break;
-    }
-}
-
-} // namespace CcnxParser
 } // namespace ns3
diff --git a/helper/ccnx-decoding-helper.h b/helper/ccnx-decoding-helper.h
index e89766c..375a57a 100644
--- a/helper/ccnx-decoding-helper.h
+++ b/helper/ccnx-decoding-helper.h
@@ -15,37 +15,19 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Author: 
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
  */
 
 #ifndef _CCNX_DECODING_HELPER_H_
 #define _CCNX_DECODING_HELPER_H_
 
-#include <sys/types.h>
-#include <boost/any.hpp>
-#include <list>
-
-#include "ns3/ptr.h"
-#include "ns3/nstime.h"
-#include "ns3/buffer.h"
-#include "ns3/simple-ref-count.h"
-
-
 namespace ns3 {
 
-namespace Name{ class Components; }
-
 class CcnxInterestHeader;
 class CcnxContentObjectHeader;
 
-namespace CcnxParser {
-class InterestVisitor;
-class ContentObjectVisitor;
-}
-
 /**
- * Helper to encode/decode ccnb formatted CCNx message
- *
+ * \brief Helper class to decode ccnb formatted CCNx message
  */
 class CcnxDecodingHelper
 {
@@ -57,276 +39,8 @@
   Deserialize (Buffer::Iterator start, const CcnxContentObjectHeader &contentObject);
   
 private:
-  static CcnxParser::InterestVisitor m_interestVisitor;
-  static CcnxParser::ContentObjectVisitor m_contentObjectVisitor;
 };
 
-namespace CcnxParser {
-
-class Block;
-class Blob;
-class Udata;
-class Tag;
-class Attr;
-class Dtag;
-class Dattr;
-class Ext;
-
-class Visitor
-{
-public:
-  virtual void visit (Blob& )=0;
-  virtual void visit (Udata&)=0;
-  virtual void visit (Tag&  )=0;
-  virtual void visit (Attr& )=0;
-  virtual void visit (Dtag& )=0;
-  virtual void visit (Dattr&)=0;
-  virtual void visit (Ext&  )=0;
-};
-  
-class GJVisitor
-{
-public:
-  virtual boost::any visit (Blob&,  boost::any)=0;
-  virtual boost::any visit (Udata&, boost::any)=0;
-  virtual boost::any visit (Tag&,   boost::any)=0;
-  virtual boost::any visit (Attr&,  boost::any)=0;
-  virtual boost::any visit (Dtag&,  boost::any)=0;
-  virtual boost::any visit (Dattr&, boost::any)=0;
-  virtual boost::any visit (Ext&,   boost::any)=0;
-};
-  
-class GJNoArguVisitor
-{
-public:
-  virtual boost::any visit (Blob& )=0;
-  virtual boost::any visit (Udata&)=0;
-  virtual boost::any visit (Tag&  )=0;
-  virtual boost::any visit (Attr& )=0;
-  virtual boost::any visit (Dtag& )=0;
-  virtual boost::any visit (Dattr&)=0;
-  virtual boost::any visit (Ext&  )=0;
-};
-
-class GJVoidVisitor
-{
-public:
-  virtual void visit (Blob&,  boost::any)=0;
-  virtual void visit (Udata&, boost::any)=0;
-  virtual void visit (Tag&,   boost::any)=0;
-  virtual void visit (Attr&,  boost::any)=0;
-  virtual void visit (Dtag&,  boost::any)=0;
-  virtual void visit (Dattr&, boost::any)=0;
-  virtual void visit (Ext&,   boost::any)=0;
-};
-
-class Block : public SimpleRefCount<Block>
-{
-public:
-  /**
-   * Parsing block header and creating an appropriate object
-   */
-  static Ptr<Block>
-  ParseBlock (Buffer::Iterator &start);
-  
-  virtual void accept( Visitor &v )                           =0;
-  virtual void accept (GJVoidVisitor &v, boost::any param)    =0;
-  virtual boost::any accept( GJNoArguVisitor &v )             =0;
-  virtual boost::any accept( GJVisitor &v, boost::any param ) =0;
-};
-
-class Blob : public Block
-{
-public:
-  Blob (Buffer::Iterator &start, uint32_t length);
-  
-  virtual void accept( Visitor &v )                           { v.visit( *this ); }
-  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
-  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
-  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
-
-  Buffer m_blob;
-};
-
-class Udata : public Block
-{
-public:
-  Udata (Buffer::Iterator &start, uint32_t length);
-  
-  virtual void accept( Visitor &v )                           { v.visit( *this ); }
-  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
-  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
-  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
-
-  std::string m_udata;
-};
-
-class Tag : public Block
-{
-public:
-  Tag (Buffer::Iterator &start, uint32_t length);
-
-  virtual void accept( Visitor &v )                           { v.visit( *this ); }
-  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
-  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
-  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
-
-  std::string m_tag;
-  std::list<Ptr<Block> > m_nestedBlocks;
-};
-
-class Attr : public Block
-{
-public:
-  Attr (Buffer::Iterator &start, uint32_t length);
-  
-  virtual void accept( Visitor &v )                           { v.visit( *this ); }
-  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
-  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
-  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
-
-  std::string m_attr;
-  Ptr<Udata> m_value;
-};
-
-class Dtag : public Block
-{
-public:
-  Dtag (Buffer::Iterator &start, uint32_t dtag);
-
-  virtual void accept( Visitor &v )                           { v.visit( *this ); }
-  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
-  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
-  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
-
-  uint32_t m_dtag;
-  std::list<Ptr<Block> > m_nestedBlocks;
-};
-
-class Dattr : public Block
-{
-public:
-  Dattr (Buffer::Iterator &start, uint32_t dattr);
-
-  virtual void accept( Visitor &v )                           { v.visit( *this ); }
-  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
-  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
-  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
-
-  uint32_t m_dattr;
-  Ptr<Udata> m_value;
-};
-
-class Ext : public Block
-{
-public:
-  Ext (Buffer::Iterator &start, uint32_t extSubtype);
-
-  virtual void accept( Visitor &v )                           { v.visit( *this ); }
-  virtual void accept( GJVoidVisitor &v, boost::any param )   { v.visit( *this, param ); }
-  virtual boost::any accept( GJNoArguVisitor &v )             { return v.visit( *this ); }
-  virtual boost::any accept( GJVisitor &v, boost::any param ) { return v.visit( *this, param ); }
-
-  uint64_t m_extSubtype;
-};
-
-class DepthFirstVisitor : public Visitor
-{
-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&  );
-};
-
-class GJDepthFirstVisitor : public GJVisitor
-{
-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);
-};
-
-class GJNoArguDepthFirstVisitor : public GJNoArguVisitor
-{
-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&  );
-};
-
-class GJVoidDepthFirstVisitor : public GJVoidVisitor
-{
-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);
-};
-
-// class NameComponentsVisitor : public 
-
-class NonNegativeIntegerVisitor : public GJNoArguDepthFirstVisitor
-{
-public:
-  virtual boost::any visit (Blob &n); //to throw parsing error
-  virtual boost::any visit (Udata &n);
-};
-
-class StringVisitor : public GJNoArguDepthFirstVisitor
-{
-public:
-  virtual boost::any visit (Blob &n); //to throw parsing error
-  virtual boost::any visit (Udata &n);
-};
-
-class NameComponentsVisitor : public GJVoidDepthFirstVisitor
-{
-public:
-  virtual void visit (Dtag &n, boost::any param/*should be Name::Components*/);
-private:
-  static StringVisitor m_stringVisitor; 
-};
-
-class InterestVisitor : public GJVoidDepthFirstVisitor
-{
-public:
-  virtual void visit (Dtag &n, boost::any param/*should be CcnxInterestHeader&*/);
-  
-private:
-  static NonNegativeIntegerVisitor m_nonNegativeIntegerVisitor;
-  static NameComponentsVisitor     m_nameComponentsVisitor;
-};
-
-class ContentObjectVisitor : public GJVoidDepthFirstVisitor
-{
-public:
-  virtual void visit (Dtag &n, boost::any param/*should be CcnxContentObjectHeader&*/);
-  
-private:
-  static NameComponentsVisitor     m_nameComponentsVisitor;
-};
-
-
-class CcnxDecodingException {};
-
-} // namespace CcnxParser
-
 } // namespace ns3
 
 #endif // _CCNX_DECODING_HELPER_H_
-
diff --git a/model/ccnx.h b/model/ccnx.h
index 412fd2e..666158f 100644
--- a/model/ccnx.h
+++ b/model/ccnx.h
@@ -140,128 +140,6 @@
    */
   virtual Ptr<CcnxFace>
   GetFace (uint32_t face) const = 0;
-
-public:
-   /**
-   * \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_SequenceNumber = 256,
-    CCN_DTAG_CCNProtocolDataUnit = 17702112
-  };
 };
 
 } // namespace ns3 
diff --git a/wscript b/wscript
index 64a7336..0eb185e 100644
--- a/wscript
+++ b/wscript
@@ -34,10 +34,15 @@
         conf.env['MODULES_NOT_BUILT'].append('NDNabstraction')
         return
    
-    module.find_sources_in_dirs (['model', 'apps', 'helper'],[],['.cc']);
+    module.find_sources_in_dirs (['model', 'apps', 'helper',
+                                   'helper/ccnb-parser',
+                                   'helper/ccnb-parser/visitors',
+                                   'helper/ccnb-parser/syntax-tree'],[],['.cc']);
     tests.find_sources_in_dirs( ['test'], [], ['.cc'] );
-    headers.find_sources_in_dirs( ['model', 'apps', 'helper'], [], ['.h'] );
-
+    headers.find_sources_in_dirs( ['model', 'apps', 'helper',
+                                   'helper/ccnb-parser',
+                                   'helper/ccnb-parser/visitors',
+                                   'helper/ccnb-parser/syntax-tree'], [], ['.h'] );
 
     if True or bld.env['ENABLE_EXAMPLES']:
         for path in ["examples"]:
@@ -45,7 +50,7 @@
             if not anode or not anode.is_child_of(bld.srcnode):
                 raise Utils.WscriptError("Unable to use '%s' - either because \
                 it's not a relative path"", or it's not child of \
-                '%s'."%(name,bld.srcnode))
+               '%s'."%(name,bld.srcnode))
             bld.rescan(anode)
             for filename in bld.cache_dir_contents[anode.id]:
                 if filename.startswith('.') or not filename.endswith(".cc"):