First steps in CCNx packet coding. ccnx_encode* routines rewritten in NS3 style (using NS3::Buffer)

diff --git a/model/ccn/ccn.h b/model/ccn/ccn.h
index 6b0443c..af9dcae 100644
--- a/model/ccn/ccn.h
+++ b/model/ccn/ccn.h
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ccn/ccn_buf_decoder.cc b/model/ccn/ccn_buf_decoder.cc
index 5e1d713..eeb51fa 100644
--- a/model/ccn/ccn_buf_decoder.cc
+++ b/model/ccn/ccn_buf_decoder.cc
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
@@ -18,15 +18,6 @@
  * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
  */
 
-/*
- *  ccn_buf_decoder.cc
- *  Abstraction
- *
- *  Created by Ilya on 7/29/11.
- *  Copyright 2011 __MyCompanyName__. All rights reserved.
- *
- */
-
 #include <string.h>
 #include <stdlib.h>
 #include "ccn.h"
@@ -34,26 +25,6 @@
 #include "ccn_coding.h"
 #include "ccn_indexbuf.h"
 
-/**
- * @file ccn_buf_decoder.c
- * @brief Support for Interest and ContentObject decoding.
- * 
- * Part of the CCNx C Library.
- *
- * Copyright (C) 2008, 2009, 2010 Palo Alto Research Center, Inc.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- * This library 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
- * Lesser General Public License for more details. You should have received
- * a copy of the GNU Lesser General Public License along with this library;
- * if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
 
 struct ccn_buf_decoder *
 ccn_buf_decoder_start(struct ccn_buf_decoder *d,
diff --git a/model/ccn/ccn_buf_encoder.cc b/model/ccn/ccn_buf_encoder.cc
index cc34551..d0d157b 100644
--- a/model/ccn/ccn_buf_encoder.cc
+++ b/model/ccn/ccn_buf_encoder.cc
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
@@ -18,15 +18,6 @@
  * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
  */
 
