diff --git a/utils/ndn-pit-queue.cc b/utils/ndn-pit-queue.cc
new file mode 100644
index 0000000..c051be8
--- /dev/null
+++ b/utils/ndn-pit-queue.cc
@@ -0,0 +1,160 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012 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 "ndn-pit-queue.h"
+
+#include "ns3/ndn-face.h"
+#include "ns3/ndn-pit-entry.h"
+
+#include "ns3/assert.h"
+
+using namespace std;
+
+namespace ns3 {
+namespace ndn {
+
+PitQueue::Entry::Entry (Ptr<Face> inFace, Ptr<pit::Entry> pitEntry, double virtualTime)
+  : m_inFace (inFace)
+  , m_pitEntry (pitEntry)
+  , m_virtualTime (virtualTime)
+{
+}
+
+bool
+PitQueue::Entry::operator < (const Entry &otherEntry) const
+{
+  return this->m_virtualTime < otherEntry.m_virtualTime;
+}
+
+
+bool
+PitQueue::Enqueue (Ptr<Face> inFace,
+		   Ptr<pit::Entry> pitEntry)
+{
+  return false;
+}
+
+Ptr<pit::Entry>
+PitQueue::Pop ()
+{
+  if (m_queue.size () == 0)
+    return 0;
+
+  PendingInterestsQueue::iterator topEntryIterator = m_queue.begin ();
+  Entry entry = *topEntryIterator; // copy entry
+  m_queue.erase (topEntryIterator); // remove entry
+
+  DecreasePerFaceCount (entry.m_inFace);
+  
+  if (m_queue.size () == 0)
+    m_lastProcessedVirtualTime = 0;
+  else
+    m_lastProcessedVirtualTime = entry.m_virtualTime;
+
+
+  return entry.m_pitEntry;
+}
+
+void
+PitQueue::DecreasePerFaceCount (Ptr<Face> inFace)
+{
+  PerInFaceMapOfNumberOfIncomingInterests::iterator numberOfEnqueued = m_numberEnqueuedInterests.find (inFace);
+  NS_ASSERT_MSG (numberOfEnqueued != m_numberEnqueuedInterests.end () &&
+		 numberOfEnqueued->second > 0,
+		 "Logic error");
+  
+  numberOfEnqueued->second --;
+  if (numberOfEnqueued->second == 0)
+    {
+      m_numberEnqueuedInterests.erase (numberOfEnqueued);
+      m_lastVirtualTime.erase (inFace);
+    }
+}
+
+void
+PitQueue::Remove (Ptr<Face> face)
+{
+  m_numberEnqueuedInterests.erase (face);
+  m_lastVirtualTime.erase (face);
+
+  for (PendingInterestsQueue::iterator item = m_queue.begin ();
+       item != m_queue.end ();
+       /* manual iterator advancement */)
+    {
+      if (item->m_inFace == face)
+	{
+	  PendingInterestsQueue::iterator toRemove = item;
+	  item ++;
+	  m_queue.erase (toRemove); // hopefully a safe operation
+	}
+      else
+	item ++;
+    }
+}
+
+void
+PitQueue::Remove (Ptr<pit::Entry> entry)
+{
+  for (PendingInterestsQueue::iterator item = m_queue.begin ();
+       item != m_queue.end ();
+       /* manual iterator advancement */)
+    {
+      // compare addresses
+      if (&(*entry) == &(**item))
+	{
+	  PendingInterestsQueue::iterator toRemove = item;
+	  item ++;
+
+	  DecreasePerFaceCount (toRemove->m_inFace);
+	  UpdateLastVirtTime (toRemove->m_inFace);
+	  
+	  m_queue.erase (toRemove); // hopefully a safe operation
+	  break; // there should be at most one item for one pit entry
+	}
+      else
+	item ++;
+    }  
+}
+
+void
+PitQueue::UpdateLastVirtTime (Ptr<Face> inFace)
+{
+  PerInFaceMapOfNumberOfIncomingInterests::iterator numberOfEnqueued = m_numberEnqueuedInterests.find (inFace);
+  if (numberOfEnqueued->second == 0)
+    return;
+
+  double lastTime = 0;
+  for (PendingInterestsQueue::iterator item = m_queue.begin ();
+       item != m_queue.end ();
+       item ++)
+    {
+      if (inFace == item->m_inFace)
+	{
+	  if (lastTime < item->m_virtualTime)
+	    lastTime = item->m_virtualTime;
+	}
+    }
+
+  m_lastVirtualTime [inFace] = lastTime; 
+}
+
+
+} // namespace ndn
+} // namespace ns3