-/*
- *  ccn_buf_encoder.cc
- *  Abstraction
- *
- *  Created by Ilya on 7/29/11.
- *  Copyright 2011 __MyCompanyName__. All rights reserved.
- *
- */
-
 #include <string.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -38,34 +29,6 @@
 #include "ccn_indexbuf.h"
 
 /**
- * Append a ccnb start marker
- *
- * This forms the basic building block of ccnb-encoded data.
- * @param c is the buffer to append to.
- * @param val is the numval, intepreted according to tt (see enum ccn_tt).
- * @param tt is the type field.
- * @returns 0 for success or -1 for error.
- */
-int
-ccn_charbuf_append_tt(struct ccn_charbuf *c, size_t val, enum ccn_tt tt)
-{
-  unsigned char buf[1+8*((sizeof(val)+6)/7)];
-  unsigned char *p = &(buf[sizeof(buf)-1]);
-  int n = 1;
-  p[0] = (CCN_TT_HBIT & ~CCN_CLOSE) |
-  ((val & CCN_MAX_TINY) << CCN_TT_BITS) |
-  (CCN_TT_MASK & tt);
-  val >>= (7-CCN_TT_BITS);
-  while (val != 0) {
-    (--p)[0] = (((unsigned char)val) & ~CCN_TT_HBIT) | CCN_CLOSE;
-    n++;
-    val >>= 7;
-  }
-  return(ccn_charbuf_append(c, p, n));
-}
-
-
-/**
  * Encode and sign a ContentObject.
  * @param buf is the output buffer where encoded object is written.
  * @param Name is the ccnb-encoded name from ccn_name_init and friends.
@@ -87,45 +50,7 @@
                          )
 {
     int res = 0;
-    //struct ccn_sigc *sig_ctx;
-    //struct ccn_signature *signature;
-    //size_t signature_size;
-    struct ccn_charbuf *content_header;
-    size_t closer_start;
     
-    content_header = ccn_charbuf_create();
-    res |= ccn_charbuf_append_tt(content_header, CCN_DTAG_Content, CCN_DTAG);
-    if (size != 0)
-        res |= ccn_charbuf_append_tt(content_header, size, CCN_BLOB);
-    closer_start = content_header->length;
-    res |= ccn_charbuf_append_closer(content_header);
-    if (res < 0)
-        return(-1);
-    //sig_ctx = ccn_sigc_create();
-    //if (sig_ctx == NULL)
-    //    return(-1);
-    //if (0 != ccn_sigc_init(sig_ctx, digest_algorithm))
-    //    return(-1);
-    //if (0 != ccn_sigc_update(sig_ctx, Name->buf, Name->length))
-    //    return(-1);
-    //if (0 != ccn_sigc_update(sig_ctx, SignedInfo->buf, SignedInfo->length))
-    //    return(-1);
-    //if (0 != ccn_sigc_update(sig_ctx, content_header->buf, closer_start))
-    //    return(-1);
-    //if (0 != ccn_sigc_update(sig_ctx, data, size))
-    //    return(-1);
-    //if (0 != ccn_sigc_update(sig_ctx, content_header->buf + closer_start,
-    //                         content_header->length - closer_start))
-    //    return(-1);
-    //signature = calloc(1, ccn_sigc_signature_max_size(sig_ctx, private_key));
-    //if (signature == NULL)
-    //    return(-1);
-    //res = ccn_sigc_final(sig_ctx, signature, &signature_size, private_key);
-    //if (0 != res) {
-    //    free(signature);
-    //    return(-1);
-    //}
-    //ccn_sigc_destroy(&sig_ctx);
     res |= ccn_charbuf_append_tt(buf, CCN_DTAG_ContentObject, CCN_DTAG);
     //res |= ccn_encode_Signature(buf, digest_algorithm,
     //                            NULL, 0, signature, signature_size);
diff --git a/model/ccn/ccn_charbuf.cc b/model/ccn/ccn_charbuf.cc
index f71b0a0..06c6544 100644
--- a/model/ccn/ccn_charbuf.cc
+++ b/model/ccn/ccn_charbuf.cc
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ccn/ccn_charbuf.h b/model/ccn/ccn_charbuf.h
index 1b2c61b..066eda2 100644
--- a/model/ccn/ccn_charbuf.h
+++ b/model/ccn/ccn_charbuf.h
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ccn/ccn_coding.cc b/model/ccn/ccn_coding.cc
deleted file mode 100644
index e7a54e7..0000000
--- a/model/ccn/ccn_coding.cc
+++ /dev/null
@@ -1,284 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "ccn_coding.h"
-
-/**
- * @file ccn_coding.c
- * @brief Support for scanning and parsing ccnb-encoded data.
- * 
- * Part of the CCNx C Library.
- *
- * Copyright (C) 2008, 2009 Palo Alto Research Center, Inc.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- * This library 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
- * Lesser General Public License for more details. You should have received
- * a copy of the GNU Lesser General Public License along with this library;
- * if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301 USA.
- */
-//#include <ccn/coding.h>
-
-/**
- * This macro documents what's happening in the state machine by
- * hinting at the XML syntax would be emitted in a re-encoder.
- * But it actually does nothing.
- */
-#define XML(goop) ((void)0)
-
-/**
- * Decodes ccnb decoded data
- *
- * @param d holds the current state of the decoder.
- * @param p points to a new block of ccnb data to feed to the decoder.
- * @param n is the size of the input, in bytes.
- * @returns the number of bytes consumed.
- *
- * The client should ensure that the decoder is initialized to all zero
- * before the first call.  In the default mode, the decoder will return
- * only when it runs out of data, encounters an error, or reaches the end
- * of the element that it started at.  This is a good way to pull
- * ccnb-encoded objects from a byte stream.
- *
- * By setting the CCN_DSTATE_PAUSE bit is set in the decoder state, the
- * decoder will additionally return just after recognizing each token.
- * In this instance, use CCN_GET_TT_FROM_DSTATE() to extract
- * the token type from the decoder state;
- * CCN_CLOSE will be reported as CCN_NO_TOKEN.
- *
- * The pause bit persists, so the end test should take that into account
- * by using the CCN_FINAL_DSTATE() macro instead of testing for state 0.
- *
- * Once an error state is entered, no addition input is processed.
- *
- * @see ccn_buf_decoder_start(), ccn_buf_advance(), ccn_buf_check_close()
- */
-ssize_t
-ccn_skeleton_decode(struct ccn_skeleton_decoder *d,
-                    const unsigned char *p, size_t n)
-{
-  enum ccn_decoder_state state = (ccn_decoder_state)(d->state);
-  int tagstate = 0;
-  size_t numval = d->numval;
-  ssize_t i = 0;
-  unsigned char c;
-  size_t chunk;
-  int pause = 0;
-  if (d->state >= 0) {
-    pause = d->state & CCN_DSTATE_PAUSE;
-    tagstate = (d->state >> 8) & 3;
-    state = (ccn_decoder_state)(d->state & 0xFF);
-  }
-  while (i < (ssize_t)n) {
-    switch (state) {
-      case CCN_DSTATE_INITIAL:
-      case CCN_DSTATE_NEWTOKEN: /* start new thing */
-        d->token_index = i + d->index;
-        if (tagstate > 1 && tagstate-- == 2) {
-          XML("\""); /* close off the attribute value */
-        } 
-        if (p[i] == CCN_CLOSE) {
-          i++;
-          if (d->nest <= 0 || tagstate > 1) {
-            state = CCN_DSTATE_ERR_NEST;
-            break;
-          }
-          if (tagstate == 1) {
-            tagstate = 0;
-            XML("/>");
-          }
-          else {
-            XML("</%s>");
-          }
-          d->nest -= 1;
-          if (d->nest == 0) {
-            state = CCN_DSTATE_INITIAL;
-            n = i;
-          }
-          if (pause) {
-            int temp = (int)state;
-            //state |= (((int)CCN_NO_TOKEN) << 16);
-            temp |= (((int)CCN_NO_TOKEN) << 16);
-            state = (ccn_decoder_state)temp;
-            n = i;
-          }
-          break;
-        }
-        numval = 0;
-        state = CCN_DSTATE_NUMVAL;
-        /* FALLTHRU */
-      case CCN_DSTATE_NUMVAL: /* parsing numval */
-        c = p[i++];
-        if ((c & CCN_TT_HBIT) == CCN_CLOSE) {
-          if (numval > ((~(size_t)0U) >> (7 + CCN_TT_BITS)))
-            state = CCN_DSTATE_ERR_OVERFLOW;
-          numval = (numval << 7) + (c & 127);
-        }
-        else {
-          numval = (numval << (7-CCN_TT_BITS)) +
-          ((c >> CCN_TT_BITS) & CCN_MAX_TINY);
-          c &= CCN_TT_MASK;
-          switch (c) {
-            case CCN_EXT:
-              if (tagstate == 1) {
-                tagstate = 0;
-                XML(">");
-              }
-              d->nest += 1;
-              d->element_index = d->token_index;
-              state = CCN_DSTATE_NEWTOKEN;
-              break;
-            case CCN_DTAG:
-              if (tagstate == 1) {
-                tagstate = 0;
-                XML(">");
-              }
-              d->nest += 1;
-              d->element_index = d->token_index;
-              XML("<%s");
-              tagstate = 1;
-              state = CCN_DSTATE_NEWTOKEN;
-              break;
-            case CCN_BLOB:
-              if (tagstate == 1) {
-                tagstate = 0;
-                XML(" ccnbencoding=\"base64Binary\">");
-              }
-              state = CCN_DSTATE_BLOB;
-              if (numval == 0)
-                state = CCN_DSTATE_NEWTOKEN;
-              break;
-            case CCN_UDATA:
-              if (tagstate == 1) {
-                tagstate = 0;
-                XML(">");
-              }
-              state = CCN_DSTATE_UDATA;
-              if (numval == 0)
-                state = CCN_DSTATE_NEWTOKEN;
-              break;
-            case CCN_DATTR:
-              if (tagstate != 1) {
-                state = CCN_DSTATE_ERR_ATTR;
-                break;
-              }
-              tagstate = 3;
-              state = CCN_DSTATE_NEWTOKEN;
-              break;
-            case CCN_ATTR:
-              if (tagstate != 1) {
-                state = CCN_DSTATE_ERR_ATTR;
-                break;
-              }
-              numval += 1; /* encoded as length-1 */
-              state = CCN_DSTATE_ATTRNAME;
-              break;
-            case CCN_TAG:
-              if (tagstate == 1) {
-                tagstate = 0;
-                XML(">");
-              }
-              numval += 1; /* encoded as length-1 */
-              d->nest += 1;
-              d->element_index = d->token_index;
-              state = CCN_DSTATE_TAGNAME;
-              break;
-            default:
-              state = CCN_DSTATE_ERR_CODING;
-          }
-          if (pause) {
-            int temp = (int)state;
-            //state |= (c << 16);
-            temp |= (c << 16);
-            state = (ccn_decoder_state)temp;
-            n = i;
-          }
-        }
-        break;
-      case CCN_DSTATE_TAGNAME: /* parsing tag name */
-        chunk = n - i;
-        if (chunk > numval)
-          chunk = numval;
-        if (chunk == 0) {
-          state = CCN_DSTATE_ERR_BUG;
-          break;
-        }
-        numval -= chunk;
-        i += chunk;
-        if (numval == 0) {
-          if (d->nest == 0) {
-            state = CCN_DSTATE_ERR_NEST;
-            break;
-          }
-          XML("<%s");
-          tagstate = 1;
-          state = CCN_DSTATE_NEWTOKEN;
-        }
-        break;                
-      case CCN_DSTATE_ATTRNAME: /* parsing attribute name */
-        chunk = n - i;
-        if (chunk > numval)
-          chunk = numval;
-        if (chunk == 0) {
-          state = CCN_DSTATE_ERR_BUG;
-          break;
-        }
-        numval -= chunk;
-        i += chunk;
-        if (numval == 0) {
-          if (d->nest == 0) {
-            state = CCN_DSTATE_ERR_ATTR;
-            break;
-          }
-          XML(" %s=\"");
-          tagstate = 3;
-          state = CCN_DSTATE_NEWTOKEN;
-        }
-        break;
-      case CCN_DSTATE_UDATA: /* utf-8 data */
-      case CCN_DSTATE_BLOB: /* BLOB */
-        chunk = n - i;
-        if (chunk > numval)
-          chunk = numval;
-        if (chunk == 0) {
-          state = CCN_DSTATE_ERR_BUG;
-          break;
-        }
-        numval -= chunk;
-        i += chunk;
-        if (numval == 0)
-          state = CCN_DSTATE_NEWTOKEN;
-        break;
-      default:
-        n = i;
-    }
-  }
-  if (state < 0)
-    tagstate = pause = 0;
-  d->state = state | pause | (tagstate << 8); 
-  d->numval = numval;
-  d->index += i;
-  return(i);
-}
diff --git a/model/ccn/ccn_coding.h b/model/ccn/ccn_coding.h
deleted file mode 100644
index acf346c..0000000
--- a/model/ccn/ccn_coding.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-/**
- * @file ccn/coding.h
- * 
- * Details of the ccn binary wire encoding.
- *
- * Part of the CCNx C Library.
- *
- * Copyright (C) 2008-2010 Palo Alto Research Center, Inc.
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- * This library 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
- * Lesser General Public License for more details. You should have received
- * a copy of the GNU Lesser General Public License along with this library;
- * if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef CCN_CODING_DEFINED
-#define CCN_CODING_DEFINED
-
-#include <sys/types.h>
-#include <stddef.h>
-
-#define CCN_TT_BITS 3
-#define CCN_TT_MASK ((1 << CCN_TT_BITS) - 1)
-#define CCN_MAX_TINY ((1 << (7-CCN_TT_BITS)) - 1)
-#define CCN_TT_HBIT ((unsigned char)(1 << 7))
-
-/**
- * Type tag for a ccnb start marker.
- */
-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 */
-};
-
-/** CCN_CLOSE terminates composites */
-#define CCN_CLOSE ((unsigned char)(0))
-
-enum ccn_ext_subtype {
-  /* skip smallest values for now */
-  CCN_PROCESSING_INSTRUCTIONS = 16 /* <?name:U value:U?> */
-};
-
-/**
- * DTAG identifies ccnb-encoded elements.
- * c.f. tagname.csvdict
- * See the gen_enum_dtag script for help updating these.
- */
-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
-};
-
-struct ccn_dict_entry {
-  int index;              /**< matches enum ccn_dtag above */
-  const char *name;       /**< textual name of dtag */
-};
-
-struct ccn_dict {
-  int count;              /**< Count of elements in the table */
-  const struct ccn_dict_entry *dict; /**< the table entries */
-};
-
-/**
- * Table for translating from DTAGs to names and vice versa.
- */
-extern const struct ccn_dict ccn_dtag_dict; /* matches enum ccn_dtag above */
-
-struct ccn_skeleton_decoder { /* initialize to all 0 */
-  ssize_t index;          /**< Number of bytes processed */
-  int state;              /**< Decoder state */
-  int nest;               /**< Element nesting */
-  size_t numval;          /**< Current numval, meaning depends on state */
-  size_t token_index;     /**< Starting index of most-recent token */
-  size_t element_index;   /**< Starting index of most-recent element */
-};
-
-/**
- * The decoder state is one of these, possibly with some
- * additional bits set for internal use.  A complete parse
- * ends up in state 0 or an error state.  Not all possible
- * error states are listed here.
- */
-enum ccn_decoder_state {
-  CCN_DSTATE_INITIAL = 0,
-  CCN_DSTATE_NEWTOKEN,
-  CCN_DSTATE_NUMVAL,
-  CCN_DSTATE_UDATA,
-  CCN_DSTATE_TAGNAME,
-  CCN_DSTATE_ATTRNAME,
-  CCN_DSTATE_BLOB,
-  /* All error states are negative */
-  CCN_DSTATE_ERR_OVERFLOW = -1,
-  CCN_DSTATE_ERR_ATTR     = -2,       
-  CCN_DSTATE_ERR_CODING   = -3,
-  CCN_DSTATE_ERR_NEST     = -4, 
-  CCN_DSTATE_ERR_BUG      = -5
-};
-
-/**
- * If the CCN_DSTATE_PAUSE bit is set in the decoder state,
- * the decoder will return just after recognizing each token.
- * In this instance, use CCN_GET_TT_FROM_DSTATE() to extract
- * the token type from the decoder state;
- * CCN_CLOSE will be reported as CCN_NO_TOKEN.
- * The pause bit persists, so the end test should take that into account
- * by using the CCN_FINAL_DSTATE macro instead of testing for state 0.
- */
-#define CCN_DSTATE_PAUSE (1 << 15)
-#define CCN_GET_TT_FROM_DSTATE(state) (CCN_TT_MASK & ((state) >> 16))
-#define CCN_FINAL_DSTATE(state) (((state) & (CCN_DSTATE_PAUSE-1)) == 0)
-
-ssize_t ccn_skeleton_decode(struct ccn_skeleton_decoder *d,
-                            const unsigned char *p,
-                            size_t n);
-
-#endif
-
diff --git a/model/ccn/ccn_indexbuf.cc b/model/ccn/ccn_indexbuf.cc
index a1cd87d..034c5db 100644
--- a/model/ccn/ccn_indexbuf.cc
+++ b/model/ccn/ccn_indexbuf.cc
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ccn/ccn_indexbuf.h b/model/ccn/ccn_indexbuf.h
index 9c9a8c9..3e133c3 100644
--- a/model/ccn/ccn_indexbuf.h
+++ b/model/ccn/ccn_indexbuf.h
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ccn/ccn_name_util.cc b/model/ccn/ccn_name_util.cc
index 94f3991..64405ce 100644
--- a/model/ccn/ccn_name_util.cc
+++ b/model/ccn/ccn_name_util.cc
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ccn/ccn_name_util.h b/model/ccn/ccn_name_util.h
index 95df0e3..6e5fda7 100644
--- a/model/ccn/ccn_name_util.h
+++ b/model/ccn/ccn_name_util.h
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ccn/ccn_random.cc b/model/ccn/ccn_random.cc
index 6e2dd0c..6176c79 100644
--- a/model/ccn/ccn_random.cc
+++ b/model/ccn/ccn_random.cc
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ccn/ccn_random.h b/model/ccn/ccn_random.h
index 0a8be4c..ddd0a38 100644
--- a/model/ccn/ccn_random.h
+++ b/model/ccn/ccn_random.h
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ccnx-content-object-header.cc b/model/ccnx-content-object-header.cc
index 726415e..46a1554 100644
--- a/model/ccnx-content-object-header.cc
+++ b/model/ccnx-content-object-header.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
@@ -29,6 +29,7 @@
 {
 
 NS_OBJECT_ENSURE_REGISTERED (CcnxContentObjectHeader);
+NS_OBJECT_ENSURE_REGISTERED (CcnxContentObjectTail);
 
 TypeId
 CcnxContentObjectHeader::GetTypeId (void)
@@ -83,8 +84,63 @@
 void
 CcnxContentObjectHeader::Print (std::ostream &os) const
 {
-  os << "ContentObject: " << *m_name;
+  os << "<ContentObject><Name>" << *m_name << "</Name><Content>";
 }
 
-} // namespace ns3
 
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+CcnxContentObjectTail::CcnxContentObjectTail ()
+{
+}
+
+TypeId
+CcnxContentObjectTail::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::CcnxContentObjectHeader")
+    .SetParent<Header> ()
+    .AddConstructor<CcnxContentObjectHeader> ()
+    ;
+  return tid;
+}
+
+TypeId
+CcnxContentObjectTail::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
+void
+CcnxContentObjectTail::Print (std::ostream &os) const
+{
+  os << "</Content></ContentObject>";
+}
+
+uint32_t
+CcnxContentObjectTail::GetSerializedSize (void) const
+{
+  return 2;
+}
+
+void
+CcnxContentObjectTail::Serialize (Buffer::Iterator start) const
+{
+  Buffer::Iterator i = start;
+  i.WriteU8 (0x00); // </Content>
+  i.WriteU8 (0x00); // </ContentObject>
+}
+
+uint32_t
+CcnxContentObjectTail::Deserialize (Buffer::Iterator start)
+{
+  Buffer::Iterator i = start;
+  uint8_t __attribute__ ((unused)) closing_tag_content = i.ReadU8 ();
+  NS_ASSERT_MSG (closing_tag_content==0, "Should be closing tag </Content> (0x00)");
+
+  uint8_t __attribute__ ((unused)) closing_tag_content_object = i.ReadU8 ();
+  NS_ASSERT_MSG (closing_tag_content_object==0, "Should be closing tag </ContentObject> (0x00)");
+
+  return 2;
+}
+  
+} // namespace ns3
diff --git a/model/ccnx-content-object-header.h b/model/ccnx-content-object-header.h
index 0800885..c26052b 100644
--- a/model/ccnx-content-object-header.h
+++ b/model/ccnx-content-object-header.h
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
@@ -40,9 +40,13 @@
  * Only few important fields are actually implemented in the simulation
  *
  *
- * NDN ContentObjectHeader and routines to serialize/deserialize
+ * ContentObjectHeader serializes/deserializes header up-to and including <Content> tags
+ * Necessary closing tags should be added using ContentObjectTail
  *
- *  Simplifications:
+ * This hacks are necessary to optimize memory use (i.e., virtual payload)
+ *
+ * "<ContentObject><Signature>..</Signature><Name>...</Name><SignedInfo>...</SignedInfo><Content>"
+ * 
  */
   
 class CcnxContentObjectHeader : public Header
@@ -77,12 +81,6 @@
 
   // ?
   // GetSignedInfo () const;
-
-  // void
-  // SetContent ();
-
-  // ?
-  // GetContent ();
   
   //////////////////////////////////////////////////////////////////
   
@@ -97,9 +95,27 @@
   Ptr<Name::Components> m_name;
   // m_signature;
   // m_signedInfo;
-  // ? content
 };
 
+/**
+ * ContentObjectTail should always be 2 bytes, representing two closing tags:
+ * "</Content><ContentObject>"
+ */
+class CcnxContentObjectTail : public Header
+{
+public:
+  CcnxContentObjectTail ();
+  //////////////////////////////////////////////////////////////////
+  
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
+  virtual void Print (std::ostream &os) const;
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
+};
+
+  
 } // namespace ns3
 
 #endif // _CCNX_CONTENT_OBJECT_HEADER_H_
diff --git a/model/ccnx-face.cc b/model/ccnx-face.cc
index 7635a3e..15ddb84 100644
--- a/model/ccnx-face.cc
+++ b/model/ccnx-face.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2005,2006,2007 INRIA
  *
diff --git a/model/ccnx-face.h b/model/ccnx-face.h
index 2b5ba5f..35f7dc1 100644
--- a/model/ccnx-face.h
+++ b/model/ccnx-face.h
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2005,2006,2007 INRIA
  *
diff --git a/model/ccnx-forwarding-protocol.cc b/model/ccnx-forwarding-strategy.cc
similarity index 73%
rename from model/ccnx-forwarding-protocol.cc
rename to model/ccnx-forwarding-strategy.cc
index afc7f33..6d4b045 100644
--- a/model/ccnx-forwarding-protocol.cc
+++ b/model/ccnx-forwarding-strategy.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2009 University of Washington
  *
@@ -19,22 +19,22 @@
 #include "ns3/assert.h"
 
 #include "ccnx-route.h"
-#include "ccnx-forwarding-protocol.h"
+#include "ccnx-forwarding-strategy.h"
 
 namespace ns3 {
 
-NS_OBJECT_ENSURE_REGISTERED (CcnxForwardingProtocol);
+NS_OBJECT_ENSURE_REGISTERED (CcnxForwardingStrategy);
 
-TypeId CcnxForwardingProtocol::GetTypeId (void)
+TypeId CcnxForwardingStrategy::GetTypeId (void)
 {
-  static TypeId tid = TypeId ("ns3::CcnxForwardingProtocol")
+  static TypeId tid = TypeId ("ns3::CcnxForwardingStrategy")
     .SetParent<Object> ()
   ;
   return tid;
 }
 
 void
-CcnxForwardingProtocol::SetCcnx (Ptr<Ccnx> ccnx)
+CcnxForwardingStrategy::SetCcnx (Ptr<Ccnx> ccnx)
 {
   m_ccnx = ccnx;
 }
diff --git a/model/ccnx-forwarding-protocol.h b/model/ccnx-forwarding-strategy.h
similarity index 92%
rename from model/ccnx-forwarding-protocol.h
rename to model/ccnx-forwarding-strategy.h
index 072c7f9..6a76531 100644
--- a/model/ccnx-forwarding-protocol.h
+++ b/model/ccnx-forwarding-strategy.h
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2009 University of Washington
  *
@@ -15,8 +15,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#ifndef CCNX_FORWARDING_PROTOCOL_H
-#define CCNX_FORWARDING_PROTOCOL_H
+#ifndef CCNX_FORWARDING_STRATEGY_H
+#define CCNX_FORWARDING_STRATEGY_H
 
 #include "ns3/packet.h"
 #include "ns3/callback.h"
@@ -33,7 +33,7 @@
 
 /**
  * \ingroup internet 
- * \defgroup ccnxForwarding CcnxForwardingProtocol 
+ * \defgroup ccnxForwarding CcnxForwardingStrategy 
  */
 /**
  * \ingroup ccnxForwarding
@@ -45,7 +45,7 @@
  * Also defines the signatures of four callbacks used in RouteInput().
  *
  */
-class CcnxForwardingProtocol : public Object
+class CcnxForwardingStrategy : public Object
 {
 public:
   static TypeId GetTypeId (void);
@@ -75,7 +75,7 @@
    * \brief Route an input packet (to be forwarded or locally delivered)
    *
    * This lookup is used in the forwarding process.  The packet is
-   * handed over to the CcnxForwardingProtocol, and will get forwarded onward
+   * handed over to the CcnxForwardingStrategy, and will get forwarded onward
    * by one of the callbacks.  The Linux equivalent is ip_route_input().
    * There are four valid outcomes, and a matching callbacks to handle each.
    *
@@ -84,7 +84,7 @@
    * \param iface Pointer to ingress face
    * \param ucb Callback for the case in which the packet is to be forwarded
    * \param ecb Callback to call if there is an error in forwarding
-   * \returns true if the CcnxForwardingProtocol takes responsibility for 
+   * \returns true if the CcnxForwardingStrategy takes responsibility for 
    *          forwarding or delivering the packet, false otherwise
    */ 
   virtual bool RouteInput  (Ptr<Packet> p, Ptr<CcnxFace> iface, 
@@ -131,7 +131,7 @@
   /**
    * \param ccnx the ccnx object this forwarding protocol is being associated with
    * 
-   * Typically, invoked directly or indirectly from ns3::Ccnx::SetForwardingProtocol
+   * Typically, invoked directly or indirectly from ns3::Ccnx::SetForwardingStrategy
    */
   virtual void SetCcnx (Ptr<Ccnx> ccnx);
 
@@ -143,4 +143,4 @@
 
 } //namespace ns3
 
-#endif /* CCNX_FORWARDING_PROTOCOL_H */
+#endif /* CCNX_FORWARDING_STRATEGY_H */
diff --git a/model/ccnx-interest-header.cc b/model/ccnx-interest-header.cc
index 6b322e2..627946c 100644
--- a/model/ccnx-interest-header.cc
+++ b/model/ccnx-interest-header.cc
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
@@ -105,9 +105,9 @@
 }
 
 void
-CcnxInterestHeader::EnableChildSelector ()
+CcnxInterestHeader::SetChildSelector (bool value)
 {
-  m_childSelector = true;
+  m_childSelector = value;
 }
 
 bool
@@ -117,9 +117,9 @@
 }
 
 void
-CcnxInterestHeader::EnableAnswerOriginKind ()
+CcnxInterestHeader::SetAnswerOriginKind (bool value)
 {
-  m_answerOriginKind = true;
+  m_answerOriginKind = value;
 }
 
 bool
@@ -141,12 +141,12 @@
 }
 
 void
-CcnxInterestHeader::SetInterestLifetime (intmax_t lifetime)
+CcnxInterestHeader::SetInterestLifetime (Time lifetime)
 {
   m_interestLifetime = lifetime;
 }
 
-intmax_t
+Time
 CcnxInterestHeader::GetInterestLifetime () const
 {
   return m_interestLifetime;
diff --git a/model/ccnx-interest-header.h b/model/ccnx-interest-header.h
index 259e156..44ffa6b 100644
--- a/model/ccnx-interest-header.h
+++ b/model/ccnx-interest-header.h
@@ -1,4 +1,4 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
@@ -24,6 +24,7 @@
 
 #include "ns3/integer.h"
 #include "ns3/header.h"
+#include "ns3/nstime.h"
 
 #include <string>
 #include <vector>
@@ -121,10 +122,10 @@
    - ChildSelector, AnswerOriginKind: 0 - false, 1 - true, -1 not set
    - Publisher* elements are not supported
    - Exclude: only simple name matching is supported (Bloom support has been deprecated in CCNx)
-   - InterestLifetime: not used if negative
+   - InterestLifetime: ?
    - Nonce: 32 bit random integer.  If value is 0, will not be serialized
  */
-class CcnxInterestHeader : public Header
+  class CcnxInterestHeader : public Header
 {
 public:
   /**
@@ -169,13 +170,13 @@
   GetExclude () const;
 
   void
-  EnableChildSelector ();
+  SetChildSelector (bool value);
 
   bool
   IsEnabledChildSelector () const;
 
   void
-  EnableAnswerOriginKind ();
+  SetAnswerOriginKind (bool value);
 
   bool
   IsEnabledAnswerOriginKind () const;
@@ -187,9 +188,9 @@
   GetScope () const;
 
   void
-  SetInterestLifetime (intmax_t lifetime);
+  SetInterestLifetime (Time time);
 
-  intmax_t
+  Time
   GetInterestLifetime () const;
 
   void
@@ -215,7 +216,7 @@
   bool m_childSelector;    
   bool m_answerOriginKind; 
   int8_t m_scope;            ///< -1 not set, 0 local scope, 1 this host, 2 immediate neighborhood
-  intmax_t m_interestLifetime; ///< InterestLifetime in 2^{-12} (0.000244140625 sec). not used if negative
+  Time  m_interestLifetime;
   uint32_t m_nonce; ///< Nonce. not used if zero
 };
 
diff --git a/model/ccnx-l3-protocol.cc b/model/ccnx-l3-protocol.cc
index b906a4c..2ea1414 100644
--- a/model/ccnx-l3-protocol.cc
+++ b/model/ccnx-l3-protocol.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 //
 // Copyright (c) 2006 Georgia Tech Research Corporation
 //
@@ -30,9 +30,14 @@
 #include "ns3/object-vector.h"
 #include "ns3/boolean.h"
 
+#include "ns3/ccnx-header-helper.h"
+
 #include "ccnx-face.h"
 #include "ccnx-route.h"
-#include "ccnx-forwarding-protocol.h"
+#include "ccnx-forwarding-strategy.h"
+#include "ccnx-interest-header.h"
+#include "ccnx-content-object-header.h"
+
 
 NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol");
 
@@ -103,17 +108,17 @@
 }
 
 void
-CcnxL3Protocol::SetForwardingProtocol (Ptr<CcnxForwardingProtocol> forwardingProtocol)
+CcnxL3Protocol::SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy)
 {
   NS_LOG_FUNCTION (this);
-  m_forwardingProtocol = forwardingProtocol;
-  m_forwardingProtocol->SetCcnx (this);
+  m_forwardingStrategy = forwardingStrategy;
+  m_forwardingStrategy->SetCcnx (this);
 }
 
-Ptr<CcnxForwardingProtocol>
-CcnxL3Protocol::GetForwardingProtocol (void) const
+Ptr<CcnxForwardingStrategy>
+CcnxL3Protocol::GetForwardingStrategy (void) const
 {
-  return m_forwardingProtocol;
+  return m_forwardingStrategy;
 }
 
 void 
@@ -127,7 +132,7 @@
     }
   m_faces.clear ();
   m_node = 0;
-  // m_forwardingProtocol = 0;
+  // m_forwardingStrategy = 0;
   Object::DoDispose ();
 }
 
@@ -196,30 +201,59 @@
   Ptr<CcnxFace> ccnxFace = GetFaceForDevice (device);
 
   Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
-  ReceiveAndProcess (ccnxFace, packet);
+  try
+    {
+      Ptr<Header> header = CcnxHeaderHelper::CreateCorrectCcnxHeader (p);
+      ReceiveAndProcess (ccnxFace, header, packet);  // header should serve as overloaded method selector... not sure whether it works with this "smart" pointers...
+    }
+  catch (CcnxUnknownHeaderException)
+    {
+      NS_ASSERT_MSG (false, "Unknown CCNx header. Should not happen");
+    }
 }
 
-// Callback from higher level
-void CcnxL3Protocol::ReceiveAndProcess (Ptr<CcnxFace> incomingFace, Ptr<Packet> packet)
+// Processing Interests
+void CcnxL3Protocol::ReceiveAndProcess (Ptr<CcnxFace> incomingFace, Ptr<CcnxInterestHeader> header, Ptr<Packet> packet)
 {
-  if ( incomingFace->IsUp ())
+  if (incomingFace->IsUp ())
     {
       NS_LOG_LOGIC ("Dropping received packet -- interface is down");
       m_dropTrace (packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ccnx> (), incomingFace);
       return;
     }
-  
-  m_rxTrace (packet, m_node->GetObject<Ccnx> (), incomingFace);
 
-  NS_ASSERT_MSG (m_forwardingProtocol != 0, "Need a forwarding protocol object to process packets");
-  if (!m_forwardingProtocol->RouteInput (packet, incomingFace,
-                                      MakeCallback (&CcnxL3Protocol::Send, this),
-                                      MakeCallback (&CcnxL3Protocol::RouteInputError, this)
-                                      ))
+  NS_LOG_LOGIC ("Receiving interest from " << incomingFace);
+  // m_rxTrace (packet, m_node->GetObject<Ccnx> (), incomingFace);
+
+  // NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
+  // if (!m_forwardingStrategy->RouteInput (packet, incomingFace,
+  //                                     MakeCallback (&CcnxL3Protocol::Send, this),
+  //                                     MakeCallback (&CcnxL3Protocol::RouteInputError, this)
+  //                                     ))
+  //   {
+  //     NS_LOG_WARN ("No route found for forwarding packet.  Drop.");
+  //     m_dropTrace (packet, DROP_NO_ROUTE, m_node->GetObject<Ccnx> (), incomingFace);
+  //   }
+}
+
+// Processing ContentObjects
+void CcnxL3Protocol::ReceiveAndProcess (Ptr<CcnxFace> incomingFace, Ptr<CcnxContentObjectHeader> header, Ptr<Packet> packet)
+{
+  if (incomingFace->IsUp ())
     {
-      NS_LOG_WARN ("No route found for forwarding packet.  Drop.");
-      m_dropTrace (packet, DROP_NO_ROUTE, m_node->GetObject<Ccnx> (), incomingFace);
+      NS_LOG_LOGIC ("Dropping received packet -- interface is down");
+      m_dropTrace (packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ccnx> (), incomingFace);
+      return;
     }
+
+  NS_LOG_LOGIC ("Receiving contentObject from " << incomingFace);
+}
+
+// fake method
+void
+CcnxL3Protocol::ReceiveAndProcess (Ptr<CcnxFace> face, Ptr<Header> header, Ptr<Packet> p)
+{
+  NS_ASSERT_MSG (false, "This function should never be called");
 }
 
 
@@ -286,9 +320,9 @@
   Ptr<CcnxFace> interface = GetFace (i);
   interface->SetUp ();
 
-  if (m_forwardingProtocol != 0)
+  if (m_forwardingStrategy != 0)
     {
-      m_forwardingProtocol->NotifyInterfaceUp (i);
+      m_forwardingStrategy->NotifyInterfaceUp (i);
     }
 }
 
@@ -299,9 +333,9 @@
   Ptr<CcnxFace> interface = GetFace (ifaceIndex);
   interface->SetDown ();
 
-  if (m_forwardingProtocol != 0)
+  if (m_forwardingStrategy != 0)
     {
-      m_forwardingProtocol->NotifyInterfaceDown (ifaceIndex);
+      m_forwardingStrategy->NotifyInterfaceDown (ifaceIndex);
     }
 }
 
diff --git a/model/ccnx-l3-protocol.h b/model/ccnx-l3-protocol.h
index 3af0c9a..32425c4 100644
--- a/model/ccnx-l3-protocol.h
+++ b/model/ccnx-l3-protocol.h
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 //
 // Copyright (c) 2006 Georgia Tech Research Corporation
 //
@@ -37,8 +37,11 @@
 class Node;
 class CcnxFace;
 class CcnxRoute;
-class CcnxForwardingProtocol;
-
+class CcnxForwardingStrategy;
+class Header;
+class CcnxInterestHeader;
+class CcnxContentObjectHeader;
+  
 /**
  * \brief Implement the Ccnx layer.
  * 
@@ -82,8 +85,8 @@
 
   // functions defined in base class Ccnx
   
-  void SetForwardingProtocol (Ptr<CcnxForwardingProtocol> forwardingProtocol);
-  Ptr<CcnxForwardingProtocol> GetForwardingProtocol (void) const;
+  void SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy);
+  Ptr<CcnxForwardingStrategy> GetForwardingStrategy (void) const;
 
   /**
    * Lower layer calls this method after calling L3Demux::Lookup
@@ -102,8 +105,20 @@
 
   /**
    * Actual processing of incoming CCNx packets. Also processing packets coming from local apps
+   * 
+   * Processing Interest packets
    */
-  void ReceiveAndProcess (Ptr<CcnxFace> face, Ptr<Packet> p);
+  virtual void
+  ReceiveAndProcess (Ptr<CcnxFace> face, Ptr<CcnxInterestHeader> header, Ptr<Packet> p);
+
+  
+  /**
+   * Actual processing of incoming CCNx packets. Also processing packets coming from local apps
+   * 
+   * Processing ContentObject packets
+   */
+  virtual void
+  ReceiveAndProcess (Ptr<CcnxFace> face, Ptr<CcnxContentObjectHeader> header, Ptr<Packet> p);
   
   /**
    * \param packet packet to send
@@ -146,12 +161,18 @@
   void RouteInputError (Ptr<Packet> p);
                         //, Socket::SocketErrno sockErrno);
 
+  /**
+   * false function. should never be called. Just to trick C++ to compile
+   */
+  virtual void
+  ReceiveAndProcess (Ptr<CcnxFace> face, Ptr<Header> header, Ptr<Packet> p);
+
 private:
   typedef std::vector<Ptr<CcnxFace> > CcnxFaceList;
   CcnxFaceList m_faces;
 
   Ptr<Node> m_node;
-  Ptr<CcnxForwardingProtocol> m_forwardingProtocol;
+  Ptr<CcnxForwardingStrategy> m_forwardingStrategy;
 
   TracedCallback<Ptr<const Packet>, Ptr<const CcnxFace> > m_sendOutgoingTrace;
   TracedCallback<Ptr<const Packet>, Ptr<const CcnxFace> > m_unicastForwardTrace;
diff --git a/model/ccnx-local-face.cc b/model/ccnx-local-face.cc
index d5de90f..4a6fa55 100644
--- a/model/ccnx-local-face.cc
+++ b/model/ccnx-local-face.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2005,2006,2007 INRIA
  *
diff --git a/model/ccnx-local-face.h b/model/ccnx-local-face.h
index 63ea570..118333a 100644
--- a/model/ccnx-local-face.h
+++ b/model/ccnx-local-face.h
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2005,2006,2007 INRIA
  *
diff --git a/model/ccnx-route.cc b/model/ccnx-route.cc
index 987c001..c2033f6 100644
--- a/model/ccnx-route.cc
+++ b/model/ccnx-route.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2009 University of Washington
  *
diff --git a/model/ccnx-route.h b/model/ccnx-route.h
index 4d45023..fcff012 100644
--- a/model/ccnx-route.h
+++ b/model/ccnx-route.h
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2009 University of Washington
  *
diff --git a/model/ccnx.cc b/model/ccnx.cc
index f54d1b0..7716366 100644
--- a/model/ccnx.cc
+++ b/model/ccnx.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2007 INRIA
  *
diff --git a/model/ccnx.h b/model/ccnx.h
index b2cde94..12c45d2 100644
--- a/model/ccnx.h
+++ b/model/ccnx.h
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2007 INRIA
  *
@@ -32,7 +32,7 @@
 class Node;
 class NetDevice;
 class Packet;
-class CcnxForwardingProtocol;
+class CcnxForwardingStrategy;
 
 /**
  * \ingroup internet
@@ -68,18 +68,18 @@
    *
    * This call will replace any forwarding protocol that has been previously 
    * registered.  If you want to add multiple forwarding protocols, you must
-   * add them to a CcnxListForwardingProtocol directly.
+   * add them to a CcnxListForwardingStrategy directly.
    * 
-   * \param forwardingProtocol smart pointer to CcnxForwardingProtocol object
+   * \param forwardingStrategy smart pointer to CcnxForwardingStrategy object
    */
-  virtual void SetForwardingProtocol (Ptr<CcnxForwardingProtocol> forwardingProtocol) = 0;
+  virtual void SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
 
   /**
    * \brief Get the forwarding protocol to be used by this Ccnx stack
    * 
-   * \returns smart pointer to CcnxForwardingProtocol object, or null pointer if none
+   * \returns smart pointer to CcnxForwardingStrategy object, or null pointer if none
    */
-  virtual Ptr<CcnxForwardingProtocol> GetForwardingProtocol (void) const = 0;
+  virtual Ptr<CcnxForwardingStrategy> GetForwardingStrategy (void) const = 0;
 
   /**
    * \param device device to add to the list of Ccnx interfaces
diff --git a/model/name-components.cc b/model/name-components.cc
index c0e9ea0..55e57c4 100644
--- a/model/name-components.cc
+++ b/model/name-components.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/name-components.h b/model/name-components.h
index 6faa38c..8c124f8 100644
--- a/model/name-components.h
+++ b/model/name-components.h
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
@@ -48,6 +48,9 @@
   // Deserialize (Buffer::Iterator start);
 
   void Print (std::ostream &os) const;
+
+  inline size_t
+  size () const;
   
 private:
   std::list<std::string> m_prefix;
@@ -58,6 +61,13 @@
 
 std::ostream & operator << (std::ostream &os, const Components &components);
 
+size_t
+Components::size () const
+{
+  return m_prefix.size ();
+}
+  
+  
 } // Namespace Name
 } // namespace ns3
 
diff --git a/model/ndn_contentstore.cc b/model/ndn_contentstore.cc
deleted file mode 100644
index 61d6452..0000000
--- a/model/ndn_contentstore.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "ndn_contentstore.h"
-
-namespace ns3
-{
-namespace NDNabstraction
-{
-    
-ContentStore::ContentStore( int maxSize )
-: m_maxSize(maxSize) { }
-
-
-ContentStore::~ContentStore( ) 
-{ }
-
-//Find corresponding CS entry for the given content name
-CsEntry* 
-ContentStore::Lookup(const char *prefix )
-{
-	CriticalSection section(m_csMutex);
-    
-    struct CsEntry *result = NULL;
-    
-    HASH_FIND_STR (m_contentStore, prefix, result);
-    
-    if(result != NULL)
-        Promote (*result);
-    
-	return result;
-}
-
-
-
-//Add entry to content store, if content store is full, use LRU replacement
-void 
-ContentStore::Add( const char *contentName, int contentSize )
-{
-    CriticalSection section(m_csMutex);
-    
-    // removing the old record
-    struct CsEntry *tmp = NULL;
-    HASH_FIND_STR (m_contentStore, contentName, tmp);
-    HASH_DELETE (hh, m_contentStore,tmp);
-    //free(tmp);
-    
-    int size = (int)HASH_COUNT(m_contentStore);
-    
-	if(size == m_maxSize )
-	{
-		CsEntry *entry = m_LRU.back();
-        HASH_DELETE (hh, m_contentStore,entry);//_cs.erase( entry->contentName );
-		m_LRU.pop_back( );
-	}
-    
-	struct CsEntry *ce = (struct CsEntry*)malloc(sizeof(struct CsEntry));
-	ce->contentName = (char*)contentName;
-	ce->contentSize = contentSize;
-    
-	//_cs[ contentName ] = ce;
-    HASH_ADD_KEYPTR (hh, m_contentStore, ce->contentName, strlen(ce->contentName), ce);
-    
-	//CsEntry *ce_in_hash = &(_cs[ contentName ]);
-    struct CsEntry *ce_in_hash = NULL;
-    HASH_FIND_STR (m_contentStore, contentName, ce_in_hash);
-	m_LRU.push_front( ce_in_hash );
-	ce_in_hash->lruPosition = m_LRU.begin( );
-}
-
-
-//move the given CS entry to the head of the list
-void 
-ContentStore::Promote(CsEntry &ce )
-{
-	// should not lock mutex. Otherwise deadlocks will be welcome
-	if( m_LRU.front() == &ce ) return;
-    
-	//assert( *(ce.lruPosition)==&ce ); // should point to the same object
-    
-	// swaping positions in _lru
-	m_LRU.erase( ce.lruPosition );
-	m_LRU.push_front( &ce );
-	ce.lruPosition = m_LRU.begin( );
-    
-	//assert( *(ce.lruPosition)==&ce ); // should point to the same object
-}
-
-void 
-ContentStore::Dump()
-{
-	CriticalSection section(m_csMutex);
-    
-    struct CsEntry *s, *tmp;
-    
-    HASH_ITER(hh, m_contentStore, s, tmp) 
-    {
-        printf("-%s-", s->contentName);
-        /* ... it is safe to delete and free s here */
-    }
-    
-    printf("\n");
-    
-}
-}
-}
diff --git a/model/ndn_contentstore.h b/model/ndn_contentstore.h
deleted file mode 100644
index 7e49fb6..0000000
--- a/model/ndn_contentstore.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#ifndef ndn_contentstore_h
-#define	ndn_contentstore_h
-
-#include <ns3/system-mutex.h>
-#include <list>
-#include <string>
-#include "uthash.h"
-
-using namespace std;
-
-//size of content store
-#define NDN_CONTENT_STORE_SIZE 100
-
-namespace  ns3
-{
-namespace NDNabstraction
-{
-    
-class CsEntry;
-typedef list<CsEntry*>::iterator CsLruIterator;
-    
-//structure for CS entry
-struct CsEntry
-{
-    char *contentName;
-    int contentSize;
-    
-	CsLruIterator lruPosition;
-    UT_hash_handle hh;         /* makes this structure hashable */
-};
-
-
-class ContentStore
-{
-public:
-	ContentStore( int max_size=NDN_CONTENT_STORE_SIZE );
-	virtual ~ContentStore( );
-    
-	// Find corresponding CS entry for the given content name
-	CsEntry* Lookup( const char *prefix );
-	//bool isValid( const CsIterator &it ) { return it!=_cs.end(); }
-	
-	// Add new content to the content store. Old content will be replaced
-	void Add( const char *contentName, int contentSize );
-    
-	// Dump content store entries
-	void Dump( );
-    
-protected:
-	//move the given CS entry to the head of the list
-	void Promote( CsEntry &entry );
-    
-private:
-	int                   m_maxSize; // maximum number of entries in cache
-    
-    struct CsEntry  *m_contentStore;     // actual content store
-	list<CsEntry*>			  m_LRU;	// LRU index of the content store
-	SystemMutex				m_csMutex;   // just to make sure we are not
-};
-    
-}
-}
-#endif
diff --git a/model/ndnabstraction-header.cc b/model/ndnabstraction-header.cc
index ccb3cf3..4cbd9f0 100644
--- a/model/ndnabstraction-header.cc
+++ b/model/ndnabstraction-header.cc
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *
diff --git a/model/ndnabstraction-header.h b/model/ndnabstraction-header.h
index cd172c7..2bc30ec 100644
--- a/model/ndnabstraction-header.h
+++ b/model/ndnabstraction-header.h
@@ -1,4 +1,4 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /*
  * Copyright (c) 2011 University of California, Los Angeles
  *