ndnSIM-v2: Removing old and legacy code
diff --git a/PyNDN/Data.py b/PyNDN/Data.py
deleted file mode 100644
index 5369380..0000000
--- a/PyNDN/Data.py
+++ /dev/null
@@ -1,131 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import ns.ndnSIM
-from Name import Name
-from SignedInfo import SignedInfo
-
-class DataError (Exception):
- pass
-
-class Data (object):
- _data = None
-
- def __init__(self,
- name = None, content = None, signed_info = None,
- data = None):
- if data:
- if isinstance (data, Data):
- self._data = data._data
- elif isinstance (data, ns.ndnSIM.ndn.Data):
- self._data = data
- else:
- raise TypeError ("Invalid type supplied for 'data' parameter [%s]" % type (data))
-
- self.signedInfo = SignedInfo ()
- # timestamp
- self.signedInfo.freshnessSeconds = self._data.GetFreshness ().ToDouble (ns.core.Time.S)
- if self._data.GetKeyLocator ():
- self.signedInfo.keyLocator = Name (name = self._data.GetKeyLocator ())
- else:
- self._data = ns.ndnSIM.ndn.Data ()
-
- self.name = name
- self.content = content
- self.signedInfo = signed_info or SignedInfo ()
-
- @staticmethod
- def fromWire (wire):
- return Data (data = ns.ndnSIM.ndn.Wire.ToDataStr (bytes (wire)))
-
- def sign (self, key):
- """There is no actual signing in ndnSIM for now, but we will assign signature bits based on key"""
- self._data.SetSignature (key.fakeKey)
-
- def toWire (self):
- if self._data.GetSignature () == 0:
- raise DataError ("Data packet has not been signed, cannot create wire format")
-
- return ns.ndnSIM.ndn.Wire.FromDataStr (self._data)
-
- def verify_signature (self, key):
- """There is no actual signing in ndnSIM for now, but we will check if signature matches the key"""
- return True
- # return self._data.GetSignature () == key.fakeKey
-
- def __getattr__ (self, name):
- if name == "_data":
- return object.__getattr__ (self, name)
-
- elif name == "signedInfo":
- return object.__getattr__ (self, name)
- elif name == "name":
- return Name (self._data.GetName ())
- elif name == "scope":
- return self._data.GetScope ()
- elif name == "interestLifetime":
- return self._data.GetInterestLifetime ().ToDouble (ns.core.Time.S)
- elif name == "content":
- pkt = self._data.GetPayload ()
- return ns.ndnSIM.ndn.PacketToBuffer (pkt)
- else:
- return self._data.__getattribute__ (name)
-
- def __setattr__(self, name, value):
- if name == "_data":
- return object.__setattr__ (self, name, value)
-
- elif name == 'signedInfo':
- if value is None:
- return
- if isinstance (value, SignedInfo):
- object.__setattr__ (self, name, value)
-
- if value.timestamp:
- # ?
- pass
- if value.freshnessSeconds:
- self._data.SetFreshness (ns.core.Seconds (value.freshnessSeconds))
- if value.keyLocator:
- self._data.SetKeyLocator (value._name)
- else:
- raise TypeError ("signedInfo can be assigned either None or SignedInfo object, [%s] supplied" % type (value))
- elif name == "name":
- if value is None:
- return self._data.SetName (ns.ndnSIM.ndn.Name ())
- elif isinstance (value, Name):
- return self._data.SetName (value._name)
- elif isinstance (value, ns.ndnSIM.ndn.Name):
- return self._data.SetName (value)
- elif isinstance (value, str):
- return self._data.SetName (ns.ndnSIM.ndn.Name (value))
- else:
- raise ValueError ("Invalid name parameter")
- elif name == "content":
- if value is None:
- pkt = ns.network.Packet ()
- self._data.SetPayload (pkt)
- else:
- pkt = ns.ndnSIM.ndn.BufferToPacket (bytes (value))
- self._data.SetPayload (pkt)
- else:
- raise NameError ("Unknown attribute [%s]" % name)
-
- def __repr__(self):
- return "ndn.Data(%s; %s)" % str (self._data, self.signedInfo)
diff --git a/PyNDN/EventLoop.py b/PyNDN/EventLoop.py
deleted file mode 100644
index 93bd8e7..0000000
--- a/PyNDN/EventLoop.py
+++ /dev/null
@@ -1,37 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import ns.core
-
-class EventLoop (object):
- """
- Class to provide compatibility with real PyNDN implementation.
- """
-
- def __init__ (self, *handlers):
- pass
-
- def execute (self, event):
- ns.core.Simulator.ScheduleNow (event)
-
- def run (self):
- pass
-
- def stop (self):
- pass
diff --git a/PyNDN/Face.py b/PyNDN/Face.py
deleted file mode 100644
index 807fee7..0000000
--- a/PyNDN/Face.py
+++ /dev/null
@@ -1,125 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import ns.core
-import ns.network
-import ns.ndnSIM
-from Data import Data
-from Interest import Interest
-from Name import Name
-
-import functools
-import traceback
-
-class Face (object):
- deleteList = []
-
- def __init__(self):
- self.nodeId = ns.core.Simulator.GetContext ()
- self.node = ns.network.NodeList.GetNode (self.nodeId)
- self._face = ns.ndnSIM.ndn.ApiFace (self.node)
- # super(Face, self).__init__ (self.node)
-
- def connect (self):
- pass
-
- def disconnect (self):
- self._face.Shutdown ()
-
- def defer_verification (self, deferVerification = True):
- pass
-
-
- def expressInterest (self, name, onData, onTimeout, template = None):
- """
- onData: void <interest, name>
- onTimeout: void <interest>
- """
-
- interest = Interest (interest = template)
- interest.name = name
-
- converter = ExpressInterestConverter (onData, onTimeout)
- self._face.ExpressInterest (interest._interest, converter.handleOnData, converter.handleOnTimeout)
-
- def setInterestFilter (self, name, onInterest, flags = None):
- """
- onInterest: void <name, interest>
- """
-
- if isinstance (name, Name):
- name = name._name
- elif isinstance (name, ns.ndnSIM.ndn.Name):
- pass
- else:
- raise TypeError ("Wrong type for 'name' parameter [%s]" % type (name))
-
- self._face.SetInterestFilter (name, OnInterestConvert (onInterest))
-
- def clearInterestFilter (self, name):
- if isinstance (name, Name):
- name = name._name
- elif isinstance (name, ns.ndnSIM.ndn.Name):
- pass
- else:
- raise TypeError ("Wrong type for 'name' parameter [%s]" % type (name))
-
- # @bug: memory leak, deleteList need to remove previosly set callback... but how?
- self._face.ClearInterestFilter (name)
-
- def get (self, name, template = None, timeoutms = 3000):
- raise NotImplementedError ("NS-3 simulation cannot have syncrhonous operations")
-
- def put (self, data):
- if isinstance (data, Data):
- self._face.Put (data._data)
- elif isinstance (data, ns.ndnSIM.ndn.Data):
- self._face.Put (data)
- else:
- raise TypeError ("Unsupported type to publish data [%s]" % type (data))
-
-class ExpressInterestConverter:
- def __init__ (self, onData, onTimeout):
- self.onData = onData
- self.onTimeout = onTimeout
-
- def handleOnData (self, interest, data):
- try:
- if self.onData:
- return self.onData (Interest (interest=interest), Data (data = data))
- except Exception, e:
- traceback.print_exc()
-
- def handleOnTimeout (self, interest):
- try:
- if self.onTimeout:
- self.onTimeout (Interest (interest=interest))
- except Exception, e:
- traceback.print_exc()
-
-class OnInterestConvert (object):
- def __init__ (self, onInterest):
- self.onInterest = onInterest
-
- def __call__ (self, name, interest):
- try:
- if self.onInterest:
- self.onInterest (Name (name = name), Interest (interest = interest))
- except Exception, e:
- traceback.print_exc()
diff --git a/PyNDN/Interest.py b/PyNDN/Interest.py
deleted file mode 100644
index d831bb5..0000000
--- a/PyNDN/Interest.py
+++ /dev/null
@@ -1,97 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import ns.ndnSIM
-import ns.core
-from Name import Name
-
-class Interest (object):
- _interest = None
-
- def __init__(self,
- name = None, scope = None, interestLifetime = None,
- interest = None):
- if interest:
- if isinstance (interest, Interest):
- self._interest = interest._interest
- elif isinstance (interest, ns.ndnSIM.ndn.Interest):
- self._interest = interest
- else:
- raise TypeError ("Invalid type supplied for 'interest' parameter [%s]" % type (interest))
- else:
- self._interest = ns.ndnSIM.ndn.Interest ()
-
- self.name = name
- self.scope = scope
- self.interestLifetime = interestLifetime
-
- @staticmethod
- def fromWire (wire):
- return Interest (interest = ns.ndnSIM.ndn.Wire.ToInterestStr (wire))
-
- def toWire (self):
- return ns.ndnSIM.ndn.Wire.FromInterestStr (self._interest)
-
- def __getattr__ (self, name):
- if name == "_interest":
- return object.__getattr__ (self, name)
-
- elif name == "name":
- return Name (self._interest.GetName ())
- elif name == "scope":
- return self._interest.GetScope ()
- elif name == "interestLifetime":
- return self._interest.GetInterestLifetime ().ToDouble (ns.core.Time.S)
- else:
- return self._interest.__getattribute__ (name)
-
- def __setattr__(self, name, value):
- if name == "_interest":
- return object.__setattr__ (self, name, value)
-
- elif name == "name":
- if value is None:
- return self._interest.SetName (ns.ndnSIM.ndn.Name ())
- elif isinstance (value, Name):
- return self._interest.SetName (value._name)
- elif isinstance (value, ns.ndnSIM.ndn.Name):
- return self._interest.SetName (value)
- elif isinstance (value, str):
- return self._interest.SetName (ns.ndnSIM.ndn.Name (value))
- else:
- raise ValueError ("Invalid name parameter")
- elif name == "scope":
- if value is None:
- return self._interest.SetScope (-1)
- elif isinstance (value, int):
- return self._interest.SetScope (value)
- else:
- raise ValueError ("Scope parameter should be int, [%s] supplied" % type (value))
- elif name == "interestLifetime":
- if value is None:
- return self._interest.SetInterestLifetime (ns.core.Time ())
- elif isinstance (value, float) or isinstance (value, int):
- return self._interest.SetInterestLifetime (ns.core.Seconds (value))
- else:
- raise ValueError ("interestLifetime parameter should be fload or int, [%s] supplied" % type (value))
- else:
- raise ValueError ("Unknown or unsupported attribute [%s]" % name)
-
- def __repr__(self):
- return "ndnSIM.Interest(%s)" % str (self._interest)
diff --git a/PyNDN/Key.py b/PyNDN/Key.py
deleted file mode 100644
index 842024b..0000000
--- a/PyNDN/Key.py
+++ /dev/null
@@ -1,83 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import ns.core
-import ns.ndnSIM
-from Name import Name
-
-class Key (object):
- def __init__ (self):
- self.publicKeyID = None # SHA256 hash
- self.fakeKey = 0
-
- def generateRSA(self, numbits):
- randVar = ns.core.UniformVariable ()
- self.fakeKey = randVar.GetInteger (0, 2147483647)
-
- def privateToDER(self):
- return self.fakeKey
-
- def publicToDER(self):
- return self.privateToDER ()
-
- def privateToPEM(self, filename = None, password = None):
- if filename:
- f = open(filename, 'w')
- f.write (self.fakeKey)
- f.close()
- else:
- return self.fakeKey
-
- def publicToPEM(self, filename = None):
- return privateToPEM (filename)
-
- def fromDER(self, private = None, public = None):
- if private:
- self.fakeKey = hash(private)
- elif public:
- self.fakeKey = hash(public)
-
- def fromPEM(self, filename = None, private = None, public = None, password = None):
- if filename:
- f = open(filename, 'r')
- self.fakeKey = hash(f.read ())
- f.close()
- elif private:
- self.fakeKey = hash(private)
- elif public:
- self.fakeKey = hash(public)
-
- @staticmethod
- def createFromDER (private = None, public = None):
- key = Key ()
- key.fromDER (private, public)
- return key
-
- @staticmethod
- def createFromPEM (filename = None, private = None, public = None, password = None):
- key = Key ()
- key.fromPEM (filename, private, public, password)
- return key
-
- @staticmethod
- def getDefaultKey ():
- context = ns.core.Simulator.GetContext ()
- key = Key ()
- key.fakeKey = context
- return key
diff --git a/PyNDN/KeyLocator.py b/PyNDN/KeyLocator.py
deleted file mode 100644
index 331ae63..0000000
--- a/PyNDN/KeyLocator.py
+++ /dev/null
@@ -1,36 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import ns.core
-import ns.ndnSIM
-from Name import Name
-
-class KeyLocator (object):
- def __init__(self, keyName = None):
- self.keyName = keyName
-
- @staticmethod
- def getDefaultKeyLocator():
- context = ns.core.Simulator.GetContext ()
- keyLocator = ns.ndnSIM.ndn.Name ()
- keyLocator.\
- append ("default-key").\
- append (str (context))
-
- return Name (keyLocator)
diff --git a/PyNDN/Name.py b/PyNDN/Name.py
deleted file mode 100644
index 628b843..0000000
--- a/PyNDN/Name.py
+++ /dev/null
@@ -1,95 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import ns.ndnSIM
-
-class Name (object):
- _name = None
-
- def __init__ (self,
- value = None,
- name = None):
- if name is not None:
- if isinstance (name, ns.ndnSIM.ndn.Name):
- self._name = name
- elif isinstance (name, Name):
- self._name = name._name
- else:
- raise TypeError ("Incorrect type for 'name' parameter [%s]" % type (name))
- else:
- if value is not None:
- if isinstance (value, Name):
- self._name = ns.ndnSIM.ndn.Name (value._name)
- else:
- self._name = ns.ndnSIM.ndn.Name (value)
- else:
- self._name = ns.ndnSIM.ndn.Name ()
-
- @staticmethod
- def fromWire (wire):
- return Name (name = ns.ndnSIM.ndn.Wire.ToName (wire))
-
- def toWire (self):
- return ns.ndnSIM.ndn.Wire.FromName (self._name)
-
- def append (self, value):
- if isinstance (value, Name):
- self._name.append (value._name)
- else:
- self._name.append (value)
- return self
-
- def __getattr__ (self, name):
- return self._name.__getattribute__ (name)
-
- def __len__ (self):
- return self._name.size ()
-
- def __add__ (self, other):
- return self._name.append (other)
-
- def __getitem__(self, key):
- if isinstance (key, int):
- if abs(key) < self._name.size ():
- return self._name.get (key)
- else:
- raise IndexError ("index out of range")
- elif isinstance (key, slice):
- name = ns.ndnSIM.ndn.Name ()
- for component in xrange (*key.indices (self.size ())):
- name.append (self._name.get (component))
- return name
- else:
- raise ValueError("Unknown __getitem__ type: %s" % type (key))
-
- def __repr__ (self):
- return "ndn.Name('" + self._name.toUri () + "')"
-
- def __str__ (self):
- return self._name.toUri ()
-
- def __eq__ (self, other):
- return self._name == other._name
-
- def isPrefixOf (self, other):
- return self[:] == other[:len(self)]
-
- @property
- def keyName (self):
- return self
diff --git a/PyNDN/SignedInfo.py b/PyNDN/SignedInfo.py
deleted file mode 100644
index 84941ad..0000000
--- a/PyNDN/SignedInfo.py
+++ /dev/null
@@ -1,56 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import utils
-
-class ContentType(utils.Enum):
- _prefix = "ndn"
-
-CONTENT_DATA = ContentType.new_flag('CONTENT_DATA', 0x0C04C0)
-CONTENT_ENCR = ContentType.new_flag('CONTENT_ENCR', 0x10D091)
-CONTENT_GONE = ContentType.new_flag('CONTENT_GONE', 0x18E344)
-CONTENT_KEY = ContentType.new_flag('CONTENT_KEY', 0x28463F)
-CONTENT_LINK = ContentType.new_flag('CONTENT_LINK', 0x2C834A)
-CONTENT_NACK = ContentType.new_flag('CONTENT_NACK', 0x34008A)
-
-class SignedInfo (object):
- def __init__(self, keyLocator = None, freshness = None,
- timestamp = None, type = CONTENT_DATA, *kw, **kwargs):
-
- self.timestamp = timestamp
- self.freshnessSeconds = freshness
- self.keyLocator = keyLocator
- self.type = type
-
- # all other parameters are silently ignored
-
- def __repr__(self):
- args = []
-
- if self.keyLocator is not None:
- args += ["keyLocator=%r" % self.keyLocator]
- if self.freshnessSeconds is not None:
- args += ["freshness=%r" % self.freshnessSeconds]
- if self.timestamp is not None:
- args += ["timestamp=%r" % self.timestamp]
- if self.type != CONTENT_DATA:
- args += ["type=%r" % self.type]
-
- return "ndn.SignedInfo(%s)" % ", ".join(args)
-
diff --git a/PyNDN/__init__.py b/PyNDN/__init__.py
deleted file mode 100644
index 2054d49..0000000
--- a/PyNDN/__init__.py
+++ /dev/null
@@ -1,46 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-__all__ = ['Face', 'Name', 'Interest', 'Data', 'Key', 'EventLoop']
-
-VERSION = 0.3
-NDNSIM = True
-
-import sys as _sys
-
-try:
- from Face import Face
- from Name import Name
- from Interest import Interest
- from Data import Data
- from Key import Key
-
- from EventLoop import EventLoop
- from KeyLocator import KeyLocator
- from SignedInfo import SignedInfo, CONTENT_DATA, CONTENT_ENCR, CONTENT_GONE, CONTENT_KEY, CONTENT_LINK, CONTENT_NACK
- # no signature
-
- # no NameCrypto
- # no LocalPrefixDiscovery
-
- import nre
-
-except ImportError:
- del _sys.modules[__name__]
- raise
diff --git a/PyNDN/impl/__init__.py b/PyNDN/impl/__init__.py
deleted file mode 100644
index e048223..0000000
--- a/PyNDN/impl/__init__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
diff --git a/PyNDN/impl/ccnb.py b/PyNDN/impl/ccnb.py
deleted file mode 100644
index b95b3fa..0000000
--- a/PyNDN/impl/ccnb.py
+++ /dev/null
@@ -1,129 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-__TT_BITS__ = 3
-__TT_MASK__ = (1 << __TT_BITS__) - 1
-__TT_HBIT__ = (1 << 7)
-__TT_LBIT__ = __TT_HBIT__ - 1
-
-DTAG_NAME = 14
-DTAG_COLLECTION = 17
-DTAG_LINK = 31
-
-def blob(value):
- return _encode(len(value), 5) + value
-
-def dtag(tag, value):
- return _encode(tag, 2) + value + '\x00'
-
-def _encode(value, tt):
- global __TT_BITS__, __TT_HBIT__, __TT_LBIT__
-
- header = (value << __TT_BITS__) | tt
-
- blocks = []
- blocks.append((header & __TT_LBIT__) | __TT_HBIT__)
- header >>= 7
-
- while header != 0:
- blocks.append(header & __TT_LBIT__)
- header >>= 7
-
- blocks.reverse()
-
- return bytearray(blocks)
-
-class CCNBDecoder(object):
- def __init__(self, ccnb_data):
- self.ccnb_data = ccnb_data
- self.reset()
-
- def reset(self):
- self.position = 0
- self.decoded = 0
- self.stack = []
-
- def _process_next_byte(self):
- global __TT_HBIT__, __TT_LBIT__
-
- assert self.position < len(self.ccnb_data)
-
- char = ord(self.ccnb_data[self.position])
- self.position += 1
-
- if self.decoded == 0 and char == 0:
- return None, True
-
- decoded = (self.decoded << 7) | (char & __TT_LBIT__)
- complete = (char & __TT_HBIT__) == __TT_HBIT__
-
- self.decoded = decoded if not complete else 0
-
- return decoded, complete
-
- def print_element(self, tt, value, data = None):
- if tt == 2:
- print "DTAG",
-
- if value == 14:
- print "Name"
- elif value == 15:
- print "Component"
- elif value == 17:
- print "Collection"
- elif value == 31:
- print "Link"
- else:
- print value
-
- elif tt == 5:
- print "BLOB",
- print value,
- print repr(data)
- else:
- print tt,
- print value,
- print repr(data)
-
- def get_tags(self):
- global __TT_MASK__, __TT_BITS__
-
- while self.position < len(self.ccnb_data):
- while True:
- decoded, complete = self._process_next_byte()
- if complete:
- break
-
- if decoded is None:
- tt, value = self.stack.pop()
- print "Close",
- else:
- tt = decoded & __TT_MASK__
- value = decoded >> __TT_BITS__
-
- data = None
- if decoded is not None:
- if tt == 2:
- self.stack.append((tt, value))
- elif tt == 5:
- data = self.ccnb_data[self.position:self.position + value]
- self.position += value
-
- self.print_element(tt, value, data)
-
diff --git a/PyNDN/impl/enumeration.py b/PyNDN/impl/enumeration.py
deleted file mode 100644
index 851e43c..0000000
--- a/PyNDN/impl/enumeration.py
+++ /dev/null
@@ -1,29 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import ndn
-from ndn.impl import ccnb
-
-def ccnb_enumerate(names):
- out = bytearray()
-
- for name in names:
- out += ccnb.dtag(ccnb.DTAG_LINK, name.get_ccnb())
-
- return ccnb.dtag(ccnb.DTAG_COLLECTION, out)
diff --git a/PyNDN/impl/segmenting.py b/PyNDN/impl/segmenting.py
deleted file mode 100644
index d58b200..0000000
--- a/PyNDN/impl/segmenting.py
+++ /dev/null
@@ -1,55 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import math
-import ndn
-
-class Wrapper(object):
- def __init__(self, name, key):
- self.name = name
- self.key = key
-
- kl = ndn.KeyLocator(key)
- self.signed_info = ndn.SignedInfo(key_locator = kl, key_digest = key.publicKeyID)
-
- def __call__(self, chunk, segment, segments):
- name = self.name + ndn.Name.num2seg(segment)
- self.signed_info.finalBlockID = ndn.Name.num2seg(segments - 1)
-
- co = ndn.Data(name = name, content = chunk, signed_info = self.signed_info)
- co.sign(self.key)
-
- return co
-
-def segmenter(data, wrapper = None, chunk_size = 4096):
- segment = 0
- segments = math.ceil(len(data) / float(chunk_size))
-
- while segment < segments:
- start = segment * chunk_size
- end = min(start + chunk_size, len(data))
- chunk = data[start : end]
-
- if wrapper is not None:
- chunk = wrapper(chunk, segment, segments)
-
- yield chunk
-
- segment += 1
-
diff --git a/PyNDN/nre.py b/PyNDN/nre.py
deleted file mode 100644
index df05e30..0000000
--- a/PyNDN/nre.py
+++ /dev/null
@@ -1,631 +0,0 @@
-# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-#
-# Copyright (c) 2013, Regents of the University of California
-# Yingdi Yu, Alexander Afanasyev
-#
-# BSD license, See the doc/LICENSE file for more information
-#
-# Author: Yingdi Yu <yingdi@cs.ucla.edu>
-# Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-import sys
-import re
-import logging
-from Name import Name
-
-_LOG = logging.getLogger ("ndn.nre")
-
-class RegexError(Exception):
- def __init__(self, msg):
- self.msg = msg
- def __str__(self):
- return self.msg
-
-class BaseMatcher(object):
- def __init__(self, expr, backRef, exact=True):
- _LOG.debug(self.__class__.__name__ + ".Constructor")
- self.expr = expr
- self.backRef = backRef
- self.exact = exact
- self.matchResult = []
- self.matcherList = []
-
- def match(self, name, offset, len):
- _LOG.debug(self.__class__.__name__ + ".match(): " + "expr: " + self.expr + " offset: " + str(offset) + " length: " + str(len))
- self.matchResult = []
-
- if self._recursiveMatch(0, name, offset, len):
- for i in range(offset, offset + len):
- self.matchResult.append(str (name[i]))
- return True
- else:
- return False
-
- def _recursiveMatch(self, mId, name, offset, length):
- _LOG.debug(self.__class__.__name__ + "._recursiveMatch(): " + self.expr)
- _LOG.debug("mId: " + str(mId) + " name: " + str(name) + " offset: " + str(offset) + " length: " + str(length) + " matcherListSize: " + str(len(self.matcherList)))
- tried = 0
-
- if mId >= len(self.matcherList) :
- if length != 0 :
- _LOG.debug("Fail " + self.__class__.__name__ + "._recursiveMatch(): no more matcher, but more components")
- return False
- else:
- _LOG.debug("Succeed " + self.__class__.__name__ + "._recursiveMatch(): no more matcher, no more components")
- return True
-
- matcher = self.matcherList[mId]
-
- while tried <= length:
- if matcher.match(name, offset, tried) and self._recursiveMatch(mId + 1, name, offset + tried, length - tried) :
- return True
- _LOG.debug(self.__class__.__name__ + " expr: " + self.expr + " mId: " + str(mId) + " tried: " + str(tried) + " length: " + str(length))
- tried += 1
-
- return False
-
-
- def aggressiveMatch(self, name, offset, len):
- _LOG.debug(self.__class__.__name__ + ".aggressiveMatch(): " + "expr: " + self.expr + " offset: " + str(offset) + " length: " + str(len))
- self.matchResult = []
-
- if self._aRecursiveMatch(0, name, offset, len):
- for i in range(offset, offset + len):
- self.matchResult.append(str (name[i]))
- return True
- else:
- return False
-
- def _aRecursiveMatch(self, mId, name, offset, length):
- _LOG.debug(self.__class__.__name__ + "._aRecursiveMatch(): " + self.expr)
- _LOG.debug("mId: " + str(mId) + " name: " + str(name) + " offset: " + str(offset) + " length: " + str(length) + " matcherListSize: " + str(len(self.matcherList)))
-
- tried = length
-
- if mId >= len(self.matcherList) :
- if length != 0 :
- _LOG.debug("Fail " + self.__class__.__name__ + "._recursiveMatch(): no more matcher, but more components")
- return False
- else:
- _LOG.debug("Succeed " + self.__class__.__name__ + "._recursiveMatch(): no more matcher, no more components")
- return True
-
- matcher = self.matcherList[mId]
-
- while tried >= 0:
- if matcher.aggressiveMatch(name, offset, tried) and self._aRecursiveMatch(mId + 1, name, offset + tried, length - tried):
- return True
- _LOG.debug(self.__class__.__name__ + " expr: " + self.expr + " mId: " + str(mId) + " tried: " + str(tried) + " length: " + str(length))
- tried -= 1
-
- return False
-
-
-class ComponentMatcher(BaseMatcher):
- def __init__(self, expr, backRef, exact=True):
- _LOG.debug(self.__class__.__name__ + ".Constructor")
- _LOG.debug("expr " + expr)
-
- super(ComponentMatcher, self).__init__(expr, backRef, exact)
-
- pattern = re.compile(self.expr)
- self.pseudoBackRefMatcher = []
- for i in range(0, pattern.groups):
- pseudoMatcher = BaseMatcher("", self.backRef)
- self.pseudoBackRefMatcher.append(pseudoMatcher)
- self.backRef.append(pseudoMatcher)
-
- def _appendBackRef(self, res):
- if res and 0 < len(res.groups()):
-
- group = res.groups()
- for i in range(0, len(group)):
- self.pseudoBackRefMatcher[i].matchResult = []
- self.pseudoBackRefMatcher[i].matchResult.append(group[i])
-
- def match(self, name, offset, len):
- _LOG.debug(self.__class__.__name__ + ".match(): " + self.expr)
- _LOG.debug("Name " + str(name) + " offset " + str(offset) + " len " +str(len))
-
- self.matchResult = []
-
- if "" == self.expr:
- res = self.matchResult.append(str (name[offset]))
- self._appendBackRef(res)
- _LOG.debug("Succeed " + self.__class__.__name__ + ".match() ")
- return True
-
- matcher = re.compile(self.expr)
- if self.exact:
- res = matcher.match(str(name[offset]))
- if res:
- self._appendBackRef(res)
- self.matchResult.append(str (name[offset]))
- _LOG.debug("Succeed " + self.__class__.__name__ + ".match() ")
- return True
- else:
- res = matcher.search(str(name[offset]))
- if res:
- self._appendBackRef(res)
- self.matchResult.append(str (name[offset]))
- return True
-
- return False
-
- def aggressiveMatch(self, name, offset, len):
- return self.match(name, offset, len)
-
-
-class ComponentSetMatcher(BaseMatcher):
- def __init__(self, expr, backRef, exact=True):
- _LOG.debug(self.__class__.__name__ + ".Constructor")
-
- errMsg = "Error: ComponentSetMatcher.Constructor: "
- self.include = True
-
- super(ComponentSetMatcher, self).__init__(expr, backRef, exact)
-
- if '<' == self.expr[0]:
- self._compileSingleComponent()
- elif '[' == self.expr[0]:
- lastIndex = len(self.expr) - 1
- if ']' != self.expr[lastIndex]:
- raise RegexError(errMsg + " No matched ']' " + self.expr)
- if '^' == self.expr[1]:
- self.include = False
-
- self._compileMultipleComponents(2, lastIndex)
- else:
- self._compileMultipleComponents(1, lastIndex)
-
-
- def _compileSingleComponent(self):
- _LOG.debug(self.__class__.__name__ + "._compileSingleComponent")
-
- errMsg = "Error: ComponentSetMatcher.CompileSingleComponent(): "
-
- end = self._extractComponent(1)
-
- if len(self.expr) != end:
- raise RegexError(errMsg + "out of bound " + self.expr)
- else:
- self.matcherList.append(ComponentMatcher(self.expr[1:end-1], self.backRef))
-
- def _compileMultipleComponents(self, start, lastIndex):
- _LOG.debug(self.__class__.__name__ + "._compileMultipleComponents")
-
- errMsg = "Error: ComponentSetMatcher.CompileMultipleComponents(): "
-
- index = start
- tmp_index = start
-
- while index < lastIndex:
- if '<' != self.expr[index]:
- raise RegexError(errMsg + "Component expr error " + self.expr)
- tmp_index = index + 1
- index = self._extractComponent(tmp_index)
- self.matcherList.append(ComponentMatcher(self.expr[tmp_index:index-1], self.backRef))
-
- if index != lastIndex:
- raise RegexError(errMsg + "Not sufficient expr to parse " + self.expr)
-
- def _extractComponent(self, index):
- _LOG.debug(self.__class__.__name__ + "._extractComponent")
- lcount = 1
- rcount = 0
-
- while lcount > rcount :
- if len(self.expr) == index:
- break
- elif '<' == self.expr[index]:
- lcount += 1
- elif '>' == self.expr[index]:
- rcount += 1
-
- index += 1
-
- return index
-
- def match(self, name, offset, len):
- _LOG.debug(self.__class__.__name__ + ".match(): " + self.expr)
-
- self.matchResult = []
-
- matched = False
-
- if 1 != len:
- return False
-
- for matcher in self.matcherList:
- res = matcher.match(name, offset, len)
- if True == res:
- matched = True
- break
-
- if(matched if self.include else (not matched)):
- self.matchResult.append(str (name[offset]))
- return True
- else:
- return False
-
- def aggressiveMatch(self, name, offset, len):
- return self.match(name, offset, len)
-
-class BackRefMatcher(BaseMatcher):
- def __init__(self, expr, backRef, exact=True):
- _LOG.debug (self.__class__.__name__ + ".Constructor")
- super(BackRefMatcher, self).__init__(expr, backRef, exact)
-
- errMsg = "Error: BackRefMatcher Constructor: "
-
- _LOG.debug ("expr: " + self.expr);
- _LOG.debug ("backRefManager " + str(self.backRef) + " size: " + str(len(self.backRef)))
-
- lastIndex = len(self.expr) - 1
-
- if '(' == self.expr[0] and ')' == self.expr[lastIndex]:
- self.backRef.append(self)
- self.matcherList.append(PatternListMatcher(self.expr[1:lastIndex], self.backRef, self.exact))
- else:
- raise RegexError(errMsg + " Unrecognoized format " + self.expr)
-
-
-class PatternListMatcher(BaseMatcher):
- def __init__(self, expr, backRef, exact=True):
- _LOG.debug(self.__class__.__name__ + ".Constructor")
- super(PatternListMatcher, self).__init__(expr, backRef, exact)
- _LOG.debug("expr: " + self.expr)
-
- exprSize = len(self.expr)
- index = 0
- subHead = index
-
- while index < exprSize:
- subHead = index
- (r_res, r_index) = self._extractPattern(subHead, index)
- index = r_index
- if not r_res:
- raise RegexError("Fail to create PatternListMatcher")
-
-
- def _extractPattern(self, index, next):
- _LOG.debug(self.__class__.__name__ + "._extractPattern")
-
- errMsg = "Error: PatternListMatcher._extractPattern: "
-
- start = index
- End = index
- indicator = index
-
- _LOG.debug ("expr: " + self.expr + " index: " + str(index))
-
- if '(' == self.expr[index]:
- index += 1
- index = self._extractSubPattern('(', ')', index)
- indicator = index
- end = self._extractRepetition(index)
- if indicator == end:
- self.matcherList.append(BackRefMatcher(self.expr[start:end], self.backRef, self.exact))
- else:
- self.matcherList.append(RepeatMatcher(self.expr[start:end], self.backRef, indicator-start, self.exact))
- elif '<' == self.expr[index]:
- index += 1
- index = self._extractSubPattern('<', '>', index)
- indicator = index
- end = self._extractRepetition(index)
- self.matcherList.append(RepeatMatcher(self.expr[start:end], self.backRef, indicator-start, self.exact))
- _LOG.debug("start: " + str(start) + " end: " + str(end) + " indicator: " + str(indicator))
- elif '[' == self.expr[index]:
- index += 1
- index = self._extractSubPattern('[', ']', index)
- indicator = index
- end = self._extractRepetition(index)
- self.matcherList.append(RepeatMatcher(self.expr[start:end], self.backRef, indicator-start, self.exact))
- _LOG.debug("start: " + str(start) + " end: " + str(end) + " indicator: " + str(indicator))
- else:
- raise RegexError(errMsg +"unexpected syntax")
-
-
-
- return (True, end)
-
- def _extractSubPattern(self, left, right, index):
- _LOG.debug(self.__class__.__name__ + "._extractSubPattern")
-
- lcount = 1
- rcount = 0
-
- while lcount > rcount:
- if index >= len(self.expr):
- raise RegexError("Error: parenthesis mismatch")
- if left == self.expr[index]:
- lcount += 1
- if right == self.expr[index]:
- rcount += 1
- index += 1
-
- return index
-
- def _extractRepetition(self, index):
- _LOG.debug(self.__class__.__name__ + "._extractRepetition")
-
- exprSize = len(self.expr)
-
- _LOG.debug("expr: " + self.expr + " index: " + str(index))
-
- errMsg = "Error: PatternListMatcher._extractRepetition: "
-
- if index == exprSize:
- return index
-
- if '+' == self.expr[index] or '?' == self.expr[index] or '*' == self.expr[index] :
- index += 1
- return index
-
- if '{' == self.expr[index]:
- while '}' != self.expr[index]:
- index += 1
- if index == exprSize:
- break
- if index == exprSize:
- raise RegexError(errMsg + "Missing right brace bracket")
- else:
- index += 1
- return index
- else:
- _LOG.debug ("return index: " + str(index))
- return index
-
-class RepeatMatcher(BaseMatcher):
- def __init__(self, expr, backRef, indicator, exact=True):
- _LOG.debug(self.__class__.__name__ + ".Constructor")
- _LOG.debug("expr: " + expr);
- super(RepeatMatcher, self).__init__(expr, backRef, exact)
- self.indicator = indicator
- if '(' == self.expr[0]:
- self.matcherList.append(BackRefMatcher(self.expr[0:self.indicator], self.backRef))
- else:
- self.matcherList.append(ComponentSetMatcher(self.expr[0:self.indicator], self.backRef))
-
- self._parseRepetition()
- _LOG.debug("repeatMin: " + str(self.repeatMin) + " repeatMax: " + str(self.repeatMax))
-
- def _parseRepetition(self):
- _LOG.debug(self.__class__.__name__ + "._parseRepetition")
-
- errMsg = "Error: RepeatMatcher._parseRepetition(): ";
-
- exprSize = len(self.expr)
- intMax = sys.maxint
-
- if exprSize == self.indicator:
- self.repeatMin = 1
- self.repeatMax = 1
- return
- else:
- if exprSize == (self.indicator + 1):
- if '?' == self.expr[self.indicator]:
- self.repeatMin = 0
- self.repeatMax = 1
- if '+' == self.expr[self.indicator]:
- self.repeatMin = 1
- self.repeatMax = intMax
- if '*' == self.expr[self.indicator]:
- self.repeatMin = 0
- self.repeatMax = intMax
- return
- else:
- repeatStruct = self.expr[self.indicator:exprSize]
- min = 0
- max = 0
-
- if re.match('{[0-9]+,[0-9]+}$', repeatStruct):
- repeats = repeatStruct[1:-1].split(',')
- min = int(repeats[0])
- max = int(repeats[1])
- elif re.match('{[0-9]+,}$', repeatStruct):
- repeats = repeatStruct[1:-1].split(',')
- min = int(repeats[0])
- max = intMax
- elif re.match('{,[0-9]+}$', repeatStruct):
- repeats = repeatStruct[1:-1].split(',')
- min = 0
- max = int(repeats[1])
- elif re.match('{[0-9]+}$', repeatStruct):
- min = int(repeatStruct[1:- 1])
- max = min;
- else:
- raise RegexError(errMsg + "Unrecognized format "+ self.expr);
-
- if min > intMax or max > intMax or min > max:
- raise RegexError(errMsg + "Wrong number " + self.expr);
-
- self.repeatMin = min
- self.repeatMax = max
-
- def match(self, name, offset, len):
- _LOG.debug(self.__class__.__name__ + ".match(): " + "expr: " + self.expr + " offset: " + str(offset) + " len: " + str(len) + " repeatMin: " + str(self.repeatMin))
- self.matchResult = []
-
- if 0 == self.repeatMin:
- if 0 == len:
- return True
-
- if self._recursiveMatch(0, name, offset, len):
- for i in range(offset, offset+len):
- self.matchResult.append(str (name[i]))
- return True
- else:
- return False
-
- def _recursiveMatch(self, repeat, name, offset, len):
- _LOG.debug (self.__class__.__name__ + "._recursiveMatch()" + " repeat: " + str(repeat) + " offset: " + str(offset) + " len: " + str(len) + " rMin: " + str(self.repeatMin) + " rMax: " + str(self.repeatMax))
- tried = 0
- matcher = self.matcherList[0]
-
- if 0 < len and repeat >= self.repeatMax:
- _LOG.debug("Match Fail: Reach m_repeatMax && More components")
- return False
-
- if 0 == len and repeat < self.repeatMin:
- _LOG.debug("Match Fail: No more components && have NOT reached m_repeatMin " + str(len) + ", " + str(self.repeatMin))
- return False
-
- if 0 == len and repeat >= self.repeatMin:
- _LOG.debug("Match Succeed: No more components && reach m_repeatMin")
- return True
-
- while tried <= len:
- _LOG.debug("Attempt tried: " + str(tried))
-
- if matcher.match(name, offset, tried) and self._recursiveMatch(repeat + 1, name, offset + tried, len - tried):
- return True;
- _LOG.debug("Failed at tried: " + str(tried));
- tried += 1
-
- return False
-
-
- def aggressiveMatch(self, name, offset, len):
- _LOG.debug(self.__class__.__name__ + ".aggressiveMatch(): " + "expr: " + self.expr + " offset: " + str(offset) + " len: " + str(len) + " repeatMin: " + str(self.repeatMin))
- self.matchResult = []
-
- if 0 == self.repeatMin:
- if 0 == len:
- return True
-
- if self._aRecursiveMatch(0, name, offset, len):
- for i in range(offset, offset+len):
- self.matchResult.append(str (name[i]))
- return True
- else:
- return False
-
- def _aRecursiveMatch(self, repeat, name, offset, len):
- _LOG.debug (self.__class__.__name__ + "._aRecursiveMatch()" + " repeat: " + str(repeat) + " offset: " + str(offset) + " len: " + str(len) + " rMin: " + str(self.repeatMin) + " rMax: " + str(self.repeatMax))
- tried = len
- matcher = self.matcherList[0]
-
- if 0 < len and repeat >= self.repeatMax:
- _LOG.debug("Match Fail: Reach m_repeatMax && More components")
- return False
-
- if 0 == len and repeat < self.repeatMin:
- _LOG.debug("Match Fail: No more components && have NOT reached m_repeatMin " + str(len) + ", " + str(self.repeatMin))
- return False
-
- if 0 == len and repeat >= self.repeatMin:
- _LOG.debug("Match Succeed: No more components && reach m_repeatMin")
- return True
-
- while tried >= 0:
- _LOG.debug("Attempt tried: " + str(tried))
-
- if matcher.aggressiveMatch(name, offset, tried) and self._aRecursiveMatch(repeat + 1, name, offset + tried, len - tried):
- return True;
- _LOG.debug("Failed at tried: " + str(tried));
- tried -= 1
-
- return False
-
-
-
-class RegexMatcher(BaseMatcher):
- def __init__(self, expr, exact=True):
- _LOG.debug(self.__class__.__name__ + ".Constructor")
- super(RegexMatcher, self).__init__(expr, None, exact)
-
- self.backRef = []
- self.second_backRef = []
-
- self.secondaryMatcher = None
-
-
- errMsg = "Error: RegexTopMatcher Constructor: "
- tmp_expr = self.expr
-
- if '$' != tmp_expr[-1]:
- tmp_expr = tmp_expr + "<.*>*";
- else:
- tmp_expr = tmp_expr[0:-1]
-
- if '^' != tmp_expr[0]:
- self.secondaryMatcher = PatternListMatcher("<.*>*" + tmp_expr, self.second_backRef, self.exact)
- else:
- tmp_expr = tmp_expr[1:]
-
- _LOG.debug ("reconstructed expr " + tmp_expr);
-
- self.primaryMatcher = PatternListMatcher(tmp_expr, self.backRef, self.exact)
-
-
-
- def firstMatcher():
- return None
-
- def matchName(self, name):
- _LOG.debug(self.__class__.__name__ + ".matchName")
-
- self.secondaryUsed = False
-
- res = self.primaryMatcher.match(name, 0, len(name))
- self.matchResult += self.primaryMatcher.matchResult
- if False == res and None != self.secondaryMatcher:
- res = self.secondaryMatcher.match(name, 0, len(name))
- self.matchResult += self.secondaryMatcher.matchResult
- self.secondaryUsed = True
- return res
-
- def extract(self, rule):
- _LOG.debug(self.__class__.__name__ + ".extract")
-
- if not re.match('(\\\\[0-9]+)+$', rule):
- raise RegexError("Wrong format of rule")
-
- refs = rule.split('\\')
- refs.pop(0)
-
- backRef = self.backRef
- if self.secondaryUsed:
- backRef = self.second_backRef
-
- result = []
- for index in refs:
- i = int(index) - 1
-
- if len(backRef) <= i or 0 > i:
- raise RegexError("Wrong back reference number!")
-
- result += backRef[i].matchResult
-
- return result
-
- def matchN(self, name):
- _LOG.debug(self.__class__.__name__ + ".matchN")
-
- self.secondaryUsed = False
-
- res = self.primaryMatcher.aggressiveMatch(name, 0, len(name))
- self.matchResult += self.primaryMatcher.matchResult
- if False == res and None != self.secondaryMatcher:
- res = self.secondaryMatcher.aggressiveMatch(name, 0, len(name))
- self.matchResult += self.secondaryMatcher.matchResult
- self.secondaryUsed = True
- return res
-
- def expand (self, rule):
- return self.extract (rule)
-
-def match (pattern, name, flags=0):
- """
- If zero or more characters at the beginning of string match the regular expression pattern, return a corresponding matches as a list. Return None if the string does not match the pattern.
-"""
- if not isinstance (name, Name):
- raise TypeError ("name is not ndn.Name type")
-
- m = RegexMatcher (pattern)
- res = m.matchN (Name (name))
- if not res:
- return None
- return m
diff --git a/PyNDN/utils.py b/PyNDN/utils.py
deleted file mode 100644
index 555ce80..0000000
--- a/PyNDN/utils.py
+++ /dev/null
@@ -1,133 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# Alexander Afanasyev
-#
-# GNU 3.0 license, See the LICENSE file for more information
-#
-# Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-#
-
-#
-# Based on PyCCN code, copyrighted and licensed as follows
-#
-# Copyright (c) 2011-2013, Regents of the University of California
-# BSD license, See the COPYING file for more information
-# Written by: Derek Kulinski <takeda@takeda.tk>
-# Jeff Burke <jburke@ucla.edu>
-#
-
-import struct
-
-class Flag(int):
- __initialized = False
- _flags = None
- _prefix = None
- __flags_values__ = None
-
- @classmethod
- def initialize(cls):
- cls._flags = {}
- cls.__flags_values__ = {}
- cls.__initialized = True
-
- @classmethod
- def new_flag(cls, name, value):
- if not cls.__initialized:
- cls.initialize()
-
- cls._flags[value] = name
-
- obj = cls(value)
- cls.__flags_values__[value] = obj
-
- return obj
-
- def __new__(cls, value):
- if cls.__flags_values__.has_key(value):
- return cls.__flags_values__[value]
-
- return super(Flag, cls).__new__(cls, value)
-
- def generate_repr(self):
- val = long(self)
- flags = [name for i, name in self._flags.items() if i & val]
- return " | ".join(flags)
-
- def __repr__(self):
- if self._prefix:
- return self._prefix + "." + self.generate_repr()
-
- t = type(self)
- type_name = "%s.%s" % (t.__module__, t.__name__)
- return "<flags %s of type %s>" % (self.generate_repr(), type_name)
-
- def __and__(self, other):
- cls = type(self)
- return cls(long(self) & long(other))
-
- def __xor__(self, other):
- cls = type(self)
- return cls(long(self) ^ long(other))
-
- def __or__(self, other):
- cls = type(self)
- return cls(long(self) | long(other))
-
-class Enum(Flag):
- def __new__(cls, value):
- if cls.__flags_values__.has_key(value):
- return cls.__flags_values__[value]
-
- if cls._flags.has_key(value):
- return super(Enum, cls).__new__(cls, value)
-
- raise ValueError("invalid flag value: %d" % value)
-
- def generate_repr(self):
- return self._flags[long(self)]
-
-def ccn2py_time(value):
- bintime = b'\x00' * (8 - len(value)) + value
- inttime = struct.unpack("!Q", bintime)[0]
- return inttime / 4096.0
-
-def py2ccn_time(value):
- inttime = int(value * 4096 + 0.5)
- bintime = struct.pack("!Q", inttime)
- return bintime.lstrip(b'\x00')
-
-class Const (object):
- def __init__ (self, obj):
- object.__setattr__ (self, "__internal_object", obj)
- object.__setattr__ (self, "__bases__", type(obj))
-
- def __getattribute__ (self, name):
- if name != "__bases__":
- return object.__getattribute__ (self, "__internal_object").__getattribute__ (name)
- else:
- return object.__getattribute__ (self, name)
-
- def __getitem__(self, key):
- return object.__getattribute__ (self, "__internal_object").__getitem__ (key)
-
- def __setattr__ (self, name, value):
- raise TypeError ("Const %s cannot be modified" % type (object.__getattribute__ (self, "__internal_object")))
-
- def __repr__ (self):
- return "const %s" % object.__getattribute__ (self, "__internal_object").__repr__ ()
-
- def __str__(self):
- return object.__getattribute__ (self, "__internal_object").__str__ ()
-
- def __add__(self, other):
- raise TypeError ("Const %s cannot be modified" % type (object.__getattribute__ (self, "__internal_object")))
-
- def __delattr__ (self, name, value):
- raise TypeError ("Const %s cannot be modified" % type (object.__getattribute__ (self, "__internal_object")))
-
- def __setitem__(self, key, value):
- raise TypeError ("Const %s cannot be modified" % type (object.__getattribute__ (self, "__internal_object")))
-
- def __delitem__(self, key):
- raise TypeError ("Const %s cannot be modified" % type (object.__getattribute__ (self, "__internal_object")))
diff --git a/apps/callback-based-app.cc b/apps/callback-based-app.cc
deleted file mode 100644
index 34c3de6..0000000
--- a/apps/callback-based-app.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- * Zhenkai Zhu
- *
- * GNU v3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "callback-based-app.h"
-
-#include <ns3/log.h>
-
-NS_LOG_COMPONENT_DEFINE ("CallbackBasedApp");
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (CallbackBasedApp);
-
-TypeId
-CallbackBasedApp::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::CallbackBasedApp")
- .SetGroupName ("Ndn")
- .SetParent<Application> ()
- .AddConstructor<CallbackBasedApp> ()
-
- .AddAttribute ("OnStart", "OnStart callback",
- CallbackValue (),
- MakeCallbackAccessor (&CallbackBasedApp::m_onStart),
- MakeCallbackChecker ())
-
- .AddAttribute ("OnStop", "OnStop callback",
- CallbackValue (),
- MakeCallbackAccessor (&CallbackBasedApp::m_onStop),
- MakeCallbackChecker ())
- ;
- return tid;
-}
-
-CallbackBasedApp::CallbackBasedApp ()
-{
-}
-
-CallbackBasedApp::~CallbackBasedApp ()
-{
-}
-
-void
-CallbackBasedApp::SetOnStartCallback (Callback< void, Ptr<Application> > onStart)
-{
- m_onStart = onStart;
-}
-
-void
-CallbackBasedApp::SetOnStopCallback (Callback< void, Ptr<Application> > onStop)
-{
- m_onStop = onStop;
-}
-
-void
-CallbackBasedApp::StartApplication ()
-{
- NS_LOG_FUNCTION (this);
- if (!m_onStart.IsNull ())
- m_onStart (this);
-}
-
-void
-CallbackBasedApp::StopApplication ()
-{
- NS_LOG_FUNCTION (this);
- if (!m_onStop.IsNull ())
- m_onStop (this);
-}
-
-}
diff --git a/apps/callback-based-app.h b/apps/callback-based-app.h
deleted file mode 100644
index 1d7e74d..0000000
--- a/apps/callback-based-app.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- * Zhenkai Zhu
- *
- * GNU v3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_CALLBACK_BASED_APP_H
-#define NDN_CALLBACK_BASED_APP_H
-
-#include "ns3/application.h"
-#include "ns3/ptr.h"
-#include "ns3/callback.h"
-
-namespace ns3 {
-
-/**
- * @ingroup ndn-apps
- * @brief A meta application that can be used to create custom apps within Python bindings
- */
-class CallbackBasedApp: public Application
-{
-public:
- static TypeId GetTypeId ();
-
- /**
- * @brief Default constructor
- */
- CallbackBasedApp ();
-
- /**
- * @brief Virtual destructor
- */
- virtual
- ~CallbackBasedApp ();
-
- /**
- * @brief Define callback that will be fired when application need to start its work
- */
- void
- SetOnStartCallback (Callback< void, Ptr<Application> > onStart);
-
- /**
- * @brief Define callback that will be fired when application need to stop its work
- */
- void
- SetOnStopCallback (Callback< void, Ptr<Application> > onStart);
-
-protected:
- // inherited from Application base class. Originally they were private
- virtual void
- StartApplication (); ///< @brief Called at time specified by Start
-
- virtual void
- StopApplication (); ///< @brief Called at time specified by Stop
-
-private:
- Callback< void, Ptr<Application> > m_onStart;
- Callback< void, Ptr<Application> > m_onStop;
-};
-
-} // ns3
-
-#endif // NDN_CALLBACK_BASED_APP_H
diff --git a/bindings/scan-header.h b/bindings/scan-header.h
deleted file mode 100644
index 72d8771..0000000
--- a/bindings/scan-header.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU 3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-using namespace ndn;
-
-static inline void
-__dummy_function_on_interest_callback_instantiation (Ptr<const Name>, Ptr<const Interest>)
-{
-}
-
-static inline void
-__dummy_function_on_data_callback_instantiation (Ptr<const Interest>, Ptr<const Data>)
-{
-}
-
-static inline void
-__dummy_function_on_timeout_callback_instantiation (Ptr<const Interest>)
-{
-}
-
-static inline void
-__dummy_function_to_force_ndn_api_face_callback_instantiations ()
-{
- ApiFace face (0);
- Ptr<Interest> interest;
- Ptr<Name> prefix;
-
- face.ExpressInterest (interest,
- MakeCallback (__dummy_function_on_data_callback_instantiation),
- MakeCallback (__dummy_function_on_timeout_callback_instantiation)
- );
-
- face.SetInterestFilter (prefix,
- MakeCallback (__dummy_function_on_interest_callback_instantiation));
-
- std::string tmp ("bla");
- char &test = tmp[0];
-}
-
-
-// /// @cond include_hidden
-// #ifdef PYTHON_SCAN
-// struct CallbackVoidNameInterest : public Callback<void, Ptr<const Name>, Ptr<const Interest> > { };
-// struct CallbackVoidInterestData : public Callback<void, Ptr<const Interest>, Ptr<const Data> > { };
-// struct CallbackVoidInterest : public Callback<void, Ptr<const Interest> > { };
-// #endif
-// /// @endcond
-
diff --git a/examples/custom-apps/ndn-api-app.cc b/examples/custom-apps/ndn-api-app.cc
deleted file mode 100644
index bb7a9b6..0000000
--- a/examples/custom-apps/ndn-api-app.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-api-app.h"
-
-NS_LOG_COMPONENT_DEFINE ("ndn.ApiApp");
-
-namespace ns3 {
-namespace ndn {
-
-// Necessary if you are planning to use ndn::AppHelper
-NS_OBJECT_ENSURE_REGISTERED (ApiApp);
-
-TypeId
-ApiApp::GetTypeId ()
-{
- static TypeId tid = TypeId ("ns3::ndn::ApiApp")
- .SetParent<Application> ()
- .AddConstructor<ApiApp> ()
-
- .AddAttribute ("Prefix","Name of the Interest",
- StringValue ("/"),
- MakeNameAccessor (&ApiApp::m_name),
- MakeNameChecker ())
- .AddAttribute ("LifeTime", "LifeTime for interest packet",
- StringValue ("2s"),
- MakeTimeAccessor (&ApiApp::m_interestLifetime),
- MakeTimeChecker ())
- ;
-
- return tid;
-}
-
-ApiApp::ApiApp ()
- : m_face (0)
-{
-}
-
-void
-ApiApp::RequestData ()
-{
- NS_LOG_FUNCTION (this);
-
- Ptr<Interest> interest = Create<Interest> ();
- interest->SetName (m_name);
- interest->SetInterestLifetime (m_interestLifetime);
-
- Ptr<Exclude> exclude = Create<Exclude> ();
- exclude->excludeOne (name::Component ("unique"));
- interest->SetExclude (exclude);
-
- m_face->ExpressInterest (interest,
- MakeCallback (&ApiApp::GotData, this),
- MakeNullCallback< void, Ptr<const Interest> > ());
-}
-
-void
-ApiApp::GotData (Ptr<const Interest> origInterest, Ptr<const Data> data)
-{
- NS_LOG_FUNCTION (this << origInterest->GetName () << data->GetName ());
- // do nothing else
-}
-
-void
-ApiApp::StartApplication ()
-{
- m_face = CreateObject<ApiFace> (GetNode ());
-
- Simulator::Schedule (Seconds (1), &::ns3::ndn::ApiApp::RequestData, this);
- Simulator::Schedule (Seconds (10), &::ns3::ndn::ApiApp::RequestData, this);
-}
-
-void
-ApiApp::StopApplication ()
-{
- NS_LOG_FUNCTION (this);
- m_face->Shutdown ();
- m_face = 0;
-}
-
-} // namespace ndn
-} // namespace ns3
-
diff --git a/examples/custom-apps/ndn-api-app.h b/examples/custom-apps/ndn-api-app.h
deleted file mode 100644
index 8345a99..0000000
--- a/examples/custom-apps/ndn-api-app.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_EXAMPLES_API_APP_H
-#define NDN_EXAMPLES_API_APP_H
-
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/ndnSIM-module.h"
-
-#include "ns3/ndnSIM/ndn.cxx/ndn-api-face.h"
-
-namespace ns3 {
-namespace ndn {
-
-class ApiApp : public Application
-{
-public:
- static TypeId
- GetTypeId ();
-
- ApiApp ();
-
-private:
- void
- RequestData ();
-
- void
- GotData (Ptr<const Interest> origInterest, Ptr<const Data> data);
-
-protected:
- // inherited from Application base class.
- virtual void
- StartApplication ();
-
- virtual void
- StopApplication ();
-
-private:
- Ptr<ApiFace> m_face;
-
- Name m_name;
- Time m_interestLifetime;
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_EXAMPLES_API_APP_H
diff --git a/examples/custom-strategies/custom-strategy.cc b/examples/custom-strategies/custom-strategy.cc
deleted file mode 100644
index b1bb6c2..0000000
--- a/examples/custom-strategies/custom-strategy.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-// custom-strategy.cc
-
-#include "custom-strategy.h"
-#include "ns3/ndn-fib.h"
-#include "ns3/ndn-fib-entry.h"
-#include "ns3/ndn-pit-entry.h"
-#include "ns3/ndn-interest.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-NS_OBJECT_ENSURE_REGISTERED(CustomStrategy);
-
-LogComponent CustomStrategy::g_log = LogComponent (CustomStrategy::GetLogName ().c_str ());
-
-std::string
-CustomStrategy::GetLogName ()
-{
- return "ndn.fw.CustomStrategy";
-}
-
-TypeId
-CustomStrategy::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::fw::CustomStrategy")
- .SetGroupName ("Ndn")
- .SetParent <BaseStrategy> ()
- .AddConstructor <CustomStrategy> ()
-
- // .AddAttribute ("Attribute", "Attribute spec",
- // StringValue ("DefaultValue"),
- // MakeStringAccessor (&BaseStrategy::m_variable),
- // MakeStringChecker ())
- ;
- return tid;
-}
-
-CustomStrategy::CustomStrategy ()
- : m_counter (0)
-{
-}
-
-bool
-CustomStrategy::DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- typedef fib::FaceMetricContainer::type::index<fib::i_metric>::type FacesByMetric;
- FacesByMetric &faces = pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ();
- FacesByMetric::iterator faceIterator = faces.begin ();
-
- int propagatedCount = 0;
-
- // forward to best-metric face
- if (faceIterator != faces.end ())
- {
- if (TrySendOutInterest (inFace, faceIterator->GetFace (), interest, pitEntry))
- propagatedCount ++;
-
- faceIterator ++;
- }
-
- // forward to second-best-metric face
- if (faceIterator != faces.end ())
- {
- if (TrySendOutInterest (inFace, faceIterator->GetFace (), interest, pitEntry))
- propagatedCount ++;
-
- faceIterator ++;
- }
- return propagatedCount > 0;
-}
-
-void
-CustomStrategy::DidSendOutInterest (Ptr<Face> inFace, Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- m_counter ++;
-}
-
-void
-CustomStrategy::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
-{
- for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- face != pitEntry->GetOutgoing ().end ();
- face ++)
- {
- m_counter --;
- }
-
- BaseStrategy::WillEraseTimedOutPendingInterest (pitEntry);
-}
-
-
-void
-CustomStrategy::WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry)
-{
- for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- face != pitEntry->GetOutgoing ().end ();
- face ++)
- {
- m_counter --;
- }
-
- BaseStrategy::WillSatisfyPendingInterest (inFace, pitEntry);
-}
-
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
diff --git a/examples/custom-strategies/custom-strategy.h b/examples/custom-strategies/custom-strategy.h
deleted file mode 100644
index 051901c..0000000
--- a/examples/custom-strategies/custom-strategy.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-
-// custom-strategy.h
-
-#ifndef CUSTOM_STRATEGY_H
-#define CUSTOM_STRATEGY_H
-
-#include "ns3/log.h"
-#include "ns3/ndn-forwarding-strategy.h"
-#include "ns3/ndn-l3-protocol.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-typedef ForwardingStrategy BaseStrategy;
-
-class CustomStrategy:
- public BaseStrategy
-{
-public:
- static TypeId
- GetTypeId ();
-
- static std::string
- GetLogName ();
-
- CustomStrategy ();
-
-protected:
- virtual bool
- DoPropagateInterest (Ptr<Face> incomingFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
-public:
- virtual void
- DidSendOutInterest (Ptr<Face> inFace, Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- virtual void
- WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
-
- virtual void
- WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry);
-
-protected:
- static LogComponent g_log;
-
-// private:
-// std::string m_variable;
-
-private:
- uint32_t m_counter;
-};
-
-
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
-#endif // CUSTOM_STRATEGY_H
diff --git a/examples/ndn-grid-topo-plugin-loss.cc b/examples/ndn-grid-topo-plugin-loss.cc
deleted file mode 100644
index 355372d..0000000
--- a/examples/ndn-grid-topo-plugin-loss.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011-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>
- */
-// ndn-grid-topo-plugin.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a grid topology (using topology reader module)
- *
- * (consumer) -- ( ) ----- ( )
- * | | |
- * ( ) ------ ( ) ----- ( )
- * | | |
- * ( ) ------ ( ) -- (producer)
- *
- * All links are 1Mbps with propagation 10ms delay.
- *
- * FIB is populated using NdnGlobalRoutingHelper.
- *
- * Consumer requests data from producer with frequency 10 interests per second
- * (interests contain constantly increasing sequence number).
- *
- * For every received interest, producer replies with a data packet, containing
- * 1024 bytes of virtual payload.
- *
- * To run scenario and see what is happening, use the following command:
- *
- * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-topo-plugin
- */
-
-int
-main (int argc, char *argv[])
-{
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- AnnotatedTopologyReader topologyReader ("", 25);
- topologyReader.SetFileName ("src/ndnSIM/examples/topologies/topo-grid-3x3-loss.txt");
- topologyReader.Read ();
-
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::BestRoute");
- ndnHelper.InstallAll ();
-
- // Installing global routing interface on all nodes
- ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
- ndnGlobalRoutingHelper.InstallAll ();
-
- // Getting containers for the consumer/producer
- Ptr<Node> producer = Names::Find<Node> ("Node8");
- NodeContainer consumerNodes;
- consumerNodes.Add (Names::Find<Node> ("Node0"));
-
- // Install NDN applications
- std::string prefix = "/prefix";
-
- ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
- consumerHelper.SetPrefix (prefix);
- consumerHelper.SetAttribute ("Frequency", StringValue ("100")); // 100 interests a second
- consumerHelper.Install (consumerNodes);
-
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- producerHelper.SetPrefix (prefix);
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (producer);
-
- // Add /prefix origins to ndn::GlobalRouter
- ndnGlobalRoutingHelper.AddOrigins (prefix, producer);
-
- // Calculate and install FIBs
- ndn::GlobalRoutingHelper::CalculateRoutes ();
-
- Simulator::Stop (Seconds (20.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-grid-topo-plugin-red-queues.cc b/examples/ndn-grid-topo-plugin-red-queues.cc
deleted file mode 100644
index d73ad79..0000000
--- a/examples/ndn-grid-topo-plugin-red-queues.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011-2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-// ndn-grid-topo-plugin.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a grid topology (using topology reader module)
- *
- * (consumer) -- ( ) ----- ( )
- * | | |
- * ( ) ------ ( ) ----- ( )
- * | | |
- * ( ) ------ ( ) -- (producer)
- *
- * All links are 1Mbps with propagation 10ms delay.
- *
- * FIB is populated using ndn::GlobalRoutingHelper.
- *
- * Consumer requests data from producer with frequency 10 interests per second
- * (interests contain constantly increasing sequence number).
- *
- * For every received interest, producer replies with a data packet, containing
- * 1024 bytes of virtual payload.
- *
- * To run scenario and see what is happening, use the following command:
- *
- * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-grid-topo-plugin
- */
-
-int
-main (int argc, char *argv[])
-{
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- AnnotatedTopologyReader topologyReader ("", 25);
- topologyReader.SetFileName ("src/ndnSIM/examples/topologies/topo-grid-3x3-red-queues.txt");
- topologyReader.Read ();
-
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::BestRoute");
- ndnHelper.InstallAll ();
-
- // Installing global routing interface on all nodes
- ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
- ndnGlobalRoutingHelper.InstallAll ();
-
- // Getting containers for the consumer/producer
- Ptr<Node> producer = Names::Find<Node> ("Node8");
- NodeContainer consumerNodes;
- consumerNodes.Add (Names::Find<Node> ("Node0"));
-
- // Install NDN applications
- std::string prefix = "/prefix";
-
- ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
- consumerHelper.SetPrefix (prefix);
- consumerHelper.SetAttribute ("Frequency", StringValue ("100")); // 100 interests a second
- consumerHelper.Install (consumerNodes);
-
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- producerHelper.SetPrefix (prefix);
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (producer);
-
- // Add /prefix origins to ndn::GlobalRouter
- ndnGlobalRoutingHelper.AddOrigins (prefix, producer);
-
- // Calculate and install FIBs
- ndn::GlobalRoutingHelper::CalculateRoutes ();
-
- Simulator::Stop (Seconds (20.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-simple-api.cc b/examples/ndn-simple-api.cc
deleted file mode 100644
index 6580fbe..0000000
--- a/examples/ndn-simple-api.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- 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>
- */
-// ndn-simple.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a very simple network topology:
- *
- *
- * +----------+ 1Mbps +--------+ 1Mbps +----------+
- * | consumer | <------------> | router | <------------> | producer |
- * +----------+ 10ms +--------+ 10ms +----------+
- *
- *
- * Consumer requests data from producer with frequency 10 interests per second
- * (interests contain constantly increasing sequence number).
- *
- * For every received interest, producer replies with a data packet, containing
- * 1024 bytes of virtual payload.
- *
- * To run scenario and see what is happening, use the following command:
- *
- * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple
- */
-
-int
-main (int argc, char *argv[])
-{
- // setting default parameters for PointToPoint links and channels
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- // Creating nodes
- NodeContainer nodes;
- nodes.Create (3);
-
- // Connecting nodes using two links
- PointToPointHelper p2p;
- p2p.Install (nodes.Get (0), nodes.Get (1));
- p2p.Install (nodes.Get (1), nodes.Get (2));
-
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetDefaultRoutes (true);
- ndnHelper.InstallAll ();
-
- // Installing applications
-
- // Consumer
- ndn::AppHelper consumerHelper ("ns3::ndn::ApiApp");
- consumerHelper.SetPrefix ("/prefix");
- ApplicationContainer app = consumerHelper.Install (nodes.Get (0)); // first node
- app.Stop (Seconds (15.0));
-
- // Producer
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- // Producer will reply to all requests starting with /prefix
- producerHelper.SetPrefix ("/");
- producerHelper.SetAttribute ("Postfix", StringValue ("/unique/postfix"));
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (nodes.Get (2)); // last node
-
- Simulator::Stop (Seconds (20.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-simple-pit-policies.cc b/examples/ndn-simple-pit-policies.cc
deleted file mode 100644
index f18b85a..0000000
--- a/examples/ndn-simple-pit-policies.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- 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>
- */
-// ndn-simple-pit-policies.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a very simple network topology:
- *
- *
- * +----------+ 1Mbps +--------+ 1Mbps +----------+
- * | consumer | <------------> | router | <------------> | producer |
- * +----------+ 10ms +--------+ 10ms +----------+
- *
- *
- * Consumer requests data from producer with frequency 10 interests per second
- * (interests contain constantly increasing sequence number).
- *
- * For every received interest, producer replies with a data packet, containing
- * 1024 bytes of virtual payload.
- *
- * To run scenario and see what is happening, use the following command:
- *
- * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple-pit-policies
- */
-
-int
-main (int argc, char *argv[])
-{
- // setting default parameters for PointToPoint links and channels
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- // Creating nodes
- NodeContainer nodes;
- nodes.Create (3);
-
- // Connecting nodes using two links
- PointToPointHelper p2p;
- p2p.Install (nodes.Get (0), nodes.Get (1));
- p2p.Install (nodes.Get (1), nodes.Get (2));
-
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetPit ("ns3::ndn::pit::SerializedSize",
- "MaxSize", "300"); // 1000 bytes ~ 10 entries
- ndnHelper.SetDefaultRoutes (true);
- ndnHelper.InstallAll ();
-
- // Installing applications
-
- // Consumer
- ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
- // Consumer will request /prefix/0, /prefix/1, ...
- consumerHelper.SetPrefix ("/prefix");
- consumerHelper.SetAttribute ("LifeTime", StringValue ("2s"));
- consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
- consumerHelper.Install (nodes.Get (0)); // first node
-
- Simulator::Stop (Seconds (5.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-simple-tcp.cc b/examples/ndn-simple-tcp.cc
deleted file mode 100644
index f959dc7..0000000
--- a/examples/ndn-simple-tcp.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- 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>
- */
-// ndn-simple-tcp.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/internet-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a very simple network topology:
- *
- *
- * +----------+ 1Mbps +--------+ 1Mbps +----------+
- * | consumer | <------------> | router | <------------> | producer |
- * +----------+ 10ms +--------+ 10ms +----------+
- * \ /
- * -------------------- tcp face --------------------
- *
- * Consumer requests data from producer with frequency 10 interests per second
- * (interests contain constantly increasing sequence number).
- *
- * For every received interest, producer replies with a data packet, containing
- * 1024 bytes of virtual payload.
- *
- * To run scenario and see what is happening, use the following command:
- *
- * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple-tcp
- */
-
-int
-main (int argc, char *argv[])
-{
- Packet::EnablePrinting ();
-
- // setting default parameters for PointToPoint links and channels
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- // Creating nodes
- NodeContainer nodes;
- nodes.Create (3);
-
- // Connecting nodes using two links
- PointToPointHelper p2p;
- NetDeviceContainer link1 = p2p.Install (nodes.Get (0), nodes.Get (1));
- NetDeviceContainer link2 = p2p.Install (nodes.Get (1), nodes.Get (2));
-
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetDefaultRoutes (false);
- ndnHelper.InstallAll ();
-
- InternetStackHelper ipStack;
- ipStack.SetIpv6StackInstall (false);
- ipStack.InstallAll ();
-
- Ipv4AddressHelper ipAddressHelper;
- ipAddressHelper.SetBase (Ipv4Address ("10.1.1.0"), Ipv4Mask ("255.255.255.0"));
- ipAddressHelper.Assign (link1);
-
- ipAddressHelper.SetBase (Ipv4Address ("10.1.2.0"), Ipv4Mask ("255.255.255.0"));
- ipAddressHelper.Assign (link2);
-
- Ipv4StaticRoutingHelper ipStaticRouting;
- ipStaticRouting.GetStaticRouting (nodes.Get (0)->GetObject<Ipv4> ())->
- AddNetworkRouteTo (Ipv4Address ("10.1.2.0"), Ipv4Mask ("255.255.255.0"),
- Ipv4Address ("10.1.1.2"),
- 1, 1);
-
- ipStaticRouting.GetStaticRouting (nodes.Get (2)->GetObject<Ipv4> ())->
- AddNetworkRouteTo (Ipv4Address ("10.1.1.0"), Ipv4Mask ("255.255.255.0"),
- Ipv4Address ("10.1.2.1"),
- 1, 1);
-
- ndn::IpFacesHelper::InstallAll ();
- ndn::IpFacesHelper::CreateTcpFace (Seconds (1.0), nodes.Get (0), Ipv4Address ("10.1.2.2"), "/tcp-route");
-
- // Installing applications
-
- // Consumer
- ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
- // Consumer will request /tcp-route/0, /tcp-route/1, ...
- consumerHelper.SetPrefix ("/tcp-route");
- consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
- consumerHelper.Install (nodes.Get (0)).
- Start (Seconds (3)); // first node
-
- // Producer
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- // Producer will reply to all requests starting with /prefix
- producerHelper.SetPrefix ("/tcp-route");
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (nodes.Get (2)); // last node
-
- Simulator::Stop (Seconds (20.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-simple-udp.cc b/examples/ndn-simple-udp.cc
deleted file mode 100644
index 2fa093d..0000000
--- a/examples/ndn-simple-udp.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-/* -*- 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>
- */
-// ndn-simple-tcp.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/internet-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a very simple network topology:
- *
- *
- * +----------+ 1Mbps +--------+ 1Mbps +----------+
- * | consumer | <------------> | router | <------------> | producer |
- * +----------+ 10ms +--------+ 10ms +----------+
- * \ /
- * -------------------- udp face --------------------
- *
- * Consumer requests data from producer with frequency 10 interests per second
- * (interests contain constantly increasing sequence number).
- *
- * For every received interest, producer replies with a data packet, containing
- * 1024 bytes of virtual payload.
- *
- * To run scenario and see what is happening, use the following command:
- *
- * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-simple-udp
- */
-
-int
-main (int argc, char *argv[])
-{
- Packet::EnablePrinting ();
-
- // setting default parameters for PointToPoint links and channels
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- // Creating nodes
- NodeContainer nodes;
- nodes.Create (3);
-
- // Connecting nodes using two links
- PointToPointHelper p2p;
- NetDeviceContainer link1 = p2p.Install (nodes.Get (0), nodes.Get (1));
- NetDeviceContainer link2 = p2p.Install (nodes.Get (1), nodes.Get (2));
-
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::BestRoute");
- ndnHelper.SetDefaultRoutes (false);
- ndnHelper.InstallAll ();
-
- InternetStackHelper ipStack;
- ipStack.SetIpv6StackInstall (false);
- ipStack.InstallAll ();
-
- Ipv4AddressHelper ipAddressHelper;
- ipAddressHelper.SetBase (Ipv4Address ("10.1.1.0"), Ipv4Mask ("255.255.255.0"));
- ipAddressHelper.Assign (link1);
-
- ipAddressHelper.SetBase (Ipv4Address ("10.1.2.0"), Ipv4Mask ("255.255.255.0"));
- ipAddressHelper.Assign (link2);
-
- Ipv4StaticRoutingHelper ipStaticRouting;
- ipStaticRouting.GetStaticRouting (nodes.Get (0)->GetObject<Ipv4> ())->
- AddNetworkRouteTo (Ipv4Address ("10.1.2.0"), Ipv4Mask ("255.255.255.0"),
- Ipv4Address ("10.1.1.2"),
- 1, 1);
-
- ipStaticRouting.GetStaticRouting (nodes.Get (2)->GetObject<Ipv4> ())->
- AddNetworkRouteTo (Ipv4Address ("10.1.1.0"), Ipv4Mask ("255.255.255.0"),
- Ipv4Address ("10.1.2.1"),
- 1, 1);
-
- ndn::IpFacesHelper::InstallAll ();
- ndn::IpFacesHelper::CreateUdpFace (Seconds (1.0), nodes.Get (0), Ipv4Address ("10.1.2.2"), "/udp-route1");
- ndn::IpFacesHelper::CreateUdpFace (Seconds (1.0), nodes.Get (0), Ipv4Address ("10.1.1.2"), "/udp-route2");
-
- // Installing applications
-
- // Consumer
- ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
- // consumerHelper.SetAttribute ("Randomize", StringValue ("uniform"));
- // Consumer will request /udp-route1/0, /udp-route1/1, ...
- consumerHelper.SetPrefix ("/udp-route1");
- consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
- consumerHelper.Install (nodes.Get (0)).
- Start (Seconds (3)); // first node
-
- // Consumer will request /udp-route1/0, /udp-route1/1, ...
- consumerHelper.SetPrefix ("/udp-route2");
- consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
- consumerHelper.Install (nodes.Get (0)).
- Start (Seconds (3)); // first node
-
- // Producer
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- // Producer will reply to all requests starting with /prefix
- producerHelper.SetPrefix ("/udp-route1");
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (nodes.Get (2)); // last node
-
- producerHelper.SetPrefix ("/udp-route2");
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (nodes.Get (1)); // last node
-
- Simulator::Stop (Seconds (20.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-simple-with-content-freshness.cc b/examples/ndn-simple-with-content-freshness.cc
deleted file mode 100644
index 23db4cb..0000000
--- a/examples/ndn-simple-with-content-freshness.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*- 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>
- */
-// ndn-simple.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a very simple network topology:
- *
- *
- * +----------+ 1Mbps +--------+ 1Mbps +----------+
- * | consumer | <------------> | router | <------------> | producer |
- * +----------+ 10ms +--------+ 10ms +----------+
- *
- * This scenario demonstrates how to use content store that responds to Freshness parameter set in Datas.
- * That is, if producer set Freshness field to 2 seconds, the corresponding content object will not be cached
- * more than 2 seconds (can be cached for a shorter time, if entry is evicted earlier)
- *
- * NS_LOG=DumbRequester ./waf --run ndn-simple-with-content-freshness
- */
-
-int
-main (int argc, char *argv[])
-{
- // setting default parameters for PointToPoint links and channels
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- // Creating nodes
- NodeContainer nodes;
- nodes.Create (3);
-
- // Connecting nodes using two links
- PointToPointHelper p2p;
- p2p.Install (nodes.Get (0), nodes.Get (1));
- p2p.Install (nodes.Get (1), nodes.Get (2));
-
- // Install CCNx stack on all nodes
- ndn::StackHelper ccnxHelper;
- ccnxHelper.SetDefaultRoutes (true);
- ccnxHelper.SetContentStore ("ns3::ndn::cs::Freshness::Lru",
- "MaxSize", "2"); // allow just 2 entries to be cached
- ccnxHelper.InstallAll ();
-
- // Installing applications
-
- // Consumer
- ndn::AppHelper consumerHelper ("DumbRequester");
-
- // /*
- // 1) at time 1 second requests Data from a producer that does not specify freshness
- // 2) at time 10 seconds requests the same Data packet as client 1
-
- // 3) at time 2 seconds requests Data from a producer that specifies freshness set to 2 seconds
- // 4) at time 12 seconds requests the same Data packet as client 3
-
- // Expectation:
- // Interests from 1, 3 and 4 will reach producers
- // Interset from 2 will be served from cache
- // */
-
- ApplicationContainer apps;
-
- consumerHelper.SetPrefix ("/no-freshness");
- apps = consumerHelper.Install (nodes.Get (0));
- apps.Start (Seconds (0.1));
- apps.Stop (Seconds (10.0));
-
- consumerHelper.SetPrefix ("/with-freshness");
- apps = consumerHelper.Install (nodes.Get (0));
- apps.Start (Seconds (20.1));
- apps.Stop (Seconds (30.0));
-
- // Producer
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
-
- producerHelper.SetAttribute ("Freshness", TimeValue (Seconds (0))); // unlimited freshness
- producerHelper.SetPrefix ("/no-freshness");
- producerHelper.Install (nodes.Get (2)); // last node
-
- producerHelper.SetAttribute ("Freshness", TimeValue (Seconds (2.0))); // freshness 2 seconds (!!! freshness granularity is 1 seconds !!!)
- producerHelper.SetPrefix ("/with-freshness");
- producerHelper.Install (nodes.Get (2)); // last node
-
- Simulator::Stop (Seconds (30.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-simple-with-different-sizes-content-store.cc b/examples/ndn-simple-with-different-sizes-content-store.cc
deleted file mode 100644
index d6da309..0000000
--- a/examples/ndn-simple-with-different-sizes-content-store.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2012-2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-// ndn-simple-with-different-sizes-content-store.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a very simple network topology:
- *
- *
- * +----------+ 1Mbps +--------+ 1Mbps +----------+
- * | consumer | <------------> | router | <------------> | producer |
- * +----------+ 10ms +--------+ 10ms +----------+
- *
- * This scenario demonstrates how to use content store that responds to Freshness parameter set in Datas.
- * That is, if producer set Freshness field to 2 seconds, the corresponding content object will not be cached
- * more than 2 seconds (can be cached for a shorter time, if entry is evicted earlier)
- *
- * NS_LOG=ndn.Consumer ./waf --run ndn-simple-with-different-sizes-content-store
- */
-
-int
-main (int argc, char *argv[])
-{
- // setting default parameters for PointToPoint links and channels
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- // Creating nodes
- NodeContainer nodes;
- nodes.Create (3);
-
- // Connecting nodes using two links
- PointToPointHelper p2p;
- p2p.Install (nodes.Get (0), nodes.Get (1));
- p2p.Install (nodes.Get (1), nodes.Get (2));
-
- // Install CCNx stack on all nodes
- ndn::StackHelper ccnxHelper;
- ccnxHelper.SetDefaultRoutes (true);
- ccnxHelper.SetContentStore ("ns3::ndn::cs::Freshness::Lru"); // don't set up max size here, will use default value = 100
- ccnxHelper.InstallAll ();
-
- // set up max sizes, after NDN stack is installed
- Config::Set ("/NodeList/0/$ns3::ndn::ContentStore/MaxSize", UintegerValue (1)); // number after nodeList is global ID of the node (= node->GetId ())
- Config::Set ("/NodeList/1/$ns3::ndn::ContentStore/MaxSize", UintegerValue (2));
- Config::Set ("/NodeList/2/$ns3::ndn::ContentStore/MaxSize", UintegerValue (200));
-
- // Installing applications
-
- // Consumer
- ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
- // Consumer will request /prefix/0, /prefix/1, ...
- consumerHelper.SetPrefix ("/prefix");
- consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
- consumerHelper.Install (nodes.Get (0)); // first node
-
- // Producer
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- // Producer will reply to all requests starting with /prefix
- producerHelper.SetPrefix ("/prefix");
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (nodes.Get (2)); // last node
-
- Simulator::Stop (Seconds (20.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-simple-with-pit-count-stats.cc b/examples/ndn-simple-with-pit-count-stats.cc
deleted file mode 100644
index 725da66..0000000
--- a/examples/ndn-simple-with-pit-count-stats.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2012-2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-// ndn-simple-with-pit-count-stats.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a very simple network topology:
- *
- *
- * +----------+ 1Mbps +--------+ 1Mbps +----------+
- * | consumer | <------------> | router | <------------> | producer |
- * +----------+ 10ms +--------+ 10ms +----------+
- *
- *
- * Consumer requests data from producer with frequency 10 interests per second
- * (interests contain constantly increasing sequence number).
- *
- * For every received interest, producer replies with a data packet, containing
- * 1024 bytes of virtual payload.
- *
- * To run scenario and see what is happening, use the following command:
- *
- * ./waf --run=ndn-simple-with-pit-count-stats
- */
-
-void
-PeriodicStatsPrinter (Ptr<Node> node, Time next)
-{
- Ptr<ndn::Pit> pit = node->GetObject<ndn::Pit> ();
-
- std::cout << Simulator::Now ().ToDouble (Time::S) << "\t"
- << node->GetId () << "\t"
- << Names::FindName (node) << "\t"
- << pit->GetSize () << "\n";
-
- Simulator::Schedule (next, PeriodicStatsPrinter, node, next);
-}
-
-int
-main (int argc, char *argv[])
-{
- // setting default parameters for PointToPoint links and channels
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- // Creating nodes
- NodeContainer nodes;
- nodes.Create (3);
-
- // Connecting nodes using two links
- PointToPointHelper p2p;
- p2p.Install (nodes.Get (0), nodes.Get (1));
- p2p.Install (nodes.Get (1), nodes.Get (2));
-
- // see more http://www.nsnam.org/doxygen/classns3_1_1_names.html
- Names::Add ("consumer", nodes.Get (0));
- Names::Add ("router", nodes.Get (1));
- Names::Add ("producer", nodes.Get (2));
-
- // Install CCNx stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetDefaultRoutes (true);
- ndnHelper.SetPit ("ns3::ndn::pit::Persistent::AggregateStats");
- ndnHelper.InstallAll ();
-
- // set up periodic PIT stats printer on node 1
- std::cout << "Time" << "\t"
- << "NodeId" << "\t"
- << "NodeName" << "\t"
- << "NumberOfPitEntries" << "\n";
- Simulator::Schedule (Seconds (1), PeriodicStatsPrinter, nodes.Get (0), Seconds (1));
- Simulator::Schedule (Seconds (1), PeriodicStatsPrinter, nodes.Get (1), Seconds (1));
- Simulator::Schedule (Seconds (1), PeriodicStatsPrinter, nodes.Get (2), Seconds (1));
-
- // Installing applications
-
- // Consumer
- ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
- // Consumer will request /prefix/0, /prefix/1, ...
- consumerHelper.SetPrefix ("/prefix");
- consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
- consumerHelper.Install (nodes.Get (0)); // first node
-
- // // Producer
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- // Producer will reply to all requests starting with /prefix
- producerHelper.SetPrefix ("/prefix");
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (nodes.Get (2)); // last node
-
- Simulator::Stop (Seconds (20.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-simple-with-pit-operation-stats.cc b/examples/ndn-simple-with-pit-operation-stats.cc
deleted file mode 100644
index 26c3f8e..0000000
--- a/examples/ndn-simple-with-pit-operation-stats.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2012-2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-// ndn-simple-with-pit-operation-stats.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/ndnSIM-module.h"
-
-#include "ns3/ndnSIM/model/pit/ndn-pit-impl.h"
-#include "ns3/ndnSIM/utils/trie/persistent-policy.h"
-// #include "ns3/ndnSIM/utils/trie/random-policy.h"
-// #include "ns3/ndnSIM/utils/trie/lru-policy.h"
-#include "ns3/ndnSIM/utils/trie/multi-policy.h"
-#include "ns3/ndnSIM/utils/trie/aggregate-stats-policy.h"
-
-using namespace ns3;
-
-/**
- * This scenario simulates a very simple network topology:
- *
- *
- * +----------+ 1Mbps +--------+ 1Mbps +----------+
- * | consumer | <------------> | router | <------------> | producer |
- * +----------+ 10ms +--------+ 10ms +----------+
- *
- *
- * Consumer requests data from producer with frequency 10 interests per second
- * (interests contain constantly increasing sequence number).
- *
- * For every received interest, producer replies with a data packet, containing
- * 1024 bytes of virtual payload.
- *
- * To run scenario and see what is happening, use the following command:
- *
- * ./waf --run=ndn-simple-with-pit-operation-stats
- */
-
-typedef ndn::ndnSIM::multi_policy_traits< boost::mpl::vector2< ndn::ndnSIM::persistent_policy_traits,
- ndn::ndnSIM::aggregate_stats_policy_traits > > PersistentWithCountsTraits;
-// typedef ndn::ndnSIM::multi_policy_traits< boost::mpl::vector2< ndn::ndnSIM::random_policy_traits,
-// ndn::ndnSIM::aggregate_stats_policy_traits > > RandomWithCountsTraits;
-// typedef ndn::ndnSIM::multi_policy_traits< boost::mpl::vector2< ndn::ndnSIM::lru_policy_traits,
-// ndn::ndnSIM::aggregate_stats_policy_traits > > LruWithCountsTraits;
-
-void
-PeriodicStatsPrinter (Ptr<Node> node, Time next)
-{
- if (DynamicCast<ndn::pit::PitImpl<PersistentWithCountsTraits> > (node->GetObject<ndn::Pit> ()) == 0)
- {
- std::cerr << "Invalid PIT class, please correct the scenario" << std::endl;
- return;
- }
-
- // "ns3::ndn::pit::Persistent::AggregateStats"
- ndn::pit::PitImpl<PersistentWithCountsTraits>::super::policy_container &policy =
- DynamicCast<ndn::pit::PitImpl<PersistentWithCountsTraits> > (node->GetObject<ndn::Pit> ())->GetPolicy ();
-
- std::cout << Simulator::Now ().ToDouble (Time::S) << "\t"
- << node->GetId () << "\t"
- << policy.get<1> ().GetUpdates () << "\t"
- << policy.get<1> ().GetInserts () << "\t"
- << policy.get<1> ().GetLookups () << "\t"
- << policy.get<1> ().GetErases () << "\n";
-
- policy.get<1> ().ResetStats ();
-
- Simulator::Schedule (next, PeriodicStatsPrinter, node, next);
-}
-
-int
-main (int argc, char *argv[])
-{
- // setting default parameters for PointToPoint links and channels
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- // Creating nodes
- NodeContainer nodes;
- nodes.Create (3);
-
- // Connecting nodes using two links
- PointToPointHelper p2p;
- p2p.Install (nodes.Get (0), nodes.Get (1));
- p2p.Install (nodes.Get (1), nodes.Get (2));
-
- // Install CCNx stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetDefaultRoutes (true);
- ndnHelper.SetPit ("ns3::ndn::pit::Persistent::AggregateStats");
- ndnHelper.InstallAll ();
-
- // set up periodic PIT stats printer on node 1
- std::cout << "Time" << "\t"
- << "NodeId" << "\t"
- << "Updates" << "\t"
- << "Inserts" << "\t"
- << "Lookups" << "\t"
- << "Erases" << "\n";
- Simulator::Schedule (Seconds (1), PeriodicStatsPrinter, nodes.Get (1), Seconds (1));
-
- // Installing applications
-
- // Consumer
- ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
- // Consumer will request /prefix/0, /prefix/1, ...
- consumerHelper.SetPrefix ("/prefix");
- consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
- consumerHelper.Install (nodes.Get (0)); // first node
-
- // Producer
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- // Producer will reply to all requests starting with /prefix
- producerHelper.SetPrefix ("/prefix");
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (nodes.Get (2)); // last node
-
- Simulator::Stop (Seconds (20.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/ndn-triangle-calculate-routes.cc b/examples/ndn-triangle-calculate-routes.cc
deleted file mode 100644
index 04575c8..0000000
--- a/examples/ndn-triangle-calculate-routes.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-// ndn-triangle-calculate-routes.cc
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/ndnSIM-module.h"
-
-using namespace ns3;
-using namespace std;
-
-int
-main (int argc, char *argv[])
-{
- // setting default parameters for PointToPoint links and channels
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
- CommandLine cmd;
- cmd.Parse (argc, argv);
-
- ofstream file1 ("/tmp/topo1.txt");
- file1 << "router\n\n"
- << "#node city y x mpi-partition\n"
- << "A1 NA 1 1 1\n"
- << "B1 NA 80 -40 1\n"
- << "C1 NA 80 40 1\n"
- << "A2 NA 1 1 1\n"
- << "B2 NA 80 -40 1\n"
- << "C2 NA 80 40 1\n\n"
- << "link\n\n"
- << "# from to capacity metric delay queue\n"
- << "A1 B1 10Mbps 100 1ms 100\n"
- << "A1 C1 10Mbps 50 1ms 100\n"
- << "B1 C1 10Mbps 1 1ms 100\n"
- << "A2 B2 10Mbps 50 1ms 100\n"
- << "A2 C2 10Mbps 100 1ms 100\n"
- << "B2 C2 10Mbps 1 1ms 100\n";
- file1.close ();
-
- AnnotatedTopologyReader topologyReader ("");
- topologyReader.SetFileName ("/tmp/topo1.txt");
- topologyReader.Read ();
-
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.InstallAll ();
-
- topologyReader.ApplyOspfMetric ();
-
- ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
- ndnGlobalRoutingHelper.InstallAll ();
-
- ndnGlobalRoutingHelper.AddOrigins ("/test/prefix", Names::Find<Node> ("C1"));
- ndnGlobalRoutingHelper.AddOrigins ("/test/prefix", Names::Find<Node> ("C2"));
- ndn::GlobalRoutingHelper::CalculateRoutes ();
-
- cout << "FIB content on node A1" << endl;
- Ptr<ndn::Fib> fib = Names::Find<Node> ("A1")->GetObject<ndn::Fib> ();
- for (Ptr<ndn::fib::Entry> entry = fib->Begin (); entry != fib->End (); entry = fib->Next (entry))
- {
- cout << *entry << " (this is towards: ";
- cout << Names::FindName (DynamicCast<const ndn::NetDeviceFace> (entry->FindBestCandidate (0).GetFace ())->GetNetDevice ()->GetChannel ()->GetDevice (1)->GetNode ());
- cout << ")" << endl;
- }
-
- cout << "FIB content on node A2" << endl;
- fib = Names::Find<Node> ("A2")->GetObject<ndn::Fib> ();
- for (Ptr<ndn::fib::Entry> entry = fib->Begin (); entry != fib->End (); entry = fib->Next (entry))
- {
- cout << *entry << " (this is towards: ";
- cout << Names::FindName (DynamicCast<const ndn::NetDeviceFace> (entry->FindBestCandidate (0).GetFace ())->GetNetDevice ()->GetChannel ()->GetDevice (1)->GetNode ());
- cout << ")" << endl;
- }
-
- Simulator::Stop (Seconds (20.0));
- Simulator::Run ();
- Simulator::Destroy ();
-
- return 0;
-}
diff --git a/examples/topologies/topo-grid-3x3-red-queues.txt b/examples/topologies/topo-grid-3x3-red-queues.txt
deleted file mode 100644
index b87a0bf..0000000
--- a/examples/topologies/topo-grid-3x3-red-queues.txt
+++ /dev/null
@@ -1,61 +0,0 @@
-# topo-grid-3x3.txt
-
-# /--------\ /-\ /-\
-# |Consumer|<---->| |<------->| |
-# \--------/ \-/ \-/
-# ^ ^ ^
-# | | | 1Mbps/10ms delay
-# v v v
-# /-\ /-\ /-\
-# | |<-------->| |<------->| |
-# \-/ \-/ \-/
-# ^ ^ ^
-# | | |
-# v v v
-# /-\ /-\ /--------\
-# | |<-------->| |<---->|Producer|
-# \-/ \-/ \--------/
-
-# any empty lines and lines starting with '#' symbol is ignored
-#
-# The file should contain exactly two sections: router and link, each starting with the corresponding keyword
-#
-# router section defines topology nodes and their relative positions (e.g., to use in visualizer)
-router
-
-# each line in this section represents one router and should have the following data
-# node comment yPos xPos
-Node0 NA 3 1
-Node1 NA 3 2
-Node2 NA 3 3
-Node3 NA 2 1
-Node4 NA 2 2
-Node5 NA 2 3
-Node6 NA 1 1
-Node7 NA 1 2
-Node8 NA 1 3
-# Note that `node` can be any string. It is possible to access to the node by name using Names::Find, see examples.
-
-# link section defines point-to-point links between nodes and characteristics of these links
-link
-
-# Each line should be in the following format (only first two are required, the rest can be omitted)
-# srcNode dstNode bandwidth metric delay queue
-# bandwidth: link bandwidth
-# metric: routing metric
-# delay: link delay
-# queue: comma-separated list, specifying class for Queue (on both sides of the link) and necessary attributes
-# error: comma-separated list, specifying class for ErrorModel and necessary attributes
-Node0 Node1 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node0 Node3 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node1 Node2 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node1 Node4 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node2 Node5 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node3 Node4 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node3 Node6 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node4 Node5 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node4 Node7 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node5 Node8 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node6 Node7 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-Node7 Node8 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100
-
diff --git a/helper/ndn-header-helper.cc b/helper/ndn-header-helper.cc
deleted file mode 100644
index edb5af8..0000000
--- a/helper/ndn-header-helper.cc
+++ /dev/null
@@ -1,74 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-header-helper.h"
-
-#include "ns3/log.h"
-#include "ns3/packet.h"
-#include "ns3/header.h"
-#include "ns3/object.h"
-
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-#include <iomanip>
-
-NS_LOG_COMPONENT_DEFINE ("ndn.HeaderHelper");
-
-const uint8_t INTEREST_CCNB_BYTES[] = {0x01, 0xD2};
-const uint8_t CONTENT_OBJECT_CCNB_BYTES[] = {0x04, 0x82};
-
-const uint8_t INTEREST_NDNSIM_BYTES[] = {0x80, 0x00};
-const uint8_t CONTENT_OBJECT_NDNSIM_BYTES[] = {0x80, 0x01};
-
-namespace ns3 {
-namespace ndn {
-
-HeaderHelper::Type
-HeaderHelper::GetNdnHeaderType (Ptr<const Packet> packet)
-{
- uint8_t type[2];
- uint32_t read=packet->CopyData (type,2);
-
- if (read!=2) throw UnknownHeaderException();
-
- NS_LOG_DEBUG (*packet);
- if (type[0] == INTEREST_CCNB_BYTES[0] && type[1] == INTEREST_CCNB_BYTES[1])
- {
- return HeaderHelper::INTEREST_CCNB;
- }
- else if (type[0] == CONTENT_OBJECT_CCNB_BYTES[0] && type[1] == CONTENT_OBJECT_CCNB_BYTES[1])
- {
- return HeaderHelper::CONTENT_OBJECT_CCNB;
- }
- else if (type[0] == INTEREST_NDNSIM_BYTES[0] && type[1] == INTEREST_NDNSIM_BYTES[1])
- {
- return HeaderHelper::INTEREST_NDNSIM;
- }
- else if (type[0] == CONTENT_OBJECT_NDNSIM_BYTES[0] && type[1] == CONTENT_OBJECT_NDNSIM_BYTES[1])
- {
- return HeaderHelper::CONTENT_OBJECT_NDNSIM;
- }
-
- NS_LOG_DEBUG (*packet);
- throw UnknownHeaderException();
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/helper/ndn-header-helper.h b/helper/ndn-header-helper.h
deleted file mode 100644
index 376cdb7..0000000
--- a/helper/ndn-header-helper.h
+++ /dev/null
@@ -1,104 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_HEADER_HELPER_H_
-#define _NDN_HEADER_HELPER_H_
-
-#include "ns3/ptr.h"
-
-namespace ns3 {
-
-class Header;
-class Packet;
-
-namespace ndn {
-
-class Name;
-typedef Name NameComponents;
-
-/**
- * @ingroup ndn-helpers
- *
- * \brief Class implementing functionality to detect Ndn packet type and
- * create the corresponding object
- *
- * Ndn doesn't really have a header, so we need this class to
- * determine type of Ndn packet and return corresponent header class,
- * Interest or Data
- *
- * Throws UnknownHeaderException if header type couldn't be determined
- */
-class HeaderHelper
-{
-public:
- /**
- @brief enum for Ndn packet types
- */
- enum Type {INTEREST_CCNB, CONTENT_OBJECT_CCNB,
- INTEREST_NDNSIM, CONTENT_OBJECT_NDNSIM};
-
- /**
- * Packet ::= Version
- * PacketType
- * (Interest | Data)
- *
- * 0 1
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Version | PacketType |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- * For ccnb-encoding compatibility, ``Version`` / ``PacketType`` has two reserved values to denote ccnb-encoded packet:
- *
- * Version 0x01, PacketType 0xD2 --- ccnb-encoded ``Interest`` packet
- * Version 0x04, PacketType 0x82 --- ccnb-encoded ``Data`` packet
- *
- *
- * It peeks first 2 bytes of a packet.
- *
- * All interests start with
- * +-----------------+ +---+---------+-------+
- * | 0 0 0 0 0 0 0 1 | | 1 | 1 0 1 0 | 0 1 0 | (0x01 0xD2)
- * +-----------------+ +---+---------+-------+
- *
- * All content objects start with
- * +-----------------+ +---+---------+-------+
- * | 0 0 0 0 0 1 0 0 | | 1 | 0 0 0 0 | 0 1 0 | (0x04 0x82)
- * +-----------------+ +---+---------+-------+
- * ^ ^^^^^
- * | |
- * terminator DTAG (Dictionary TAG)
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-
- static Type
- GetNdnHeaderType (Ptr<const Packet> packet);
-};
-
- /**
- * \brief Exception thrown if NDN stack receives unrecognized message type
- */
-class UnknownHeaderException {};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // _NDN_HEADER_HELPER_H_
diff --git a/model/fib/ndn-fib-entry.cc b/model/fib/ndn-fib-entry.cc
deleted file mode 100644
index f05140e..0000000
--- a/model/fib/ndn-fib-entry.cc
+++ /dev/null
@@ -1,209 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-fib-entry.h"
-#include "ndn-fib.h"
-
-#include "ns3/ndn-name.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-
-#define NDN_RTO_ALPHA 0.125
-#define NDN_RTO_BETA 0.25
-#define NDN_RTO_K 4
-
-#include <boost/ref.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-namespace ll = boost::lambda;
-
-NS_LOG_COMPONENT_DEFINE ("ndn.fib.Entry");
-
-namespace ns3 {
-namespace ndn {
-namespace fib {
-
-//////////////////////////////////////////////////////////////////////
-// Helpers
-//////////////////////////////////////////////////////////////////////
-
-struct FaceMetricByFace
-{
- typedef FaceMetricContainer::type::index<i_face>::type
- type;
-};
-
-
-void
-FaceMetric::UpdateRtt (const Time &rttSample)
-{
- // const Time & this->m_rttSample
-
- //update srtt and rttvar (RFC 2988)
- if (m_sRtt.IsZero ())
- {
- //first RTT measurement
- NS_ASSERT_MSG (m_rttVar.IsZero (), "SRTT is zero, but variation is not");
-
- m_sRtt = rttSample;
- m_rttVar = Time (m_sRtt / 2.0);
- }
- else
- {
- m_rttVar = Time ((1 - NDN_RTO_BETA) * m_rttVar + 1.0 * NDN_RTO_BETA * Abs(m_sRtt - rttSample));
- m_sRtt = Time ((1 - NDN_RTO_ALPHA) * m_sRtt + 1.0 * NDN_RTO_ALPHA * rttSample);
- }
-}
-
-/////////////////////////////////////////////////////////////////////
-
-void
-Entry::UpdateFaceRtt (Ptr<Face> face, const Time &sample)
-{
- FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
- if (record == m_faces.get<i_face> ().end ())
- {
- return;
- }
-
- m_faces.modify (record,
- ll::bind (&FaceMetric::UpdateRtt, ll::_1, sample));
-
- // reordering random access index same way as by metric index
- m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
-}
-
-void
-Entry::UpdateStatus (Ptr<Face> face, FaceMetric::Status status)
-{
- NS_LOG_FUNCTION (this << boost::cref(*face) << status);
-
- FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
- if (record == m_faces.get<i_face> ().end ())
- {
- return;
- }
-
- m_faces.modify (record,
- ll::bind (&FaceMetric::SetStatus, ll::_1, status));
-
- // reordering random access index same way as by metric index
- m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
-}
-
-void
-Entry::AddOrUpdateRoutingMetric (Ptr<Face> face, int32_t metric)
-{
- NS_LOG_FUNCTION (this);
- NS_ASSERT_MSG (face != NULL, "Trying to Add or Update NULL face");
-
- FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
- if (record == m_faces.get<i_face> ().end ())
- {
- m_faces.insert (FaceMetric (face, metric));
- }
- else
- {
- // don't update metric to higher value
- if (record->GetRoutingCost () > metric || record->GetStatus () == FaceMetric::NDN_FIB_RED)
- {
- m_faces.modify (record,
- ll::bind (&FaceMetric::SetRoutingCost, ll::_1, metric));
-
- m_faces.modify (record,
- ll::bind (&FaceMetric::SetStatus, ll::_1, FaceMetric::NDN_FIB_YELLOW));
- }
- }
-
- // reordering random access index same way as by metric index
- m_faces.get<i_nth> ().rearrange (m_faces.get<i_metric> ().begin ());
-}
-
-void
-Entry::SetRealDelayToProducer (Ptr<Face> face, Time delay)
-{
- NS_LOG_FUNCTION (this);
- NS_ASSERT_MSG (face != NULL, "Trying to Update NULL face");
-
- FaceMetricByFace::type::iterator record = m_faces.get<i_face> ().find (face);
- if (record != m_faces.get<i_face> ().end ())
- {
- m_faces.modify (record,
- ll::bind (&FaceMetric::SetRealDelay, ll::_1, delay));
- }
-}
-
-
-void
-Entry::Invalidate ()
-{
- for (FaceMetricByFace::type::iterator face = m_faces.begin ();
- face != m_faces.end ();
- face++)
- {
- m_faces.modify (face,
- ll::bind (&FaceMetric::SetRoutingCost, ll::_1, std::numeric_limits<uint16_t>::max ()));
-
- m_faces.modify (face,
- ll::bind (&FaceMetric::SetStatus, ll::_1, FaceMetric::NDN_FIB_RED));
- }
-}
-
-const FaceMetric &
-Entry::FindBestCandidate (uint32_t skip/* = 0*/) const
-{
- if (m_faces.size () == 0) throw Entry::NoFaces ();
- skip = skip % m_faces.size();
- return m_faces.get<i_nth> () [skip];
-}
-
-Ptr<Fib>
-Entry::GetFib ()
-{
- return m_fib;
-}
-
-
-std::ostream& operator<< (std::ostream& os, const Entry &entry)
-{
- for (FaceMetricContainer::type::index<i_nth>::type::iterator metric =
- entry.m_faces.get<i_nth> ().begin ();
- metric != entry.m_faces.get<i_nth> ().end ();
- metric++)
- {
- if (metric != entry.m_faces.get<i_nth> ().begin ())
- os << ", ";
-
- os << *metric;
- }
- return os;
-}
-
-std::ostream& operator<< (std::ostream& os, const FaceMetric &metric)
-{
- static const std::string statusString[] = {"","g","y","r"};
-
- os << *metric.m_face << "(" << metric.m_routingCost << ","<< statusString [metric.m_status] << "," << metric.m_face->GetMetric () << ")";
- return os;
-}
-
-} // namespace fib
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fib/ndn-fib-entry.h b/model/fib/ndn-fib-entry.h
deleted file mode 100644
index 655c0cb..0000000
--- a/model/fib/ndn-fib-entry.h
+++ /dev/null
@@ -1,361 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_FIB_ENTRY_H_
-#define _NDN_FIB_ENTRY_H_
-
-#include "ns3/ptr.h"
-#include "ns3/nstime.h"
-#include "ns3/ndn-face.h"
-#include "ns3/ndn-name.h"
-#include "ns3/ndn-limits.h"
-#include "ns3/traced-value.h"
-
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/tag.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/composite_key.hpp>
-#include <boost/multi_index/hashed_index.hpp>
-#include <boost/multi_index/random_access_index.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/mem_fun.hpp>
-
-namespace ns3 {
-namespace ndn {
-
-class Name;
-typedef Name NameComponents;
-
-class Fib;
-
-/**
- * @ingroup ndn-fib
- * @brief Namespace for FIB operations
- */
-namespace fib {
-
-/**
- * @ingroup ndn-fib
- * \brief Structure holding various parameters associated with a (FibEntry, Face) tuple
- */
-class FaceMetric
-{
-public:
- /**
- * @brief Color codes for FIB face status
- */
- enum Status { NDN_FIB_GREEN = 1,
- NDN_FIB_YELLOW = 2,
- NDN_FIB_RED = 3 };
-public:
- /**
- * \brief Metric constructor
- *
- * \param face Face for which metric
- * \param cost Initial value for routing cost
- */
- FaceMetric (Ptr<Face> face, int32_t cost)
- : m_face (face)
- , m_status (NDN_FIB_YELLOW)
- , m_routingCost (cost)
- , m_sRtt (Seconds (0))
- , m_rttVar (Seconds (0))
- , m_realDelay (Seconds (0))
- { }
-
- /**
- * \brief Comparison operator used by boost::multi_index::identity<>
- */
- bool
- operator< (const FaceMetric &fm) const { return *m_face < *fm.m_face; } // return identity of the face
-
- /**
- * @brief Comparison between FaceMetric and Face
- */
- bool
- operator< (const Ptr<Face> &face) const { return *m_face < *face; }
-
- /**
- * @brief Return Face associated with FaceMetric
- */
- Ptr<Face>
- GetFace () const { return m_face; }
-
- /**
- * \brief Recalculate smoothed RTT and RTT variation
- * \param rttSample RTT sample
- */
- void
- UpdateRtt (const Time &rttSample);
-
- /**
- * @brief Get current status of FIB entry
- */
- Status
- GetStatus () const
- {
- return m_status;
- }
-
- /**
- * @brief Set current status of FIB entry
- */
- void
- SetStatus (Status status)
- {
- m_status.Set (status);
- }
-
- /**
- * @brief Get current routing cost
- */
- int32_t
- GetRoutingCost () const
- {
- return m_routingCost;
- }
-
- /**
- * @brief Set routing cost
- */
- void
- SetRoutingCost (int32_t routingCost)
- {
- m_routingCost = routingCost;
- }
-
- /**
- * @brief Get current estimate for smoothed RTT value
- */
- Time
- GetSRtt () const
- {
- return m_sRtt;
- }
-
- /**
- * @brief Get current estimate for the RTT variation
- */
- Time
- GetRttVar () const
- {
- return m_rttVar;
- }
-
- /**
- * @brief Get real propagation delay to the producer, calculated based on NS-3 p2p link delays
- */
- Time
- GetRealDelay () const
- {
- return m_realDelay;
- }
-
- /**
- * @brief Set real propagation delay to the producer, calculated based on NS-3 p2p link delays
- */
- void
- SetRealDelay (Time realDelay)
- {
- m_realDelay = realDelay;
- }
-
- /**
- * @brief Get direct access to status trace
- */
- TracedValue<Status> &
- GetStatusTrace ()
- {
- return m_status;
- }
-
-private:
- friend std::ostream& operator<< (std::ostream& os, const FaceMetric &metric);
-
-private:
- Ptr<Face> m_face; ///< Face
-
- TracedValue<Status> m_status; ///< \brief Status of the next hop:
- ///< - NDN_FIB_GREEN
- ///< - NDN_FIB_YELLOW
- ///< - NDN_FIB_RED
-
- int32_t m_routingCost; ///< \brief routing protocol cost (interpretation of the value depends on the underlying routing protocol)
-
- Time m_sRtt; ///< \brief smoothed round-trip time
- Time m_rttVar; ///< \brief round-trip time variation
-
- Time m_realDelay; ///< \brief real propagation delay to the producer, calculated based on NS-3 p2p link delays
-};
-
-/// @cond include_hidden
-class i_face {};
-class i_metric {};
-class i_nth {};
-/// @endcond
-
-
-/**
- * @ingroup ndn-fib
- * @brief Typedef for indexed face container of Entry
- *
- * Currently, there are 2 indexes:
- * - by face (used to find record and update metric)
- * - by metric (face ranking)
- * - random access index (for fast lookup on nth face). Order is
- * maintained manually to be equal to the 'by metric' order
- */
-struct FaceMetricContainer
-{
- /// @cond include_hidden
- typedef boost::multi_index::multi_index_container<
- FaceMetric,
- boost::multi_index::indexed_by<
- // For fast access to elements using Face
- boost::multi_index::ordered_unique<
- boost::multi_index::tag<i_face>,
- boost::multi_index::const_mem_fun<FaceMetric,Ptr<Face>,&FaceMetric::GetFace>
- >,
-
- // List of available faces ordered by (status, m_routingCost)
- boost::multi_index::ordered_non_unique<
- boost::multi_index::tag<i_metric>,
- boost::multi_index::composite_key<
- FaceMetric,
- boost::multi_index::const_mem_fun<FaceMetric,FaceMetric::Status,&FaceMetric::GetStatus>,
- boost::multi_index::const_mem_fun<FaceMetric,int32_t,&FaceMetric::GetRoutingCost>
- >
- >,
-
- // To optimize nth candidate selection (sacrifice a little bit space to gain speed)
- boost::multi_index::random_access<
- boost::multi_index::tag<i_nth>
- >
- >
- > type;
- /// @endcond
-};
-
-/**
- * @ingroup ndn-fib
- * \brief Structure for FIB table entry, holding indexed list of
- * available faces and their respective metrics
- */
-class Entry : public Object
-{
-public:
- typedef Entry base_type;
-
-public:
- class NoFaces {}; ///< @brief Exception class for the case when FIB entry is not found
-
- /**
- * \brief Constructor
- * \param prefix smart pointer to the prefix for the FIB entry
- */
- Entry (Ptr<Fib> fib, const Ptr<const Name> &prefix)
- : m_fib (fib)
- , m_prefix (prefix)
- , m_needsProbing (false)
- {
- }
-
- /**
- * \brief Update status of FIB next hop
- * \param status Status to set on the FIB entry
- */
- void UpdateStatus (Ptr<Face> face, FaceMetric::Status status);
-
- /**
- * \brief Add or update routing metric of FIB next hop
- *
- * Initial status of the next hop is set to YELLOW
- */
- void AddOrUpdateRoutingMetric (Ptr<Face> face, int32_t metric);
-
- /**
- * \brief Set real delay to the producer
- */
- void
- SetRealDelayToProducer (Ptr<Face> face, Time delay);
-
- /**
- * @brief Invalidate face
- *
- * Set routing metric on all faces to max and status to RED
- */
- void
- Invalidate ();
-
- /**
- * @brief Update RTT averages for the face
- */
- void
- UpdateFaceRtt (Ptr<Face> face, const Time &sample);
-
- /**
- * \brief Get prefix for the FIB entry
- */
- const Name&
- GetPrefix () const { return *m_prefix; }
-
- /**
- * \brief Find "best route" candidate, skipping `skip' first candidates (modulo # of faces)
- *
- * throws Entry::NoFaces if m_faces.size()==0
- */
- const FaceMetric &
- FindBestCandidate (uint32_t skip = 0) const;
-
- /**
- * @brief Remove record associated with `face`
- */
- void
- RemoveFace (const Ptr<Face> &face)
- {
- m_faces.erase (face);
- }
-
- /**
- * @brief Get pointer to access FIB, to which this entry is added
- */
- Ptr<Fib>
- GetFib ();
-
-private:
- friend std::ostream& operator<< (std::ostream& os, const Entry &entry);
-
-public:
- Ptr<Fib> m_fib; ///< \brief FIB to which entry is added
-
- Ptr<const Name> m_prefix; ///< \brief Prefix of the FIB entry
- FaceMetricContainer::type m_faces; ///< \brief Indexed list of faces
-
- bool m_needsProbing; ///< \brief flag indicating that probing should be performed
-};
-
-std::ostream& operator<< (std::ostream& os, const Entry &entry);
-std::ostream& operator<< (std::ostream& os, const FaceMetric &metric);
-
-} // namespace fib
-} // namespace ndn
-} // namespace ns3
-
-#endif // _NDN_FIB_ENTRY_H_
diff --git a/model/fib/ndn-fib-impl.cc b/model/fib/ndn-fib-impl.cc
deleted file mode 100644
index cef9306..0000000
--- a/model/fib/ndn-fib-impl.cc
+++ /dev/null
@@ -1,329 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-fib-impl.h"
-
-#include "ns3/ndn-face.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-forwarding-strategy.h"
-
-#include "ns3/node.h"
-#include "ns3/assert.h"
-#include "ns3/names.h"
-#include "ns3/log.h"
-
-#include <boost/ref.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-namespace ll = boost::lambda;
-
-NS_LOG_COMPONENT_DEFINE ("ndn.fib.FibImpl");
-
-namespace ns3 {
-namespace ndn {
-namespace fib {
-
-NS_OBJECT_ENSURE_REGISTERED (FibImpl);
-
-TypeId
-FibImpl::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::fib::Default") // cheating ns3 object system
- .SetParent<Fib> ()
- .SetGroupName ("Ndn")
- .AddConstructor<FibImpl> ()
- ;
- return tid;
-}
-
-FibImpl::FibImpl ()
-{
-}
-
-void
-FibImpl::NotifyNewAggregate ()
-{
- Object::NotifyNewAggregate ();
-}
-
-void
-FibImpl::DoDispose (void)
-{
- clear ();
- Object::DoDispose ();
-}
-
-
-Ptr<Entry>
-FibImpl::LongestPrefixMatch (const Interest &interest)
-{
- super::iterator item = super::longest_prefix_match (interest.GetName ());
- // @todo use predicate to search with exclude filters
-
- if (item == super::end ())
- return 0;
- else
- return item->payload ();
-}
-
-Ptr<fib::Entry>
-FibImpl::Find (const Name &prefix)
-{
- super::iterator item = super::find_exact (prefix);
-
- if (item == super::end ())
- return 0;
- else
- return item->payload ();
-}
-
-
-Ptr<Entry>
-FibImpl::Add (const Name &prefix, Ptr<Face> face, int32_t metric)
-{
- return Add (Create<Name> (prefix), face, metric);
-}
-
-Ptr<Entry>
-FibImpl::Add (const Ptr<const Name> &prefix, Ptr<Face> face, int32_t metric)
-{
- NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix) << boost::cref(*face) << metric);
-
- // will add entry if doesn't exists, or just return an iterator to the existing entry
- std::pair< super::iterator, bool > result = super::insert (*prefix, 0);
- if (result.first != super::end ())
- {
- if (result.second)
- {
- Ptr<EntryImpl> newEntry = Create<EntryImpl> (this, prefix);
- newEntry->SetTrie (result.first);
- result.first->set_payload (newEntry);
- }
-
- super::modify (result.first,
- ll::bind (&Entry::AddOrUpdateRoutingMetric, ll::_1, face, metric));
-
- if (result.second)
- {
- // notify forwarding strategy about new FIB entry
- NS_ASSERT (this->GetObject<ForwardingStrategy> () != 0);
- this->GetObject<ForwardingStrategy> ()->DidAddFibEntry (result.first->payload ());
- }
-
- return result.first->payload ();
- }
- else
- return 0;
-}
-
-void
-FibImpl::Remove (const Ptr<const Name> &prefix)
-{
- NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
-
- super::iterator fibEntry = super::find_exact (*prefix);
- if (fibEntry != super::end ())
- {
- // notify forwarding strategy about soon be removed FIB entry
- NS_ASSERT (this->GetObject<ForwardingStrategy> () != 0);
- this->GetObject<ForwardingStrategy> ()->WillRemoveFibEntry (fibEntry->payload ());
-
- super::erase (fibEntry);
- }
- // else do nothing
-}
-
-// void
-// FibImpl::Invalidate (const Ptr<const Name> &prefix)
-// {
-// NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix));
-
-// super::iterator foundItem, lastItem;
-// bool reachLast;
-// boost::tie (foundItem, reachLast, lastItem) = super::getTrie ().find (*prefix);
-
-// if (!reachLast || lastItem->payload () == 0)
-// return; // nothing to invalidate
-
-// super::modify (lastItem,
-// ll::bind (&Entry::Invalidate, ll::_1));
-// }
-
-void
-FibImpl::InvalidateAll ()
-{
- NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId ());
-
- super::parent_trie::recursive_iterator item (super::getTrie ());
- super::parent_trie::recursive_iterator end (0);
- for (; item != end; item++)
- {
- if (item->payload () == 0) continue;
-
- super::modify (&(*item),
- ll::bind (&Entry::Invalidate, ll::_1));
- }
-}
-
-void
-FibImpl::RemoveFace (super::parent_trie &item, Ptr<Face> face)
-{
- if (item.payload () == 0) return;
- NS_LOG_FUNCTION (this);
-
- super::modify (&item,
- ll::bind (&Entry::RemoveFace, ll::_1, face));
-}
-
-void
-FibImpl::RemoveFromAll (Ptr<Face> face)
-{
- NS_LOG_FUNCTION (this);
-
- Ptr<Entry> entry = Begin ();
- while (entry != End ())
- {
- entry->RemoveFace (face);
- if (entry->m_faces.size () == 0)
- {
- Ptr<Entry> nextEntry = Next (entry);
-
- // notify forwarding strategy about soon be removed FIB entry
- NS_ASSERT (this->GetObject<ForwardingStrategy> () != 0);
- this->GetObject<ForwardingStrategy> ()->WillRemoveFibEntry (entry);
-
- super::erase (StaticCast<EntryImpl> (entry)->to_iterator ());
- entry = nextEntry;
- }
- else
- {
- entry = Next (entry);
- }
- }
-}
-
-void
-FibImpl::Print (std::ostream &os) const
-{
- // !!! unordered_set imposes "random" order of item in the same level !!!
- super::parent_trie::const_recursive_iterator item (super::getTrie ());
- super::parent_trie::const_recursive_iterator end (0);
- for (; item != end; item++)
- {
- if (item->payload () == 0) continue;
-
- os << item->payload ()->GetPrefix () << "\t" << *item->payload () << "\n";
- }
-}
-
-uint32_t
-FibImpl::GetSize () const
-{
- return super::getPolicy ().size ();
-}
-
-Ptr<const Entry>
-FibImpl::Begin () const
-{
- super::parent_trie::const_recursive_iterator item (super::getTrie ());
- super::parent_trie::const_recursive_iterator end (0);
- for (; item != end; item++)
- {
- if (item->payload () == 0) continue;
- break;
- }
-
- if (item == end)
- return End ();
- else
- return item->payload ();
-}
-
-Ptr<const Entry>
-FibImpl::End () const
-{
- return 0;
-}
-
-Ptr<const Entry>
-FibImpl::Next (Ptr<const Entry> from) const
-{
- if (from == 0) return 0;
-
- super::parent_trie::const_recursive_iterator item (*StaticCast<const EntryImpl> (from)->to_iterator ());
- super::parent_trie::const_recursive_iterator end (0);
- for (item++; item != end; item++)
- {
- if (item->payload () == 0) continue;
- break;
- }
-
- if (item == end)
- return End ();
- else
- return item->payload ();
-}
-
-Ptr<Entry>
-FibImpl::Begin ()
-{
- super::parent_trie::recursive_iterator item (super::getTrie ());
- super::parent_trie::recursive_iterator end (0);
- for (; item != end; item++)
- {
- if (item->payload () == 0) continue;
- break;
- }
-
- if (item == end)
- return End ();
- else
- return item->payload ();
-}
-
-Ptr<Entry>
-FibImpl::End ()
-{
- return 0;
-}
-
-Ptr<Entry>
-FibImpl::Next (Ptr<Entry> from)
-{
- if (from == 0) return 0;
-
- super::parent_trie::recursive_iterator item (*StaticCast<EntryImpl> (from)->to_iterator ());
- super::parent_trie::recursive_iterator end (0);
- for (item++; item != end; item++)
- {
- if (item->payload () == 0) continue;
- break;
- }
-
- if (item == end)
- return End ();
- else
- return item->payload ();
-}
-
-
-} // namespace fib
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fib/ndn-fib-impl.h b/model/fib/ndn-fib-impl.h
deleted file mode 100644
index b221d48..0000000
--- a/model/fib/ndn-fib-impl.h
+++ /dev/null
@@ -1,155 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_FIB_IMPL_H_
-#define _NDN_FIB_IMPL_H_
-
-#include "ns3/ndn-fib.h"
-#include "ns3/ndn-name.h"
-
-#include "../../utils/trie/trie-with-policy.h"
-#include "../../utils/trie/counting-policy.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fib {
-
-/**
- * @ingroup ndn-fib
- * @brief FIB entry implementation with with additional references to the base container
- */
-class EntryImpl : public Entry
-{
-public:
- typedef ndnSIM::trie_with_policy<
- Name,
- ndnSIM::smart_pointer_payload_traits<EntryImpl>,
- ndnSIM::counting_policy_traits
- > trie;
-
- EntryImpl (Ptr<Fib> fib, const Ptr<const Name> &prefix)
- : Entry (fib, prefix)
- , item_ (0)
- {
- }
-
- void
- SetTrie (trie::iterator item)
- {
- item_ = item;
- }
-
- trie::iterator to_iterator () { return item_; }
- trie::const_iterator to_iterator () const { return item_; }
-
-private:
- trie::iterator item_;
-};
-
-/**
- * @ingroup ndn-fib
- * \brief Class implementing FIB functionality
- */
-class FibImpl : public Fib,
- protected ndnSIM::trie_with_policy< Name,
- ndnSIM::smart_pointer_payload_traits< EntryImpl >,
- ndnSIM::counting_policy_traits >
-{
-public:
- typedef ndnSIM::trie_with_policy< Name,
- ndnSIM::smart_pointer_payload_traits<EntryImpl>,
- ndnSIM::counting_policy_traits > super;
-
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId GetTypeId ();
-
- /**
- * \brief Constructor
- */
- FibImpl ();
-
- virtual Ptr<Entry>
- LongestPrefixMatch (const Interest &interest);
-
- virtual Ptr<fib::Entry>
- Find (const Name &prefix);
-
- virtual Ptr<Entry>
- Add (const Name &prefix, Ptr<Face> face, int32_t metric);
-
- virtual Ptr<Entry>
- Add (const Ptr<const Name> &prefix, Ptr<Face> face, int32_t metric);
-
- virtual void
- Remove (const Ptr<const Name> &prefix);
-
- virtual void
- InvalidateAll ();
-
- virtual void
- RemoveFromAll (Ptr<Face> face);
-
- virtual void
- Print (std::ostream &os) const;
-
- virtual uint32_t
- GetSize () const;
-
- virtual Ptr<const Entry>
- Begin () const;
-
- virtual Ptr<Entry>
- Begin ();
-
- virtual Ptr<const Entry>
- End () const;
-
- virtual Ptr<Entry>
- End ();
-
- virtual Ptr<const Entry>
- Next (Ptr<const Entry> item) const;
-
- virtual Ptr<Entry>
- Next (Ptr<Entry> item);
-
-protected:
- // inherited from Object class
- virtual void NotifyNewAggregate (); ///< @brief Notify when object is aggregated
- virtual void DoDispose (); ///< @brief Perform cleanup
-
-private:
- /**
- * @brief Remove reference to a face from the entry. If entry had only this face, the whole
- * entry will be removed
- */
- void
- RemoveFace (super::parent_trie &item, Ptr<Face> face);
-};
-
-} // namespace fib
-} // namespace ndn
-} // namespace ns3
-
-#endif /* _NDN_FIB_IMPL_H_ */
diff --git a/model/fib/ndn-fib.cc b/model/fib/ndn-fib.cc
deleted file mode 100644
index f63dadf..0000000
--- a/model/fib/ndn-fib.cc
+++ /dev/null
@@ -1,51 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-fib.h"
-
-#include "ns3/node.h"
-#include "ns3/names.h"
-
-namespace ns3 {
-namespace ndn {
-
-TypeId
-Fib::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::Fib") // cheating ns3 object system
- .SetParent<Object> ()
- .SetGroupName ("Ndn")
- ;
- return tid;
-}
-
-std::ostream&
-operator<< (std::ostream& os, const Fib &fib)
-{
- os << "Node " << Names::FindName (fib.GetObject<Node>()) << "\n";
- os << " Dest prefix Interfaces(Costs) \n";
- os << "+-------------+--------------------------------------+\n";
-
- fib.Print (os);
- return os;
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fib/ndn-fib.h b/model/fib/ndn-fib.h
deleted file mode 100644
index f088515..0000000
--- a/model/fib/ndn-fib.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011-2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_FIB_H_
-#define _NDN_FIB_H_
-
-#include "ns3/simple-ref-count.h"
-#include "ns3/node.h"
-
-#include "ns3/ndn-fib-entry.h"
-
-namespace ns3 {
-namespace ndn {
-
-class Interest;
-typedef Interest InterestHeader;
-
-/**
- * @ingroup ndn
- * @defgroup ndn-fib FIB
- */
-
-/**
- * @ingroup ndn-fib
- * @brief Class implementing FIB functionality
- */
-class Fib : public Object
-{
-public:
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId GetTypeId ();
- /**
- * @brief Default constructor
- */
- Fib () {}
-
- /**
- * @brief Virtual destructor
- */
- virtual ~Fib () { };
-
- /**
- * \brief Perform longest prefix match
- *
- * \todo Implement exclude filters
- *
- * \param interest Interest packet header
- * \returns If entry found a valid iterator (Ptr<fib::Entry>) will be returned, otherwise End () (==0)
- */
- virtual Ptr<fib::Entry>
- LongestPrefixMatch (const Interest &interest) = 0;
-
- /**
- * @brief Get FIB entry for the prefix (exact match)
- *
- * @param prefix Name for FIB entry
- * @returns If entry is found, a valid iterator (Ptr<fib::Entry>) will be returned. Otherwise End () (==0)
- */
- virtual Ptr<fib::Entry>
- Find (const Name &prefix) = 0;
-
- /**
- * \brief Add or update FIB entry
- *
- * If the entry exists, metric will be updated. Otherwise, new entry will be created
- *
- * @param name Prefix
- * @param face Forwarding face
- * @param metric Routing metric
- */
- virtual Ptr<fib::Entry>
- Add (const Name &prefix, Ptr<Face> face, int32_t metric) = 0;
-
- /**
- * \brief Add or update FIB entry using smart pointer to prefix
- *
- * If the entry exists, metric will be updated. Otherwise, new entry will be created
- *
- * @param name Smart pointer to prefix
- * @param face Forwarding face
- * @param metric Routing metric
- */
- virtual Ptr<fib::Entry>
- Add (const Ptr<const Name> &prefix, Ptr<Face> face, int32_t metric) = 0;
-
- /**
- * @brief Remove FIB entry
- *
- * ! ATTENTION ! Use with caution. All PIT entries referencing the corresponding FIB entry will become invalid.
- * So, simulation may crash.
- *
- * @param name Smart pointer to prefix
- */
- virtual void
- Remove (const Ptr<const Name> &prefix) = 0;
-
- /**
- * @brief Invalidate all FIB entries
- */
- virtual void
- InvalidateAll () = 0;
-
- /**
- * @brief Remove all references to a face from FIB. If for some enty that face was the only element,
- * this FIB entry will be removed.
- */
- virtual void
- RemoveFromAll (Ptr<Face> face) = 0;
-
- /**
- * @brief Print out entries in FIB
- */
- virtual void
- Print (std::ostream &os) const = 0;
-
- /**
- * @brief Get number of entries in FIB
- */
- virtual uint32_t
- GetSize () const = 0;
-
- /**
- * @brief Return first element of FIB (no order guaranteed)
- */
- virtual Ptr<const fib::Entry>
- Begin () const = 0;
-
- /**
- * @brief Return first element of FIB (no order guaranteed)
- */
- virtual Ptr<fib::Entry>
- Begin () = 0;
-
- /**
- * @brief Return item next after last (no order guaranteed)
- */
- virtual Ptr<const fib::Entry>
- End () const = 0;
-
- /**
- * @brief Return item next after last (no order guaranteed)
- */
- virtual Ptr<fib::Entry>
- End () = 0;
-
- /**
- * @brief Advance the iterator
- */
- virtual Ptr<const fib::Entry>
- Next (Ptr<const fib::Entry>) const = 0;
-
- /**
- * @brief Advance the iterator
- */
- virtual Ptr<fib::Entry>
- Next (Ptr<fib::Entry>) = 0;
-
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
-
- /**
- * @brief Static call to cheat python bindings
- */
- static inline Ptr<Fib>
- GetFib (Ptr<Object> node);
-
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
-
-private:
- Fib (const Fib&) {} ; ///< \brief copy constructor is disabled
-};
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-
-std::ostream& operator<< (std::ostream& os, const Fib &fib);
-
-Ptr<Fib>
-Fib::GetFib (Ptr<Object> node)
-{
- return node->GetObject<Fib> ();
-}
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // _NDN_FIB_H_
diff --git a/model/fw/best-route.cc b/model/fw/best-route.cc
deleted file mode 100644
index f5ab205..0000000
--- a/model/fw/best-route.cc
+++ /dev/null
@@ -1,104 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "best-route.h"
-
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-pit-entry.h"
-
-#include "ns3/assert.h"
-#include "ns3/log.h"
-
-#include <boost/foreach.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-namespace ll = boost::lambda;
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-NS_OBJECT_ENSURE_REGISTERED (BestRoute);
-
-LogComponent BestRoute::g_log = LogComponent (BestRoute::GetLogName ().c_str ());
-
-std::string
-BestRoute::GetLogName ()
-{
- return super::GetLogName ()+".BestRoute";
-}
-
-
-TypeId
-BestRoute::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::fw::BestRoute")
- .SetGroupName ("Ndn")
- .SetParent <super> ()
- .AddConstructor <BestRoute> ()
- ;
- return tid;
-}
-
-BestRoute::BestRoute ()
-{
-}
-
-bool
-BestRoute::DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this << interest->GetName ());
-
- // No real need to call parent's (green-yellow-red's strategy) method, since it is incorporated
- // in the logic of the BestRoute strategy
- //
- // // Try to work out with just green faces
- // bool greenOk = super::DoPropagateInterest (inFace, interest, origPacket, pitEntry);
- // if (greenOk)
- // return true;
-
- int propagatedCount = 0;
-
- BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
- {
- NS_LOG_DEBUG ("Trying " << boost::cref(metricFace));
- if (metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in front
- break;
-
- if (!TrySendOutInterest (inFace, metricFace.GetFace (), interest, pitEntry))
- {
- continue;
- }
-
- propagatedCount++;
- break; // do only once
- }
-
- NS_LOG_INFO ("Propagated to " << propagatedCount << " faces");
- return propagatedCount > 0;
-}
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fw/best-route.h b/model/fw/best-route.h
deleted file mode 100644
index 1939a84..0000000
--- a/model/fw/best-route.h
+++ /dev/null
@@ -1,71 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-
-#ifndef NDNSIM_BEST_ROUTE_H
-#define NDNSIM_BEST_ROUTE_H
-
-#include "green-yellow-red.h"
-#include "ns3/log.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-/**
- * @ingroup ndn-fw
- * @brief Best route strategy
- */
-class BestRoute :
- public GreenYellowRed
-{
-private:
- typedef GreenYellowRed super;
-
-public:
- static TypeId
- GetTypeId ();
-
- /**
- * @brief Helper function to retrieve logging name for the forwarding strategy
- */
- static std::string
- GetLogName ();
-
- /**
- * @brief Default constructor
- */
- BestRoute ();
-
- // from super
- virtual bool
- DoPropagateInterest (Ptr<Face> incomingFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-protected:
- static LogComponent g_log;
-};
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDNSIM_BEST_ROUTE_H
diff --git a/model/fw/flooding.cc b/model/fw/flooding.cc
deleted file mode 100644
index 3d93248..0000000
--- a/model/fw/flooding.cc
+++ /dev/null
@@ -1,96 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "flooding.h"
-
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-pit-entry.h"
-
-#include "ns3/assert.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ns3/boolean.h"
-
-#include <boost/ref.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-namespace ll = boost::lambda;
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-NS_OBJECT_ENSURE_REGISTERED (Flooding);
-
-LogComponent Flooding::g_log = LogComponent (Flooding::GetLogName ().c_str ());
-
-std::string
-Flooding::GetLogName ()
-{
- return super::GetLogName ()+".Flooding";
-}
-
-TypeId Flooding::GetTypeId ()
-{
- static TypeId tid = TypeId ("ns3::ndn::fw::Flooding")
- .SetGroupName ("Ndn")
- .SetParent <Nacks> ()
- .AddConstructor <Flooding> ()
- ;
- return tid;
-}
-
-Flooding::Flooding ()
-{
-}
-
-bool
-Flooding::DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this);
-
- int propagatedCount = 0;
-
- BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
- {
- NS_LOG_DEBUG ("Trying " << boost::cref(metricFace));
- if (metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
- break;
-
- if (!TrySendOutInterest (inFace, metricFace.GetFace (), interest, pitEntry))
- {
- continue;
- }
-
- propagatedCount++;
- }
-
- NS_LOG_INFO ("Propagated to " << propagatedCount << " faces");
- return propagatedCount > 0;
-}
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fw/flooding.h b/model/fw/flooding.h
deleted file mode 100644
index 1aa50b0..0000000
--- a/model/fw/flooding.h
+++ /dev/null
@@ -1,82 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#ifndef NDNSIM_FLOODING_H
-#define NDNSIM_FLOODING_H
-
-#include "nacks.h"
-#include "ns3/log.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-/**
- * @ingroup ndn-fw
- * @brief Simple flooding strategy
- *
- * Interests will be forwarded to all available faces available for a route (FIB entry).
- * If there are no available GREEN or YELLOW faces, interests is dropped.
- *
- * Usage example:
- * @code
- * ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::Flooding");
- * ...
- * ndnHelper.Install (nodes);
- * @endcode
- */
-class Flooding :
- public Nacks
-{
-private:
- typedef Nacks super;
-
-public:
- static TypeId
- GetTypeId ();
-
- /**
- * @brief Helper function to retrieve logging name for the forwarding strategy
- */
- static std::string
- GetLogName ();
-
- /**
- * @brief Default constructor
- */
- Flooding ();
-
-protected:
- // inherited from Nacks/ForwardingStrategy
- virtual bool
- DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
-protected:
- static LogComponent g_log;
-};
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDNSIM_FLOODING
diff --git a/model/fw/green-yellow-red.cc b/model/fw/green-yellow-red.cc
deleted file mode 100644
index a2d4e3c..0000000
--- a/model/fw/green-yellow-red.cc
+++ /dev/null
@@ -1,141 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "green-yellow-red.h"
-
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-pit-entry.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-fib.h"
-#include "ns3/ndn-content-store.h"
-
-#include "ns3/assert.h"
-#include "ns3/ptr.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ns3/boolean.h"
-#include "ns3/string.h"
-
-#include <boost/ref.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-#include <boost/tuple/tuple.hpp>
-namespace ll = boost::lambda;
-
-NS_LOG_COMPONENT_DEFINE ("ndn.fw.GreenYellowRed");
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-NS_OBJECT_ENSURE_REGISTERED (GreenYellowRed);
-
-TypeId
-GreenYellowRed::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::fw::GreenYellowRed")
- .SetGroupName ("Ndn")
- .SetParent<Nacks> ()
-
- ;
- return tid;
-}
-
-bool
-GreenYellowRed::DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this);
- NS_ASSERT_MSG (m_pit != 0, "PIT should be aggregated with forwarding strategy");
-
- int propagatedCount = 0;
-
- BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
- {
- if (metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_RED ||
- metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_YELLOW)
- break; //propagate only to green faces
-
- if (!TrySendOutInterest (inFace, metricFace.GetFace (), interest, pitEntry))
- {
- continue;
- }
-
- propagatedCount++;
- break; // propagate only one interest
- }
-
- return propagatedCount > 0;
-}
-
-void
-GreenYellowRed::WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry)
-{
- if (inFace != 0)
- {
- // Update metric status for the incoming interface in the corresponding FIB entry
- pitEntry->GetFibEntry ()->UpdateStatus (inFace, fib::FaceMetric::NDN_FIB_GREEN);
- }
-
- super::WillSatisfyPendingInterest (inFace, pitEntry);
-}
-
-void
-GreenYellowRed::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_DEBUG ("WillEraseTimedOutPendingInterest for " << pitEntry->GetPrefix ());
-
- for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- face != pitEntry->GetOutgoing ().end ();
- face ++)
- {
- // NS_LOG_DEBUG ("Face: " << face->m_face);
- pitEntry->GetFibEntry ()->UpdateStatus (face->m_face, fib::FaceMetric::NDN_FIB_YELLOW);
- }
-
- super::WillEraseTimedOutPendingInterest (pitEntry);
-}
-
-void
-GreenYellowRed::DidReceiveValidNack (Ptr<Face> inFace,
- uint32_t nackCode,
- Ptr<const Interest> nack,
- Ptr<pit::Entry> pitEntry)
-{
- super::DidReceiveValidNack (inFace, nackCode, nack, pitEntry);
-
- if (inFace != 0 &&
- (nackCode == Interest::NACK_CONGESTION ||
- nackCode == Interest::NACK_GIVEUP_PIT))
- {
- pitEntry->GetFibEntry ()->UpdateStatus (inFace, fib::FaceMetric::NDN_FIB_YELLOW);
- }
-}
-
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fw/green-yellow-red.h b/model/fw/green-yellow-red.h
deleted file mode 100644
index 57f17dd..0000000
--- a/model/fw/green-yellow-red.h
+++ /dev/null
@@ -1,67 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-#ifndef NDNSIM_GREEN_YELLOW_RED_H
-#define NDNSIM_GREEN_YELLOW_RED_H
-
-#include "nacks.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-/**
- * @ingroup ndn-fw
- * @brief Forwarding strategy extensions to track simple link status based on data plane performance
- */
-class GreenYellowRed :
- public Nacks
-{
-public:
- static TypeId
- GetTypeId (void);
-
-protected:
- virtual void
- WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry);
-
- virtual bool
- DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- virtual void
- WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
-
- virtual void
- DidReceiveValidNack (Ptr<Face> incomingFace,
- uint32_t nackCode,
- Ptr<const Interest> nack,
- Ptr<pit::Entry> pitEntry);
-private:
- typedef Nacks super;
-};
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDNSIM_GREEN_YELLOW_RED
diff --git a/model/fw/nacks.cc b/model/fw/nacks.cc
deleted file mode 100644
index b035514..0000000
--- a/model/fw/nacks.cc
+++ /dev/null
@@ -1,188 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "nacks.h"
-
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-pit-entry.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-fib.h"
-#include "ns3/ndn-content-store.h"
-#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
-
-#include "ns3/assert.h"
-#include "ns3/ptr.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ns3/boolean.h"
-#include "ns3/string.h"
-
-#include <boost/ref.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-#include <boost/tuple/tuple.hpp>
-namespace ll = boost::lambda;
-
-NS_LOG_COMPONENT_DEFINE ("ndn.fw.Nacks");
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-NS_OBJECT_ENSURE_REGISTERED (Nacks);
-
-TypeId
-Nacks::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::fw::Nacks")
- .SetGroupName ("Ndn")
- .SetParent<ForwardingStrategy> ()
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- .AddTraceSource ("OutNacks", "OutNacks", MakeTraceSourceAccessor (&Nacks::m_outNacks))
- .AddTraceSource ("InNacks", "InNacks", MakeTraceSourceAccessor (&Nacks::m_inNacks))
- .AddTraceSource ("DropNacks", "DropNacks", MakeTraceSourceAccessor (&Nacks::m_dropNacks))
-
- .AddAttribute ("EnableNACKs", "Enabling support of NACKs",
- BooleanValue (false),
- MakeBooleanAccessor (&Nacks::m_nacksEnabled),
- MakeBooleanChecker ())
- ;
- return tid;
-}
-
-void
-Nacks::OnInterest (Ptr<Face> inFace,
- Ptr<Interest> interest)
-{
- if (interest->GetNack () > 0)
- OnNack (inFace, interest);
- else
- super::OnInterest (inFace, interest);
-}
-
-void
-Nacks::OnNack (Ptr<Face> inFace,
- Ptr<Interest> nack)
-{
- // NS_LOG_FUNCTION (inFace << nack->GetName ());
- m_inNacks (nack, inFace);
-
- Ptr<pit::Entry> pitEntry = m_pit->Lookup (*nack);
- if (pitEntry == 0)
- {
- // somebody is doing something bad
- m_dropNacks (nack, inFace);
- return;
- }
-
- DidReceiveValidNack (inFace, nack->GetNack (), nack, pitEntry);
-}
-
-void
-Nacks::DidReceiveDuplicateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- super::DidReceiveDuplicateInterest (inFace, interest, pitEntry);
-
- if (m_nacksEnabled)
- {
- NS_LOG_DEBUG ("Sending NACK_LOOP");
- Ptr<Interest> nack = Create<Interest> (*interest);
- nack->SetNack (Interest::NACK_LOOP);
-
- inFace->SendInterest (nack);
- m_outNacks (nack, inFace);
- }
-}
-
-void
-Nacks::DidExhaustForwardingOptions (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- if (m_nacksEnabled)
- {
- Ptr<Interest> nack = Create<Interest> (*interest);
- nack->SetNack (Interest::NACK_GIVEUP_PIT);
-
- BOOST_FOREACH (const pit::IncomingFace &incoming, pitEntry->GetIncoming ())
- {
- NS_LOG_DEBUG ("Send NACK for " << boost::cref (nack->GetName ()) << " to " << boost::cref (*incoming.m_face));
- incoming.m_face->SendInterest (nack);
- m_outNacks (nack, incoming.m_face);
- }
-
- pitEntry->ClearOutgoing (); // to force erasure of the record
- }
-
- super::DidExhaustForwardingOptions (inFace, interest, pitEntry);
-}
-
-void
-Nacks::DidReceiveValidNack (Ptr<Face> inFace,
- uint32_t nackCode,
- Ptr<const Interest> nack,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_DEBUG ("nackCode: " << nackCode << " for [" << nack->GetName () << "]");
-
- // If NACK is NACK_GIVEUP_PIT, then neighbor gave up trying to and removed it's PIT entry.
- // So, if we had an incoming entry to this neighbor, then we can remove it now
- if (nackCode == Interest::NACK_GIVEUP_PIT)
- {
- pitEntry->RemoveIncoming (inFace);
- }
-
- if (nackCode == Interest::NACK_LOOP ||
- nackCode == Interest::NACK_CONGESTION ||
- nackCode == Interest::NACK_GIVEUP_PIT)
- {
- pitEntry->SetWaitingInVain (inFace);
-
- if (!pitEntry->AreAllOutgoingInVain ()) // not all ougtoing are in vain
- {
- NS_LOG_DEBUG ("Not all outgoing are in vain");
- // suppress
- // Don't do anything, we are still expecting data from some other face
- m_dropNacks (nack, inFace);
- return;
- }
-
- Ptr<Interest> interest = Create<Interest> (*nack);
- interest->SetNack (Interest::NORMAL_INTEREST);
-
- bool propagated = DoPropagateInterest (inFace, interest, pitEntry);
- if (!propagated)
- {
- DidExhaustForwardingOptions (inFace, interest, pitEntry);
- }
- }
-}
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fw/nacks.h b/model/fw/nacks.h
deleted file mode 100644
index f9f8bb1..0000000
--- a/model/fw/nacks.h
+++ /dev/null
@@ -1,88 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-#ifndef NDNSIM_NACKS_H
-#define NDNSIM_NACKS_H
-
-#include "ns3/ndn-forwarding-strategy.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-/**
- * @ingroup ndn-fw
- * @brief Implementation of experimental NACK messages (enables with EnableNACKs option)
- */
-class Nacks :
- public ForwardingStrategy
-{
-private:
- typedef ForwardingStrategy super;
-
-public:
- static TypeId
- GetTypeId ();
-
- // from super
- virtual void
- OnInterest (Ptr<Face> face,
- Ptr<Interest> interest);
-
-protected:
- // from super
- virtual void
- DidReceiveDuplicateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- // from super
- virtual void
- DidExhaustForwardingOptions (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- virtual void
- OnNack (Ptr<Face> inFace,
- Ptr<Interest> nack);
-
- virtual void
- DidReceiveValidNack (Ptr<Face> inFace,
- uint32_t nackCode,
- Ptr<const Interest> nack,
- Ptr<pit::Entry> pitEntry);
-
-protected:
- bool m_nacksEnabled;
-
- TracedCallback<Ptr<const Interest>,
- Ptr<const Face> > m_outNacks; ///< @brief trace of outgoing NACKs
-
- TracedCallback<Ptr<const Interest>,
- Ptr<const Face> > m_inNacks; ///< @brief trace of incoming NACKs
-
- TracedCallback<Ptr<const Interest>,
- Ptr<const Face> > m_dropNacks; ///< @brief trace of dropped NACKs
-};
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDNSIM_NACKS
diff --git a/model/fw/ndn-forwarding-strategy.cc b/model/fw/ndn-forwarding-strategy.cc
deleted file mode 100644
index 690e3d2..0000000
--- a/model/fw/ndn-forwarding-strategy.cc
+++ /dev/null
@@ -1,597 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "ndn-forwarding-strategy.h"
-
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-pit-entry.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-fib.h"
-#include "ns3/ndn-content-store.h"
-#include "ns3/ndn-face.h"
-
-#include "ns3/assert.h"
-#include "ns3/ptr.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ns3/boolean.h"
-#include "ns3/string.h"
-
-#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
-
-#include <boost/ref.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-#include <boost/tuple/tuple.hpp>
-namespace ll = boost::lambda;
-
-namespace ns3 {
-namespace ndn {
-
-NS_OBJECT_ENSURE_REGISTERED (ForwardingStrategy);
-
-NS_LOG_COMPONENT_DEFINE (ForwardingStrategy::GetLogName ().c_str ());
-
-std::string
-ForwardingStrategy::GetLogName ()
-{
- return "ndn.fw";
-}
-
-TypeId ForwardingStrategy::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::ForwardingStrategy")
- .SetGroupName ("Ndn")
- .SetParent<Object> ()
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- .AddTraceSource ("OutInterests", "OutInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_outInterests))
- .AddTraceSource ("InInterests", "InInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_inInterests))
- .AddTraceSource ("DropInterests", "DropInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_dropInterests))
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- .AddTraceSource ("OutData", "OutData", MakeTraceSourceAccessor (&ForwardingStrategy::m_outData))
- .AddTraceSource ("InData", "InData", MakeTraceSourceAccessor (&ForwardingStrategy::m_inData))
- .AddTraceSource ("DropData", "DropData", MakeTraceSourceAccessor (&ForwardingStrategy::m_dropData))
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- .AddTraceSource ("SatisfiedInterests", "SatisfiedInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_satisfiedInterests))
- .AddTraceSource ("TimedOutInterests", "TimedOutInterests", MakeTraceSourceAccessor (&ForwardingStrategy::m_timedOutInterests))
-
- .AddAttribute ("CacheUnsolicitedDataFromApps", "Cache unsolicited data that has been pushed from applications",
- BooleanValue (true),
- MakeBooleanAccessor (&ForwardingStrategy::m_cacheUnsolicitedDataFromApps),
- MakeBooleanChecker ())
-
- .AddAttribute ("CacheUnsolicitedData", "Cache overheard data that have not been requested",
- BooleanValue (false),
- MakeBooleanAccessor (&ForwardingStrategy::m_cacheUnsolicitedData),
- MakeBooleanChecker ())
-
- .AddAttribute ("DetectRetransmissions", "If non-duplicate interest is received on the same face more than once, "
- "it is considered a retransmission",
- BooleanValue (true),
- MakeBooleanAccessor (&ForwardingStrategy::m_detectRetransmissions),
- MakeBooleanChecker ())
- ;
- return tid;
-}
-
-ForwardingStrategy::ForwardingStrategy ()
-{
-}
-
-ForwardingStrategy::~ForwardingStrategy ()
-{
-}
-
-void
-ForwardingStrategy::NotifyNewAggregate ()
-{
- if (m_pit == 0)
- {
- m_pit = GetObject<Pit> ();
- }
- if (m_fib == 0)
- {
- m_fib = GetObject<Fib> ();
- }
- if (m_contentStore == 0)
- {
- m_contentStore = GetObject<ContentStore> ();
- }
-
- Object::NotifyNewAggregate ();
-}
-
-void
-ForwardingStrategy::DoDispose ()
-{
- m_pit = 0;
- m_contentStore = 0;
- m_fib = 0;
-
- Object::DoDispose ();
-}
-
-void
-ForwardingStrategy::OnInterest (Ptr<Face> inFace,
- Ptr<Interest> interest)
-{
- NS_LOG_FUNCTION (inFace << interest->GetName ());
- m_inInterests (interest, inFace);
-
- Ptr<pit::Entry> pitEntry = m_pit->Lookup (*interest);
- bool similarInterest = true;
- if (pitEntry == 0)
- {
- similarInterest = false;
- pitEntry = m_pit->Create (interest);
- if (pitEntry != 0)
- {
- DidCreatePitEntry (inFace, interest, pitEntry);
- }
- else
- {
- FailedToCreatePitEntry (inFace, interest);
- return;
- }
- }
-
- bool isDuplicated = true;
- if (!pitEntry->IsNonceSeen (interest->GetNonce ()))
- {
- pitEntry->AddSeenNonce (interest->GetNonce ());
- isDuplicated = false;
- }
-
- if (isDuplicated)
- {
- DidReceiveDuplicateInterest (inFace, interest, pitEntry);
- return;
- }
-
- Ptr<Data> contentObject;
- contentObject = m_contentStore->Lookup (interest);
- if (contentObject != 0)
- {
- FwHopCountTag hopCountTag;
- if (interest->GetPayload ()->PeekPacketTag (hopCountTag))
- {
- contentObject->GetPayload ()->AddPacketTag (hopCountTag);
- }
-
- pitEntry->AddIncoming (inFace/*, Seconds (1.0)*/);
-
- // Do data plane performance measurements
- WillSatisfyPendingInterest (0, pitEntry);
-
- // Actually satisfy pending interest
- SatisfyPendingInterest (0, contentObject, pitEntry);
- return;
- }
-
- if (similarInterest && ShouldSuppressIncomingInterest (inFace, interest, pitEntry))
- {
- pitEntry->AddIncoming (inFace/*, interest->GetInterestLifetime ()*/);
- // update PIT entry lifetime
- pitEntry->UpdateLifetime (interest->GetInterestLifetime ());
-
- // Suppress this interest if we're still expecting data from some other face
- NS_LOG_DEBUG ("Suppress interests");
- m_dropInterests (interest, inFace);
-
- DidSuppressSimilarInterest (inFace, interest, pitEntry);
- return;
- }
-
- if (similarInterest)
- {
- DidForwardSimilarInterest (inFace, interest, pitEntry);
- }
-
- PropagateInterest (inFace, interest, pitEntry);
-}
-
-void
-ForwardingStrategy::OnData (Ptr<Face> inFace,
- Ptr<Data> data)
-{
- NS_LOG_FUNCTION (inFace << data->GetName ());
- m_inData (data, inFace);
-
- // Lookup PIT entry
- Ptr<pit::Entry> pitEntry = m_pit->Lookup (*data);
- if (pitEntry == 0)
- {
- bool cached = false;
-
- if (m_cacheUnsolicitedData || (m_cacheUnsolicitedDataFromApps && (inFace->GetFlags () & Face::APPLICATION)))
- {
- // Optimistically add or update entry in the content store
- cached = m_contentStore->Add (data);
- }
- else
- {
- // Drop data packet if PIT entry is not found
- // (unsolicited data packets should not "poison" content store)
-
- //drop dulicated or not requested data packet
- m_dropData (data, inFace);
- }
-
- DidReceiveUnsolicitedData (inFace, data, cached);
- return;
- }
- else
- {
- bool cached = m_contentStore->Add (data);
- DidReceiveSolicitedData (inFace, data, cached);
- }
-
- while (pitEntry != 0)
- {
- // Do data plane performance measurements
- WillSatisfyPendingInterest (inFace, pitEntry);
-
- // Actually satisfy pending interest
- SatisfyPendingInterest (inFace, data, pitEntry);
-
- // Lookup another PIT entry
- pitEntry = m_pit->Lookup (*data);
- }
-}
-
-void
-ForwardingStrategy::DidCreatePitEntry (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntrypitEntry)
-{
-}
-
-void
-ForwardingStrategy::FailedToCreatePitEntry (Ptr<Face> inFace,
- Ptr<const Interest> interest)
-{
- m_dropInterests (interest, inFace);
-}
-
-void
-ForwardingStrategy::DidReceiveDuplicateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- /////////////////////////////////////////////////////////////////////////////////////////
- // //
- // !!!! IMPORTANT CHANGE !!!! Duplicate interests will create incoming face entry !!!! //
- // //
- /////////////////////////////////////////////////////////////////////////////////////////
- pitEntry->AddIncoming (inFace);
- m_dropInterests (interest, inFace);
-}
-
-void
-ForwardingStrategy::DidSuppressSimilarInterest (Ptr<Face> face,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
-}
-
-void
-ForwardingStrategy::DidForwardSimilarInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
-}
-
-void
-ForwardingStrategy::DidExhaustForwardingOptions (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this << boost::cref (*inFace));
- if (pitEntry->AreAllOutgoingInVain ())
- {
- m_dropInterests (interest, inFace);
-
- // All incoming interests cannot be satisfied. Remove them
- pitEntry->ClearIncoming ();
-
- // Remove also outgoing
- pitEntry->ClearOutgoing ();
-
- // Set pruning timout on PIT entry (instead of deleting the record)
- m_pit->MarkErased (pitEntry);
- }
-}
-
-
-
-bool
-ForwardingStrategy::DetectRetransmittedInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- pit::Entry::in_iterator existingInFace = pitEntry->GetIncoming ().find (inFace);
-
- bool isRetransmitted = false;
-
- if (existingInFace != pitEntry->GetIncoming ().end ())
- {
- // this is almost definitely a retransmission. But should we trust the user on that?
- isRetransmitted = true;
- }
-
- return isRetransmitted;
-}
-
-void
-ForwardingStrategy::SatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<const Data> data,
- Ptr<pit::Entry> pitEntry)
-{
- if (inFace != 0)
- pitEntry->RemoveIncoming (inFace);
-
- //satisfy all pending incoming Interests
- BOOST_FOREACH (const pit::IncomingFace &incoming, pitEntry->GetIncoming ())
- {
- bool ok = incoming.m_face->SendData (data);
-
- DidSendOutData (inFace, incoming.m_face, data, pitEntry);
- NS_LOG_DEBUG ("Satisfy " << *incoming.m_face);
-
- if (!ok)
- {
- m_dropData (data, incoming.m_face);
- NS_LOG_DEBUG ("Cannot satisfy data to " << *incoming.m_face);
- }
- }
-
- // All incoming interests are satisfied. Remove them
- pitEntry->ClearIncoming ();
-
- // Remove all outgoing faces
- pitEntry->ClearOutgoing ();
-
- // Set pruning timout on PIT entry (instead of deleting the record)
- m_pit->MarkErased (pitEntry);
-}
-
-void
-ForwardingStrategy::DidReceiveSolicitedData (Ptr<Face> inFace,
- Ptr<const Data> data,
- bool didCreateCacheEntry)
-{
- // do nothing
-}
-
-void
-ForwardingStrategy::DidReceiveUnsolicitedData (Ptr<Face> inFace,
- Ptr<const Data> data,
- bool didCreateCacheEntry)
-{
- // do nothing
-}
-
-void
-ForwardingStrategy::WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry)
-{
- pit::Entry::out_iterator out = pitEntry->GetOutgoing ().find (inFace);
-
- // If we have sent interest for this data via this face, then update stats.
- if (out != pitEntry->GetOutgoing ().end ())
- {
- pitEntry->GetFibEntry ()->UpdateFaceRtt (inFace, Simulator::Now () - out->m_sendTime);
- }
-
- m_satisfiedInterests (pitEntry);
-}
-
-bool
-ForwardingStrategy::ShouldSuppressIncomingInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- bool isNew = pitEntry->GetIncoming ().size () == 0 && pitEntry->GetOutgoing ().size () == 0;
-
- if (isNew) return false; // never suppress new interests
-
- bool isRetransmitted = m_detectRetransmissions && // a small guard
- DetectRetransmittedInterest (inFace, interest, pitEntry);
-
- if (pitEntry->GetOutgoing ().find (inFace) != pitEntry->GetOutgoing ().end ())
- {
- NS_LOG_DEBUG ("Non duplicate interests from the face we have sent interest to. Don't suppress");
- // got a non-duplicate interest from the face we have sent interest to
- // Probably, there is no point in waiting data from that face... Not sure yet
-
- // If we're expecting data from the interface we got the interest from ("producer" asks us for "his own" data)
- // Mark interface YELLOW, but keep a small hope that data will come eventually.
-
- // ?? not sure if we need to do that ?? ...
-
- // pitEntry->GetFibEntry ()->UpdateStatus (inFace, fib::FaceMetric::NDN_FIB_YELLOW);
- }
- else
- if (!isNew && !isRetransmitted)
- {
- return true;
- }
-
- return false;
-}
-
-void
-ForwardingStrategy::PropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- bool isRetransmitted = m_detectRetransmissions && // a small guard
- DetectRetransmittedInterest (inFace, interest, pitEntry);
-
- pitEntry->AddIncoming (inFace/*, interest->GetInterestLifetime ()*/);
- /// @todo Make lifetime per incoming interface
- pitEntry->UpdateLifetime (interest->GetInterestLifetime ());
-
- bool propagated = DoPropagateInterest (inFace, interest, pitEntry);
-
- if (!propagated && isRetransmitted) //give another chance if retransmitted
- {
- // increase max number of allowed retransmissions
- pitEntry->IncreaseAllowedRetxCount ();
-
- // try again
- propagated = DoPropagateInterest (inFace, interest, pitEntry);
- }
-
- // if (!propagated)
- // {
- // NS_LOG_DEBUG ("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- // NS_LOG_DEBUG ("+++ Not propagated ["<< interest->GetName () <<"], but number of outgoing faces: " << pitEntry->GetOutgoing ().size ());
- // NS_LOG_DEBUG ("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- // }
-
- // ForwardingStrategy will try its best to forward packet to at least one interface.
- // If no interests was propagated, then there is not other option for forwarding or
- // ForwardingStrategy failed to find it.
- if (!propagated && pitEntry->AreAllOutgoingInVain ())
- {
- DidExhaustForwardingOptions (inFace, interest, pitEntry);
- }
-}
-
-bool
-ForwardingStrategy::CanSendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- if (outFace == inFace)
- {
- // NS_LOG_DEBUG ("Same as incoming");
- return false; // same face as incoming, don't forward
- }
-
- pit::Entry::out_iterator outgoing =
- pitEntry->GetOutgoing ().find (outFace);
-
- if (outgoing != pitEntry->GetOutgoing ().end ())
- {
- if (!m_detectRetransmissions)
- return false; // suppress
- else if (outgoing->m_retxCount >= pitEntry->GetMaxRetxCount ())
- {
- // NS_LOG_DEBUG ("Already forwarded before during this retransmission cycle (" <<outgoing->m_retxCount << " >= " << pitEntry->GetMaxRetxCount () << ")");
- return false; // already forwarded before during this retransmission cycle
- }
- }
-
- return true;
-}
-
-
-bool
-ForwardingStrategy::TrySendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- if (!CanSendOutInterest (inFace, outFace, interest, pitEntry))
- {
- return false;
- }
-
- pitEntry->AddOutgoing (outFace);
-
- //transmission
- bool successSend = outFace->SendInterest (interest);
- if (!successSend)
- {
- m_dropInterests (interest, outFace);
- }
-
- DidSendOutInterest (inFace, outFace, interest, pitEntry);
-
- return true;
-}
-
-void
-ForwardingStrategy::DidSendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- m_outInterests (interest, outFace);
-}
-
-void
-ForwardingStrategy::DidSendOutData (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Data> data,
- Ptr<pit::Entry> pitEntry)
-{
- m_outData (data, inFace == 0, outFace);
-}
-
-void
-ForwardingStrategy::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
-{
- m_timedOutInterests (pitEntry);
-}
-
-void
-ForwardingStrategy::AddFace (Ptr<Face> face)
-{
- // do nothing here
-}
-
-void
-ForwardingStrategy::RemoveFace (Ptr<Face> face)
-{
- // do nothing here
-}
-
-void
-ForwardingStrategy::DidAddFibEntry (Ptr<fib::Entry> fibEntry)
-{
- // do nothing here
-}
-
-void
-ForwardingStrategy::WillRemoveFibEntry (Ptr<fib::Entry> fibEntry)
-{
- // do nothing here
-}
-
-
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fw/ndn-forwarding-strategy.h b/model/fw/ndn-forwarding-strategy.h
deleted file mode 100644
index 05078d6..0000000
--- a/model/fw/ndn-forwarding-strategy.h
+++ /dev/null
@@ -1,479 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_FORWARDING_STRATEGY_H
-#define NDN_FORWARDING_STRATEGY_H
-
-#include "ns3/packet.h"
-#include "ns3/callback.h"
-#include "ns3/object.h"
-#include "ns3/traced-callback.h"
-
-namespace ns3 {
-namespace ndn {
-
-/**
- * @ingroup ndn
- * @defgroup ndn-fw NDN forwarding strategies
- */
-
-
-/**
- * @ingroup ndn-fw
- * @brief Namespace for Forwarding Strategy operations
- */
-namespace fw {
-}
-
-class Face;
-
-class Interest;
-class Data;
-
-class Pit;
-namespace pit { class Entry; }
-class FibFaceMetric;
-class Fib;
-namespace fib { class Entry; }
-class ContentStore;
-
-/**
- * @ingroup ndn-fw
- * @brief Abstract base class for Ndn forwarding strategies
- */
-class ForwardingStrategy :
- public Object
-{
-public:
- static TypeId GetTypeId ();
-
- /**
- * @brief Helper function to retrieve logging name for the forwarding strategy
- */
- static std::string GetLogName ();
-
- /**
- * @brief Default constructor
- */
- ForwardingStrategy ();
- virtual ~ForwardingStrategy ();
-
- /**
- * \brief Actual processing of incoming Ndn interests. Note, interests do not have payload
- *
- * Processing Interest packets
- * @param face incoming face
- * @param interest Interest packet
- */
- virtual void
- OnInterest (Ptr<Face> face,
- Ptr<Interest> interest);
-
- /**
- * \brief Actual processing of incoming Ndn content objects
- *
- * Processing Data packets
- * @param face incoming face
- * @param data Data packet
- */
- virtual void
- OnData (Ptr<Face> face,
- Ptr<Data> data);
-
- /**
- * @brief Event fired just before PIT entry is removed by timeout
- * @param pitEntry PIT entry to be removed
- */
- virtual void
- WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Event fired every time face is added to NDN stack
- * @param face face to be removed
- */
- virtual void
- AddFace (Ptr<Face> face);
-
- /**
- * @brief Event fired every time face is removed from NDN stack
- * @param face face to be removed
- *
- * For example, when an application terminates, AppFace is removed and this method called by NDN stack.
- */
- virtual void
- RemoveFace (Ptr<Face> face);
-
- /**
- * @brief Event fired every time a FIB entry is added to FIB
- * @param fibEntry FIB entry that was added
- */
- virtual void
- DidAddFibEntry (Ptr<fib::Entry> fibEntry);
-
- /**
- * @brief Fired just before FIB entry will be removed from FIB
- * @param fibEntry FIB entry that will be removed
- */
- virtual void
- WillRemoveFibEntry (Ptr<fib::Entry> fibEntry);
-
-protected:
- /**
- * @brief An event that is fired every time a new PIT entry is created
- *
- * Note that if NDN node is receiving a similar interest (interest for the same name),
- * then either DidReceiveDuplicateInterest, DidSuppressSimilarInterest, or DidForwardSimilarInterest
- * will be called
- *
- * Suppression of similar Interests is controlled using ShouldSuppressIncomingInterest virtual method
- *
- * @param inFace incoming face
- * @param header deserialized Interest header
- * @param pitEntry created PIT entry (incoming and outgoing face sets are empty)
- *
- * @see DidReceiveDuplicateInterest, DidSuppressSimilarInterest, DidForwardSimilarInterest, ShouldSuppressIncomingInterest
- */
- virtual void
- DidCreatePitEntry (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief An event that is fired every time a new PIT entry cannot be created (e.g., PIT container imposes a limit)
- *
- * Note that this call can be called only for non-similar Interest (i.e., there is an attempt to create a new PIT entry).
- * For any non-similar Interests, either FailedToCreatePitEntry or DidCreatePitEntry is called.
- *
- * @param inFace incoming face
- * @param interest Interest packet
- */
- virtual void
- FailedToCreatePitEntry (Ptr<Face> inFace,
- Ptr<const Interest> interest);
-
- /**
- * @brief An event that is fired every time a duplicated Interest is received
- *
- * This even is the last action that is performed before the Interest processing is halted
- *
- * @param inFace incoming face
- * @param interest Interest packet
- * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
- *
- * @see DidReceiveDuplicateInterest, DidSuppressSimilarInterest, DidForwardSimilarInterest, ShouldSuppressIncomingInterest
- */
- virtual void
- DidReceiveDuplicateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief An event that is fired every time when a similar Interest is received and suppressed (collapsed)
- *
- * This even is the last action that is performed before the Interest processing is halted
- *
- * @param inFace incoming face
- * @param interest Interest packet
- * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
- *
- * @see DidReceiveDuplicateInterest, DidForwardSimilarInterest, ShouldSuppressIncomingInterest
- */
- virtual void
- DidSuppressSimilarInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief An event that is fired every time when a similar Interest is received and further forwarded (not suppressed/collapsed)
- *
- * This even is fired just before handling the Interest to PropagateInterest method
- *
- * @param inFace incoming face
- * @param interest Interest packet
- * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
- *
- * @see DidReceiveDuplicateInterest, DidSuppressSimilarInterest, ShouldSuppressIncomingInterest
- */
- virtual void
- DidForwardSimilarInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief An even that is fired when Interest cannot be forwarded
- *
- * Note that the event will not fire if retransmission detection is enabled (by default)
- * and retransmitted Interest cannot by forwarded. For more details, refer to the implementation.
- *
- * @param inFace incoming face
- * @param interest Interest header
- * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
- *
- * @see DetectRetransmittedInterest
- */
- virtual void
- DidExhaustForwardingOptions (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Method that implements logic to distinguish between new and retransmitted interest
- *
- * This method is called only when DetectRetransmissions attribute is set true (by default).
- *
- * Currently, the retransmission detection logic relies on the fact that list of incoming faces
- * already has inFace (i.e., a similar interest is received on the same face more than once).
- *
- * @param inFace incoming face
- * @param interest Interest header
- * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
- * @return true if Interest should be considered as retransmitted
- */
- virtual bool
- DetectRetransmittedInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Even fired just before Interest will be satisfied
- *
- * Note that when Interest is satisfied from the cache, incoming face will be 0
- *
- * @param inFace incoming face
- * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
- */
- virtual void
- WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Actual procedure to satisfy Interest
- *
- * Note that when Interest is satisfied from the cache, incoming face will be 0
- *
- * @param inFace incoming face
- * @param data Data packet
- * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
- */
- virtual void
- SatisfyPendingInterest (Ptr<Face> inFace, // 0 allowed (from cache)
- Ptr<const Data> data,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Event which is fired just after data was send out on the face
- *
- * @param inFace incoming face of the Data
- * @param outFace outgoing face
- * @param data Data packet
- * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
- */
- virtual void
- DidSendOutData (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Data> data,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Event which is fired every time a requested (solicited) DATA packet (there is an active PIT entry) is received
- *
- * @param inFace incoming face
- * @param data Data packet
- * @param didCreateCacheEntry flag indicating whether a cache entry was added for this data packet or not (e.g., packet already exists in cache)
- */
- virtual void
- DidReceiveSolicitedData (Ptr<Face> inFace,
- Ptr<const Data> data,
- bool didCreateCacheEntry);
-
- /**
- * @brief Event which is fired every time an unsolicited DATA packet (no active PIT entry) is received
- *
- * The current implementation allows ignoring unsolicited DATA (by default), or cache it by setting
- * attribute CacheUnsolicitedData true
- *
- * @param inFace incoming face
- * @param data Data packet
- * @param didCreateCacheEntry flag indicating whether a cache entry was added for this data packet or not (e.g., packet already exists in cache)
- */
- virtual void
- DidReceiveUnsolicitedData (Ptr<Face> inFace,
- Ptr<const Data> data,
- bool didCreateCacheEntry);
-
- /**
- * @brief Method implementing logic to suppress (collapse) similar Interests
- *
- * In the base class implementation this method checks list of incoming/outgoing faces of the PIT entry
- * (for new Intersets, both lists are empty before this call)
- *
- * For more details, refer to the source code.
- *
- * @param inFace incoming face
- * @param interest Interest packet
- * @param payload Data payload
- */
- virtual bool
- ShouldSuppressIncomingInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Method to check whether Interest can be send out on the particular face or not
- *
- * In the base class, this method perfoms two checks:
- * 1. If inFace is equal to outFace (when equal, Interest forwarding is prohibited)
- * 2. Whether Interest should be suppressed (list of outgoing faces include outFace),
- * considering (if enabled) retransmission logic
- *
- * @param inFace incoming face of the Interest
- * @param outFace proposed outgoing face of the Interest
- * @param interest Interest packet
- * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
- *
- * @see DetectRetransmittedInterest
- */
- virtual bool
- CanSendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Method implementing actual interest forwarding, taking into account CanSendOutInterest decision
- *
- * If event returns false, then there is some kind of a problem exists
- *
- * @param inFace incoming face of the Interest
- * @param outFace proposed outgoing face of the Interest
- * @param interest Interest packet
- * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
- *
- * @see CanSendOutInterest
- */
- virtual bool
- TrySendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Event fired just after forwarding the Interest
- *
- * @param inFace incoming face of the Interest
- * @param outFace outgoing face of the Interest
- * @param interest Interest packet
- * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
- */
- virtual void
- DidSendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Wrapper method, which performs general tasks and calls DoPropagateInterest method
- *
- * General tasks so far are adding face to the list of incoming face, updating
- * PIT entry lifetime, calling DoPropagateInterest, and retransmissions (enabled by default).
- *
- * @param inFace incoming face
- * @param interest Interest packet
- * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
- *
- * @see DoPropagateInterest
- */
- virtual void
- PropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /**
- * @brief Virtual method to perform Interest propagation according to the forwarding strategy logic
- *
- * In most cases, this is the call that needs to be implemented/re-implemented in order
- * to perform forwarding of Interests according to the desired logic.
- *
- * There is also PropagateInterest method (generally, do not require to be overriden)
- * which performs general tasks (adding face to the list of incoming face, updating
- * PIT entry lifetime, calling DoPropagateInterest, as well as perform retransmissions (enabled by default).
- *
- * @param inFace incoming face
- * @param interest Interest packet
- * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
- *
- * @return true if interest was successfully propagated, false if all options have failed
- *
- * @see PropagateInterest
- */
- virtual bool
- DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry) = 0;
-
-protected:
- // inherited from Object class
- virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
- virtual void DoDispose (); ///< @brief Do cleanup
-
-protected:
- Ptr<Pit> m_pit; ///< \brief Reference to PIT to which this forwarding strategy is associated
- Ptr<Fib> m_fib; ///< \brief FIB
- Ptr<ContentStore> m_contentStore; ///< \brief Content store (for caching purposes only)
-
- bool m_cacheUnsolicitedDataFromApps;
- bool m_cacheUnsolicitedData;
- bool m_detectRetransmissions;
-
- TracedCallback<Ptr<const Interest>,
- Ptr<const Face> > m_outInterests; ///< @brief Transmitted interests trace
-
- TracedCallback<Ptr<const Interest>,
- Ptr<const Face> > m_inInterests; ///< @brief trace of incoming Interests
-
- TracedCallback<Ptr<const Interest>,
- Ptr<const Face> > m_dropInterests; ///< @brief trace of dropped Interests
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- TracedCallback<Ptr<const Data>,
- bool /*from cache*/,
- Ptr<const Face> > m_outData; ///< @brief trace of outgoing Data
-
- TracedCallback<Ptr<const Data>,
- Ptr<const Face> > m_inData; ///< @brief trace of incoming Data
-
- TracedCallback<Ptr<const Data>,
- Ptr<const Face> > m_dropData; ///< @brief trace of dropped Data
-
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////
-
- TracedCallback< Ptr<const pit::Entry> > m_satisfiedInterests;
- TracedCallback< Ptr<const pit::Entry> > m_timedOutInterests;
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif /* NDN_FORWARDING_STRATEGY_H */
diff --git a/model/fw/ndn-fw-tag.h b/model/fw/ndn-fw-tag.h
deleted file mode 100644
index 5d02b31..0000000
--- a/model/fw/ndn-fw-tag.h
+++ /dev/null
@@ -1,43 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-
-#ifndef NDNSIM_FW_TAG_H
-#define NDNSIM_FW_TAG_H
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-/**
- * @ingroup ndn-fw
- * @brief Abstract class for the forwarding strategy tag, which can be added to PIT entries
- */
-class Tag
-{
-public:
- virtual ~Tag () { };
-};
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDNSIM_FW_TAG_H
diff --git a/model/fw/per-fib-limits.cc b/model/fw/per-fib-limits.cc
deleted file mode 100644
index 87e99fc..0000000
--- a/model/fw/per-fib-limits.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- 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 "per-fib-limits.h"
-#include "per-out-face-limits.h"
-
-#include "ns3/ndn-l3-protocol.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-
-#include "best-route.h"
-#include "flooding.h"
-#include "smart-flooding.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-extern template class PerOutFaceLimits<BestRoute>;
-extern template class PerOutFaceLimits<Flooding>;
-extern template class PerOutFaceLimits<SmartFlooding>;
-
-template class PerFibLimits< PerOutFaceLimits<BestRoute> >;
-typedef PerFibLimits< PerOutFaceLimits<BestRoute> > PerFibLimitsPerOutFaceLimitsBestRoute;
-NS_OBJECT_ENSURE_REGISTERED (PerFibLimitsPerOutFaceLimitsBestRoute);
-
-template class PerFibLimits< PerOutFaceLimits<Flooding> >;
-typedef PerFibLimits< PerOutFaceLimits<Flooding> > PerFibLimitsPerOutFaceLimitsFlooding;
-NS_OBJECT_ENSURE_REGISTERED (PerFibLimitsPerOutFaceLimitsFlooding);
-
-template class PerFibLimits< PerOutFaceLimits<SmartFlooding> >;
-typedef PerFibLimits< PerOutFaceLimits<SmartFlooding> > PerFibLimitsPerOutFaceLimitsSmartFlooding;
-NS_OBJECT_ENSURE_REGISTERED (PerFibLimitsPerOutFaceLimitsSmartFlooding);
-
-#ifdef DOXYGEN
-// /**
-// * \brief Strategy implementing per-fib-per-out-face limits on top of BestRoute strategy
-// */
-class BestRoute::PerOutFaceLimits::PerFibLimits : public ::ns3::ndn::fw::PerFibLimits< ::ns3::ndn::fw::PerOutFaceLimits<BestRoute> > { };
-
-/**
- * \brief Strategy implementing per-fib-per-out-face limits on top of Flooding strategy
- */
-class Flooding::PerOutFaceLimits::PerFibLimits : public ::ns3::ndn::fw::PerFibLimits< ::ns3::ndn::fw::PerOutFaceLimits<Flooding> > { };
-
-/**
- * \brief Strategy implementing per-fib-per-out-face limits on top of SmartFlooding strategy
- */
-class SmartFlooding::PerOutFaceLimits::PerFibLimits : public ::ns3::ndn::fw::PerFibLimits< ::ns3::ndn::fw::PerOutFaceLimits<SmartFlooding> > { };
-
-#endif
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fw/per-fib-limits.h b/model/fw/per-fib-limits.h
deleted file mode 100644
index 89ce352..0000000
--- a/model/fw/per-fib-limits.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/* -*- 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>
- */
-
-
-#ifndef NDNSIM_PER_FIB_LIMITS_H
-#define NDNSIM_PER_FIB_LIMITS_H
-
-#include "ns3/event-id.h"
-#include "ns3/log.h"
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-pit-entry.h"
-#include "ns3/simulator.h"
-#include "ns3/string.h"
-
-#include "ns3/ndn-forwarding-strategy.h"
-
-#include "ns3/ndn-limits.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-/**
- * @ingroup ndn-fw
- * @brief Strategy implementing per-FIB entry limits
- */
-template<class Parent>
-class PerFibLimits :
- public Parent
-{
-private:
- typedef Parent super;
-
-public:
- static TypeId
- GetTypeId ();
-
- /**
- * @brief Helper function to retrieve logging name for the forwarding strategy
- */
- static std::string
- GetLogName ();
-
- /**
- * @brief Default constructor
- */
- PerFibLimits ()
- { }
-
- /// \copydoc ForwardingStrategy::WillEraseTimedOutPendingInterest
- virtual void
- WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
-
- /// \copydoc ForwardingStrategy::AddFace
- virtual void
- AddFace (Ptr<Face> face)
- {
- super::AddFace (face);
-
- if (face->GetObject<Limits> () == 0)
- {
- NS_FATAL_ERROR ("At least per-face limits should be enabled");
- exit (1);
- }
- }
-
- /// \copydoc ForwardingStrategy::DidAddFibEntry
- virtual void
- DidAddFibEntry (Ptr<fib::Entry> fibEntry)
- {
- ObjectFactory factory;
- factory.SetTypeId (fibEntry->m_faces.begin ()->GetFace ()->GetObject<Limits> ()->GetInstanceTypeId ());
-
- Ptr<Limits> limits = factory.template Create<Limits> ();
- fibEntry->AggregateObject (limits);
-
- super::DidAddFibEntry (fibEntry);
- }
-
-protected:
- /// \copydoc ForwardingStrategy::CanSendOutInterest
- virtual bool
- CanSendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /// \copydoc ForwardingStrategy::WillSatisfyPendingInterest
- virtual void
- WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry);
-
-protected:
- static LogComponent g_log; ///< @brief Logging variable
-
-private:
- std::string m_limitType;
-};
-
-template<class Parent>
-LogComponent PerFibLimits<Parent>::g_log = LogComponent (PerFibLimits<Parent>::GetLogName ().c_str ());
-
-template<class Parent>
-std::string
-PerFibLimits<Parent>::GetLogName ()
-{
- return super::GetLogName ()+".PerFibLimits";
-}
-
-template<class Parent>
-TypeId
-PerFibLimits<Parent>::GetTypeId (void)
-{
- static TypeId tid = TypeId ((super::GetTypeId ().GetName ()+"::PerFibLimits").c_str ())
- .SetGroupName ("Ndn")
- .template SetParent <super> ()
- .template AddConstructor <PerFibLimits> ()
- ;
- return tid;
-}
-
-template<class Parent>
-bool
-PerFibLimits<Parent>::CanSendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
-
- Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
- // no checks for the limit here. the check should be somewhere elese
-
- if (fibLimits->IsBelowLimit ())
- {
- if (super::CanSendOutInterest (inFace, outFace, interest, pitEntry))
- {
- fibLimits->BorrowLimit ();
- return true;
- }
- }
-
- return false;
-}
-
-template<class Parent>
-void
-PerFibLimits<Parent>::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
-
- Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
-
- for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- face != pitEntry->GetOutgoing ().end ();
- face ++)
- {
- for (uint32_t i = 0; i <= face->m_retxCount; i++)
- fibLimits->ReturnLimit ();
- }
-
- super::WillEraseTimedOutPendingInterest (pitEntry);
-}
-
-
-template<class Parent>
-void
-PerFibLimits<Parent>::WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
-
- Ptr<Limits> fibLimits = pitEntry->GetFibEntry ()->template GetObject<Limits> ();
-
- for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- face != pitEntry->GetOutgoing ().end ();
- face ++)
- {
- for (uint32_t i = 0; i <= face->m_retxCount; i++)
- fibLimits->ReturnLimit ();
- }
-
- super::WillSatisfyPendingInterest (inFace, pitEntry);
-}
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDNSIM_PER_FIB_LIMITS_H
diff --git a/model/fw/per-out-face-limits.cc b/model/fw/per-out-face-limits.cc
deleted file mode 100644
index d07f79b..0000000
--- a/model/fw/per-out-face-limits.cc
+++ /dev/null
@@ -1,67 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "per-out-face-limits.h"
-
-#include "ns3/ndn-l3-protocol.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-
-#include "best-route.h"
-#include "flooding.h"
-#include "smart-flooding.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-template class PerOutFaceLimits<BestRoute>;
-typedef PerOutFaceLimits<BestRoute> PerOutFaceLimitsBestRoute;
-NS_OBJECT_ENSURE_REGISTERED (PerOutFaceLimitsBestRoute);
-
-template class PerOutFaceLimits<Flooding>;
-typedef PerOutFaceLimits<Flooding> PerOutFaceLimitsFlooding;
-NS_OBJECT_ENSURE_REGISTERED (PerOutFaceLimitsFlooding);
-
-template class PerOutFaceLimits<SmartFlooding>;
-typedef PerOutFaceLimits<SmartFlooding> PerOutFaceLimitsSmartFlooding;
-NS_OBJECT_ENSURE_REGISTERED (PerOutFaceLimitsSmartFlooding);
-
-#ifdef DOXYGEN
-// /**
-// * \brief Strategy implementing per-out-face limits on top of BestRoute strategy
-// */
-class BestRoute::PerOutFaceLimits : public ::ns3::ndn::fw::PerOutFaceLimits<BestRoute> { };
-
-/**
- * \brief Strategy implementing per-out-face limits on top of Flooding strategy
- */
-class Flooding::PerOutFaceLimits : public ::ns3::ndn::fw::PerOutFaceLimits<Flooding> { };
-
-/**
- * \brief Strategy implementing per-out-face limits on top of SmartFlooding strategy
- */
-class SmartFlooding::PerOutFaceLimits : public ::ns3::ndn::fw::PerOutFaceLimits<SmartFlooding> { };
-#endif
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
diff --git a/model/fw/per-out-face-limits.h b/model/fw/per-out-face-limits.h
deleted file mode 100644
index 2f8f662..0000000
--- a/model/fw/per-out-face-limits.h
+++ /dev/null
@@ -1,196 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-
-#ifndef NDNSIM_PER_OUT_FACE_LIMITS_H
-#define NDNSIM_PER_OUT_FACE_LIMITS_H
-
-#include "ns3/event-id.h"
-#include "ns3/log.h"
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-pit-entry.h"
-#include "ns3/simulator.h"
-#include "ns3/string.h"
-
-#include "ns3/ndn-forwarding-strategy.h"
-
-#include "ns3/ndn-limits.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-/**
- * @ingroup ndn-fw
- * @brief Strategy implementing per-outgoing face limits
- */
-template<class Parent>
-class PerOutFaceLimits :
- public Parent
-{
-private:
- typedef Parent super;
-
-public:
- /**
- * @brief Get TypeId of the class
- */
- static TypeId
- GetTypeId ();
-
- /**
- * @brief Helper function to retrieve logging name for the forwarding strategy
- */
- static std::string
- GetLogName ();
-
- /**
- * @brief Default constructor
- */
- PerOutFaceLimits ()
- { }
-
- /// \copydoc ForwardingStrategy::WillEraseTimedOutPendingInterest
- virtual void
- WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
-
- /// \copydoc ForwardingStrategy::AddFace
- virtual void
- AddFace (Ptr<Face> face)
- {
- ObjectFactory factory (m_limitType);
- Ptr<Limits> limits = factory.template Create<Limits> ();
- face->AggregateObject (limits);
-
- super::AddFace (face);
- }
-
-protected:
- /// \copydoc ForwardingStrategy::CanSendOutInterest
- virtual bool
- CanSendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
- /// \copydoc ForwardingStrategy::WillSatisfyPendingInterest
- virtual void
- WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry);
-
-protected:
- static LogComponent g_log; ///< @brief Logging variable
-
-private:
- std::string m_limitType;
-};
-
-template<class Parent>
-LogComponent PerOutFaceLimits<Parent>::g_log = LogComponent (PerOutFaceLimits<Parent>::GetLogName ().c_str ());
-
-template<class Parent>
-std::string
-PerOutFaceLimits<Parent>::GetLogName ()
-{
- return super::GetLogName ()+".PerOutFaceLimits";
-}
-
-template<class Parent>
-TypeId
-PerOutFaceLimits<Parent>::GetTypeId (void)
-{
- static TypeId tid = TypeId ((super::GetTypeId ().GetName ()+"::PerOutFaceLimits").c_str ())
- .SetGroupName ("Ndn")
- .template SetParent <super> ()
- .template AddConstructor <PerOutFaceLimits> ()
-
- .AddAttribute ("Limit", "Limit type to be used (e.g., ns3::ndn::Limits::Window or ns3::ndn::Limits::Rate)",
- StringValue ("ns3::ndn::Limits::Window"),
- MakeStringAccessor (&PerOutFaceLimits<Parent>::m_limitType),
- MakeStringChecker ())
- ;
- return tid;
-}
-
-template<class Parent>
-bool
-PerOutFaceLimits<Parent>::CanSendOutInterest (Ptr<Face> inFace,
- Ptr<Face> outFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
-
- Ptr<Limits> faceLimits = outFace->template GetObject<Limits> ();
- if (faceLimits->IsBelowLimit ())
- {
- if (super::CanSendOutInterest (inFace, outFace, interest, pitEntry))
- {
- faceLimits->BorrowLimit ();
- return true;
- }
- }
-
- return false;
-}
-
-template<class Parent>
-void
-PerOutFaceLimits<Parent>::WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
-
- for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- face != pitEntry->GetOutgoing ().end ();
- face ++)
- {
- Ptr<Limits> faceLimits = face->m_face->GetObject<Limits> ();
- for (uint32_t i = 0; i <= face->m_retxCount; i++)
- faceLimits->ReturnLimit ();
- }
-
- super::WillEraseTimedOutPendingInterest (pitEntry);
-}
-
-
-template<class Parent>
-void
-PerOutFaceLimits<Parent>::WillSatisfyPendingInterest (Ptr<Face> inFace,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this << pitEntry->GetPrefix ());
-
- for (pit::Entry::out_container::iterator face = pitEntry->GetOutgoing ().begin ();
- face != pitEntry->GetOutgoing ().end ();
- face ++)
- {
- Ptr<Limits> faceLimits = face->m_face->GetObject<Limits> ();
- for (uint32_t i = 0; i <= face->m_retxCount; i++)
- faceLimits->ReturnLimit ();
- }
-
- super::WillSatisfyPendingInterest (inFace, pitEntry);
-}
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDNSIM_PER_OUT_FACE_LIMITS_H
diff --git a/model/fw/smart-flooding.cc b/model/fw/smart-flooding.cc
deleted file mode 100644
index 86ec8ee..0000000
--- a/model/fw/smart-flooding.cc
+++ /dev/null
@@ -1,101 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "smart-flooding.h"
-
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-pit-entry.h"
-
-#include "ns3/assert.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ns3/boolean.h"
-
-#include <boost/ref.hpp>
-#include <boost/foreach.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-namespace ll = boost::lambda;
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-NS_OBJECT_ENSURE_REGISTERED (SmartFlooding);
-
-LogComponent SmartFlooding::g_log = LogComponent (SmartFlooding::GetLogName ().c_str ());
-
-std::string
-SmartFlooding::GetLogName ()
-{
- return super::GetLogName ()+".SmartFlooding";
-}
-
-TypeId
-SmartFlooding::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::fw::SmartFlooding")
- .SetGroupName ("Ndn")
- .SetParent <GreenYellowRed> ()
- .AddConstructor <SmartFlooding> ()
- ;
- return tid;
-}
-
-SmartFlooding::SmartFlooding ()
-{
-}
-
-bool
-SmartFlooding::DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry)
-{
- NS_LOG_FUNCTION (this);
-
- // Try to work out with just green faces
- bool greenOk = super::DoPropagateInterest (inFace, interest, pitEntry);
- if (greenOk)
- return true;
-
- int propagatedCount = 0;
-
- BOOST_FOREACH (const fib::FaceMetric &metricFace, pitEntry->GetFibEntry ()->m_faces.get<fib::i_metric> ())
- {
- NS_LOG_DEBUG ("Trying " << boost::cref(metricFace));
- if (metricFace.GetStatus () == fib::FaceMetric::NDN_FIB_RED) // all non-read faces are in the front of the list
- break;
-
- if (!TrySendOutInterest (inFace, metricFace.GetFace (), interest, pitEntry))
- {
- continue;
- }
-
- propagatedCount++;
- }
-
- NS_LOG_INFO ("Propagated to " << propagatedCount << " faces");
- return propagatedCount > 0;
-}
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
diff --git a/model/fw/smart-flooding.h b/model/fw/smart-flooding.h
deleted file mode 100644
index b764de8..0000000
--- a/model/fw/smart-flooding.h
+++ /dev/null
@@ -1,70 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDNSIM_SMART_FLOODING_H
-#define NDNSIM_SMART_FLOODING_H
-
-#include "green-yellow-red.h"
-#include "ns3/log.h"
-
-namespace ns3 {
-namespace ndn {
-namespace fw {
-
-/**
- * @ingroup ndn-fw
- * @brief Smart flooding forwarding strategy
- */
-class SmartFlooding :
- public GreenYellowRed
-{
-private:
- typedef GreenYellowRed super;
-
-public:
- static TypeId
- GetTypeId ();
-
- /**
- * @brief Helper function to retrieve logging name for the forwarding strategy
- */
- static std::string
- GetLogName ();
-
- /**
- * @brief Default constructor
- */
- SmartFlooding ();
-
- // inherited
- virtual bool
- DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> interest,
- Ptr<pit::Entry> pitEntry);
-
-protected:
- static LogComponent g_log;
-};
-
-} // namespace fw
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDNSIM_SMART_FLOODING_H
diff --git a/model/ndn-content-object.h b/model/ndn-content-object.h
deleted file mode 100644
index e69de29..0000000
--- a/model/ndn-content-object.h
+++ /dev/null
diff --git a/model/ndn-data.cc b/model/ndn-data.cc
deleted file mode 100644
index c6b9778..0000000
--- a/model/ndn-data.cc
+++ /dev/null
@@ -1,161 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011-2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-data.h"
-
-#include "ns3/log.h"
-
-#include <boost/foreach.hpp>
-
-NS_LOG_COMPONENT_DEFINE ("ndn.Data");
-
-namespace ns3 {
-namespace ndn {
-
-Data::Data (Ptr<Packet> payload/* = Create<Packet> ()*/)
- : m_name (Create<Name> ())
- , m_signature (0)
- , m_payload (payload)
- , m_keyLocator (0)
- , m_wire (0)
-{
- if (m_payload == 0) // just in case
- {
- m_payload = Create<Packet> ();
- }
-}
-
-Data::Data (const Data &other)
- : m_name (Create<Name> (other.GetName ()))
- , m_freshness (other.GetFreshness ())
- , m_timestamp (other.GetTimestamp ())
- , m_signature (other.GetSignature ())
- , m_payload (other.GetPayload ()->Copy ())
- , m_wire (0)
-{
- if (other.GetKeyLocator ())
- {
- m_keyLocator = Create<Name> (*other.GetKeyLocator ());
- }
-}
-
-void
-Data::SetName (Ptr<Name> name)
-{
- m_name = name;
- m_wire = 0;
-}
-
-void
-Data::SetName (const Name &name)
-{
- m_name = Create<Name> (name);
- m_wire = 0;
-}
-
-const Name&
-Data::GetName () const
-{
- if (m_name==0) throw DataException();
- return *m_name;
-}
-
-Ptr<const Name>
-Data::GetNamePtr () const
-{
- return m_name;
-}
-
-
-void
-Data::SetTimestamp (const Time ×tamp)
-{
- m_timestamp = timestamp;
- m_wire = 0;
-}
-
-Time
-Data::GetTimestamp () const
-{
- return m_timestamp;
-}
-
-void
-Data::SetFreshness (const Time &freshness)
-{
- m_freshness = freshness;
- m_wire = 0;
-}
-
-
-Time
-Data::GetFreshness () const
-{
- return m_freshness;
-}
-
-void
-Data::SetSignature (uint32_t signature)
-{
- m_signature = signature;
- m_wire = 0;
-}
-
-uint32_t
-Data::GetSignature () const
-{
- return m_signature;
-}
-
-void
-Data::SetKeyLocator (Ptr<Name> keyLocator)
-{
- m_keyLocator = keyLocator;
-}
-
-Ptr<const Name>
-Data::GetKeyLocator () const
-{
- return m_keyLocator;
-}
-
-void
-Data::Print (std::ostream &os) const
-{
- os << "D: " << GetName ();
- // os << "<Data><Name>" << GetName () << "</Name><Content>";
-}
-
-void
-Data::SetPayload (Ptr<Packet> payload)
-{
- m_payload = payload;
- m_wire = 0;
-}
-
-Ptr<const Packet>
-Data::GetPayload () const
-{
- return m_payload;
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/model/ndn-data.h b/model/ndn-data.h
deleted file mode 100644
index 4d51d37..0000000
--- a/model/ndn-data.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011-2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Ilya Moiseenko <iliamo@cs.ucla.edu>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_CONTENT_OBJECT_HEADER_H_
-#define _NDN_CONTENT_OBJECT_HEADER_H_
-
-#include "ns3/simple-ref-count.h"
-#include "ns3/nstime.h"
-#include "ns3/packet.h"
-#include "ns3/ptr.h"
-
-#include <ns3/ndn-name.h>
-
-namespace ns3 {
-namespace ndn {
-
-/**
- * @ingroup ndn
- * @brief Data header
- */
-class Data : public SimpleRefCount<Data>
-{
-public:
- /**
- * @brief Constructor
- *
- * Creates a null header
- **/
- Data (Ptr<Packet> payload = Create<Packet> ());
-
- /**
- * @brief Copy constructor
- */
- Data (const Data &other);
-
- /**
- * \brief Set content object name
- *
- * Sets name of the content object
- **/
- void
- SetName (Ptr<Name> name);
-
- /**
- * @brief Another, less efficient, variant of setting content object name
- *
- * Sets name of the content object
- */
- void
- SetName (const Name &name);
-
- /**
- * @brief Get name of the content object
- */
- const Name&
- GetName () const;
-
- /**
- * @brief Get smart pointer to the interest name (to avoid extra memory usage)
- */
- Ptr<const Name>
- GetNamePtr () const;
-
- /**
- * @brief Set content object timestamp
- * @param timestamp timestamp
- */
- void
- SetTimestamp (const Time ×tamp);
-
- /**
- * @brief Get timestamp of the content object
- */
- Time
- GetTimestamp () const;
-
- /**
- * @brief Set freshness of the content object
- * @param freshness Freshness, 0s means infinity
- */
- void
- SetFreshness (const Time &freshness);
-
- /**
- * @brief Get freshness of the content object
- */
- Time
- GetFreshness () const;
-
- /**
- * @brief Set "fake" signature on the content object
- * @param signature uint32_t number, simulating content object signature
- *
- * Values for the signature totally depend on the application
- */
- void
- SetSignature (uint32_t signature);
-
- /**
- * @brief Get "fake" signature of the content object
- *
- * Values for the signature totally depend on the application
- */
- uint32_t
- GetSignature () const;
-
- /**
- * @brief Set key locator
- * @param keyLocator name of the key
- */
- void
- SetKeyLocator (Ptr<Name> keyLocator);
-
- /**
- * @brief Get key locator
- *
- * Note that only <KeyName> option for the key locator is supported
- */
- Ptr<const Name>
- GetKeyLocator () const;
-
- //////////////////////////////////////////////////////////////////
- /**
- * @brief Get payload of data packet
- *
- * This payload can also carry packet tags
- */
- void
- SetPayload (Ptr<Packet> payload);
-
- /**
- * @brief Set payload of data packet
- *
- * This payload can also carry packet tags
- */
- Ptr<const Packet>
- GetPayload () const;
-
- /**
- * @brief Get wire formatted packet
- *
- * If wire formatted packet has not been set before, 0 will be returned
- */
- inline Ptr<const Packet>
- GetWire () const;
-
- /**
- * @brief Set (cache) wire formatted packet
- */
- inline void
- SetWire (Ptr<const Packet> packet) const;
-
- /**
- * @brief Print Interest in plain-text to the specified output stream
- */
- void
- Print (std::ostream &os) const;
-
-private:
- // NO_ASSIGN
- Data &
- operator = (const Data &other) { return *this; }
-
-private:
- Ptr<Name> m_name;
- Time m_freshness;
- Time m_timestamp;
- uint32_t m_signature; // 0, means no signature, any other value application dependent (not a real signature)
- Ptr<Packet> m_payload;
- Ptr<Name> m_keyLocator;
-
- mutable Ptr<const Packet> m_wire;
-};
-
-inline std::ostream &
-operator << (std::ostream &os, const Data &d)
-{
- d.Print (os);
- return os;
-}
-
-/**
- * @brief Class for Data parsing exception
- */
-class DataException {};
-
-inline Ptr<const Packet>
-Data::GetWire () const
-{
- return m_wire;
-}
-
-inline void
-Data::SetWire (Ptr<const Packet> packet) const
-{
- m_wire = packet;
-}
-
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // _NDN_CONTENT_OBJECT_HEADER_H_
diff --git a/model/ndn-interest.cc b/model/ndn-interest.cc
deleted file mode 100644
index 3b09fde..0000000
--- a/model/ndn-interest.cc
+++ /dev/null
@@ -1,200 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-interest.h"
-
-#include "ns3/log.h"
-#include "ns3/unused.h"
-#include "ns3/packet.h"
-
-NS_LOG_COMPONENT_DEFINE ("ndn.Interest");
-
-namespace ns3 {
-namespace ndn {
-
-Interest::Interest (Ptr<Packet> payload/* = Create<Packet> ()*/)
- : m_name ()
- , m_scope (0xFF)
- , m_interestLifetime (Seconds (0))
- , m_nonce (0)
- , m_nackType (NORMAL_INTEREST)
- , m_exclude (0)
- , m_payload (payload)
- , m_wire (0)
-{
- if (m_payload == 0) // just in case
- {
- m_payload = Create<Packet> ();
- }
-}
-
-Interest::Interest (const Interest &interest)
- : m_name (Create<Name> (interest.GetName ()))
- , m_scope (interest.m_scope)
- , m_interestLifetime (interest.m_interestLifetime)
- , m_nonce (interest.m_nonce)
- , m_nackType (interest.m_nackType)
- , m_exclude (interest.m_exclude ? Create<Exclude> (*interest.GetExclude ()) : 0)
- , m_payload (interest.GetPayload ()->Copy ())
- , m_wire (0)
-{
- NS_LOG_FUNCTION ("correct copy constructor");
-}
-
-void
-Interest::SetName (Ptr<Name> name)
-{
- m_name = name;
- m_wire = 0;
-}
-
-void
-Interest::SetName (const Name &name)
-{
- m_name = Create<Name> (name);
- m_wire = 0;
-}
-
-const Name&
-Interest::GetName () const
-{
- if (m_name==0) throw InterestException();
- return *m_name;
-}
-
-Ptr<const Name>
-Interest::GetNamePtr () const
-{
- return m_name;
-}
-
-void
-Interest::SetScope (int8_t scope)
-{
- m_scope = scope;
- m_wire = 0;
-}
-
-int8_t
-Interest::GetScope () const
-{
- return m_scope;
-}
-
-void
-Interest::SetInterestLifetime (Time lifetime)
-{
- m_interestLifetime = lifetime;
- m_wire = 0;
-}
-
-Time
-Interest::GetInterestLifetime () const
-{
- return m_interestLifetime;
-}
-
-void
-Interest::SetNonce (uint32_t nonce)
-{
- m_nonce = nonce;
- m_wire = 0;
-}
-
-uint32_t
-Interest::GetNonce () const
-{
- return m_nonce;
-}
-
-void
-Interest::SetNack (uint8_t nackType)
-{
- m_nackType = nackType;
- m_wire = 0;
-}
-
-uint8_t
-Interest::GetNack () const
-{
- return m_nackType;
-}
-
-void
-Interest::SetExclude (Ptr<Exclude> exclude)
-{
- m_exclude = exclude;
- m_wire = 0;
-}
-
-Ptr<const Exclude>
-Interest::GetExclude () const
-{
- return m_exclude;
-}
-
-void
-Interest::SetPayload (Ptr<Packet> payload)
-{
- m_payload = payload;
- m_wire = 0;
-}
-
-Ptr<const Packet>
-Interest::GetPayload () const
-{
- return m_payload;
-}
-
-void
-Interest::Print (std::ostream &os) const
-{
- os << "I: " << GetName ();
-
- return;
- os << "<Interest>\n <Name>" << GetName () << "</Name>\n";
- if (GetNack ()>0)
- {
- os << " <NACK>";
- switch (GetNack ())
- {
- case NACK_LOOP:
- os << "loop";
- break;
- case NACK_CONGESTION:
- os << "congestion";
- break;
- default:
- os << "unknown";
- break;
- }
- os << "</NACK>\n";
- }
- os << " <Scope>" << GetScope () << "</Scope>\n";
- if ( !GetInterestLifetime ().IsZero() )
- os << " <InterestLifetime>" << GetInterestLifetime () << "</InterestLifetime>\n";
- if (GetNonce ()>0)
- os << " <Nonce>" << GetNonce () << "</Nonce>\n";
- os << "</Interest>";
-}
-
-} // namespace ndn
-} // namespace ns3
-
diff --git a/model/ndn-interest.h b/model/ndn-interest.h
deleted file mode 100644
index d7ab5df..0000000
--- a/model/ndn-interest.h
+++ /dev/null
@@ -1,276 +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>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_INTEREST_HEADER_H_
-#define _NDN_INTEREST_HEADER_H_
-
-#include "ns3/simple-ref-count.h"
-#include "ns3/nstime.h"
-#include "ns3/packet.h"
-#include "ns3/ptr.h"
-
-#include <ns3/ndnSIM/ndn.cxx/name.h>
-#include <ns3/ndnSIM/ndn.cxx/exclude.h>
-
-namespace ns3 {
-
-class Packet;
-
-namespace ndn {
-
-/**
- * @ingroup ndn
- * @brief NDN Interest (wire formats are defined in wire)
- **/
-class Interest : public SimpleRefCount<Interest>
-{
-public:
- /**
- * \brief Constructor
- *
- * Creates a null header
- **/
- Interest (Ptr<Packet> payload = Create<Packet> ());
-
- /**
- * @brief Copy constructor
- */
- Interest (const Interest &interest);
-
- /**
- * \brief Set interest name
- *
- * @param name smart pointer to Name
- *
- **/
- void
- SetName (Ptr<Name> name);
-
- /**
- * \brief Another variant to set interest name
- *
- * @param name const reference to Name object
- *
- **/
- void
- SetName (const Name &name);
-
- /**
- * \brief Get interest name
- *
- * Gets name of the interest.
- **/
- const Name&
- GetName () const;
-
- /**
- * @brief Get smart pointer to the interest name (to avoid extra memory usage)
- */
- Ptr<const Name>
- GetNamePtr () const;
-
- /**
- * \brief Set Scope
- * Scope limits where the Interest may propagate.
- * Scope 0 prevents propagation beyond the local ccnd (even to other applications on the same host).
- * Scope 1 limits propagation to the applications on the originating host.
- * Scope 2 limits propagation to no further than the next host.
- * Other values are not defined, and will cause the Interest message to be dropped.
- * Note that this is not a hop count - the value is not decremented as the interest is forwarded.
- * @param[in] scope interest scope
- */
- void
- SetScope (int8_t scope);
-
- /**
- * \brief Get Scope value
- * Scope limits where the Interest may propagate.
- * Scope 0 prevents propagation beyond the local ccnd (even to other applications on the same host).
- * Scope 1 limits propagation to the applications on the originating host.
- * Scope 2 limits propagation to no further than the next host.
- * Other values are not defined, and will cause the Interest message to be dropped.
- * Note that this is not a hop count - the value is not decremented as the interest is forwarded.
- */
- int8_t
- GetScope () const;
-
- /**
- * \brief Set InterestLifetime
- * InterestLifetime indicates the (approximate) time remaining before the interest times out.
- * The timeout is relative to the arrival time of the interest at the current node.
- * \see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html for more information.
- * @param[in] time interest lifetime
- */
- void
- SetInterestLifetime (Time time);
-
- /**
- * \brief Get InterestLifetime value
- * InterestLifetime indicates the (approximate) time remaining before the interest times out.
- * The timeout is relative to the arrival time of the interest at the current node.
- * \see http://www.ndn.org/releases/latest/doc/technical/InterestMessage.html for more information.
- */
- Time
- GetInterestLifetime () const;
-
- /**
- * \brief Set Nonce
- * Nonce carries a randomly-genenerated bytestring that is used to detect and discard duplicate Interest messages.
- * @param[in] nonce Unique packet identification number
- */
- void
- SetNonce (uint32_t nonce);
-
- /**
- * \brief Get Nonce value
- * Nonce carries a randomly-genenerated bytestring that is used to detect and discard duplicate Interest messages.
- *
- */
- uint32_t
- GetNonce () const;
-
- /**
- * @brief NACK Type
- * Specifies the type of Interest packet
- */
- enum
- {
- NORMAL_INTEREST = 0,
- NACK_LOOP = 10,
- NACK_CONGESTION = 11,
- NACK_GIVEUP_PIT = 12,
- };
-
- /**
- * \brief Mark the Interest as a Negative Acknowledgement
- * Three types of NACKs are supported
- * 1. NACK_LOOP
- * 2. NACK_CONGESTION
- * 3. NACK_GIVEUP_PIT
- * @param[in] nackType NACK_LOOP or NACK_CONGESTION or NACK_GIVEUP_PIT or NORMAL_INTEREST
- */
- void
- SetNack (uint8_t nackType); //using reserved field
-
- /**
- * \brief Get NACK type
- * Returns NACK_LOOP, NACK_CONGESTION or NACK_GIVEUP_PIT.
- * Otherwise, in case of normal interest packet, returns NORMAL_INTEREST (equals 0).
- */
- uint8_t
- GetNack () const;
-
- /**
- * @brief Set exclude filter of interest packet
- *
- * Empty or 0 means no exclude filter
- */
- void
- SetExclude (Ptr<Exclude> exclude);
-
- /**
- * @brief Get exclude filter of interest packet
- */
- Ptr<const Exclude>
- GetExclude () const;
-
- /**
- * @brief Set virtual "payload" of interest packet
- *
- * This payload can carry packet tags
- */
- void
- SetPayload (Ptr<Packet> payload);
-
- /**
- * @brief Get virtual "payload" to interest packet
- *
- * This payload can carry packet tags
- */
- Ptr<const Packet>
- GetPayload () const;
-
- /**
- * @brief Get wire formatted packet
- *
- * If wire formatted packet has not been set before, 0 will be returned
- */
- inline Ptr<const Packet>
- GetWire () const;
-
- /**
- * @brief Set (cache) wire formatted packet
- */
- inline void
- SetWire (Ptr<const Packet> packet) const;
-
- /**
- * @brief Print Interest in plain-text to the specified output stream
- */
- void
- Print (std::ostream &os) const;
-
-private:
- // NO_ASSIGN
- Interest &
- operator = (const Interest &other) { return *this; }
-
-private:
- Ptr<Name> m_name; ///< @brief Interest name
- uint8_t m_scope; ///< @brief 0xFF not set, 0 local scope, 1 this host, 2 immediate neighborhood
- Time m_interestLifetime; ///< @brief InterestLifetime
- uint32_t m_nonce; ///< @brief Nonce. not used if zero
- uint8_t m_nackType; ///< @brief Negative Acknowledgement type
-
- Ptr<Exclude> m_exclude; ///< @brief Exclude filter
- Ptr<Packet> m_payload; ///< @brief virtual payload
-
- mutable Ptr<const Packet> m_wire;
-};
-
-inline std::ostream &
-operator << (std::ostream &os, const Interest &i)
-{
- i.Print (os);
- return os;
-}
-
-inline Ptr<const Packet>
-Interest::GetWire () const
-{
- return m_wire;
-}
-
-inline void
-Interest::SetWire (Ptr<const Packet> packet) const
-{
- m_wire = packet;
-}
-
-/**
- * @brief Class for Interest parsing exception
- */
-class InterestException {};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // _NDN_INTEREST_HEADER_H_
diff --git a/model/ndn-name-components.h b/model/ndn-name-components.h
deleted file mode 100644
index 04915df..0000000
--- a/model/ndn-name-components.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_NAME_COMPONENTS_H
-#define NDN_NAME_COMPONENTS_H
-
-// #warning ndn-name-components.h is now deprecated header. Please include ndn-name.h instead
-
-#include "ndn-name.h"
-
-#endif // NDN_NAME_COMPONENTS_H
diff --git a/model/ndn-name.h b/model/ndn-name.h
deleted file mode 100644
index 797de98..0000000
--- a/model/ndn-name.h
+++ /dev/null
@@ -1,2 +0,0 @@
-// backwards compatibility header
-#include "ns3/ndnSIM/ndn.cxx/name.h"
diff --git a/model/pit/custom-policies/serialized-size-policy.h b/model/pit/custom-policies/serialized-size-policy.h
deleted file mode 100644
index 4c2fc81..0000000
--- a/model/pit/custom-policies/serialized-size-policy.h
+++ /dev/null
@@ -1,197 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef SERIALIZED_POLICY_H_
-#define SERIALIZED_POLICY_H_
-
-#include <boost/intrusive/options.hpp>
-#include <boost/intrusive/set.hpp>
-
-namespace ns3 {
-namespace ndn {
-namespace ndnSIM {
-
-/**
- * @brief Traits for Least Recently Used replacement policy
- */
-struct serialized_size_policy_traits
-{
- /// @brief Name that can be used to identify the policy (for NS-3 object model and logging)
- static std::string GetName () { return "SerializedSize"; }
-
- struct policy_hook_type : public boost::intrusive::set_member_hook<> { uint32_t size; };
-
- template<class Container>
- struct container_hook
- {
- typedef boost::intrusive::member_hook< Container,
- policy_hook_type,
- &Container::policy_hook_ > type;
- };
-
- template<class Base,
- class Container,
- class Hook>
- struct policy
- {
- static uint32_t& get_size (typename Container::iterator item)
- {
- return static_cast<typename policy_container::value_traits::hook_type*>
- (policy_container::value_traits::to_node_ptr(*item))->size;
- }
-
- static const uint32_t& get_size (typename Container::const_iterator item)
- {
- return static_cast<const typename policy_container::value_traits::hook_type*>
- (policy_container::value_traits::to_node_ptr(*item))->size;
- }
-
- template<class Key>
- struct MemberHookLess
- {
- bool operator () (const Key &a, const Key &b) const
- {
- return get_size (&a) < get_size (&b);
- }
- };
-
- typedef typename boost::intrusive::multiset< Container,
- boost::intrusive::compare< MemberHookLess< Container > >,
- Hook > policy_container;
-
- // could be just typedef
- class type : public policy_container
- {
- public:
- typedef Container parent_trie;
-
- type (Base &base)
- : base_ (base)
- , max_size_ (10000) // size in bytes. Default ~10 kilobytes
- , current_space_used_ (0)
- {
- }
-
- inline void
- update (typename parent_trie::iterator item)
- {
- // in case size got changed
- current_space_used_ -= get_size (item);
- policy_container::erase (*item);
-
- if (item->payload ()->GetInterest ()->GetWire ())
- {
- policy::get_size (item) = item->payload ()->GetInterest ()->GetWire ()->GetSize ();
- }
- else
- {
- policy::get_size (item) = 0;
- }
- current_space_used_ += get_size (item); // this operation can violate policy constraint, so in some case
- // it may be necessary to remove some other element
- policy_container::insert (*item);
- }
-
- inline bool
- insert (typename parent_trie::iterator item)
- {
- uint32_t interestSize = 0;
- if (item->payload ()->GetInterest ()->GetWire ())
- {
- interestSize = item->payload ()->GetInterest ()->GetWire ()->GetSize ();
- }
-
- // can't use logging here
- NS_LOG_DEBUG ("Number of entries: " << policy_container::size ()
- << ", space used: " << current_space_used_
- << ", name: " << item->payload ()->GetPrefix ()
- << ", interest size: " << interestSize);
-
- if (max_size_ != 0 && current_space_used_ + interestSize > max_size_)
- {
- NS_LOG_DEBUG ("Rejecting PIT entry");
-
- // the current version just fails to add an element, but it also possible
- // to remove the largest element (last element in multi_map policy container)
- return false;
- }
-
- policy::get_size (item) = interestSize;
- current_space_used_ += interestSize;
-
- policy_container::insert (*item);
- return true;
- }
-
- inline void
- lookup (typename parent_trie::iterator item)
- {
- // do nothing
- }
-
- inline void
- erase (typename parent_trie::iterator item)
- {
- NS_LOG_DEBUG ("Erasing entry with name: " << item->payload ()->GetPrefix ());
-
- current_space_used_ -= policy::get_size (item);
- policy_container::erase (policy_container::s_iterator_to (*item));
- }
-
- inline void
- clear ()
- {
- policy_container::clear ();
- }
-
- inline void
- set_max_size (size_t max_size)
- {
- max_size_ = max_size;
- }
-
- inline size_t
- get_max_size () const
- {
- return max_size_;
- }
-
- inline uint32_t
- get_current_space_used () const
- {
- return current_space_used_;
- }
-
- private:
- type () : base_(*((Base*)0)) { };
-
- private:
- Base &base_;
- uint32_t max_size_;
- uint32_t current_space_used_;
- };
- };
-};
-
-} // ndnSIM
-} // ndn
-} // ns3
-
-#endif
diff --git a/model/pit/ndn-pit-entry-impl.h b/model/pit/ndn-pit-entry-impl.h
deleted file mode 100644
index f3e8c62..0000000
--- a/model/pit/ndn-pit-entry-impl.h
+++ /dev/null
@@ -1,112 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_PIT_ENTRY_IMPL_H_
-#define _NDN_PIT_ENTRY_IMPL_H_
-
-namespace ns3 {
-namespace ndn {
-
-class Pit;
-
-namespace pit {
-
-/**
- * @ingroup ndn-pit
- * @brief PIT entry implementation with additional pointers to the underlying container
- */
-template<class Pit>
-class EntryImpl : public Entry
-{
-public:
- typedef Entry base_type;
-
- typedef Entry super;
- #define CONTAINER static_cast<Pit&> (m_container)
-
-public:
- EntryImpl (Pit &pit,
- Ptr<const Interest> header,
- Ptr<fib::Entry> fibEntry)
- : Entry (pit, header, fibEntry)
- , item_ (0)
- {
- CONTAINER.i_time.insert (*this);
- CONTAINER.RescheduleCleaning ();
- }
-
- virtual ~EntryImpl ()
- {
- CONTAINER.i_time.erase (Pit::time_index::s_iterator_to (*this));
-
- CONTAINER.RescheduleCleaning ();
- }
-
- virtual void
- UpdateLifetime (const Time &offsetTime)
- {
- CONTAINER.i_time.erase (Pit::time_index::s_iterator_to (*this));
- super::UpdateLifetime (offsetTime);
- CONTAINER.i_time.insert (*this);
-
- CONTAINER.RescheduleCleaning ();
- }
-
- virtual void
- OffsetLifetime (const Time &offsetTime)
- {
- CONTAINER.i_time.erase (Pit::time_index::s_iterator_to (*this));
- super::OffsetLifetime (offsetTime);
- CONTAINER.i_time.insert (*this);
-
- CONTAINER.RescheduleCleaning ();
- }
-
- // to make sure policies work
- void
- SetTrie (typename Pit::super::iterator item) { item_ = item; }
-
- typename Pit::super::iterator to_iterator () { return item_; }
- typename Pit::super::const_iterator to_iterator () const { return item_; }
-
-public:
- boost::intrusive::set_member_hook<> time_hook_;
-
-private:
- typename Pit::super::iterator item_;
-};
-
-/// @cond include_hidden
-template<class T>
-struct TimestampIndex
-{
- bool
- operator () (const T &a, const T &b) const
- {
- return a.GetExpireTime () < b.GetExpireTime ();
- }
-};
-/// @endcond
-
-} // namespace pit
-} // namespace ndn
-} // namespace ns3
-
-#endif
diff --git a/model/pit/ndn-pit-entry-incoming-face.cc b/model/pit/ndn-pit-entry-incoming-face.cc
deleted file mode 100644
index 5e3adce..0000000
--- a/model/pit/ndn-pit-entry-incoming-face.cc
+++ /dev/null
@@ -1,55 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-pit-entry-incoming-face.h"
-
-#include "ns3/simulator.h"
-
-namespace ns3 {
-namespace ndn {
-namespace pit {
-
-IncomingFace::IncomingFace (Ptr<Face> face)
- : m_face (face)
- , m_arrivalTime (Simulator::Now ())
- // , m_nonce (nonce)
-{
-}
-
-IncomingFace::IncomingFace ()
- : m_face (0)
- , m_arrivalTime (0)
-{
-}
-
-/**
- * @brie Copy operator
- */
-IncomingFace &
-IncomingFace::operator = (const IncomingFace &other)
-{
- m_face = other.m_face;
- m_arrivalTime = other.m_arrivalTime;
- return *this;
-}
-
-} // namespace pit
-} // namespace ndn
-} // namespace ns3
diff --git a/model/pit/ndn-pit-entry-incoming-face.h b/model/pit/ndn-pit-entry-incoming-face.h
deleted file mode 100644
index 14885c8..0000000
--- a/model/pit/ndn-pit-entry-incoming-face.h
+++ /dev/null
@@ -1,81 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_PIT_ENTRY_INCOMING_FACE_H_
-#define _NDN_PIT_ENTRY_INCOMING_FACE_H_
-
-#include "ns3/nstime.h"
-#include "ns3/ptr.h"
-
-#include "ns3/ndn-face.h"
-
-namespace ns3 {
-namespace ndn {
-namespace pit {
-
-/**
- * @ingroup ndn-pit
- * @brief PIT state component for each incoming interest (not including duplicates)
- */
-struct IncomingFace
-{
- Ptr< Face > m_face; ///< \brief face of the incoming Interest
- Time m_arrivalTime; ///< \brief arrival time of the incoming Interest
-
-public:
- /**
- * \brief Constructor
- * \param face face of the incoming interest
- * \param lifetime lifetime of the incoming interest
- */
- IncomingFace (Ptr<Face> face);
-
- /**
- * @brief Default constructor, necessary for Python bindings, but should not be used anywhere else.
- */
- IncomingFace ();
- /**
- * @brief Copy operator
- */
- IncomingFace &
- operator = (const IncomingFace &other);
-
- /**
- * @brief Compare two PitEntryIncomingFace
- */
- bool operator== (const IncomingFace &dst) const { return *m_face==*(dst.m_face); }
-
- /**
- * @brief Compare PitEntryIncomingFace with Face
- */
- bool operator== (Ptr<Face> face) const { return *m_face==*face; }
-
- /**
- * \brief Comparison operator used by boost::multi_index::identity<>
- */
- bool
- operator< (const IncomingFace &m) const { return *m_face < *(m.m_face); } // return identity of the face
-};
-
-} // namespace pit
-} // namespace ndn
-} // namespace ns3
-
-#endif /* NDN_PIT_ENTRY_INCOMING_FACE_H */
diff --git a/model/pit/ndn-pit-entry-outgoing-face.cc b/model/pit/ndn-pit-entry-outgoing-face.cc
deleted file mode 100644
index 1ddf1d6..0000000
--- a/model/pit/ndn-pit-entry-outgoing-face.cc
+++ /dev/null
@@ -1,67 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-pit-entry-outgoing-face.h"
-
-#include "ns3/simulator.h"
-
-namespace ns3 {
-namespace ndn {
-namespace pit {
-
-OutgoingFace::OutgoingFace (Ptr<Face> face)
- : m_face (face)
- , m_sendTime (Simulator::Now ())
- , m_retxCount (0)
- , m_waitingInVain (false)
-{
-}
-
-OutgoingFace::OutgoingFace ()
- : m_face (0)
- , m_sendTime (0)
- , m_retxCount (0)
- , m_waitingInVain (false)
-{
-}
-
-OutgoingFace &
-OutgoingFace::operator = (const OutgoingFace &other)
-{
- m_face = other.m_face;
- m_sendTime = other.m_sendTime;
- m_retxCount = other.m_retxCount;
- m_waitingInVain = other.m_waitingInVain;
-
- return *this;
-}
-
-
-void
-OutgoingFace::UpdateOnRetransmit ()
-{
- m_sendTime = Simulator::Now ();
- m_retxCount++;
- m_waitingInVain = false;
-}
-
-} // namespace pit
-} // namespace ndn
-} // namespace ns3
diff --git a/model/pit/ndn-pit-entry-outgoing-face.h b/model/pit/ndn-pit-entry-outgoing-face.h
deleted file mode 100644
index 6b498a8..0000000
--- a/model/pit/ndn-pit-entry-outgoing-face.h
+++ /dev/null
@@ -1,91 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_PIT_ENTRY_OUTGOING_FACE_H_
-#define _NDN_PIT_ENTRY_OUTGOING_FACE_H_
-
-#include "ns3/nstime.h"
-#include "ns3/ptr.h"
-
-#include "ns3/ndn-face.h"
-
-namespace ns3 {
-namespace ndn {
-namespace pit {
-
-/**
- * @ingroup ndn-pit
- * @brief PIT state component for each outgoing interest
- */
-struct OutgoingFace
-{
- Ptr<Face> m_face; ///< \brief face of the outgoing Interest
- Time m_sendTime; ///< \brief time when the first outgoing interest is sent (for RTT measurements)
- ///< \todo handle problem of retransmitted interests... Probably, we should include something similar
- ///< to TimeStamp TCP option for retransmitted (i.e., only lost interests will suffer)
- uint32_t m_retxCount; ///< \brief number of retransmission
- bool m_waitingInVain; ///< \brief when flag is set, we do not expect data for this interest, only a small hope that it will happen
-
-public:
- /**
- * @brief Constructor to create PitEntryOutgoingFace
- * \param face face of the outgoing interest
- */
- OutgoingFace (Ptr<Face> face);
-
- /**
- * @brief Default constructor, necessary for Python bindings, but should not be used anywhere else.
- */
- OutgoingFace ();
-
- /**
- * @brief Copy operator
- */
- OutgoingFace &
- operator = (const OutgoingFace &other);
-
- /**
- * @brief Update outgoing entry upon retransmission
- */
- void
- UpdateOnRetransmit ();
-
- /**
- * @brief Compare to PitEntryOutgoingFace
- */
- bool operator== (const OutgoingFace &dst) { return *m_face==*dst.m_face; }
-
- /**
- * @brief Compare PitEntryOutgoingFace with Face
- */
- bool operator== (Ptr<Face> face) { return *m_face==*face; }
-
- /**
- * \brief Comparison operator used by boost::multi_index::identity<>
- */
- bool
- operator< (const OutgoingFace &m) const { return *m_face < *(m.m_face); } // return identity of the face
-};
-
-} // namespace pit
-} // namespace ndn
-} // namespace ns3
-
-#endif /* NDN_PIT_ENTRY_OUTGOING_FACE_H */
diff --git a/model/pit/ndn-pit-entry.cc b/model/pit/ndn-pit-entry.cc
deleted file mode 100644
index 1908dd0..0000000
--- a/model/pit/ndn-pit-entry.cc
+++ /dev/null
@@ -1,318 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-pit-entry.h"
-
-#include "ns3/ndn-pit.h"
-#include "ns3/ndn-fib.h"
-#include "ns3/ndn-name.h"
-#include "ns3/ndn-interest.h"
-
-#include "ns3/packet.h"
-#include "ns3/simulator.h"
-#include "ns3/log.h"
-
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-#include <boost/foreach.hpp>
-namespace ll = boost::lambda;
-
-NS_LOG_COMPONENT_DEFINE ("ndn.pit.Entry");
-
-namespace ns3 {
-namespace ndn {
-namespace pit {
-
-Entry::Entry (Pit &container,
- Ptr<const Interest> header,
- Ptr<fib::Entry> fibEntry)
- : m_container (container)
- , m_interest (header)
- , m_fibEntry (fibEntry)
- , m_maxRetxCount (0)
-{
- NS_LOG_FUNCTION (this);
-
- // UpdateLifetime is (and should) be called from the forwarding strategy
-
- UpdateLifetime ((!header->GetInterestLifetime ().IsZero ()?
- header->GetInterestLifetime ():
- Seconds (1.0)));
-}
-
-Entry::~Entry ()
-{
- NS_LOG_FUNCTION (GetPrefix ());
-}
-
-void
-Entry::UpdateLifetime (const Time &offsetTime)
-{
- NS_LOG_FUNCTION (this);
-
- Time newExpireTime = Simulator::Now () + (m_container.GetMaxPitEntryLifetime ().IsZero () ?
- offsetTime :
- std::min (m_container.GetMaxPitEntryLifetime (), offsetTime));
- if (newExpireTime > m_expireTime)
- m_expireTime = newExpireTime;
-
- NS_LOG_INFO (this->GetPrefix () << ", Updated lifetime to " << m_expireTime.ToDouble (Time::S) << "s, " << (m_expireTime-Simulator::Now ()).ToDouble (Time::S) << "s left");
-}
-
-void
-Entry::OffsetLifetime (const Time &offsetTime)
-{
- m_expireTime += offsetTime;
- if (m_expireTime < Simulator::Now ())
- {
- m_expireTime = Simulator::Now ();
- }
- NS_LOG_INFO (this->GetPrefix () << ", Offsetting lifetime to " << m_expireTime.ToDouble (Time::S) << "s, " << (m_expireTime-Simulator::Now ()).ToDouble (Time::S) << "s left");
-}
-
-
-const Name &
-Entry::GetPrefix () const
-{
- return m_interest->GetName ();
-}
-
-const Time &
-Entry::GetExpireTime () const
-{
- return m_expireTime;
-}
-
-bool
-Entry::IsNonceSeen (uint32_t nonce) const
-{
- return m_seenNonces.find (nonce) != m_seenNonces.end ();
-}
-
-void
-Entry::AddSeenNonce (uint32_t nonce)
-{
- m_seenNonces.insert (nonce);
-}
-
-
-Entry::in_iterator
-Entry::AddIncoming (Ptr<Face> face)
-{
- std::pair<in_iterator,bool> ret =
- m_incoming.insert (IncomingFace (face));
-
- // NS_ASSERT_MSG (ret.second, "Something is wrong");
-
- return ret.first;
-}
-
-void
-Entry::RemoveIncoming (Ptr<Face> face)
-{
- m_incoming.erase (face);
-}
-
-void
-Entry::ClearIncoming ()
-{
- m_incoming.clear ();
-}
-
-Entry::out_iterator
-Entry::AddOutgoing (Ptr<Face> face)
-{
- std::pair<out_iterator,bool> ret =
- m_outgoing.insert (OutgoingFace (face));
-
- if (!ret.second)
- { // outgoing face already exists
- const_cast<OutgoingFace&>(*ret.first).UpdateOnRetransmit ();
- // m_outgoing.modify (ret.first,
- // ll::bind (&OutgoingFace::UpdateOnRetransmit, ll::_1));
- }
-
- return ret.first;
-}
-
-void
-Entry::ClearOutgoing ()
-{
- m_outgoing.clear ();
-}
-
-void
-Entry::RemoveAllReferencesToFace (Ptr<Face> face)
-{
- in_iterator incoming = m_incoming.find (face);
-
- if (incoming != m_incoming.end ())
- m_incoming.erase (incoming);
-
- out_iterator outgoing =
- m_outgoing.find (face);
-
- if (outgoing != m_outgoing.end ())
- m_outgoing.erase (outgoing);
-}
-
-// void
-// Entry::SetWaitingInVain (Entry::out_iterator face)
-// {
-// NS_LOG_DEBUG (boost::cref (*face->m_face));
-
-// m_outgoing.modify (face,
-// (&ll::_1)->*&EntryOutgoingFace::m_waitingInVain = true);
-// }
-
-void
-Entry::SetWaitingInVain (Ptr<Face> face)
-{
- // NS_LOG_DEBUG (boost::cref (*face->m_face));
-
- out_iterator item = m_outgoing.find (face);
- if (item == m_outgoing.end ())
- return;
-
- const_cast<OutgoingFace&>(*item).m_waitingInVain = true;
- // m_outgoing.modify (item,
- // (&ll::_1)->*&OutgoingFace::m_waitingInVain = true);
-}
-
-
-bool
-Entry::AreAllOutgoingInVain () const
-{
- NS_LOG_DEBUG (m_outgoing.size ());
-
- bool inVain = true;
- std::for_each (m_outgoing.begin (), m_outgoing.end (),
- ll::var(inVain) &= (&ll::_1)->*&OutgoingFace::m_waitingInVain);
-
- NS_LOG_DEBUG ("inVain " << inVain);
- return inVain;
-}
-
-bool
-Entry::AreTherePromisingOutgoingFacesExcept (Ptr<Face> face) const
-{
- bool inVain = true;
- std::for_each (m_outgoing.begin (), m_outgoing.end (),
- ll::var(inVain) &=
- ((&ll::_1)->*&OutgoingFace::m_face == face ||
- (&ll::_1)->*&OutgoingFace::m_waitingInVain));
-
- return !inVain;
-}
-
-void
-Entry::IncreaseAllowedRetxCount ()
-{
- if (Simulator::Now () - m_lastRetransmission >= MilliSeconds (100))
- {
- // cheat:
- // don't allow retransmission faster than every 100ms
- m_maxRetxCount++;
- m_lastRetransmission = Simulator::Now ();
- }
-}
-
-Ptr<fib::Entry>
-Entry::GetFibEntry ()
-{
- return m_fibEntry;
-};
-
-const Entry::in_container &
-Entry::GetIncoming () const
-{
- return m_incoming;
-}
-
-const Entry::out_container &
-Entry::GetOutgoing () const
-{
- return m_outgoing;
-}
-
-uint32_t
-Entry::GetOutgoingCount () const
-{
- return m_outgoing.size ();
-}
-
-
-uint32_t
-Entry::GetMaxRetxCount () const
-{
- return m_maxRetxCount;
-}
-
-Ptr<const Interest>
-Entry::GetInterest () const
-{
- return m_interest;
-}
-
-std::ostream& operator<< (std::ostream& os, const Entry &entry)
-{
- os << "Prefix: " << entry.GetPrefix () << "\n";
- os << "In: ";
- bool first = true;
- BOOST_FOREACH (const IncomingFace &face, entry.m_incoming)
- {
- if (!first)
- os << ",";
- else
- first = false;
-
- os << *face.m_face;
- }
-
- os << "\nOut: ";
- first = true;
- BOOST_FOREACH (const OutgoingFace &face, entry.m_outgoing)
- {
- if (!first)
- os << ",";
- else
- first = false;
-
- os << *face.m_face;
- }
- os << "\nNonces: ";
- first = true;
- BOOST_FOREACH (uint32_t nonce, entry.m_seenNonces)
- {
- if (!first)
- os << ",";
- else
- first = false;
-
- os << nonce;
- }
-
- return os;
-}
-
-
-} // namespace pit
-} // namespace ndn
-} // namespace ns3
diff --git a/model/pit/ndn-pit-entry.h b/model/pit/ndn-pit-entry.h
deleted file mode 100644
index dd90b9f..0000000
--- a/model/pit/ndn-pit-entry.h
+++ /dev/null
@@ -1,367 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_PIT_ENTRY_H_
-#define _NDN_PIT_ENTRY_H_
-
-#include "ns3/ptr.h"
-#include "ns3/simple-ref-count.h"
-
-#include "ns3/ndn-fib.h"
-
-#include "ns3/ndn-pit-entry-incoming-face.h"
-#include "ns3/ndn-pit-entry-outgoing-face.h"
-
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/tag.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-// #include <boost/multi_index/composite_key.hpp>
-// #include <boost/multi_index/hashed_index.hpp>
-#include <boost/multi_index/member.hpp>
-// #include <boost/multi_index/mem_fun.hpp>
-#include <set>
-#include <boost/shared_ptr.hpp>
-
-namespace ns3 {
-namespace ndn {
-
-class Pit;
-
-namespace fw { class Tag; }
-
-namespace pit {
-
-/**
- * @ingroup ndn-pit
- * @brief structure for PIT entry
- *
- * All set-methods are virtual, in case index rearrangement is necessary in the derived classes
- */
-class Entry : public SimpleRefCount<Entry>
-{
-public:
- typedef std::set< IncomingFace > in_container; ///< @brief incoming faces container type
- typedef in_container::iterator in_iterator; ///< @brief iterator to incoming faces
-
- // typedef OutgoingFaceContainer::type out_container; ///< @brief outgoing faces container type
- typedef std::set< OutgoingFace > out_container; ///< @brief outgoing faces container type
- typedef out_container::iterator out_iterator; ///< @brief iterator to outgoing faces
-
- typedef std::set< uint32_t > nonce_container; ///< @brief nonce container type
-
- /**
- * \brief PIT entry constructor
- * \param prefix Prefix of the PIT entry
- * \param offsetTime Relative time to the current moment, representing PIT entry lifetime
- * \param fibEntry A FIB entry associated with the PIT entry
- */
- Entry (Pit &container, Ptr<const Interest> header, Ptr<fib::Entry> fibEntry);
-
- /**
- * @brief Virtual destructor
- */
- virtual ~Entry ();
-
- /**
- * @brief Update lifetime of PIT entry
- *
- * @param lifetime desired lifetime of the pit entry (relative to the Simulator::Now ())
- *
- * This function will update PIT entry lifetime to the maximum of the current lifetime and
- * the lifetime Simulator::Now () + lifetime
- */
- virtual void
- UpdateLifetime (const Time &lifetime);
-
- /**
- * @brief Offset the currently set PIT lifetime (allowed both negative and positive offsets)
- *
- * @param offsetTime positive or negative offset for the PIT lifetime.
- *
- * If PIT expire time becomes less than Simulator::Now, then it is adjusted to Simulator::Now.
- */
- virtual void
- OffsetLifetime (const Time &offsetTime);
-
- /**
- * @brief Get prefix of the PIT entry
- */
- const Name &
- GetPrefix () const;
-
- /**
- * @brief Get current expiration time of the record
- *
- * @returns current expiration time of the record
- */
- const Time &
- GetExpireTime () const;
-
- /**
- * @brief Check if nonce `nonce` for the same prefix has already been seen
- *
- * @param nonce Nonce to check
- */
- bool
- IsNonceSeen (uint32_t nonce) const;
-
- /**
- * @brief Add `nonce` to the list of seen nonces
- *
- * @param nonce nonce to add to the list of seen nonces
- *
- * All nonces are stored for the lifetime of the PIT entry
- */
- virtual void
- AddSeenNonce (uint32_t nonce);
-
- /**
- * @brief Add `face` to the list of incoming faces
- *
- * @param face Face to add to the list of incoming faces
- * @returns iterator to the added entry
- */
- virtual in_iterator
- AddIncoming (Ptr<Face> face);
-
- /**
- * @brief Remove incoming entry for face `face`
- */
- virtual void
- RemoveIncoming (Ptr<Face> face);
-
- /**
- * @brief Clear all incoming faces either after all of them were satisfied or NACKed
- */
- virtual void
- ClearIncoming ();
-
- /**
- * @brief Add `face` to the list of outgoing faces
- *
- * @param face Face to add to the list of outgoing faces
- * @returns iterator to the added entry
- */
- virtual out_iterator
- AddOutgoing (Ptr<Face> face);
-
- /**
- * @brief Clear all incoming faces either after all of them were satisfied or NACKed
- */
- virtual void
- ClearOutgoing ();
-
- /**
- * @brief Remove all references to face.
- *
- * This method should be called before face is completely removed from the stack.
- * Face is removed from the lists of incoming and outgoing faces
- */
- virtual void
- RemoveAllReferencesToFace (Ptr<Face> face);
-
- /**
- * @brief Flag outgoing face as hopeless
- */
- // virtual void
- // SetWaitingInVain (out_iterator face);
- virtual void
- SetWaitingInVain (Ptr<Face> face);
-
- /**
- * @brief Check if all outgoing faces are NACKed
- */
- bool
- AreAllOutgoingInVain () const;
-
- /**
- * @brief Similar to AreAllOutgoingInVain, but ignores `face`
- * \see AreAllOutgoingInVain
- **/
- bool
- AreTherePromisingOutgoingFacesExcept (Ptr<Face> face) const;
-
- /**
- * @brief Increase maximum limit of allowed retransmission per outgoing face
- */
- virtual void
- IncreaseAllowedRetxCount ();
-
- /**
- * @brief Get maximum allowed number of retransmissions via outgoing faces
- */
- uint32_t
- GetMaxRetxCount () const;
-
- /**
- * @brief Get associated FIB entry
- */
- Ptr<fib::Entry>
- GetFibEntry ();
-
- /**
- * @brief Get associated list (const reference) of incoming faces
- */
- const in_container &
- GetIncoming () const;
-
- /**
- * @brief Get associated list (const reference) of outgoing faces
- */
- const out_container &
- GetOutgoing () const;
-
- /**
- * @brief Get number of outgoing faces (needed for python bindings)
- */
- uint32_t
- GetOutgoingCount () const;
-
- /**
- * @brief Add new forwarding strategy tag
- */
- inline void
- AddFwTag (boost::shared_ptr< fw::Tag > tag);
-
- /**
- * @brief Get forwarding strategy tag (tag is not removed)
- */
- template<class T>
- inline boost::shared_ptr< T >
- GetFwTag ();
-
- /**
- * @brief Remove the forwarding strategy tag
- */
- template<class T>
- inline void
- RemoveFwTag ();
-
- /**
- * @brief Get Interest (if several interests are received, then nonce is from the first Interest)
- */
- Ptr<const Interest>
- GetInterest () const;
-
-private:
- friend std::ostream& operator<< (std::ostream& os, const Entry &entry);
-
-protected:
- Pit &m_container; ///< @brief Reference to the container (to rearrange indexes, if necessary)
-
- Ptr<const Interest> m_interest; ///< \brief Interest of the PIT entry (if several interests are received, then nonce is from the first Interest)
- Ptr<fib::Entry> m_fibEntry; ///< \brief FIB entry related to this prefix
-
- nonce_container m_seenNonces; ///< \brief map of nonces that were seen for this prefix
- in_container m_incoming; ///< \brief container for incoming interests
- out_container m_outgoing; ///< \brief container for outgoing interests
-
- Time m_expireTime; ///< \brief Time when PIT entry will be removed
-
- Time m_lastRetransmission; ///< @brief Last time when number of retransmissions were increased
- uint32_t m_maxRetxCount; ///< @brief Maximum allowed number of retransmissions via outgoing faces
-
- std::list< boost::shared_ptr<fw::Tag> > m_fwTags; ///< @brief Forwarding strategy tags
-};
-
-/// @cond include_hidden
-struct EntryIsNotEmpty
-{
- bool
- operator () (Ptr<Entry> entry)
- {
- return !entry->GetIncoming ().empty ();
- }
-};
-/// @endcond
-
-std::ostream& operator<< (std::ostream& os, const Entry &entry);
-
-inline void
-Entry::AddFwTag (boost::shared_ptr< fw::Tag > tag)
-{
- m_fwTags.push_back (tag);
-}
-
-/**
- * @brief Get and remove forwarding strategy tag
- */
-template<class T>
-inline boost::shared_ptr< T >
-Entry::GetFwTag ()
-{
- for (std::list< boost::shared_ptr<fw::Tag> >::iterator item = m_fwTags.begin ();
- item != m_fwTags.end ();
- item ++)
- {
- boost::shared_ptr< T > retPtr = boost::dynamic_pointer_cast<T> (*item);
- if (retPtr != boost::shared_ptr< T > ())
- {
- return retPtr;
- }
- }
-
- return boost::shared_ptr< T > ();
-}
-
-// /**
-// * @brief Peek the forwarding strategy tag
-// */
-// template<class T>
-// inline boost::shared_ptr< const T >
-// Entry::PeekFwTag () const
-// {
-// for (std::list< boost::shared_ptr<fw::Tag> >::const_iterator item = m_fwTags.begin ();
-// item != m_fwTags.end ();
-// item ++)
-// {
-// boost::shared_ptr< const T > retPtr = boost::dynamic_pointer_cast<const T> (*item);
-// if (retPtr != 0)
-// {
-// return retPtr;
-// }
-// }
-
-// return 0;
-// }
-
-template<class T>
-inline void
-Entry::RemoveFwTag ()
-{
- for (std::list< boost::shared_ptr<fw::Tag> >::iterator item = m_fwTags.begin ();
- item != m_fwTags.end ();
- item ++)
- {
- boost::shared_ptr< T > retPtr = boost::dynamic_pointer_cast< T > (*item);
- if (retPtr != boost::shared_ptr< T > ())
- {
- m_fwTags.erase (item);
- return;
- }
- }
-}
-
-
-} // namespace pit
-} // namespace ndn
-} // namespace ns3
-
-#endif // _NDN_PIT_ENTRY_H_
diff --git a/model/pit/ndn-pit-impl.cc b/model/pit/ndn-pit-impl.cc
deleted file mode 100644
index a0d0c3e..0000000
--- a/model/pit/ndn-pit-impl.cc
+++ /dev/null
@@ -1,133 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-pit-impl.h"
-
-#include "../../utils/trie/empty-policy.h"
-#include "../../utils/trie/persistent-policy.h"
-#include "../../utils/trie/random-policy.h"
-#include "../../utils/trie/lru-policy.h"
-#include "../../utils/trie/multi-policy.h"
-#include "../../utils/trie/aggregate-stats-policy.h"
-
-#include "ns3/log.h"
-
-NS_LOG_COMPONENT_DEFINE ("ndn.pit.PitImpl");
-
-#include "custom-policies/serialized-size-policy.h"
-
-#include "ns3/string.h"
-#include "ns3/uinteger.h"
-#include "ns3/simulator.h"
-
-#include <boost/lambda/bind.hpp>
-#include <boost/lambda/lambda.hpp>
-
-
-using namespace boost::tuples;
-using namespace boost;
-namespace ll = boost::lambda;
-
-#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
- static struct X ## type ## templ ## RegistrationClass \
- { \
- X ## type ## templ ## RegistrationClass () { \
- ns3::TypeId tid = type<templ>::GetTypeId (); \
- tid.GetParent (); \
- } \
- } x_ ## type ## templ ## RegistrationVariable
-
-namespace ns3 {
-namespace ndn {
-namespace pit {
-
-using namespace ndnSIM;
-
-template<>
-uint32_t
-PitImpl<serialized_size_policy_traits>::GetCurrentSize () const
-{
- return super::getPolicy ().get_current_space_used ();
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////
-
-// explicit instantiation and registering
-template class PitImpl<persistent_policy_traits>;
-template class PitImpl<random_policy_traits>;
-template class PitImpl<lru_policy_traits>;
-template class PitImpl<serialized_size_policy_traits>;
-
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, persistent_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, random_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, lru_policy_traits);
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, serialized_size_policy_traits);
-
-
-typedef multi_policy_traits< boost::mpl::vector2< persistent_policy_traits,
- aggregate_stats_policy_traits > > PersistentWithCountsTraits;
-typedef multi_policy_traits< boost::mpl::vector2< random_policy_traits,
- aggregate_stats_policy_traits > > RandomWithCountsTraits;
-typedef multi_policy_traits< boost::mpl::vector2< lru_policy_traits,
- aggregate_stats_policy_traits > > LruWithCountsTraits;
-typedef multi_policy_traits< boost::mpl::vector2< serialized_size_policy_traits,
- aggregate_stats_policy_traits > > SerializedSizeWithCountsTraits;
-
-template class PitImpl<PersistentWithCountsTraits>;
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, PersistentWithCountsTraits);
-
-template class PitImpl<RandomWithCountsTraits>;
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, RandomWithCountsTraits);
-
-template class PitImpl<LruWithCountsTraits>;
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, LruWithCountsTraits);
-
-template class PitImpl<SerializedSizeWithCountsTraits>;
-NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, SerializedSizeWithCountsTraits);
-
-#ifdef DOXYGEN
-// /**
-// * \brief PIT in which new entries will be rejected if PIT size reached its limit
-// */
-class Persistent : public PitImpl<persistent_policy_traits> { };
-
-/**
- * \brief PIT in which PIT reaches its limit, random entry (could be the newly created one) will be removed from PIT
- */
-class Random : public PitImpl<random_policy_traits> { };
-
-/**
- * \brief PIT in which the least recently used entry (the oldest entry with minimum number of incoming faces)
- * will be removed when PIT size reached its limit
- */
-class Lru : public PitImpl<lru_policy_traits> { };
-
-/**
- * @brief A variant of persistent PIT implementation where size of PIT is based on size of interests in bytes (MaxSize parameter)
- */
-class SerializedSize : public PitImpl<serialized_size_policy_traits> { };
-
-#endif
-
-} // namespace pit
-} // namespace ndn
-} // namespace ns3
diff --git a/model/pit/ndn-pit-impl.h b/model/pit/ndn-pit-impl.h
deleted file mode 100644
index eece4c4..0000000
--- a/model/pit/ndn-pit-impl.h
+++ /dev/null
@@ -1,466 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_PIT_IMPL_H_
-#define _NDN_PIT_IMPL_H_
-
-#include "ndn-pit.h"
-
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-
-#include "../../utils/trie/trie-with-policy.h"
-#include "ndn-pit-entry-impl.h"
-
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-#include "ns3/ndn-forwarding-strategy.h"
-#include "ns3/ndn-name.h"
-
-
-namespace ns3 {
-namespace ndn {
-
-class ForwardingStrategy;
-
-namespace pit {
-
-/**
- * @ingroup ndn-pit
- * @brief Class implementing Pending Interests Table
- */
-template<class Policy>
-class PitImpl : public Pit
- , protected ndnSIM::trie_with_policy<Name,
- ndnSIM::smart_pointer_payload_traits< EntryImpl< PitImpl< Policy > > >,
- // ndnSIM::persistent_policy_traits
- Policy
- >
-{
-public:
- typedef ndnSIM::trie_with_policy<Name,
- ndnSIM::smart_pointer_payload_traits< EntryImpl< PitImpl< Policy > > >,
- // ndnSIM::persistent_policy_traits
- Policy
- > super;
- typedef EntryImpl< PitImpl< Policy > > entry;
-
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId GetTypeId ();
-
- /**
- * \brief PIT constructor
- */
- PitImpl ();
-
- /**
- * \brief Destructor
- */
- virtual ~PitImpl ();
-
- // inherited from Pit
- virtual Ptr<Entry>
- Lookup (const Data &header);
-
- virtual Ptr<Entry>
- Lookup (const Interest &header);
-
- virtual Ptr<Entry>
- Find (const Name &prefix);
-
- virtual Ptr<Entry>
- Create (Ptr<const Interest> header);
-
- virtual void
- MarkErased (Ptr<Entry> entry);
-
- virtual void
- Print (std::ostream &os) const;
-
- virtual uint32_t
- GetSize () const;
-
- virtual Ptr<Entry>
- Begin ();
-
- virtual Ptr<Entry>
- End ();
-
- virtual Ptr<Entry>
- Next (Ptr<Entry>);
-
- const typename super::policy_container &
- GetPolicy () const { return super::getPolicy (); }
-
- typename super::policy_container &
- GetPolicy () { return super::getPolicy (); }
-
-protected:
- void RescheduleCleaning ();
- void CleanExpired ();
-
- // inherited from Object class
- virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
- virtual void DoDispose (); ///< @brief Do cleanup
-
-private:
- uint32_t
- GetMaxSize () const;
-
- void
- SetMaxSize (uint32_t maxSize);
-
- uint32_t
- GetCurrentSize () const;
-
-private:
- EventId m_cleanEvent;
- Ptr<Fib> m_fib; ///< \brief Link to FIB table
- Ptr<ForwardingStrategy> m_forwardingStrategy;
-
- static LogComponent g_log; ///< @brief Logging variable
-
- // indexes
- typedef
- boost::intrusive::multiset<entry,
- boost::intrusive::compare < TimestampIndex< entry > >,
- boost::intrusive::member_hook< entry,
- boost::intrusive::set_member_hook<>,
- &entry::time_hook_>
- > time_index;
- time_index i_time;
-
- friend class EntryImpl< PitImpl >;
-};
-
-//////////////////////////////////////////
-////////// Implementation ////////////////
-//////////////////////////////////////////
-
-template<class Policy>
-LogComponent PitImpl< Policy >::g_log = LogComponent (("ndn.pit." + Policy::GetName ()).c_str ());
-
-
-template<class Policy>
-TypeId
-PitImpl< Policy >::GetTypeId ()
-{
- static TypeId tid = TypeId (("ns3::ndn::pit::"+Policy::GetName ()).c_str ())
- .SetGroupName ("Ndn")
- .SetParent<Pit> ()
- .AddConstructor< PitImpl< Policy > > ()
- .AddAttribute ("MaxSize",
- "Set maximum size of PIT in bytes. If 0, limit is not enforced",
- UintegerValue (0),
- MakeUintegerAccessor (&PitImpl< Policy >::GetMaxSize,
- &PitImpl< Policy >::SetMaxSize),
- MakeUintegerChecker<uint32_t> ())
-
- .AddAttribute ("CurrentSize", "Get current size of PIT in bytes",
- TypeId::ATTR_GET,
- UintegerValue (0),
- MakeUintegerAccessor (&PitImpl< Policy >::GetCurrentSize),
- MakeUintegerChecker<uint32_t> ())
- ;
-
- return tid;
-}
-
-template<class Policy>
-uint32_t
-PitImpl<Policy>::GetCurrentSize () const
-{
- return super::getPolicy ().size ();
-}
-
-template<class Policy>
-PitImpl<Policy>::PitImpl ()
-{
-}
-
-template<class Policy>
-PitImpl<Policy>::~PitImpl ()
-{
-}
-
-template<class Policy>
-uint32_t
-PitImpl<Policy>::GetMaxSize () const
-{
- return super::getPolicy ().get_max_size ();
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::SetMaxSize (uint32_t maxSize)
-{
- super::getPolicy ().set_max_size (maxSize);
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::NotifyNewAggregate ()
-{
- if (m_fib == 0)
- {
- m_fib = GetObject<Fib> ();
- }
- if (m_forwardingStrategy == 0)
- {
- m_forwardingStrategy = GetObject<ForwardingStrategy> ();
- }
-
- Pit::NotifyNewAggregate ();
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::DoDispose ()
-{
- super::clear ();
-
- m_forwardingStrategy = 0;
- m_fib = 0;
-
- Pit::DoDispose ();
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::RescheduleCleaning ()
-{
- // m_cleanEvent.Cancel ();
- Simulator::Remove (m_cleanEvent); // slower, but better for memory
- if (i_time.empty ())
- {
- // NS_LOG_DEBUG ("No items in PIT");
- return;
- }
-
- Time nextEvent = i_time.begin ()->GetExpireTime () - Simulator::Now ();
- if (nextEvent <= 0) nextEvent = Seconds (0);
-
- NS_LOG_DEBUG ("Schedule next cleaning in " <<
- nextEvent.ToDouble (Time::S) << "s (at " <<
- i_time.begin ()->GetExpireTime () << "s abs time");
-
- m_cleanEvent = Simulator::Schedule (nextEvent,
- &PitImpl<Policy>::CleanExpired, this);
-}
-
-template<class Policy>
-void
-PitImpl<Policy>::CleanExpired ()
-{
- NS_LOG_LOGIC ("Cleaning PIT. Total: " << i_time.size ());
- Time now = Simulator::Now ();
-
- // uint32_t count = 0;
- while (!i_time.empty ())
- {
- typename time_index::iterator entry = i_time.begin ();
- if (entry->GetExpireTime () <= now) // is the record stale?
- {
- m_forwardingStrategy->WillEraseTimedOutPendingInterest (entry->to_iterator ()->payload ());
- super::erase (entry->to_iterator ());
- // count ++;
- }
- else
- break; // nothing else to do. All later records will not be stale
- }
-
- if (super::getPolicy ().size ())
- {
- NS_LOG_DEBUG ("Size: " << super::getPolicy ().size ());
- NS_LOG_DEBUG ("i_time size: " << i_time.size ());
- }
- RescheduleCleaning ();
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Lookup (const Data &header)
-{
- /// @todo use predicate to search with exclude filters
- typename super::iterator item = super::longest_prefix_match_if (header.GetName (), EntryIsNotEmpty ());
-
- if (item == super::end ())
- return 0;
- else
- return item->payload (); // which could also be 0
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Lookup (const Interest &header)
-{
- // NS_LOG_FUNCTION (header.GetName ());
- NS_ASSERT_MSG (m_fib != 0, "FIB should be set");
- NS_ASSERT_MSG (m_forwardingStrategy != 0, "Forwarding strategy should be set");
-
- typename super::iterator foundItem, lastItem;
- bool reachLast;
- boost::tie (foundItem, reachLast, lastItem) = super::getTrie ().find (header.GetName ());
-
- if (!reachLast || lastItem == super::end ())
- return 0;
- else
- return lastItem->payload (); // which could also be 0
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Find (const Name &prefix)
-{
- typename super::iterator item = super::find_exact (prefix);
-
- if (item == super::end ())
- return 0;
- else
- return item->payload ();
-}
-
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Create (Ptr<const Interest> header)
-{
- NS_LOG_DEBUG (header->GetName ());
- Ptr<fib::Entry> fibEntry = m_fib->LongestPrefixMatch (*header);
- if (fibEntry == 0)
- return 0;
-
- // NS_ASSERT_MSG (fibEntry != 0,
- // "There should be at least default route set" <<
- // " Prefix = "<< header->GetName() << ", NodeID == " << m_fib->GetObject<Node>()->GetId() << "\n" << *m_fib);
-
- Ptr< entry > newEntry = ns3::Create< entry > (boost::ref (*this), header, fibEntry);
- std::pair< typename super::iterator, bool > result = super::insert (header->GetName (), newEntry);
- if (result.first != super::end ())
- {
- if (result.second)
- {
- newEntry->SetTrie (result.first);
- return newEntry;
- }
- else
- {
- // should we do anything?
- // update payload? add new payload?
- return result.first->payload ();
- }
- }
- else
- return 0;
-}
-
-
-template<class Policy>
-void
-PitImpl<Policy>::MarkErased (Ptr<Entry> item)
-{
- if (this->m_PitEntryPruningTimout.IsZero ())
- {
- super::erase (StaticCast< entry > (item)->to_iterator ());
- }
- else
- {
- item->OffsetLifetime (this->m_PitEntryPruningTimout - item->GetExpireTime () + Simulator::Now ());
- }
-}
-
-
-template<class Policy>
-void
-PitImpl<Policy>::Print (std::ostream& os) const
-{
- // !!! unordered_set imposes "random" order of item in the same level !!!
- typename super::parent_trie::const_recursive_iterator item (super::getTrie ()), end (0);
- for (; item != end; item++)
- {
- if (item->payload () == 0) continue;
-
- os << item->payload ()->GetPrefix () << "\t" << *item->payload () << "\n";
- }
-}
-
-template<class Policy>
-uint32_t
-PitImpl<Policy>::GetSize () const
-{
- return super::getPolicy ().size ();
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Begin ()
-{
- typename super::parent_trie::recursive_iterator item (super::getTrie ()), end (0);
- for (; item != end; item++)
- {
- if (item->payload () == 0) continue;
- break;
- }
-
- if (item == end)
- return End ();
- else
- return item->payload ();
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::End ()
-{
- return 0;
-}
-
-template<class Policy>
-Ptr<Entry>
-PitImpl<Policy>::Next (Ptr<Entry> from)
-{
- if (from == 0) return 0;
-
- typename super::parent_trie::recursive_iterator
- item (*StaticCast< entry > (from)->to_iterator ()),
- end (0);
-
- for (item++; item != end; item++)
- {
- if (item->payload () == 0) continue;
- break;
- }
-
- if (item == end)
- return End ();
- else
- return item->payload ();
-}
-
-
-} // namespace pit
-} // namespace ndn
-} // namespace ns3
-
-#endif /* NDN_PIT_IMPL_H */
diff --git a/model/pit/ndn-pit.cc b/model/pit/ndn-pit.cc
deleted file mode 100644
index 281a8d0..0000000
--- a/model/pit/ndn-pit.cc
+++ /dev/null
@@ -1,75 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-pit.h"
-
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-
-#include "ns3/log.h"
-#include "ns3/nstime.h"
-#include "ns3/uinteger.h"
-#include "ns3/simulator.h"
-#include "ns3/packet.h"
-
-#include <boost/lambda/bind.hpp>
-#include <boost/lambda/lambda.hpp>
-
-NS_LOG_COMPONENT_DEFINE ("ndn.Pit");
-
-namespace ns3 {
-namespace ndn {
-
-NS_OBJECT_ENSURE_REGISTERED (Pit);
-
-TypeId
-Pit::GetTypeId ()
-{
- static TypeId tid = TypeId ("ns3::ndn::Pit")
- .SetGroupName ("Ndn")
- .SetParent<Object> ()
-
- .AddAttribute ("PitEntryPruningTimout",
- "Timeout for PIT entry to live after being satisfied. To make sure recently satisfied interest will not be satisfied again",
- TimeValue (), // by default, PIT entries are removed instantly
- MakeTimeAccessor (&Pit::m_PitEntryPruningTimout),
- MakeTimeChecker ())
-
- .AddAttribute ("MaxPitEntryLifetime",
- "Maximum amount of time for which a router is willing to maintain a PIT entry. "
- "Actual PIT lifetime should be minimum of MaxPitEntryLifetime and InterestLifetime specified in the Interest packet",
- TimeValue (), // by default, PIT entries are kept for the time, specified by the InterestLifetime
- MakeTimeAccessor (&Pit::GetMaxPitEntryLifetime, &Pit::SetMaxPitEntryLifetime),
- MakeTimeChecker ())
- ;
-
- return tid;
-}
-
-Pit::Pit ()
-{
-}
-
-Pit::~Pit ()
-{
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/model/pit/ndn-pit.h b/model/pit/ndn-pit.h
deleted file mode 100644
index 1185892..0000000
--- a/model/pit/ndn-pit.h
+++ /dev/null
@@ -1,226 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _NDN_PIT_H_
-#define _NDN_PIT_H_
-
-#include "ns3/object.h"
-#include "ns3/nstime.h"
-#include "ns3/event-id.h"
-
-#include "ndn-pit-entry.h"
-
-namespace ns3 {
-namespace ndn {
-
-/**
- * @ingroup ndn
- * @defgroup ndn-pit PIT
- */
-
-/**
- * @ingroup ndn-pit
- * @brief Namespace for PIT operations
- */
-namespace pit {
-}
-
-class L3Protocol;
-class Face;
-class Data;
-class Interest;
-
-typedef Interest InterestHeader;
-typedef Data DataHeader;
-
-////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////
-
-/**
- * @ingroup ndn-pit
- * @brief Class implementing Pending Interests Table
- */
-class Pit : public Object
-{
-public:
- /**
- * \brief Interface ID
- *
- * \return interface ID
- */
- static TypeId GetTypeId ();
-
- /**
- * \brief PIT constructor
- */
- Pit ();
-
- /**
- * \brief Destructor
- */
- virtual ~Pit ();
-
- /**
- * \brief Find corresponding PIT entry for the given content name
- *
- * Not that this call should be repeated enough times until it return 0.
- * This way all records with shorter or equal prefix as in content object will be found
- * and satisfied.
- *
- * \param prefix Prefix for which to lookup the entry
- * \returns smart pointer to PIT entry. If record not found,
- * returns 0
- */
- virtual Ptr<pit::Entry>
- Lookup (const Data &header) = 0;
-
- /**
- * \brief Find a PIT entry for the given content interest
- * \param header parsed interest header
- * \returns iterator to Pit entry. If record not found,
- * return end() iterator
- */
- virtual Ptr<pit::Entry>
- Lookup (const Interest &header) = 0;
-
- /**
- * @brief Get PIT entry for the prefix (exact match)
- *
- * @param prefix Name for PIT entry
- * @returns If entry is found, a valid iterator (Ptr<pit::Entry>) will be returned. Otherwise End () (==0)
- */
- virtual Ptr<pit::Entry>
- Find (const Name &prefix) = 0;
-
- /**
- * @brief Creates a PIT entry for the given interest
- * @param header parsed interest header
- * @returns iterator to Pit entry. If record could not be created (e.g., limit reached),
- * return end() iterator
- *
- * Note. This call assumes that the entry does not exist (i.e., there was a Lookup call before)
- */
- virtual Ptr<pit::Entry>
- Create (Ptr<const Interest> header) = 0;
-
- /**
- * @brief Mark PIT entry deleted
- * @param entry PIT entry
- *
- * Effectively, this method removes all incoming/outgoing faces and set
- * lifetime +m_PitEntryDefaultLifetime from Now ()
- */
- virtual void
- MarkErased (Ptr<pit::Entry> entry) = 0;
-
- /**
- * @brief Print out PIT contents for debugging purposes
- *
- * Note that there is no definite order in which entries are printed out
- */
- virtual void
- Print (std::ostream &os) const = 0;
-
- /**
- * @brief Get number of entries in PIT
- */
- virtual uint32_t
- GetSize () const = 0;
-
- /**
- * @brief Return first element of FIB (no order guaranteed)
- */
- virtual Ptr<pit::Entry>
- Begin () = 0;
-
- /**
- * @brief Return item next after last (no order guaranteed)
- */
- virtual Ptr<pit::Entry>
- End () = 0;
-
- /**
- * @brief Advance the iterator
- */
- virtual Ptr<pit::Entry>
- Next (Ptr<pit::Entry>) = 0;
-
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
-
- /**
- * @brief Static call to cheat python bindings
- */
- static inline Ptr<Pit>
- GetPit (Ptr<Object> node);
-
- /**
- * @brief Get maximum PIT entry lifetime
- */
- inline const Time&
- GetMaxPitEntryLifetime () const;
-
- /**
- * @brief Set maximum PIT entry lifetime
- */
- inline void
- SetMaxPitEntryLifetime (const Time &maxLifetime);
-
-protected:
- // configuration variables. Check implementation of GetTypeId for more details
- Time m_PitEntryPruningTimout;
-
- Time m_maxPitEntryLifetime;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-
-inline std::ostream&
-operator<< (std::ostream& os, const Pit &pit)
-{
- pit.Print (os);
- return os;
-}
-
-inline Ptr<Pit>
-Pit::GetPit (Ptr<Object> node)
-{
- return node->GetObject<Pit> ();
-}
-
-inline const Time&
-Pit::GetMaxPitEntryLifetime () const
-{
- return m_maxPitEntryLifetime;
-}
-
-inline void
-Pit::SetMaxPitEntryLifetime (const Time &maxLifetime)
-{
- m_maxPitEntryLifetime = maxLifetime;
-}
-
-
-} // namespace ndn
-} // namespace ns3
-
-#endif /* NDN_PIT_H */
diff --git a/model/wire/ccnb.h b/model/wire/ccnb.h
deleted file mode 100644
index eca8707..0000000
--- a/model/wire/ccnb.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * BSD license, See the doc/LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_WIRE_CCNB_H
-#define NDN_WIRE_CCNB_H
-
-#include "ns3/ndn-common.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-
-/**
- * @brief Namespace for CCNb wire format operations
- */
-namespace ccnb {
-
-/**
- * @brief Routines to serialize/deserialize NDN interest in ccnb format
- *
- * @see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- **/
-class Interest : public Header
-{
-public:
- Interest ();
- Interest (Ptr<ndn::Interest> interest);
-
- Ptr<ndn::Interest>
- GetInterest ();
-
- static Ptr<Packet>
- ToWire (Ptr<const ndn::Interest> interest);
-
- static Ptr<ndn::Interest>
- FromWire (Ptr<Packet> packet);
-
- //////////////////////////////////////////////////////////////////
- // from Header
- static TypeId GetTypeId (void);
- virtual TypeId GetInstanceTypeId (void) const;
- virtual void Print (std::ostream &os) const;
- virtual uint32_t GetSerializedSize (void) const;
- virtual void Serialize (Buffer::Iterator start) const;
- virtual uint32_t Deserialize (Buffer::Iterator start);
-
-private:
- Ptr<ndn::Interest> m_interest;
-};
-
-
-/**
- * @brief Routines to serialize/deserialize NDN Data packet in ccnb format
- *
- * @see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- **/
-class Data : public Header
-{
-public:
- Data ();
- Data (Ptr<ndn::Data> data);
-
- Ptr<ndn::Data>
- GetData ();
-
- static Ptr<Packet>
- ToWire (Ptr<const ndn::Data> data);
-
- static Ptr<ndn::Data>
- FromWire (Ptr<Packet> packet);
-
- // from Header
- static TypeId GetTypeId (void);
- virtual TypeId GetInstanceTypeId (void) const;
- virtual void Print (std::ostream &os) const;
- virtual uint32_t GetSerializedSize (void) const;
- virtual void Serialize (Buffer::Iterator start) const;
- virtual uint32_t Deserialize (Buffer::Iterator start);
-
-private:
- Ptr<ndn::Data> m_data;
-};
-
-} // ccnb
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // NDN_WIRE_CCNB_H
diff --git a/model/wire/ccnb/ccnb-parser/common.h b/model/wire/ccnb/ccnb-parser/common.h
deleted file mode 100644
index 1485b96..0000000
--- a/model/wire/ccnb/ccnb-parser/common.h
+++ /dev/null
@@ -1,179 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_COMMON_H_
-#define _CCNB_PARSER_COMMON_H_
-
-#include "ns3/ndn-common.h"
-
-#ifndef NDN_NAMESPACE_BEGIN
-#error "dafaq"
-#endif
-
-NDN_NAMESPACE_BEGIN;
-
-namespace wire {
-
-namespace CcnbParser {
-
-// forward declarations
-class Block;
-class Blob;
-class Udata;
-class Tag;
-class Attr;
-class Dtag;
-class Dattr;
-class Ext;
-
-
-/**
- * \brief Exception thrown if there is a parsing error
- */
-class CcnbDecodingException {};
-
-/**
- * \brief Type tag for a ccnb start marker.
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html
- */
-enum ccn_tt {
- CCN_EXT, /**< starts composite extension - numval is subtype */
- CCN_TAG, /**< starts composite - numval is tagnamelen-1 */
- CCN_DTAG, /**< starts composite - numval is tagdict index (enum ccn_dtag) */
- CCN_ATTR, /**< attribute - numval is attrnamelen-1, value follows */
- CCN_DATTR, /**< attribute numval is attrdict index */
- CCN_BLOB, /**< opaque binary data - numval is byte count */
- CCN_UDATA, /**< UTF-8 encoded character data - numval is byte count */
- CCN_NO_TOKEN /**< should not occur in encoding */
-};
-
-/** \brief CCN_CLOSE terminates composites */
-enum {CCN_CLOSE = 0};
-
-/**
- * \brief DTAG identifies ccnb-encoded elements.
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html
- */
-enum ccn_dtag {
- CCN_DTAG_Any = 13,
- CCN_DTAG_Name = 14,
- CCN_DTAG_Component = 15,
- CCN_DTAG_Certificate = 16,
- CCN_DTAG_Collection = 17,
- CCN_DTAG_CompleteName = 18,
- CCN_DTAG_Content = 19,
- CCN_DTAG_SignedInfo = 20,
- CCN_DTAG_ContentDigest = 21,
- CCN_DTAG_ContentHash = 22,
- CCN_DTAG_Count = 24,
- CCN_DTAG_Header = 25,
- CCN_DTAG_Interest = 26, /* 20090915 */
- CCN_DTAG_Key = 27,
- CCN_DTAG_KeyLocator = 28,
- CCN_DTAG_KeyName = 29,
- CCN_DTAG_Length = 30,
- CCN_DTAG_Link = 31,
- CCN_DTAG_LinkAuthenticator = 32,
- CCN_DTAG_NameComponentCount = 33, /* DeprecatedInInterest */
- CCN_DTAG_RootDigest = 36,
- CCN_DTAG_Signature = 37,
- CCN_DTAG_Start = 38,
- CCN_DTAG_Timestamp = 39,
- CCN_DTAG_Type = 40,
- CCN_DTAG_Nonce = 41,
- CCN_DTAG_Scope = 42,
- CCN_DTAG_Exclude = 43,
- CCN_DTAG_Bloom = 44,
- CCN_DTAG_BloomSeed = 45,
- CCN_DTAG_AnswerOriginKind = 47,
- CCN_DTAG_InterestLifetime = 48,
- CCN_DTAG_Witness = 53,
- CCN_DTAG_SignatureBits = 54,
- CCN_DTAG_DigestAlgorithm = 55,
- CCN_DTAG_BlockSize = 56,
- CCN_DTAG_FreshnessSeconds = 58,
- CCN_DTAG_FinalBlockID = 59,
- CCN_DTAG_PublisherPublicKeyDigest = 60,
- CCN_DTAG_PublisherCertificateDigest = 61,
- CCN_DTAG_PublisherIssuerKeyDigest = 62,
- CCN_DTAG_PublisherIssuerCertificateDigest = 63,
- CCN_DTAG_Data = 64, /* 20090915 */
- CCN_DTAG_WrappedKey = 65,
- CCN_DTAG_WrappingKeyIdentifier = 66,
- CCN_DTAG_WrapAlgorithm = 67,
- CCN_DTAG_KeyAlgorithm = 68,
- CCN_DTAG_Label = 69,
- CCN_DTAG_EncryptedKey = 70,
- CCN_DTAG_EncryptedNonceKey = 71,
- CCN_DTAG_WrappingKeyName = 72,
- CCN_DTAG_Action = 73,
- CCN_DTAG_FaceID = 74,
- CCN_DTAG_IPProto = 75,
- CCN_DTAG_Host = 76,
- CCN_DTAG_Port = 77,
- CCN_DTAG_MulticastInterface = 78,
- CCN_DTAG_ForwardingFlags = 79,
- CCN_DTAG_FaceInstance = 80,
- CCN_DTAG_ForwardingEntry = 81,
- CCN_DTAG_MulticastTTL = 82,
- CCN_DTAG_MinSuffixComponents = 83,
- CCN_DTAG_MaxSuffixComponents = 84,
- CCN_DTAG_ChildSelector = 85,
- CCN_DTAG_RepositoryInfo = 86,
- CCN_DTAG_Version = 87,
- CCN_DTAG_RepositoryVersion = 88,
- CCN_DTAG_GlobalPrefix = 89,
- CCN_DTAG_LocalName = 90,
- CCN_DTAG_Policy = 91,
- CCN_DTAG_Namespace = 92,
- CCN_DTAG_GlobalPrefixName = 93,
- CCN_DTAG_PolicyVersion = 94,
- CCN_DTAG_KeyValueSet = 95,
- CCN_DTAG_KeyValuePair = 96,
- CCN_DTAG_IntegerValue = 97,
- CCN_DTAG_DecimalValue = 98,
- CCN_DTAG_StringValue = 99,
- CCN_DTAG_BinaryValue = 100,
- CCN_DTAG_NameValue = 101,
- CCN_DTAG_Entry = 102,
- CCN_DTAG_ACL = 103,
- CCN_DTAG_ParameterizedName = 104,
- CCN_DTAG_Prefix = 105,
- CCN_DTAG_Suffix = 106,
- CCN_DTAG_Root = 107,
- CCN_DTAG_ProfileName = 108,
- CCN_DTAG_Parameters = 109,
- CCN_DTAG_InfoString = 110,
- CCN_DTAG_StatusResponse = 112,
- CCN_DTAG_StatusCode = 113,
- CCN_DTAG_StatusText = 114,
- CCN_DTAG_Nack = 200,
- CCN_DTAG_SequenceNumber = 256,
- CCN_DTAG_CCNProtocolDataUnit = 17702112
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_COMMON_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/attr.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/attr.cc
deleted file mode 100644
index f661186..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/attr.cc
+++ /dev/null
@@ -1,48 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "attr.h"
-#include "../common.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-// length length in octets of UTF-8 encoding of tag name - 1 (minimum tag name length is 1)
-Attr::Attr (Buffer::Iterator &start, uint32_t length)
-{
- m_attr.reserve (length+2); // extra byte for potential \0 at the end
- uint32_t i = 0;
- for (; !start.IsEnd () && i < (length+1); i++)
- {
- m_attr.push_back (start.ReadU8 ());
- }
- if (i < (length+1) && start.IsEnd ())
- throw CcnbDecodingException ();
- m_value = DynamicCast<Udata> (Block::ParseBlock (start));
- if (m_value == 0)
- throw CcnbDecodingException (); // "ATTR must be followed by UDATA field"
-}
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/attr.h b/model/wire/ccnb/ccnb-parser/syntax-tree/attr.h
deleted file mode 100644
index 37882ad..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/attr.h
+++ /dev/null
@@ -1,64 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_ATTR_H_
-#define _CCNB_PARSER_ATTR_H_
-
-#include "base-attr.h"
-#include <string>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Class to represent ATTR ccnb-encoded node
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-class Attr : public BaseAttr
-{
-public:
- /**
- * \brief Constructor that actually parsed ccnb-encoded ATTR block
- *
- * \param start buffer iterator pointing to the first byte of ATTR block name
- * \param length length of ATTR name (extracted from the value field)
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
- Attr (Buffer::Iterator &start, uint32_t length);
-
- virtual void accept( VoidNoArguVisitor &v ) { v.visit( *this ); }
- virtual void accept( VoidVisitor &v, boost::any param ) { v.visit( *this, param ); }
- virtual boost::any accept( NoArguVisitor &v ) { return v.visit( *this ); }
- virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
-
- std::string m_attr; ///< field holding name of the attribute
-};
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_ATTR_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/base-attr.h b/model/wire/ccnb/ccnb-parser/syntax-tree/base-attr.h
deleted file mode 100644
index c2b2627..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/base-attr.h
+++ /dev/null
@@ -1,49 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_BASE_ATTR_H_
-#define _CCNB_PARSER_BASE_ATTR_H_
-
-#include "udata.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Virtual base class providing a common storage for ATTR
- * and DATTR ccnb-encoded blocks
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-class BaseAttr : public Block
-{
-public:
- Ptr<Udata> m_value; ///< \brief Value of the attribute
-};
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_BASE_ATTR_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/base-tag.h b/model/wire/ccnb/ccnb-parser/syntax-tree/base-tag.h
deleted file mode 100644
index 1449d9f..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/base-tag.h
+++ /dev/null
@@ -1,58 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_BASE_TAG_H_
-#define _CCNB_PARSER_BASE_TAG_H_
-
-#include "block.h"
-#include <list>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Virtual base class providing a common storage for TAG
- * and DTAG ccnb-encoded blocks
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-class BaseTag : public Block
-{
-public:
- std::list<Ptr<Block> > m_attrs; ///< \brief List of attributes, associated with this tag
- std::list<Ptr<Block> > m_nestedTags; ///< \brief List of nested tags
-
-protected:
- /**
- * \brief Default constructor
- */
- BaseTag() { }
-};
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_BASE_TAG_H_
-
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/blob.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/blob.cc
deleted file mode 100644
index 6c2ab2e..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/blob.cc
+++ /dev/null
@@ -1,53 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "blob.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-Blob::Blob (Buffer::Iterator &start, uint32_t length)
-{
- m_blobSize = length;
- m_blob = new char[length];
- if (m_blob == 0 )
- throw CcnbDecodingException (); // memory problem
-
- uint32_t i = 0;
- for (; !start.IsEnd () && i < length; i++)
- {
- m_blob[i] = start.ReadU8 ();
- }
- if (i < length && start.IsEnd ())
- throw CcnbDecodingException ();
- // Block::counter += length;
-}
-
-Blob::~Blob ()
-{
- delete [] m_blob;
-}
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/blob.h b/model/wire/ccnb/ccnb-parser/syntax-tree/blob.h
deleted file mode 100644
index 2b480ca..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/blob.h
+++ /dev/null
@@ -1,65 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_BLOB_H_
-#define _CCNB_PARSER_BLOB_H_
-
-#include "block.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Class to represent BLOB ccnb-encoded node
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-class Blob : public Block
-{
-public:
- /**
- * \brief Constructor that actually parsed ccnb-encoded BLOB block
- *
- * \param start buffer iterator pointing to the first byte of BLOB data in ccnb-encoded block
- * \param length length of data in BLOB block (extracted from the value field)
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
- Blob (Buffer::Iterator &start, uint32_t length);
- ~Blob ();
-
- virtual void accept( VoidNoArguVisitor &v ) { v.visit( *this ); }
- virtual void accept( VoidVisitor &v, boost::any param ) { v.visit( *this, param ); }
- virtual boost::any accept( NoArguVisitor &v ) { return v.visit( *this ); }
- virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
-
- char* m_blob; ///< \brief field holding a parsed BLOB value of the block
- uint32_t m_blobSize; ///< @brief field representing size of the BLOB field stored
-};
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_BLOB_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/block.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/block.cc
deleted file mode 100644
index ac0d285..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/block.cc
+++ /dev/null
@@ -1,106 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "block.h"
-
-#include "blob.h"
-#include "udata.h"
-#include "tag.h"
-#include "dtag.h"
-#include "attr.h"
-#include "dattr.h"
-#include "ext.h"
-
-#include "ns3/log.h"
-
-NS_LOG_COMPONENT_DEFINE ("ndn.CcnbParser.Block");
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/// @cond include_hidden
-const uint8_t CCN_TT_BITS = 3;
-const uint8_t CCN_TT_MASK = ((1 << CCN_TT_BITS) - 1);
-const uint8_t CCN_MAX_TINY= ((1 << (7-CCN_TT_BITS)) - 1);
-const uint8_t CCN_TT_HBIT = ((uint8_t)(1 << 7));
-/// @endcond
-
-// int Block::counter = 0;
-
-Ptr<Block> Block::ParseBlock (Buffer::Iterator &start, bool dontParseBlock)
-{
- // std::cout << "<< pos: " << counter << "\n";
- uint32_t value = 0;
-
- // We will have problems if length field is more than 32 bits. Though it's really impossible
- uint8_t byte = 0;
- while (!start.IsEnd() && !(byte & CCN_TT_HBIT))
- {
- value <<= 7;
- value += byte;
- byte = start.ReadU8 ();
- // Block::counter ++;
- }
- if (start.IsEnd())
- CcnbDecodingException ();
-
- if (dontParseBlock)
- {
- return 0;
- }
-
- value <<= 4;
- value += ( (byte&(~CCN_TT_HBIT)) >> 3);
-
- /**
- * Huh. After fighting with NS-3, it became apparent that Create<T>(...) construct
- * doesn't work with references. Just simply doesn't work. wtf?
- */
- switch (byte & CCN_TT_MASK)
- {
- case CCN_BLOB:
- return Ptr<Blob> (new Blob(start, value), false);
- case CCN_UDATA:
- return Ptr<Udata> (new Udata(start, value), false);
- case CCN_TAG:
- return Ptr<Tag> (new Tag(start, value), false);
- case CCN_ATTR:
- return Ptr<Attr> (new Attr(start, value), false);
- case CCN_DTAG:
- return Ptr<Dtag> (new Dtag(start, value), false);
- case CCN_DATTR:
- return Ptr<Dattr> (new Dattr(start, value), false);
- case CCN_EXT:
- return Ptr<Ext> (new Ext(start, value), false);
- default:
- throw CcnbDecodingException ();
- }
-}
-
-Block::~Block ()
-{
-}
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/block.h b/model/wire/ccnb/ccnb-parser/syntax-tree/block.h
deleted file mode 100644
index dcaadaf..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/block.h
+++ /dev/null
@@ -1,91 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_BLOCK_H_
-#define _CCNB_PARSER_BLOCK_H_
-
-#include "ns3/simple-ref-count.h"
-#include "ns3/buffer.h"
-#include "ns3/ptr.h"
-
-// visitors
-#include "../visitors/void-no-argu-visitor.h"
-#include "../visitors/void-visitor.h"
-#include "../visitors/no-argu-visitor.h"
-#include "../visitors/visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Base class for ccnb-encoded node
- *
- * This class provides a static method to create a new block
- * (recursively) from the stream
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-class Block : public SimpleRefCount<Block>
-{
-public:
- // static int counter;
- /**
- * \brief Parsing stream (recursively) and creating a parsed BLOCK
- * object
- *
- * \param start buffer iterator pointing to the start position for parsing
- * \param dontParseBlock parameter to indicate whether the block should not be parsed, just length
- * of the block should be consumed (e.g., in case of "cheating" with content of Data packets)
- * \returns parsed ccnb-encoded block, that could contain more block inside
- */
- static Ptr<Block>
- ParseBlock (Buffer::Iterator &start, bool dontParseBlock = false);
-
- virtual ~Block ();
-
- virtual void accept( VoidNoArguVisitor &v ) = 0; ///< @brief Accept visitor void(*)()
- virtual void accept( VoidVisitor &v, boost::any param ) = 0; ///< @brief Accept visitor void(*)(boost::any)
- virtual boost::any accept( NoArguVisitor &v ) = 0; ///< @brief Accept visitor boost::any(*)()
- virtual boost::any accept( Visitor &v, boost::any param ) = 0; ///< @brief Accept visitor boost::any(*)(boost::any)
-};
-
-/**
- * @brief Necessary until Buffer::Iterator gets PeekU8 call
- * @param i buffer iterator
- * @return peeked uint8_t value
- */
-inline
-uint8_t
-BufferIteratorPeekU8 (Buffer::Iterator &i)
-{
- uint8_t ret = i.ReadU8 ();
- i.Prev ();
- return ret;
-}
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_BLOCK_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.cc
deleted file mode 100644
index a37db84..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.cc
+++ /dev/null
@@ -1,40 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "dattr.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-// dictionary attributes are not used (yet?) in CCNx
-Dattr::Dattr (Buffer::Iterator &start, uint32_t dattr)
-{
- m_dattr = dattr;
- m_value = DynamicCast<Udata> (Block::ParseBlock (start));
- if (m_value == 0)
- throw CcnbDecodingException (); // "ATTR must be followed by UDATA field"
-}
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.h b/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.h
deleted file mode 100644
index 3728d6e..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/dattr.h
+++ /dev/null
@@ -1,63 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_DATTR_H_
-#define _CCNB_PARSER_DATTR_H_
-
-#include "base-attr.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Class to represent DATTR ccnb-encoded node
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-class Dattr : public BaseAttr
-{
-public:
- /**
- * \brief Constructor that actually parsed ccnb-encoded DATTR block
- *
- * \param start buffer iterator pointing to the first byte of attribute value (UDATA block)
- * \param dattr dictionary code of DATTR (extracted from the value field)
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
- Dattr (Buffer::Iterator &start, uint32_t dattr);
-
- virtual void accept( VoidNoArguVisitor &v ) { v.visit( *this ); }
- virtual void accept( VoidVisitor &v, boost::any param ) { v.visit( *this, param ); }
- virtual boost::any accept( NoArguVisitor &v ) { return v.visit( *this ); }
- virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
-
- uint32_t m_dattr; ///< \brief Dictionary code of DATTR
-};
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_DATTR_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.cc
deleted file mode 100644
index 0bf5296..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.cc
+++ /dev/null
@@ -1,94 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "dtag.h"
-
-#include "base-attr.h"
-#include "base-tag.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-Dtag::Dtag (Buffer::Iterator &start, uint32_t dtag)
-{
- m_dtag = dtag;
- // std::cout << m_dtag << ", position: " << Block::counter << "\n";
- /**
- * Hack
- *
- * Stop processing after encountering "Content" dtag. Actual
- * content (including virtual payload) will be stored in Packet
- * buffer
- */
- if (dtag == CCN_DTAG_Content)
- {
- Block::ParseBlock (start, true); // process length field and ignore it
- return; // hack #1. Do not process nesting block for <Content>
- }
-
- // parse attributes until first nested block reached
- while (!start.IsEnd () && BufferIteratorPeekU8 (start)!=CCN_CLOSE)
- {
- Ptr<Block> block = Block::ParseBlock (start);
- if (DynamicCast<BaseAttr> (block)!=0)
- m_attrs.push_back (block);
- else
- {
- m_nestedTags.push_back (block);
- break;
- }
- }
-
- // parse the rest of nested blocks
- while (!start.IsEnd () && BufferIteratorPeekU8 (start)!=CCN_CLOSE)
- {
- // hack #2. Stop processing nested blocks if last block was <Content>
- if (m_dtag == CCN_DTAG_Data && // we are in <Data>
- DynamicCast<Dtag> (m_nestedTags.back())!=0 && // last block is DTAG
- DynamicCast<Dtag> (m_nestedTags.back())->m_dtag == CCN_DTAG_Content)
- {
- return;
- }
-
- m_nestedTags.push_back (Block::ParseBlock (start));
- }
-
- // hack #3. Stop processing when last tag was <Data>
- if (m_dtag == CCN_DTAG_Data && // we are in <Data>
- DynamicCast<Dtag> (m_nestedTags.back())!=0 && // last block is DTAG
- DynamicCast<Dtag> (m_nestedTags.back())->m_dtag == CCN_DTAG_Content)
- {
- return;
- }
-
- if (start.IsEnd ())
- throw CcnbDecodingException ();
-
- start.ReadU8 (); // read CCN_CLOSE
- // std::cout << "closer, position = " << Block::counter << "\n";
- // Block::counter ++;
-}
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.h b/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.h
deleted file mode 100644
index 0d00f50..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/dtag.h
+++ /dev/null
@@ -1,68 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_DTAG_H_
-#define _CCNB_PARSER_DTAG_H_
-
-#include "base-tag.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Class to represent DTAG ccnb-encoded node
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-class Dtag : public BaseTag
-{
-public:
- /**
- * \brief Constructor that actually parsed ccnb-encoded DTAG block
- *
- * \param start buffer iterator pointing to the first nesting block or closing tag
- * \param dtag dictionary code of DTAG (extracted from the value field)
- *
- * DTAG parsing is slightly hacked to provide memory optimization
- * for NS-3 simulations. Parsing will be stopped after encountering
- * "Content" dtag. Actual content (including virtual payload) will
- * be stored in Packet buffer
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
- Dtag (Buffer::Iterator &start, uint32_t dtag);
-
- virtual void accept( VoidNoArguVisitor &v ) { v.visit( *this ); }
- virtual void accept( VoidVisitor &v, boost::any param ) { v.visit( *this, param ); }
- virtual boost::any accept( NoArguVisitor &v ) { return v.visit( *this ); }
- virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
-
- uint32_t m_dtag; ///< \brief Dictionary code for DTAG
-};
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_DTAG_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/ext.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/ext.cc
deleted file mode 100644
index 79ac738..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/ext.cc
+++ /dev/null
@@ -1,36 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ext.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-Ext::Ext (Buffer::Iterator &start, uint32_t extSubtype)
-{
- m_extSubtype = extSubtype;
-}
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/ext.h b/model/wire/ccnb/ccnb-parser/syntax-tree/ext.h
deleted file mode 100644
index 532eb87..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/ext.h
+++ /dev/null
@@ -1,63 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_EXT_H_
-#define _CCNB_PARSER_EXT_H_
-
-#include "block.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Class to represent EXT ccnb-encoded node
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-class Ext : public Block
-{
-public:
- /**
- * \brief Constructor that actually parsed ccnb-encoded DTAG block
- *
- * \param start buffer iterator pointing to the next byte past EXT block
- * \param extSubtype extension type (extracted from the value field)
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
- Ext (Buffer::Iterator &start, uint32_t extSubtype);
-
- virtual void accept( VoidNoArguVisitor &v ) { v.visit( *this ); }
- virtual void accept( VoidVisitor &v, boost::any param ) { v.visit( *this, param ); }
- virtual boost::any accept( NoArguVisitor &v ) { return v.visit( *this ); }
- virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
-
- uint64_t m_extSubtype; ///< \brief Extension type
-};
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_EXT_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/tag.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/tag.cc
deleted file mode 100644
index 8cd7fd1..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/tag.cc
+++ /dev/null
@@ -1,70 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "tag.h"
-
-#include "base-attr.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-Tag::Tag (Buffer::Iterator &start, uint32_t length)
-{
- m_tag.reserve (length+2); // extra byte for potential \0 at the end
- uint32_t i = 0;
- for (; !start.IsEnd () && i < (length+1); i++)
- {
- m_tag.push_back (start.ReadU8 ());
- }
- if (i < (length+1) && start.IsEnd ())
- throw CcnbDecodingException ();
-
- // parse attributes until first nested block reached
- while (!start.IsEnd () && BufferIteratorPeekU8 (start)!=CCN_CLOSE)
- {
- Ptr<Block> block = Block::ParseBlock (start);
- if (DynamicCast<BaseAttr> (block)!=0)
- m_attrs.push_back (block);
- else
- {
- m_nestedTags.push_back (block);
- break;
- }
- }
-
- // parse the rest of nested blocks
- while (!start.IsEnd () && BufferIteratorPeekU8 (start)!=CCN_CLOSE)
- {
- Ptr<Block> block = Block::ParseBlock (start);
- m_nestedTags.push_back (block);
- }
-
- if (start.IsEnd ()) //should not be the end
- throw CcnbDecodingException ();
-
- start.ReadU8 (); // read CCN_CLOSE
-}
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/tag.h b/model/wire/ccnb/ccnb-parser/syntax-tree/tag.h
deleted file mode 100644
index 8949119..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/tag.h
+++ /dev/null
@@ -1,64 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_TAG_H_
-#define _CCNB_PARSER_TAG_H_
-
-#include "base-tag.h"
-#include <string>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Class to represent TAG ccnb-encoded node
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
-class Tag : public BaseTag
-{
-public:
- /**
- * \brief Constructor that actually parsed ccnb-encoded TAG block
- *
- * \param start buffer iterator pointing to the first byte of TAG block name
- * \param length length of TAG name - 1 byte (i.e., minimum tag name is 1 byte)
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
- Tag (Buffer::Iterator &start, uint32_t length);
-
- virtual void accept( VoidNoArguVisitor &v ) { v.visit( *this ); }
- virtual void accept( VoidVisitor &v, boost::any param ) { v.visit( *this, param ); }
- virtual boost::any accept( NoArguVisitor &v ) { return v.visit( *this ); }
- virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
-
- std::string m_tag; ///< \brief Name of TAG block
-};
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_TAG_H_
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/udata.cc b/model/wire/ccnb/ccnb-parser/syntax-tree/udata.cc
deleted file mode 100644
index 9d3c8df..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/udata.cc
+++ /dev/null
@@ -1,50 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "udata.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-Udata::Udata (Buffer::Iterator &start, uint32_t length)
-{
- // Ideally, the code should look like this. Unfortunately, we don't have normal compatible iterators
- // Buffer::Iterator realStart = start;
- // start.Next (length); // advancing forward
- // m_udata.assign (realStart, start/*actually, it is the end*/);
-
- m_udata.reserve (length+1); //just in case we will need \0 at the end later
- // this is actually the way Read method is implemented in network/src/buffer.cc
- uint32_t i = 0;
- for (; !start.IsEnd () && i < length; i++)
- {
- m_udata.push_back (start.ReadU8 ());
- }
-
- if (i < length && start.IsEnd ())
- throw CcnbDecodingException ();
-}
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/syntax-tree/udata.h b/model/wire/ccnb/ccnb-parser/syntax-tree/udata.h
deleted file mode 100644
index 463898f..0000000
--- a/model/wire/ccnb/ccnb-parser/syntax-tree/udata.h
+++ /dev/null
@@ -1,62 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_UDATA_H_
-#define _CCNB_PARSER_UDATA_H_
-
-#include "block.h"
-#include <string>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Class to represent UDATA ccnb-encoded node
- */
-class Udata : public Block
-{
-public:
- /**
- * \brief Constructor that actually parsed ccnb-encoded UDATA block
- *
- * \param start buffer iterator pointing to the first byte of string in ccnb-encoded block
- * \param length length of data in UDATA block (extracted from the value field)
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- */
- Udata (Buffer::Iterator &start, uint32_t length);
-
- virtual void accept( VoidNoArguVisitor &v ) { v.visit( *this ); }
- virtual void accept( VoidVisitor &v, boost::any param ) { v.visit( *this, param ); }
- virtual boost::any accept( NoArguVisitor &v ) { return v.visit( *this ); }
- virtual boost::any accept( Visitor &v, boost::any param ) { return v.visit( *this, param ); }
-
- std::string m_udata; ///< \brief field holding a parsed UDATA value of the block
-};
-
-} // namespace CcnbParser
-} // namespace wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_UDATA_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.cc
deleted file mode 100644
index 91112da..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.cc
+++ /dev/null
@@ -1,54 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "content-type-visitor.h"
-#include "../syntax-tree/blob.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-boost::any
-ContentTypeVisitor::visit (Blob &n)
-{
- // Buffer n.m_blob;
- if (n.m_blobSize != 3)
- throw CcnbDecodingException ();
-
- uint32_t type =
- (n.m_blob [0] << 16) |
- (n.m_blob [1] << 8 ) |
- (n.m_blob [2] );
-
- return boost::any (type);
-}
-
-boost::any
-ContentTypeVisitor::visit (Udata &n)
-{
- // std::string n.m_udata;
- throw CcnbDecodingException ();
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.h
deleted file mode 100644
index aa9abbf..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/content-type-visitor.h
+++ /dev/null
@@ -1,52 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
-#define _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
-
-#include "no-argu-depth-first-visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor to obtain nonce value from BLOB block
- *
- * Note, only first 32 bits will be actually parsed into nonce. If
- * original Nonce contains more, the rest will be ignored
- *
- * Will return empty boost::any() if called on anything except BLOB block
- */
-class ContentTypeVisitor : public NoArguDepthFirstVisitor
-{
-public:
- virtual boost::any visit (Blob &n);
- virtual boost::any visit (Udata &n); ///< Throws parsing error if BLOB object is encountered
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_CONTENT_TYPE_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.cc
deleted file mode 100644
index b82b140..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.cc
+++ /dev/null
@@ -1,112 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "depth-first-visitor.h"
-
-#include "../syntax-tree/blob.h"
-#include "../syntax-tree/udata.h"
-#include "../syntax-tree/tag.h"
-#include "../syntax-tree/dtag.h"
-#include "../syntax-tree/attr.h"
-#include "../syntax-tree/dattr.h"
-#include "../syntax-tree/ext.h"
-
-#include <boost/foreach.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-boost::any
-DepthFirstVisitor::visit (Blob &n, boost::any param)
-{
- // Buffer n.m_blob;
- return n.m_blob;
-}
-
-boost::any
-DepthFirstVisitor::visit (Udata &n, boost::any param)
-{
- // std::string n.m_udata;
- return n.m_udata;
-}
-
-boost::any
-DepthFirstVisitor::visit (Tag &n, boost::any param)
-{
- // std::string n.m_tag;
- // std::list<Ptr<Block> > n.m_attrs;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
- BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
- {
- block->accept (*this, param);
- }
- BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
- {
- block->accept (*this, param);
- }
- return boost::any();
-}
-
-boost::any
-DepthFirstVisitor::visit (Dtag &n, boost::any param)
-{
- // std::string n.m_tag;
- // std::list<Ptr<Block> > n.m_attrs;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
- BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
- {
- block->accept (*this, param);
- }
- BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
- {
- block->accept (*this, param);
- }
- return boost::any ();
-}
-
-boost::any
-DepthFirstVisitor::visit (Attr &n, boost::any param)
-{
- // std::string n.m_attr;
- // Ptr<Udata> n.m_value;
- return boost::any ();
-}
-
-boost::any
-DepthFirstVisitor::visit (Dattr &n, boost::any param)
-{
- // uint32_t n.m_dattr;
- // Ptr<Udata> n.m_value;
- return boost::any ();
-}
-
-boost::any
-DepthFirstVisitor::visit (Ext &n, boost::any param)
-{
- // uint64_t n.m_extSubtype;
- return n.m_extSubtype;
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.h
deleted file mode 100644
index be701b1..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/depth-first-visitor.h
+++ /dev/null
@@ -1,52 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
-#define _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
-
-#include "visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Depth-first visitor that takes boot::any as argument and returns boost::any value
- */
-class DepthFirstVisitor : public Visitor
-{
-public:
- virtual boost::any visit (Blob&, boost::any);
- virtual boost::any visit (Udata&, boost::any);
- virtual boost::any visit (Tag&, boost::any);
- virtual boost::any visit (Attr&, boost::any);
- virtual boost::any visit (Dtag&, boost::any);
- virtual boost::any visit (Dattr&, boost::any);
- virtual boost::any visit (Ext&, boost::any);
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_DEPTH_FIRST_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/name-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/name-visitor.cc
deleted file mode 100644
index 998e4e2..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/name-visitor.cc
+++ /dev/null
@@ -1,61 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "name-visitor.h"
-
-#include "string-visitor.h"
-#include "../syntax-tree/dtag.h"
-
-#include "ns3/ndn-name.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-void
-NameVisitor::visit (Dtag &n, boost::any param/*should be Name* */)
-{
- // uint32_t n.m_dtag;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
- static StringVisitor stringVisitor;
-
- Name &components = *(boost::any_cast<Name*> (param));
-
- switch (n.m_dtag)
- {
- case CCN_DTAG_Component:
- if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
- throw CcnbDecodingException ();
- components.append (
- boost::any_cast<std::string> ((*n.m_nestedTags.begin())->accept(
- stringVisitor
- )));
- break;
- default:
- VoidDepthFirstVisitor::visit (n, param);
- break;
- }
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/name-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/name-visitor.h
deleted file mode 100644
index f71e202..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/name-visitor.h
+++ /dev/null
@@ -1,47 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
-#define _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
-
-#include "void-depth-first-visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor to obtain fill CcnxName object with name components
- */
-class NameVisitor : public VoidDepthFirstVisitor
-{
-public:
- virtual void visit (Dtag &n, boost::any param/*should be Name* */);
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_NAME_COMPONENTS_VISITOR_H_
-
diff --git a/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.cc
deleted file mode 100644
index 6393e7e..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.cc
+++ /dev/null
@@ -1,112 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "no-argu-depth-first-visitor.h"
-
-#include "../syntax-tree/blob.h"
-#include "../syntax-tree/udata.h"
-#include "../syntax-tree/tag.h"
-#include "../syntax-tree/dtag.h"
-#include "../syntax-tree/attr.h"
-#include "../syntax-tree/dattr.h"
-#include "../syntax-tree/ext.h"
-
-#include <boost/foreach.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-boost::any
-NoArguDepthFirstVisitor::visit (Blob &n)
-{
- // Buffer n.m_blob;
- return n.m_blob;
-}
-
-boost::any
-NoArguDepthFirstVisitor::visit (Udata &n)
-{
- // std::string n.m_udata;
- return n.m_udata;
-}
-
-boost::any
-NoArguDepthFirstVisitor::visit (Tag &n)
-{
- // uint32_t n.m_dtag;
- // std::list<Ptr<Block> > n.m_attrs;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
- BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
- {
- block->accept (*this);
- }
- BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
- {
- block->accept (*this);
- }
- return boost::any ();
-}
-
-boost::any
-NoArguDepthFirstVisitor::visit (Dtag &n)
-{
- // uint32_t n.m_dtag;
- // std::list<Ptr<Block> > n.m_attrs;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
- BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
- {
- block->accept (*this);
- }
- BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
- {
- block->accept (*this);
- }
- return boost::any();
-}
-
-boost::any
-NoArguDepthFirstVisitor::visit (Attr &n)
-{
- // std::string n.m_attr;
- // Ptr<Udata> n.m_value;
- return boost::any ();
-}
-
-boost::any
-NoArguDepthFirstVisitor::visit (Dattr &n)
-{
- // uint32_t n.m_dattr;
- // Ptr<Udata> n.m_value;
- return boost::any ();
-}
-
-boost::any
-NoArguDepthFirstVisitor::visit (Ext &n)
-{
- // uint64_t n.m_extSubtype;
- return n.m_extSubtype;
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.h
deleted file mode 100644
index c400083..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/no-argu-depth-first-visitor.h
+++ /dev/null
@@ -1,52 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
-#define _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
-
-#include "no-argu-visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Depth-first visitor that takes no arguments and returns boost::any value
- */
-class NoArguDepthFirstVisitor : public NoArguVisitor
-{
-public:
- virtual boost::any visit (Blob& );
- virtual boost::any visit (Udata&);
- virtual boost::any visit (Tag& );
- virtual boost::any visit (Attr& );
- virtual boost::any visit (Dtag& );
- virtual boost::any visit (Dattr&);
- virtual boost::any visit (Ext& );
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_NO_ARGU_DEPTH_FIRST_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/no-argu-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/no-argu-visitor.h
deleted file mode 100644
index d603a0a..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/no-argu-visitor.h
+++ /dev/null
@@ -1,58 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_NO_ARGU_VISITOR_H_
-#define _CCNB_PARSER_NO_ARGU_VISITOR_H_
-
-#include "../common.h"
-#include <boost/any.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor interface that takes no arguments and returns boost::any
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- * for ccnb encoding format help
- */
-class NoArguVisitor
-{
-public:
- virtual boost::any visit (Blob& )=0; ///< \brief Method accepting BLOB block
- virtual boost::any visit (Udata&)=0; ///< \brief Method accepting UDATA block
- virtual boost::any visit (Tag& )=0; ///< \brief Method accepting TAG block
- virtual boost::any visit (Attr& )=0; ///< \brief Method accepting ATTR block
- virtual boost::any visit (Dtag& )=0; ///< \brief Method accepting DTAG block
- virtual boost::any visit (Dattr&)=0; ///< \brief Method accepting DATTR block
- virtual boost::any visit (Ext& )=0; ///< \brief Method accepting EXT block
-
- virtual ~NoArguVisitor () { }
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_NO_ARGU_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.cc
deleted file mode 100644
index 9c2fee3..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.cc
+++ /dev/null
@@ -1,55 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "non-negative-integer-visitor.h"
-
-#include "../syntax-tree/blob.h"
-#include "../syntax-tree/udata.h"
-#include <sstream>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-boost::any
-NonNegativeIntegerVisitor::visit (Blob &n) //to throw parsing error
-{
- // Buffer n.m_blob;
- throw CcnbDecodingException ();
-}
-
-boost::any
-NonNegativeIntegerVisitor::visit (Udata &n)
-{
- // std::string n.m_udata;
- std::istringstream is (n.m_udata);
- int32_t value;
- is >> value;
- if (value<0) // value should be non-negative
- throw CcnbDecodingException ();
-
- return static_cast<uint32_t> (value);
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.h
deleted file mode 100644
index 027e0eb..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/non-negative-integer-visitor.h
+++ /dev/null
@@ -1,49 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
-#define _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
-
-#include "no-argu-depth-first-visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor to obtain non-negative integer value from UDATA block
- *
- * Will return empty boost::any() if called on anything except UDATA block
- */
-class NonNegativeIntegerVisitor : public NoArguDepthFirstVisitor
-{
-public:
- virtual boost::any visit (Blob &n); ///< Throws an exception if BLOB object is encountered
- virtual boost::any visit (Udata &n);
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_NON_NEGATIVE_INTEGER_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/string-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/string-visitor.cc
deleted file mode 100644
index 5c41779..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/string-visitor.cc
+++ /dev/null
@@ -1,47 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "string-visitor.h"
-#include "../syntax-tree/udata.h"
-#include "../syntax-tree/blob.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-boost::any
-StringVisitor::visit (Blob &n)
-{
- // Buffer n.m_blob;
- return std::string (n.m_blob, n.m_blobSize);
-}
-
-boost::any
-StringVisitor::visit (Udata &n)
-{
- // std::string n.m_udata;
- return n.m_udata;
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/string-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/string-visitor.h
deleted file mode 100644
index b6a74fd..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/string-visitor.h
+++ /dev/null
@@ -1,49 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_STRING_VISITOR_H_
-#define _CCNB_PARSER_STRING_VISITOR_H_
-
-#include "no-argu-depth-first-visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor to obtain string value from UDATA block
- *
- * Will return empty boost::any() if called on anything except UDATA block
- */
-class StringVisitor : public NoArguDepthFirstVisitor
-{
-public:
- virtual boost::any visit (Blob &n);
- virtual boost::any visit (Udata &n);
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_STRING_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.cc
deleted file mode 100644
index efea82a..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.cc
+++ /dev/null
@@ -1,67 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "timestamp-visitor.h"
-#include "../syntax-tree/blob.h"
-
-#include "ns3/nstime.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-boost::any/*Time*/
-TimestampVisitor::visit (Blob &n)
-{
- // Buffer n.m_blob;
- if (n.m_blobSize < 2)
- throw CcnbDecodingException ();
-
- const char *start = n.m_blob;
-
- intmax_t seconds = 0;
- intmax_t nanoseconds = 0;
-
- for (uint32_t i=0; i < n.m_blobSize-2; i++)
- {
- seconds = (seconds << 8) | (uint8_t)start[i];
- }
- uint8_t combo = start[n.m_blobSize-2]; // 4 most significant bits hold 4 least significant bits of number of seconds
- seconds = (seconds << 4) | (combo >> 4);
-
- nanoseconds = combo & 0x0F; /*00001111*/ // 4 least significant bits hold 4 most significant bits of number of
- nanoseconds = (nanoseconds << 8) | start[n.m_blobSize-1];
- nanoseconds = (intmax_t) ((nanoseconds / 4096.0/*2^12*/) * 1000000 /*up-convert useconds*/);
-
- return boost::any (Time::FromInteger (seconds, Time::S) + Time::FromInteger (nanoseconds, Time::US));
-}
-
-boost::any
-TimestampVisitor::visit (Udata &n)
-{
- // std::string n.m_udata;
- throw CcnbDecodingException ();
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.h
deleted file mode 100644
index a5ad224..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/timestamp-visitor.h
+++ /dev/null
@@ -1,49 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_TIMESTAMP_VISITOR_H_
-#define _CCNB_PARSER_TIMESTAMP_VISITOR_H_
-
-#include "no-argu-depth-first-visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor to obtain timestamp value from BLOB block
- *
- * Will return empty boost::any() if called on anything except BLOB block
- */
-class TimestampVisitor : public NoArguDepthFirstVisitor
-{
-public:
- virtual boost::any visit (Blob &n);
- virtual boost::any/*Time*/ visit (Udata &n); ///< Throws parsing error if UDATA object is encountered
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_TIMESTAMP_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.cc
deleted file mode 100644
index f5620ae..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.cc
+++ /dev/null
@@ -1,49 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "uint32t-blob-visitor.h"
-#include "../syntax-tree/blob.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-boost::any
-Uint32tBlobVisitor::visit (Blob &n)
-{
- // Buffer n.m_blob;
- if (n.m_blobSize < 4)
- throw CcnbDecodingException ();
-
- return boost::any (*(reinterpret_cast<uint32_t*> (n.m_blob)));
-}
-
-boost::any
-Uint32tBlobVisitor::visit (Udata &n)
-{
- // std::string n.m_udata;
- throw CcnbDecodingException ();
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.h
deleted file mode 100644
index 5d30405..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/uint32t-blob-visitor.h
+++ /dev/null
@@ -1,52 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
-#define _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
-
-#include "no-argu-depth-first-visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor to obtain nonce value from BLOB block
- *
- * Note, only first 32 bits will be actually parsed into nonce. If
- * original Nonce contains more, the rest will be ignored
- *
- * Will return empty boost::any() if called on anything except BLOB block
- */
-class Uint32tBlobVisitor : public NoArguDepthFirstVisitor
-{
-public:
- virtual boost::any visit (Blob &n);
- virtual boost::any visit (Udata &n); ///< Throws parsing error if BLOB object is encountered
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_UINT32T_BLOB_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/visitor.h b/model/wire/ccnb/ccnb-parser/visitors/visitor.h
deleted file mode 100644
index ee9f831..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/visitor.h
+++ /dev/null
@@ -1,58 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_VISITOR_H_
-#define _CCNB_PARSER_VISITOR_H_
-
-#include "../common.h"
-#include <boost/any.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Visitor interface that takes one boost::any argument and returns boost::any
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- * for ccnb encoding format help
- */
-class Visitor
-{
-public:
- virtual boost::any visit (Blob&, boost::any)=0; ///< \brief Method accepting BLOB block
- virtual boost::any visit (Udata&, boost::any)=0; ///< \brief Method accepting UDATA block
- virtual boost::any visit (Tag&, boost::any)=0; ///< \brief Method accepting TAG block
- virtual boost::any visit (Attr&, boost::any)=0; ///< \brief Method accepting ATTR block
- virtual boost::any visit (Dtag&, boost::any)=0; ///< \brief Method accepting DTAG block
- virtual boost::any visit (Dattr&, boost::any)=0; ///< \brief Method accepting DATTR block
- virtual boost::any visit (Ext&, boost::any)=0; ///< \brief Method accepting EXT block
-
- virtual ~Visitor () { }
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.cc
deleted file mode 100644
index 8a8adde..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.cc
+++ /dev/null
@@ -1,105 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "void-depth-first-visitor.h"
-
-#include "../syntax-tree/blob.h"
-#include "../syntax-tree/udata.h"
-#include "../syntax-tree/tag.h"
-#include "../syntax-tree/dtag.h"
-#include "../syntax-tree/attr.h"
-#include "../syntax-tree/dattr.h"
-#include "../syntax-tree/ext.h"
-
-#include <boost/foreach.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-void
-VoidDepthFirstVisitor::visit (Blob &n, boost::any param)
-{
- // Buffer n.m_blob;
-}
-
-void
-VoidDepthFirstVisitor::visit (Udata &n, boost::any param)
-{
- // std::string n.m_udata;
-}
-
-void
-VoidDepthFirstVisitor::visit (Tag &n, boost::any param)
-{
- // std::string n.m_tag;
- // std::list<Ptr<Block> > n.m_attrs;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
- BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
- {
- block->accept (*this, param);
- }
- BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
- {
- block->accept (*this, param);
- }
-}
-
-void
-VoidDepthFirstVisitor::visit (Dtag &n, boost::any param)
-{
- // std::string n.m_tag;
- // std::list<Ptr<Block> > n.m_attrs;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
- BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
- {
- block->accept (*this, param);
- }
- BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
- {
- block->accept (*this, param);
- }
-}
-
-void
-VoidDepthFirstVisitor::visit (Attr &n, boost::any param)
-{
- // std::string n.m_attr;
- // Ptr<Udata> n.m_value;
-}
-
-void
-VoidDepthFirstVisitor::visit (Dattr &n, boost::any param)
-{
- // uint32_t n.m_dattr;
- // Ptr<Udata> n.m_value;
-}
-
-void
-VoidDepthFirstVisitor::visit (Ext &n, boost::any param)
-{
- // uint64_t n.m_extSubtype;
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.h
deleted file mode 100644
index 96f8b6f..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/void-depth-first-visitor.h
+++ /dev/null
@@ -1,52 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
-#define _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
-
-#include "void-visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Depth-first visitor that takes one argument and returns nothing
- */
-class VoidDepthFirstVisitor : public VoidVisitor
-{
-public:
- virtual void visit (Blob&, boost::any);
- virtual void visit (Udata&, boost::any);
- virtual void visit (Tag&, boost::any);
- virtual void visit (Attr&, boost::any);
- virtual void visit (Dtag&, boost::any);
- virtual void visit (Dattr&, boost::any);
- virtual void visit (Ext&, boost::any);
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_VOID_DEPTH_FIRST_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.cc b/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.cc
deleted file mode 100644
index 5bcecb8..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.cc
+++ /dev/null
@@ -1,105 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "void-no-argu-depth-first-visitor.h"
-
-#include "../syntax-tree/blob.h"
-#include "../syntax-tree/udata.h"
-#include "../syntax-tree/tag.h"
-#include "../syntax-tree/dtag.h"
-#include "../syntax-tree/attr.h"
-#include "../syntax-tree/dattr.h"
-#include "../syntax-tree/ext.h"
-
-#include <boost/foreach.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-void
-VoidNoArguDepthFirstVisitor::visit (Blob &n)
-{
- // Buffer n.m_blob;
-}
-
-void
-VoidNoArguDepthFirstVisitor::visit (Udata &n)
-{
- // std::string n.m_udata;
-}
-
-void
-VoidNoArguDepthFirstVisitor::visit (Tag &n)
-{
- // std::string n.m_tag;
- // std::list<Ptr<Block> > n.m_attrs;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
- BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
- {
- block->accept (*this);
- }
- BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
- {
- block->accept (*this);
- }
-}
-
-void
-VoidNoArguDepthFirstVisitor::visit (Dtag &n)
-{
- // uint32_t n.m_dtag;
- // std::list<Ptr<Block> > n.m_attrs;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
- BOOST_FOREACH (Ptr<Block> block, n.m_attrs)
- {
- block->accept (*this);
- }
- BOOST_FOREACH (Ptr<Block> block, n.m_nestedTags)
- {
- block->accept (*this);
- }
-}
-
-void
-VoidNoArguDepthFirstVisitor::visit (Attr &n)
-{
- // std::string n.m_attr;
- // Ptr<Udata> n.m_value;
-}
-
-void
-VoidNoArguDepthFirstVisitor::visit (Dattr &n)
-{
- // uint32_t n.m_dattr;
- // Ptr<Udata> n.m_value;
-}
-
-void
-VoidNoArguDepthFirstVisitor::visit (Ext &n)
-{
- // uint64_t n.m_extSubtype;
-}
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.h
deleted file mode 100644
index 59b59d7..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-depth-first-visitor.h
+++ /dev/null
@@ -1,52 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
-#define _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
-
-#include "void-no-argu-visitor.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ccnx-ccnb
- * \brief Depth-first visitor that takes no arguments and returns nothing
- */
-class VoidNoArguDepthFirstVisitor : public VoidNoArguVisitor
-{
-public:
- virtual void visit (Blob& );
- virtual void visit (Udata&);
- virtual void visit (Tag& );
- virtual void visit (Attr& );
- virtual void visit (Dtag& );
- virtual void visit (Dattr&);
- virtual void visit (Ext& );
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_VOID_NO_ARGU_DEPTH_FIRST_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-visitor.h
deleted file mode 100644
index a98d933..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/void-no-argu-visitor.h
+++ /dev/null
@@ -1,57 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
-#define _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
-
-#include "../common.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ndn-ccnb
- * \brief Visitor interface that takes no arguments and returns nothing
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- * for ccnb encoding format help
- */
-class VoidNoArguVisitor
-{
-public:
- virtual void visit (Blob& )=0; ///< \brief Method accepting BLOB block
- virtual void visit (Udata&)=0; ///< \brief Method accepting UDATA block
- virtual void visit (Tag& )=0; ///< \brief Method accepting TAG block
- virtual void visit (Attr& )=0; ///< \brief Method accepting ATTR block
- virtual void visit (Dtag& )=0; ///< \brief Method accepting DTAG block
- virtual void visit (Dattr&)=0; ///< \brief Method accepting DATTR block
- virtual void visit (Ext& )=0; ///< \brief Method accepting EXT block
-
- virtual ~VoidNoArguVisitor () { }
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_VOID_NO_ARGU_VISITOR_H_
diff --git a/model/wire/ccnb/ccnb-parser/visitors/void-visitor.h b/model/wire/ccnb/ccnb-parser/visitors/void-visitor.h
deleted file mode 100644
index 8c51e21..0000000
--- a/model/wire/ccnb/ccnb-parser/visitors/void-visitor.h
+++ /dev/null
@@ -1,58 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef _CCNB_PARSER_VOID_VISITOR_H_
-#define _CCNB_PARSER_VOID_VISITOR_H_
-
-#include "../common.h"
-#include <boost/any.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace CcnbParser {
-
-/**
- * \ingroup ndn-ccnb
- * \brief Visitor interface that takes one boost::any argument and returns nothing
- *
- * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
- * for ccnb encoding format help
- */
-class VoidVisitor
-{
-public:
- virtual void visit (Blob&, boost::any)=0; ///< \brief Method accepting BLOB block
- virtual void visit (Udata&, boost::any)=0; ///< \brief Method accepting UDATA block
- virtual void visit (Tag&, boost::any)=0; ///< \brief Method accepting TAG block
- virtual void visit (Attr&, boost::any)=0; ///< \brief Method accepting ATTR block
- virtual void visit (Dtag&, boost::any)=0; ///< \brief Method accepting DTAG block
- virtual void visit (Dattr&, boost::any)=0; ///< \brief Method accepting DATTR block
- virtual void visit (Ext&, boost::any)=0; ///< \brief Method accepting EXT block
-
- virtual ~VoidVisitor () { }
-};
-
-} // CcnbParser
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // _CCNB_PARSER_VOID_VISITOR_H_
diff --git a/model/wire/ccnb/wire-ccnb-data.cc b/model/wire/ccnb/wire-ccnb-data.cc
deleted file mode 100644
index 3b18717..0000000
--- a/model/wire/ccnb/wire-ccnb-data.cc
+++ /dev/null
@@ -1,505 +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>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "../ccnb.h"
-
-#include "wire-ccnb.h"
-
-#include "ns3/log.h"
-
-#include "ccnb-parser/common.h"
-#include "ccnb-parser/visitors/void-depth-first-visitor.h"
-#include "ccnb-parser/visitors/name-visitor.h"
-#include "ccnb-parser/visitors/non-negative-integer-visitor.h"
-#include "ccnb-parser/visitors/timestamp-visitor.h"
-#include "ccnb-parser/visitors/string-visitor.h"
-#include "ccnb-parser/visitors/uint32t-blob-visitor.h"
-#include "ccnb-parser/visitors/content-type-visitor.h"
-
-#include "ccnb-parser/syntax-tree/block.h"
-#include "ccnb-parser/syntax-tree/dtag.h"
-
-#include <boost/foreach.hpp>
-
-NS_LOG_COMPONENT_DEFINE ("ndn.wire.Ccnb.Data");
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace ccnb {
-
-// const std::string DefaultDigestAlgorithm = "2.16.840.1.101.3.4.2.1";
-
-class DataTrailer : public Trailer
-{
-public:
- DataTrailer ()
- {
- }
-
- static TypeId GetTypeId ()
- {
- static TypeId tid = TypeId ("ns3::ndn::Data::Ccnb::Closer")
- .SetGroupName ("Ndn")
- .SetParent<Trailer> ()
- .AddConstructor<DataTrailer> ()
- ;
- return tid;
- }
-
- virtual TypeId GetInstanceTypeId (void) const
- {
- return GetTypeId ();
- }
-
- virtual void Print (std::ostream &os) const
- {
- }
-
- virtual uint32_t GetSerializedSize (void) const
- {
- return 2;
- }
-
- virtual void Serialize (Buffer::Iterator end) const
- {
- Buffer::Iterator i = end;
- i.Prev (2); // Trailer interface requires us to go backwards
-
- i.WriteU8 (0x00); // </Content>
- i.WriteU8 (0x00); // </Data>
- }
-
- virtual uint32_t Deserialize (Buffer::Iterator end)
- {
- Buffer::Iterator i = end;
- i.Prev (2); // Trailer interface requires us to go backwards
-
- uint8_t closing_tag_content = i.ReadU8 ();
- NS_ASSERT_MSG (closing_tag_content==0, "Should be a closing tag </Content> (0x00)");
-
- uint8_t closing_tag_content_object = i.ReadU8 ();
- NS_ASSERT_MSG (closing_tag_content_object==0, "Should be a closing tag </Data> (0x00)");
-
- return 2;
- }
-};
-
-NS_OBJECT_ENSURE_REGISTERED (Data);
-NS_OBJECT_ENSURE_REGISTERED (DataTrailer);
-
-TypeId
-Data::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::Data::Ccnb")
- .SetGroupName ("Ndn")
- .SetParent<Header> ()
- .AddConstructor<Data> ()
- ;
- return tid;
-}
-
-TypeId
-Data::GetInstanceTypeId (void) const
-{
- return GetTypeId ();
-}
-
-Data::Data ()
- : m_data (Create<ndn::Data> ())
-{
-}
-
-Data::Data (Ptr<ndn::Data> data)
- : m_data (data)
-{
-}
-
-Ptr<ndn::Data>
-Data::GetData ()
-{
- return m_data;
-}
-
-Ptr<Packet>
-Data::ToWire (Ptr<const ndn::Data> data)
-{
- static DataTrailer trailer;
-
- Ptr<const Packet> p = data->GetWire ();
- if (!p)
- {
- Ptr<Packet> packet = Create<Packet> (*data->GetPayload ());
- Data wireEncoding (ConstCast<ndn::Data> (data));
- packet->AddHeader (wireEncoding);
- packet->AddTrailer (trailer);
- data->SetWire (packet);
-
- p = packet;
- }
-
- return p->Copy ();
-}
-
-Ptr<ndn::Data>
-Data::FromWire (Ptr<Packet> packet)
-{
- static DataTrailer trailer;
-
- Ptr<ndn::Data> data = Create<ndn::Data> ();
- Ptr<Packet> wire = packet->Copy ();
-
- Data wireEncoding (data);
- packet->RemoveHeader (wireEncoding);
- packet->RemoveTrailer (trailer);
-
- data->SetPayload (packet);
- data->SetWire (wire);
-
- return data;
-}
-
-void
-Data::Serialize (Buffer::Iterator start) const
-{
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Data, CcnbParser::CCN_DTAG); // <Data>
-
- // fake signature
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Signature, CcnbParser::CCN_DTAG); // <Signature>
- // Signature ::= √DigestAlgorithm?
- // Witness?
- // √SignatureBits
- // if (GetSignature ().GetDigestAlgorithm () != Signature::DefaultDigestAlgorithm)
- // {
- // Ccnb::AppendString (start, CcnbParser::CCN_DTAG_DigestAlgorithm, GetSignature ().GetDigestAlgorithm ());
- // }
- Ccnb::AppendString (start, CcnbParser::CCN_DTAG_DigestAlgorithm, "NOP");
- Ccnb::AppendTaggedBlobWithPadding (start, CcnbParser::CCN_DTAG_SignatureBits, 16, m_data->GetSignature ()); // <SignatureBits />
- Ccnb::AppendCloser (start); // </Signature>
-
- // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
- Ccnb::SerializeName (start, m_data->GetName()); // <Component>...</Component>...
- // Ccnb::AppendCloser (start); // </Name>
-
- // fake signature
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_SignedInfo, CcnbParser::CCN_DTAG); // <SignedInfo>
- // SignedInfo ::= √PublisherPublicKeyDigest
- // √Timestamp
- // √Type?
- // √FreshnessSeconds?
- // FinalBlockID?
- // KeyLocator?
- // Ccnb::AppendTaggedBlob (start, CcnbParser::CCN_DTAG_PublisherPublicKeyDigest, // <PublisherPublicKeyDigest>...
- // GetSignedInfo ().GetPublisherPublicKeyDigest ());
-
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Timestamp, CcnbParser::CCN_DTAG); // <Timestamp>...
- Ccnb::AppendTimestampBlob (start, m_data->GetTimestamp ());
- Ccnb::AppendCloser (start);
-
- // if (GetSignedInfo ().GetContentType () != DATA)
- // {
- // uint8_t type[3];
- // type[0] = (GetSignedInfo ().GetContentType () >> 16) & 0xFF;
- // type[1] = (GetSignedInfo ().GetContentType () >> 8 ) & 0xFF;
- // type[2] = (GetSignedInfo ().GetContentType () ) & 0xFF;
-
- // Ccnb::AppendTaggedBlob (start, CCN_DTAG_Type, type, 3);
- // }
- if (m_data->GetFreshness () > Seconds(0))
- {
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_FreshnessSeconds, CcnbParser::CCN_DTAG);
- Ccnb::AppendNumber (start, m_data->GetFreshness ().ToInteger (Time::S));
- Ccnb::AppendCloser (start);
- }
- if (m_data->GetKeyLocator () != 0)
- {
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_KeyLocator, CcnbParser::CCN_DTAG); // <KeyLocator>
- {
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_KeyName, CcnbParser::CCN_DTAG); // <KeyName>
- {
- // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
- Ccnb::SerializeName (start, *m_data->GetKeyLocator ()); // <Component>...</Component>...
- // Ccnb::AppendCloser (start); // </Name>
- }
- Ccnb::AppendCloser (start); // </KeyName>
- }
- Ccnb::AppendCloser (start); // </KeyLocator>
- }
-
- Ccnb::AppendCloser (start); // </SignedInfo>
-
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Content, CcnbParser::CCN_DTAG); // <Content>
-
- uint32_t payloadSize = m_data->GetPayload ()->GetSize ();
- if (payloadSize > 0)
- Ccnb::AppendBlockHeader (start, payloadSize, CcnbParser::CCN_BLOB);
-
- // there are no closing tags !!!
- // The closing tag is handled by DataTail
-}
-
-uint32_t
-Data::GetSerializedSize () const
-{
- size_t written = 0;
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Data); // <Data>
-
- // fake signature
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Signature); // <Signature>
- // Signature ::= DigestAlgorithm?
- // Witness?
- // SignatureBits
- // if (GetSignature ().GetDigestAlgorithm () != Signature::DefaultDigestAlgorithm)
- // {
- // written += Ccnb::EstimateString (CcnbParser::CCN_DTAG_DigestAlgorithm, GetSignature ().GetDigestAlgorithm ());
- // }
- written += Ccnb::EstimateString (CcnbParser::CCN_DTAG_DigestAlgorithm, "NOP");
- // "signature" will be always padded to 16 octets
- written += Ccnb::EstimateTaggedBlob (CcnbParser::CCN_DTAG_SignatureBits, 16); // <SignatureBits />
- // written += Ccnb::EstimateTaggedBlob (CcnbParser::CCN_DTAG_SignatureBits, sizeof (m_data->GetSignature ())); // <SignatureBits />
- written += 1; // </Signature>
-
- //written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
- written += Ccnb::SerializedSizeName (m_data->GetName ()); // <Component>...</Component>...
- //written += 1; // </Name>
-
- // fake signature
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_SignedInfo); // <SignedInfo>
- // SignedInfo ::= √PublisherPublicKeyDigest
- // √Timestamp
- // √Type?
- // √FreshnessSeconds?
- // FinalBlockID?
- // KeyLocator?
-
- // written += Ccnb::EstimateTaggedBlob (CCN_DTAG_PublisherPublicKeyDigest, // <PublisherPublicKeyDigest>...
- // sizeof (GetSignedInfo ().GetPublisherPublicKeyDigest ()));
-
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Timestamp); // <Timestamp>...
- written += Ccnb::EstimateTimestampBlob (m_data->GetTimestamp ());
- written += 1;
-
- // if (GetSignedInfo ().GetContentType () != DATA)
- // {
- // written += Ccnb::EstimateTaggedBlob (CcnbParser::CCN_DTAG_Type, 3);
- // }
- if (m_data->GetFreshness () > Seconds(0))
- {
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_FreshnessSeconds);
- written += Ccnb::EstimateNumber (m_data->GetFreshness ().ToInteger (Time::S));
- written += 1;
- }
-
- if (m_data->GetKeyLocator () != 0)
- {
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_KeyLocator); // <KeyLocator>
- {
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_KeyName); // <KeyName>
- {
- //written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
- written += Ccnb::SerializedSizeName (*m_data->GetKeyLocator ()); // <Component>...</Component>...
- //written += 1; // </Name>
- }
- written += 1; // </KeyName>
- }
- written += 1; // </KeyLocator>
- }
-
- written += 1; // </SignedInfo>
-
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Content); // <Content>
-
- uint32_t payloadSize = m_data->GetPayload ()->GetSize ();
- if (payloadSize > 0)
- written += Ccnb::EstimateBlockHeader (payloadSize);
-
- // there are no closing tags !!!
- // The closing tag is handled by DataTail
- return written;
-}
-
-class DataVisitor : public CcnbParser::VoidDepthFirstVisitor
-{
-public:
- virtual void visit (CcnbParser::Dtag &n, boost::any param/*should be Data* */)
- {
- // uint32_t n.m_dtag;
- // std::list< Ptr<CcnbParser::Block> > n.m_nestedBlocks;
- static CcnbParser::NameVisitor nameVisitor;
- static CcnbParser::NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
- static CcnbParser::TimestampVisitor timestampVisitor;
- static CcnbParser::StringVisitor stringVisitor;
- static CcnbParser::Uint32tBlobVisitor uint32tBlobVisitor;
- static CcnbParser::ContentTypeVisitor contentTypeVisitor;
-
- ndn::Data &contentObject = *(boost::any_cast<ndn::Data*> (param));
-
- switch (n.m_dtag)
- {
- case CcnbParser::CCN_DTAG_Data:
- // process nested blocks
- BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
- {
- block->accept (*this, param);
- }
- break;
- case CcnbParser::CCN_DTAG_Name:
- {
- // process name components
- Ptr<Name> name = Create<Name> ();
- n.accept (nameVisitor, GetPointer (name));
- contentObject.SetName (name);
- break;
- }
-
- case CcnbParser::CCN_DTAG_Signature:
- // process nested blocks
- BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
- {
- block->accept (*this, param);
- }
- break;
-
- // case CCN_DTAG_DigestAlgorithm:
- // NS_LOG_DEBUG ("DigestAlgorithm");
- // if (n.m_nestedTags.size ()!=1) // should be exactly one UDATA inside this tag
- // throw CcnbParser::CcnbDecodingException ();
-
- // contentObject.GetSignature ().SetDigestAlgorithm
- // (boost::any_cast<std::string> ((*n.m_nestedTags.begin())->accept
- // (stringVisitor)));
- // break;
-
- case CcnbParser::CCN_DTAG_SignatureBits:
- NS_LOG_DEBUG ("SignatureBits");
- if (n.m_nestedTags.size ()!=1) // should be only one nested tag
- throw CcnbParser::CcnbDecodingException ();
-
- contentObject.SetSignature
- (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
- (uint32tBlobVisitor)));
- break;
-
- case CcnbParser::CCN_DTAG_SignedInfo:
- // process nested blocks
- BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
- {
- block->accept (*this, param);
- }
- break;
-
- // case CCN_DTAG_PublisherPublicKeyDigest:
- // NS_LOG_DEBUG ("PublisherPublicKeyDigest");
- // if (n.m_nestedTags.size ()!=1) // should be only one nested tag
- // throw CcnbParser::CcnbDecodingException ();
-
- // contentObject.GetSignedInfo ().SetPublisherPublicKeyDigest
- // (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
- // (uint32tBlobVisitor)));
- // break;
-
- case CcnbParser::CCN_DTAG_Timestamp:
- NS_LOG_DEBUG ("Timestamp");
- if (n.m_nestedTags.size()!=1) // should be exactly one nested tag
- throw CcnbParser::CcnbDecodingException ();
-
- contentObject.SetTimestamp
- (boost::any_cast<Time> ((*n.m_nestedTags.begin())->accept
- (timestampVisitor)));
- break;
-
- // case CCN_DTAG_Type:
- // NS_LOG_DEBUG ("Type");
- // if (n.m_nestedTags.size ()!=1) // should be only one nested tag
- // throw CcnbParser::CcnbDecodingException ();
-
- // contentObject.GetSignedInfo ().SetContentType
- // (static_cast<Data::ContentType>
- // (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
- // (contentTypeVisitor))));
- // break;
-
- case CcnbParser::CCN_DTAG_FreshnessSeconds:
- NS_LOG_DEBUG ("FreshnessSeconds");
-
- if (n.m_nestedTags.size()!=1) // should be exactly one nested tag
- throw CcnbParser::CcnbDecodingException ();
-
- contentObject.SetFreshness
- (Seconds
- (boost::any_cast<uint32_t> ((*n.m_nestedTags.begin())->accept
- (nonNegativeIntegerVisitor))));
- break;
-
- case CcnbParser::CCN_DTAG_KeyLocator:
- // process nested blocks
- BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
- {
- block->accept (*this, param);
- }
- break;
-
- case CcnbParser::CCN_DTAG_KeyName:
- {
- if (n.m_nestedTags.size ()!=1) // should be exactly one nested tag
- throw CcnbParser::CcnbDecodingException ();
-
- // process name components
- Ptr<Name> name = Create<Name> ();
- n.accept (nameVisitor, GetPointer (name));
- contentObject.SetKeyLocator (name);
- break;
- }
-
- case CcnbParser::CCN_DTAG_Content: // !!! HACK
- // This hack was necessary for memory optimizations (i.e., content is virtual payload)
- NS_ASSERT_MSG (n.m_nestedTags.size() == 0, "Parser should have stopped just after processing <Content> tag");
- break;
-
- default: // ignore all other stuff
- break;
- }
- }
-};
-
-uint32_t
-Data::Deserialize (Buffer::Iterator start)
-{
- static DataVisitor contentObjectVisitor;
-
- Buffer::Iterator i = start;
- Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
- root->accept (contentObjectVisitor, GetPointer (m_data));
-
- return i.GetDistanceFrom (start);
-}
-
-void
-Data::Print (std::ostream &os) const
-{
- os << "D: " << m_data->GetName ();
- // os << "<Data><Name>" << GetName () << "</Name><Content>";
-}
-
-} // ccnb
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/wire-ccnb-interest.cc b/model/wire/ccnb/wire-ccnb-interest.cc
deleted file mode 100644
index af4fc0f..0000000
--- a/model/wire/ccnb/wire-ccnb-interest.cc
+++ /dev/null
@@ -1,448 +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>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "../ccnb.h"
-
-#include "wire-ccnb.h"
-
-#include "ns3/log.h"
-#include "ns3/unused.h"
-#include "ns3/packet.h"
-
-#include "ccnb-parser/visitors/name-visitor.h"
-#include "ccnb-parser/visitors/non-negative-integer-visitor.h"
-#include "ccnb-parser/visitors/timestamp-visitor.h"
-#include "ccnb-parser/visitors/uint32t-blob-visitor.h"
-
-#include "ccnb-parser/syntax-tree/block.h"
-#include "ccnb-parser/syntax-tree/dtag.h"
-
-#include <boost/foreach.hpp>
-
-NS_LOG_COMPONENT_DEFINE ("ndn.wire.Ccnb.Interest");
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace ccnb {
-
-NS_OBJECT_ENSURE_REGISTERED (Interest);
-
-TypeId
-Interest::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::Interest::Ccnb")
- .SetGroupName ("Ndn")
- .SetParent<Header> ()
- .AddConstructor<Interest> ()
- ;
- return tid;
-}
-
-TypeId
-Interest::GetInstanceTypeId (void) const
-{
- return GetTypeId ();
-}
-
-Interest::Interest ()
- : m_interest (Create<ndn::Interest> ())
-{
-}
-
-Interest::Interest (Ptr<ndn::Interest> interest)
- : m_interest (interest)
-{
-}
-
-Ptr<ndn::Interest>
-Interest::GetInterest ()
-{
- return m_interest;
-}
-
-Ptr<Packet>
-Interest::ToWire (Ptr<const ndn::Interest> interest)
-{
- Ptr<const Packet> p = interest->GetWire ();
- if (!p)
- {
- Ptr<Packet> packet = Create<Packet> (*interest->GetPayload ());
- Interest wireEncoding (ConstCast<ndn::Interest> (interest));
- packet->AddHeader (wireEncoding);
- interest->SetWire (packet);
-
- p = packet;
- }
-
- return p->Copy ();
-}
-
-Ptr<ndn::Interest>
-Interest::FromWire (Ptr<Packet> packet)
-{
- Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
- Ptr<Packet> wire = packet->Copy ();
-
- Interest wireEncoding (interest);
- packet->RemoveHeader (wireEncoding);
-
- interest->SetPayload (packet);
- interest->SetWire (wire);
-
- return interest;
-}
-
-void
-Interest::Serialize (Buffer::Iterator start) const
-{
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Interest, CcnbParser::CCN_DTAG); // <Interest>
-
- // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG); // <Name>
- Ccnb::SerializeName (start, m_interest->GetName()); // <Component>...</Component>...
- // Ccnb::AppendCloser (start); // </Name>
-
- // if (m_interest->GetMinSuffixComponents() >= 0)
- // {
- // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_MinSuffixComponents, CcnbParser::CCN_DTAG);
- // Ccnb::AppendNumber (start, m_interest->GetMinSuffixComponents ());
- // Ccnb::AppendCloser (start);
- // }
- // if (m_interest->GetMaxSuffixComponents() >= 0)
- // {
- // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_MaxSuffixComponents, CcnbParser::CCN_DTAG);
- // Ccnb::AppendNumber (start, m_interest->GetMaxSuffixComponents ());
- // Ccnb::AppendCloser (start);
- // }
- // if (m_interest->IsEnabledExclude() && m_interest->GetExclude().size() > 0)
- // {
- // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Exclude, CcnbParser::CCN_DTAG); // <Exclude>
- // Ccnb::AppendName (start, m_interest->GetExclude()); // <Component>...</Component>...
- // Ccnb::AppendCloser (start); // </Exclude>
- // }
- // if (m_interest->IsEnabledChildSelector())
- // {
- // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_ChildSelector, CcnbParser::CCN_DTAG);
- // Ccnb::AppendNumber (start, 1);
- // Ccnb::AppendCloser (start);
- // }
- // if (m_interest->IsEnabledAnswerOriginKind())
- // {
- // Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_AnswerOriginKind, CcnbParser::CCN_DTAG);
- // Ccnb::AppendNumber (start, 1);
- // Ccnb::AppendCloser (start);
- // }
- if (m_interest->GetScope() >= 0)
- {
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Scope, CcnbParser::CCN_DTAG);
- Ccnb::AppendNumber (start, m_interest->GetScope ());
- Ccnb::AppendCloser (start);
- }
- if (!m_interest->GetInterestLifetime().IsZero())
- {
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_InterestLifetime, CcnbParser::CCN_DTAG);
- Ccnb::AppendTimestampBlob (start, m_interest->GetInterestLifetime ());
- Ccnb::AppendCloser (start);
- }
- if (m_interest->GetNonce()>0)
- {
- uint32_t nonce = m_interest->GetNonce();
- Ccnb::AppendTaggedBlob (start, CcnbParser::CCN_DTAG_Nonce, nonce);
- }
-
- if (m_interest->GetNack ()>0)
- {
- Ccnb::AppendBlockHeader (start, CcnbParser::CCN_DTAG_Nack, CcnbParser::CCN_DTAG);
- Ccnb::AppendNumber (start, m_interest->GetNack ());
- Ccnb::AppendCloser (start);
- }
- Ccnb::AppendCloser (start); // </Interest>
-}
-
-uint32_t
-Interest::GetSerializedSize () const
-{
- size_t written = 0;
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Interest); // <Interest>
-
- // written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Name); // <Name>
- written += Ccnb::SerializedSizeName (m_interest->GetName()); // <Component>...</Component>...
- // written += 1; // </Name>
-
- // if (m_interest->GetMinSuffixComponents() >= 0)
- // {
- // written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_MinSuffixComponents);
- // written += Ccnb::EstimateNumber (m_interest->GetMinSuffixComponents ());
- // written += 1;
- // }
- // if (m_interest->GetMaxSuffixComponents() >= 0)
- // {
- // written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_MaxSuffixComponents);
- // written += Ccnb::EstimateNumber (m_interest->GetMaxSuffixComponents ());
- // written += 1;
- // }
- // if (m_interest->IsEnabledExclude() && m_interest->GetExclude().size() > 0)
- // {
- // written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Exclude);
- // written += Ccnb::EstimateName (m_interest->GetExclude()); // <Component>...</Component>...
- // written += 1; // </Exclude>
- // }
- // if (m_interest->IsEnabledChildSelector())
- // {
- // written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_ChildSelector);
- // written += Ccnb::EstimateNumber (1);
- // written += 1;
- // }
- // if (m_interest->IsEnabledAnswerOriginKind())
- // {
- // written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_AnswerOriginKind);
- // written += Ccnb::EstimateNumber (1);
- // written += 1;
- // }
- if (m_interest->GetScope() >= 0)
- {
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Scope);
- written += Ccnb::EstimateNumber (m_interest->GetScope ());
- written += 1;
- }
- if (!m_interest->GetInterestLifetime().IsZero())
- {
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_InterestLifetime);
- written += Ccnb::EstimateTimestampBlob (m_interest->GetInterestLifetime());
- written += 1;
- }
- if (m_interest->GetNonce()>0)
- {
- written += Ccnb::EstimateTaggedBlob (CcnbParser::CCN_DTAG_Nonce, sizeof(uint32_t));
- }
- if (m_interest->GetNack ()>0)
- {
- written += Ccnb::EstimateBlockHeader (CcnbParser::CCN_DTAG_Nack);
- written += Ccnb::EstimateNumber (m_interest->GetNack ());
- written += 1;
- }
-
- written += 1; // </Interest>
-
- return written;
-}
-
-class InterestVisitor : public CcnbParser::VoidDepthFirstVisitor
-{
-public:
- virtual void visit (CcnbParser::Dtag &n, boost::any param/*should be CcnxInterest* */);
-};
-
-// We don't care about any other fields
-void
-InterestVisitor::visit (CcnbParser::Dtag &n, boost::any param/*should be Interest* */)
-{
- // uint32_t n.m_dtag;
- // std::list<Ptr<Block> > n.m_nestedBlocks;
-
- static CcnbParser::NonNegativeIntegerVisitor nonNegativeIntegerVisitor;
- static CcnbParser::NameVisitor nameVisitor;
- static CcnbParser::TimestampVisitor timestampVisitor;
- static CcnbParser::Uint32tBlobVisitor nonceVisitor;
-
- ndn::Interest &interest = *(boost::any_cast<ndn::Interest*> (param));
-
- switch (n.m_dtag)
- {
- case CcnbParser::CCN_DTAG_Interest:
- NS_LOG_DEBUG ("Interest");
-
- // process nested blocks
- BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
- {
- block->accept (*this, param);
- }
- break;
- case CcnbParser::CCN_DTAG_Name:
- {
- NS_LOG_DEBUG ("Name");
-
- // process name components
- Ptr<Name> name = Create<Name> ();
- n.accept (nameVisitor, GetPointer (name));
- interest.SetName (name);
- break;
- }
- // case CcnbParser::CCN_DTAG_MinSuffixComponents:
- // NS_LOG_DEBUG ("MinSuffixComponents");
- // if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
- // throw CcnbParser::CcnbDecodingException ();
- // interest.SetMinSuffixComponents (
- // boost::any_cast<uint32_t> (
- // (*n.m_nestedTags.begin())->accept(
- // nonNegativeIntegerVisitor
- // )));
- // break;
- // case CcnbParser::CCN_DTAG_MaxSuffixComponents:
- // NS_LOG_DEBUG ("MaxSuffixComponents");
- // if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
- // throw CcnbParser::CcnbDecodingException ();
- // interest.SetMaxSuffixComponents (
- // boost::any_cast<uint32_t> (
- // (*n.m_nestedTags.begin())->accept(
- // nonNegativeIntegerVisitor
- // )));
- // break;
- // case CcnbParser::CCN_DTAG_Exclude:
- // {
- // NS_LOG_DEBUG ("Exclude");
- // // process exclude components
- // Ptr<Name> exclude = Create<Name> ();
-
- // BOOST_FOREACH (Ptr<CcnbParser::Block> block, n.m_nestedTags)
- // {
- // block->accept (nameVisitor, &(*exclude));
- // }
- // interest.SetExclude (exclude);
- // break;
- // }
- // case CcnbParser::CCN_DTAG_ChildSelector:
- // NS_LOG_DEBUG ("ChildSelector");
- // if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
- // throw CcnbParser::CcnbDecodingException ();
-
- // interest.SetChildSelector (
- // 1 == boost::any_cast<uint32_t> (
- // (*n.m_nestedTags.begin())->accept(
- // nonNegativeIntegerVisitor
- // )));
- // break;
- // case CCN_DTAG_AnswerOriginKind:
- // NS_LOG_DEBUG ("AnswerOriginKind");
- // if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
- // throw CcnbParser::CcnbDecodingException ();
- // interest.SetAnswerOriginKind (
- // 1 == boost::any_cast<uint32_t> (
- // (*n.m_nestedTags.begin())->accept(
- // nonNegativeIntegerVisitor
- // )));
- // break;
- case CcnbParser::CCN_DTAG_Scope:
- NS_LOG_DEBUG ("Scope");
- if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
- throw CcnbParser::CcnbDecodingException ();
- interest.SetScope (
- boost::any_cast<uint32_t> (
- (*n.m_nestedTags.begin())->accept(
- nonNegativeIntegerVisitor
- )));
- break;
- case CcnbParser::CCN_DTAG_InterestLifetime:
- NS_LOG_DEBUG ("InterestLifetime");
- if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
- throw CcnbParser::CcnbDecodingException ();
-
- interest.SetInterestLifetime (
- boost::any_cast<Time> (
- (*n.m_nestedTags.begin())->accept(
- timestampVisitor
- )));
- break;
- case CcnbParser::CCN_DTAG_Nonce:
- NS_LOG_DEBUG ("Nonce");
- if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
- throw CcnbParser::CcnbDecodingException ();
-
- interest.SetNonce (
- boost::any_cast<uint32_t> (
- (*n.m_nestedTags.begin())->accept(
- nonceVisitor
- )));
- break;
-
-
- case CcnbParser::CCN_DTAG_Nack:
- NS_LOG_DEBUG ("Nack");
- if (n.m_nestedTags.size()!=1) // should be exactly one UDATA inside this tag
- throw CcnbParser::CcnbDecodingException ();
-
- interest.SetNack (
- boost::any_cast<uint32_t> (
- (*n.m_nestedTags.begin())->accept(nonNegativeIntegerVisitor)));
- break;
- }
-}
-
-
-uint32_t
-Interest::Deserialize (Buffer::Iterator start)
-{
- static InterestVisitor interestVisitor;
-
- Buffer::Iterator i = start;
- Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
- root->accept (interestVisitor, GetPointer (m_interest));
-
- return i.GetDistanceFrom (start);
-}
-
-void
-Interest::Print (std::ostream &os) const
-{
- os << "I: " << m_interest->GetName ();
-
- return;
- // os << "<Interest>\n <Name>" << GetName () << "</Name>\n";
- // if (GetNack ()>0)
- // {
- // os << " <NACK>";
- // switch (GetNack ())
- // {
- // case NACK_LOOP:
- // os << "loop";
- // break;
- // case NACK_CONGESTION:
- // os << "congestion";
- // break;
- // default:
- // os << "unknown";
- // break;
- // }
- // os << "</NACK>\n";
- // }
- // if (GetMinSuffixComponents () >= 0)
- // os << " <MinSuffixComponents>" << GetMinSuffixComponents () << "</MinSuffixComponents>\n";
- // if (GetMaxSuffixComponents () >= 0)
- // os << " <MaxSuffixComponents>" << m_maxSuffixComponents << "</MaxSuffixComponents>\n";
- // if (IsEnabledExclude () && GetExclude ().size()>0)
- // os << " <Exclude>" << GetExclude () << "</Exclude>\n";
- // if (IsEnabledChildSelector ())
- // os << " <ChildSelector />\n";
- // if (IsEnabledAnswerOriginKind ())
- // os << " <AnswerOriginKind />\n";
- // if (GetScope () >= 0)
- // os << " <Scope>" << GetScope () << "</Scope>\n";
- // if ( !GetInterestLifetime ().IsZero() )
- // os << " <InterestLifetime>" << GetInterestLifetime () << "</InterestLifetime>\n";
- // if (GetNonce ()>0)
- // os << " <Nonce>" << GetNonce () << "</Nonce>\n";
- // os << "</Interest>";
-}
-
-} // ccnb
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/wire-ccnb.cc b/model/wire/ccnb/wire-ccnb.cc
deleted file mode 100644
index 3403611..0000000
--- a/model/wire/ccnb/wire-ccnb.cc
+++ /dev/null
@@ -1,260 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "wire-ccnb.h"
-
-#include <sstream>
-#include <boost/foreach.hpp>
-#include "ccnb-parser/common.h"
-#include "ccnb-parser/visitors/name-visitor.h"
-#include "ccnb-parser/syntax-tree/block.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
-
-#define CCN_TT_BITS 3
-#define CCN_TT_MASK ((1 << CCN_TT_BITS) - 1)
-#define CCN_MAX_TINY ((1 << (7-CCN_TT_BITS)) - 1)
-#define CCN_TT_HBIT ((unsigned char)(1 << 7))
-
-size_t
-Ccnb::AppendBlockHeader (Buffer::Iterator &start, size_t val, uint32_t tt)
-{
- unsigned char buf[1+8*((sizeof(val)+6)/7)];
- unsigned char *p = &(buf[sizeof(buf)-1]);
- size_t n = 1;
- p[0] = (CCN_TT_HBIT & ~CcnbParser::CCN_CLOSE) |
- ((val & CCN_MAX_TINY) << CCN_TT_BITS) |
- (CCN_TT_MASK & tt);
- val >>= (7-CCN_TT_BITS);
- while (val != 0) {
- (--p)[0] = (((unsigned char)val) & ~CCN_TT_HBIT) | CcnbParser::CCN_CLOSE;
- n++;
- val >>= 7;
- }
- start.Write (p,n);
- return n;
-}
-
-size_t
-Ccnb::EstimateBlockHeader (size_t value)
-{
- value >>= (7-CCN_TT_BITS);
- size_t n = 1;
- while (value>0)
- {
- value >>= 7;
- n++;
- }
- return n;
-}
-
-size_t
-Ccnb::AppendNumber (Buffer::Iterator &start, uint32_t number)
-{
- std::ostringstream os;
- os << number;
-
- size_t written = 0;
- written += AppendBlockHeader (start, os.str().size(), CcnbParser::CCN_UDATA);
- written += os.str().size();
- start.Write (reinterpret_cast<const unsigned char*>(os.str().c_str()), os.str().size());
-
- return written;
-}
-
-size_t
-Ccnb::EstimateNumber (uint32_t number)
-{
- std::ostringstream os;
- os << number;
- return EstimateBlockHeader (os.str ().size ()) + os.str ().size ();
-}
-
-size_t
-Ccnb::AppendCloser (Buffer::Iterator &start)
-{
- start.WriteU8 (CcnbParser::CCN_CLOSE);
- return 1;
-}
-
-size_t
-Ccnb::AppendTimestampBlob (Buffer::Iterator &start, const Time &time)
-{
- // the original function implements Markers... thought not sure what are these markers for...
-
- // Determine miminal number of bytes required to store the timestamp
- int required_bytes = 2; // 12 bits for fractions of a second, 4 bits left for seconds. Sometimes it is enough
- intmax_t ts = time.ToInteger (Time::S) >> 4;
- for (; required_bytes < 7 && ts != 0; ts >>= 8) // not more than 6 bytes?
- required_bytes++;
-
- size_t len = AppendBlockHeader(start, required_bytes, CcnbParser::CCN_BLOB);
-
- // write part with seconds
- ts = time.ToInteger (Time::S) >> 4;
- for (int i = 0; i < required_bytes - 2; i++)
- start.WriteU8 ( ts >> (8 * (required_bytes - 3 - i)) );
-
- /* arithmetic contortions are to avoid overflowing 31 bits */
- ts = ((time.ToInteger (Time::S) & 15) << 12) +
- (((time.ToInteger (Time::NS) % 1000000000) / 5 * 8 + 195312) / 390625);
- for (int i = required_bytes - 2; i < required_bytes; i++)
- start.WriteU8 ( ts >> (8 * (required_bytes - 1 - i)) );
-
- return len + required_bytes;
-}
-
-size_t
-Ccnb::EstimateTimestampBlob (const Time &time)
-{
- int required_bytes = 2; // 12 bits for fractions of a second, 4 bits left for seconds. Sometimes it is enough
- intmax_t ts = time.ToInteger (Time::S) >> 4;
- for (; required_bytes < 7 && ts != 0; ts >>= 8) // not more than 6 bytes?
- required_bytes++;
-
- return EstimateBlockHeader (required_bytes) + required_bytes;
-}
-
-size_t
-Ccnb::AppendTaggedBlob (Buffer::Iterator &start, uint32_t dtag,
- const uint8_t *data, size_t size)
-{
- size_t written = AppendBlockHeader (start, dtag, CcnbParser::CCN_DTAG);
- /* 2 */
- if (size>0)
- {
- written += AppendBlockHeader (start, size, CcnbParser::CCN_BLOB);
- start.Write (data, size);
- written += size;
- /* size */
- }
- written += AppendCloser (start);
- /* 1 */
-
- return written;
-}
-
-size_t
-Ccnb::AppendTaggedBlobWithPadding (Buffer::Iterator &start, uint32_t dtag,
- uint32_t length,
- const uint8_t *data, size_t size)
-{
- if (size > length)
- {
- // no padding required
- return AppendTaggedBlob (start, dtag, data, size);
- }
-
-
- size_t written = AppendBlockHeader (start, dtag, CcnbParser::CCN_DTAG);
-
- /* 2 */
- if (length>0)
- {
- written += AppendBlockHeader (start, length, CcnbParser::CCN_BLOB);
- start.Write (data, size);
- start.WriteU8 (0, length - size);
- written += length;
- /* size */
- }
- written += AppendCloser (start);
- /* 1 */
-
- return written;
-}
-
-size_t
-Ccnb::EstimateTaggedBlob (uint32_t dtag, size_t size)
-{
- if (size>0)
- return EstimateBlockHeader (dtag) + EstimateBlockHeader (size) + size + 1;
- else
- return EstimateBlockHeader (dtag) + 1;
-}
-
-size_t
-Ccnb::AppendString (Buffer::Iterator &start, uint32_t dtag,
- const std::string &string)
-{
- size_t written = AppendBlockHeader (start, dtag, CcnbParser::CCN_DTAG);
- {
- written += AppendBlockHeader (start, string.size (), CcnbParser::CCN_UDATA);
- start.Write (reinterpret_cast<const uint8_t*> (string.c_str ()), string.size ());
- written += string.size ();
- }
- written += AppendCloser (start);
-
- return written;
-}
-
-size_t
-Ccnb::EstimateString (uint32_t dtag, const std::string &string)
-{
- return EstimateBlockHeader (dtag) + EstimateBlockHeader (string.size ()) + string.size () + 1;
-}
-
-size_t
-Ccnb::SerializeName (Buffer::Iterator &start, const Name &name)
-{
- size_t written = 0;
- written += AppendBlockHeader (start, CcnbParser::CCN_DTAG_Name, CcnbParser::CCN_DTAG);
- BOOST_FOREACH (const name::Component &component, name)
- {
- written += AppendTaggedBlob (start, CcnbParser::CCN_DTAG_Component,
- reinterpret_cast<const uint8_t*>(component.buf ()), component.size());
- }
- written += AppendCloser (start);
- return written;
-}
-
-size_t
-Ccnb::SerializedSizeName (const Name &name)
-{
- size_t written = 0;
- written += EstimateBlockHeader (CcnbParser::CCN_DTAG_Name);
- BOOST_FOREACH (const name::Component &component, name)
- {
- written += EstimateTaggedBlob (CcnbParser::CCN_DTAG_Component, component.size ());
- }
- written += 1;
- return written;
-}
-
-Ptr<Name>
-Ccnb::DeserializeName (Buffer::Iterator &i)
-{
- Ptr<Name> name = Create<Name> ();
- CcnbParser::NameVisitor nameVisitor;
-
- Ptr<CcnbParser::Block> root = CcnbParser::Block::ParseBlock (i);
- root->accept (nameVisitor, GetPointer (name));
-
- return name;
-}
-
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ccnb/wire-ccnb.h b/model/wire/ccnb/wire-ccnb.h
deleted file mode 100644
index bb1eef6..0000000
--- a/model/wire/ccnb/wire-ccnb.h
+++ /dev/null
@@ -1,259 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011-2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_WIRE_CCNB_SYNTAX_H
-#define NDN_WIRE_CCNB_SYNTAX_H
-
-#include "ns3/ptr.h"
-#include "ns3/nstime.h"
-#include "ns3/buffer.h"
-
-#include "ns3/ndn-common.h"
-#include "ns3/ndn-name.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-
-/**
- * \brief Helper to encode CCNb blocks
- */
-class Ccnb
-{
-public:
- /**
- * @brief Append CCNB block header
- * @param start Buffer to store serialized
- * @param value dictionary id of the block header
- * @param block_type Type of CCNB block
- *
- * @returns written length
- */
- static size_t
- AppendBlockHeader (Buffer::Iterator &start, size_t value, uint32_t block_type);
-
- /**
- * @brief Estimate size of the CCNB block header
- * @param value dictionary id of the block header
- * @returns estimated length
- */
- static size_t
- EstimateBlockHeader (size_t value);
-
- /**
- * @brief Add number in CCNB encoding
- * @param start Buffer to store serialized NdnInterest
- * @param number Number to be written
- *
- * @returns written length
- */
- static size_t
- AppendNumber (Buffer::Iterator &start, uint32_t number);
-
- /**
- * @brief Estimate size of the number in CCNB encoding
- * @param number Number to be written
- * @returns estimated length
- */
- static size_t
- EstimateNumber (uint32_t number);
-
- /**
- * @brief Append CCNB closer tag (estimated size is 1)
- * @param start Buffer to store serialized Interest
- *
- * @returns written length
- */
- static size_t
- AppendCloser (Buffer::Iterator &start);
-
- /**
- * Append a binary timestamp as a BLOB using the ccn binary
- * Timestamp representation (12-bit fraction).
- *
- * @param start start iterator of the buffer to append to.
- * @param time - Time object
- *
- * @returns written length
- */
- static size_t
- AppendTimestampBlob (Buffer::Iterator &start, const Time &time);
-
- /**
- * @brief Estimate size of a binary timestamp as a BLOB using CCNB enconding
- * @param time - Time object
- * @returns estimated length
- */
- static size_t
- EstimateTimestampBlob (const Time &time);
-
- /**
- * Append a tagged BLOB
- *
- * This is a ccnb-encoded element with containing the BLOB as content
- *
- * @param start start iterator of the buffer to append to.
- * @param dtag is the element's dtab
- * @param data points to the binary data
- * @param size is the size of the data, in bytes
- *
- * @returns written length
- */
- static size_t
- AppendTaggedBlob (Buffer::Iterator &start, uint32_t dtag,
- const uint8_t *data, size_t size);
-
- /**
- * Append a tagged BLOB, adding 0-byte padding if necessary
- *
- * This is a ccnb-encoded element with containing the BLOB as content
- *
- * @param start start iterator of the buffer to append to.
- * @param dtag is the element's dtab
- * @param length minimum required length of the added field (padding added if necessary)
- * @param data points to the binary data
- * @param size is the size of the data, in bytes
- *
- * @returns written length
- */
- static size_t
- AppendTaggedBlobWithPadding (Buffer::Iterator &start, uint32_t dtag,
- uint32_t length,
- const uint8_t *data, size_t size);
-
- /**
- * @brief Estimate size of a tagged BLOB in CCNB enconding
- * @param dtag is the element's dtab
- * @param size is the size of the data, in bytes
- * @returns estimated length
- */
- static size_t
- EstimateTaggedBlob (uint32_t dtag, size_t size);
-
- /**
- * Append value as a tagged BLOB (templated version)
- *
- * This is a ccnb-encoded element with containing the BLOB as content
- *
- * Data will be reinterpret_cast<const uint8_t*> and size will be obtained using sizeof
- *
- * @param start start iterator of the buffer to append to.
- * @param dtag is the element's dtab
- * @param data a value to add
- *
- * @returns written length
- */
- template<class T>
- static inline size_t
- AppendTaggedBlob (Buffer::Iterator &start, uint32_t dtag, const T &data);
-
- /**
- * Append value as a tagged BLOB (templated version), add 0-padding if necessary
- *
- * This is a ccnb-encoded element with containing the BLOB as content
- *
- * Data will be reinterpret_cast<const uint8_t*> and size will be obtained using sizeof
- *
- * @param start start iterator of the buffer to append to.
- * @param dtag is the element's dtab
- * @param length minimum required length of the field
- * @param data a value to add
- *
- * @returns written length
- */
- template<class T>
- static inline size_t
- AppendTaggedBlobWithPadding (Buffer::Iterator &start, uint32_t dtag, uint32_t length, const T &data);
-
- /**
- * Append a tagged string (should be a valid UTF-8 coded string)
- *
- * This is a ccnb-encoded element with containing UDATA as content
- *
- * @param start start iterator of the buffer to append to.
- * @param dtag is the element's dtab
- * @param string UTF-8 string to be written
- *
- * @returns written length
- */
- static size_t
- AppendString (Buffer::Iterator &start, uint32_t dtag,
- const std::string &string);
-
- /**
- * @brief Estimate size of the string in CCNB encoding
- * @param dtag is the element's dtab
- * @param string UTF-8 string to be written
- * @returns estimated length
- */
- static size_t
- EstimateString (uint32_t dtag, const std::string &string);
-
- ////////////////////////////////
- // General use wire formatters
- ////////////////////////////////
-
- /**
- * @brief Append Name in CCNB encoding
- * @param start Buffer to store serialized Interest
- * @param name constant reference to Name object
- *
- * @returns written length
- */
- static size_t
- SerializeName (Buffer::Iterator &start, const Name &name);
-
- /**
- * @brief Estimate size of Name in CCNB encoding
- * @param name constant reference to Name object
- * @returns estimated length
- */
- static size_t
- SerializedSizeName (const Name &name);
-
- /**
- * @brief Deserialize Name from CCNB encodeing
- * @param start Buffer that stores serialized Interest
- * @param name Name object
- */
- static Ptr<Name>
- DeserializeName (Buffer::Iterator &start);
-}; // Ccnb
-
-
-template<class T>
-inline size_t
-Ccnb::AppendTaggedBlob (Buffer::Iterator &start, uint32_t dtag, const T &data)
-{
- return AppendTaggedBlob (start, dtag, reinterpret_cast<const uint8_t*> (&data), sizeof (data));
-}
-
-template<class T>
-inline size_t
-Ccnb::AppendTaggedBlobWithPadding (Buffer::Iterator &start, uint32_t dtag, uint32_t length, const T &data)
-{
- return AppendTaggedBlobWithPadding (start, dtag, length, reinterpret_cast<const uint8_t*> (&data), sizeof (data));
-}
-
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // NDN_WIRE_CCNB_SYNTAX_H
diff --git a/model/wire/ndn-wire.cc b/model/wire/ndn-wire.cc
deleted file mode 100644
index 7753f83..0000000
--- a/model/wire/ndn-wire.cc
+++ /dev/null
@@ -1,306 +0,0 @@
-/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU 3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-wire.h"
-
-#include "ns3/global-value.h"
-#include "ns3/integer.h"
-#include "ns3/ndn-common.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-#include "ns3/ndn-header-helper.h"
-
-#include "ndnsim.h"
-#include "ndnsim/wire-ndnsim.h"
-#include "ccnb.h"
-#include "ccnb/wire-ccnb.h"
-
-NDN_NAMESPACE_BEGIN
-
-static
-GlobalValue g_wireFormat ("ndn::WireFormat",
- "Default wire format for ndnSIM. ndnSIM will be accepting packets "
- "in any supported packet formats, but if encoding requested, it will "
- "use default wire format to encode (0 for ndnSIM (default), 1 for CCNb)",
- IntegerValue (Wire::WIRE_FORMAT_NDNSIM),
- MakeIntegerChecker<int32_t> ());
-
-static inline uint32_t
-GetWireFormat ()
-{
- static int32_t format = -1;
- if (format >= 0)
- return format;
-
- IntegerValue value;
- g_wireFormat.GetValue (value);
- format = value.Get ();
-
- return format;
-}
-
-Ptr<Packet>
-Wire::FromInterest (Ptr<const Interest> interest, int8_t wireFormat/* = WIRE_FORMAT_DEFAULT*/)
-{
- if (wireFormat == WIRE_FORMAT_DEFAULT)
- wireFormat = GetWireFormat ();
-
- if (wireFormat == WIRE_FORMAT_NDNSIM)
- return wire::ndnSIM::Interest::ToWire (interest);
- else if (wireFormat == WIRE_FORMAT_CCNB)
- return wire::ccnb::Interest::ToWire (interest);
- else
- {
- NS_FATAL_ERROR ("Unsupported format requested");
- return 0;
- }
-}
-
-Ptr<Interest>
-Wire::ToInterest (Ptr<Packet> packet, int8_t wireFormat/* = WIRE_FORMAT_AUTODETECT*/)
-{
- if (wireFormat == WIRE_FORMAT_AUTODETECT)
- {
- try
- {
- HeaderHelper::Type type = HeaderHelper::GetNdnHeaderType (packet);
- switch (type)
- {
- case HeaderHelper::INTEREST_NDNSIM:
- {
- return wire::ndnSIM::Interest::FromWire (packet);
- }
- case HeaderHelper::INTEREST_CCNB:
- {
- return wire::ccnb::Interest::FromWire (packet);
- }
- case HeaderHelper::CONTENT_OBJECT_NDNSIM:
- case HeaderHelper::CONTENT_OBJECT_CCNB:
- NS_FATAL_ERROR ("Data packet supplied for InterestFromWire function");
- break;
- default:
- NS_FATAL_ERROR ("Unsupported format");
- return 0;
- }
-
- // exception will be thrown if packet is not recognized
- }
- catch (UnknownHeaderException)
- {
- NS_FATAL_ERROR ("Unknown NDN header");
- return 0;
- }
- }
- else
- {
- if (wireFormat == WIRE_FORMAT_NDNSIM)
- return wire::ndnSIM::Interest::FromWire (packet);
- else if (wireFormat == WIRE_FORMAT_CCNB)
- return wire::ccnb::Interest::FromWire (packet);
- else
- {
- NS_FATAL_ERROR ("Unsupported format requested");
- return 0;
- }
- }
-}
-
-Ptr<Packet>
-Wire::FromData (Ptr<const Data> data, int8_t wireFormat/* = WIRE_FORMAT_DEFAULT*/)
-{
- if (wireFormat == WIRE_FORMAT_DEFAULT)
- wireFormat = GetWireFormat ();
-
- if (wireFormat == WIRE_FORMAT_NDNSIM)
- return wire::ndnSIM::Data::ToWire (data);
- else if (wireFormat == WIRE_FORMAT_CCNB)
- return wire::ccnb::Data::ToWire (data);
- else
- {
- NS_FATAL_ERROR ("Unsupported format requested");
- return 0;
- }
-}
-
-Ptr<Data>
-Wire::ToData (Ptr<Packet> packet, int8_t wireFormat/* = WIRE_FORMAT_AUTODETECT*/)
-{
- if (wireFormat == WIRE_FORMAT_AUTODETECT)
- {
- try
- {
- HeaderHelper::Type type = HeaderHelper::GetNdnHeaderType (packet);
- switch (type)
- {
- case HeaderHelper::CONTENT_OBJECT_NDNSIM:
- {
- return wire::ndnSIM::Data::FromWire (packet);
- }
- case HeaderHelper::CONTENT_OBJECT_CCNB:
- {
- return wire::ccnb::Data::FromWire (packet);
- }
- case HeaderHelper::INTEREST_NDNSIM:
- case HeaderHelper::INTEREST_CCNB:
- NS_FATAL_ERROR ("Interest supplied for DataFromWire function");
- break;
- default:
- NS_FATAL_ERROR ("Unsupported format");
- return 0;
- }
-
- // exception will be thrown if packet is not recognized
- }
- catch (UnknownHeaderException)
- {
- NS_FATAL_ERROR ("Unknown NDN header");
- return 0;
- }
- }
- else
- {
- if (wireFormat == WIRE_FORMAT_NDNSIM)
- return wire::ndnSIM::Data::FromWire (packet);
- else if (wireFormat == WIRE_FORMAT_CCNB)
- return wire::ccnb::Data::FromWire (packet);
- else
- {
- NS_FATAL_ERROR ("Unsupported format requested");
- return 0;
- }
- }
-}
-
-
-std::string
-Wire::FromInterestStr (Ptr<const Interest> interest, int8_t wireFormat/* = WIRE_FORMAT_DEFAULT*/)
-{
- Ptr<Packet> pkt = FromInterest (interest, wireFormat);
- std::string wire;
- wire.resize (pkt->GetSize ());
- pkt->CopyData (reinterpret_cast<uint8_t*> (&wire[0]), wire.size ());
-
- return wire;
-}
-
-Ptr<Interest>
-Wire::ToInterestStr (const std::string &wire, int8_t type/* = WIRE_FORMAT_AUTODETECT*/)
-{
- Ptr<Packet> pkt = Create<Packet> (reinterpret_cast<const uint8_t*> (&wire[0]), wire.size ());
- return ToInterest (pkt, type);
-}
-
-std::string
-Wire::FromDataStr (Ptr<const Data> data, int8_t wireFormat/* = WIRE_FORMAT_DEFAULT*/)
-{
- Ptr<Packet> pkt = FromData (data, wireFormat);
- std::string wire;
- wire.resize (pkt->GetSize ());
- pkt->CopyData (reinterpret_cast<uint8_t*> (&wire[0]), wire.size ());
-
- return wire;
-}
-
-Ptr<Data>
-Wire::ToDataStr (const std::string &wire, int8_t type/* = WIRE_FORMAT_AUTODETECT*/)
-{
- Ptr<Packet> pkt = Create<Packet> (reinterpret_cast<const uint8_t*> (&wire[0]), wire.size ());
- return ToData (pkt, type);
-}
-
-// uint32_t
-// Wire::FromNameSize (Ptr<const Name> name, int8_t wireFormat/* = WIRE_FORMAT_DEFAULT*/)
-// {
-// if (wireFormat == WIRE_FORMAT_DEFAULT)
-// wireFormat = GetWireFormat ();
-
-// if (wireFormat == WIRE_FORMAT_NDNSIM)
-// {
-// std::cout << wire::NdnSim::SerializedSizeName (*name) << std::endl;
-// return wire::NdnSim::SerializedSizeName (*name);
-// }
-// else if (wireFormat == WIRE_FORMAT_CCNB)
-// return wire::Ccnb::SerializedSizeName (*name);
-// else
-// {
-// NS_FATAL_ERROR ("Unsupported format requested");
-// return 0;
-// }
-// }
-
-std::string
-Wire::FromName (Ptr<const Name> name, int8_t wireFormat/* = WIRE_FORMAT_DEFAULT*/)
-{
-
- if (wireFormat == WIRE_FORMAT_DEFAULT)
- wireFormat = GetWireFormat ();
-
- if (wireFormat == WIRE_FORMAT_NDNSIM)
- {
- Buffer buf;
- buf.AddAtStart (wire::NdnSim::SerializedSizeName (*name));
- Buffer::Iterator i = buf.Begin ();
-
- wire::NdnSim::SerializeName (i, *name);
-
- std::string wire;
- wire.resize (buf.GetSize ());
- buf.CopyData (reinterpret_cast<uint8_t *>(&wire[0]), wire.size ());
-
- return wire;
- }
- else if (wireFormat == WIRE_FORMAT_CCNB)
- {
- Buffer buf;
- buf.AddAtStart (wire::NdnSim::SerializedSizeName (*name));
- Buffer::Iterator i = buf.Begin ();
-
- wire::Ccnb::SerializeName (i, *name);
-
- std::string wire;
- wire.resize (buf.GetSize ());
- buf.CopyData (reinterpret_cast<uint8_t *>(&wire[0]), wire.size ());
-
- return wire;
- }
- else
- {
- NS_FATAL_ERROR ("Unsupported format requested");
- }
-}
-
-Ptr<Name>
-Wire::ToName (const std::string &name, int8_t wireFormat/* = WIRE_FORMAT_DEFAULT*/)
-{
- Buffer buf;
- buf.AddAtStart (name.size ());
- Buffer::Iterator i = buf.Begin ();
- i.Write (reinterpret_cast<const uint8_t *> (&name[0]), name.size ());
-
- i = buf.Begin ();
-
- if (wireFormat == WIRE_FORMAT_DEFAULT)
- wireFormat = GetWireFormat ();
-
- if (wireFormat == WIRE_FORMAT_NDNSIM)
- {
- return wire::NdnSim::DeserializeName (i);
- }
- else if (wireFormat == WIRE_FORMAT_CCNB)
- {
- return wire::Ccnb::DeserializeName (i);
- }
- else
- {
- NS_FATAL_ERROR ("Unsupported format requested");
- }
-}
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ndn-wire.h b/model/wire/ndn-wire.h
deleted file mode 100644
index 38420e9..0000000
--- a/model/wire/ndn-wire.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU 3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_WIRE_H
-#define NDN_WIRE_H
-
-#include "ns3/buffer.h"
-
-#include "ns3/ndn-common.h"
-#include "ns3/ndn-name.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-
-NDN_NAMESPACE_BEGIN
-
-struct Wire
-{
- enum
- {
- WIRE_FORMAT_DEFAULT = -2,
- WIRE_FORMAT_AUTODETECT = -1,
-
- WIRE_FORMAT_NDNSIM = 0,
- WIRE_FORMAT_CCNB = 1
- };
-
- static Ptr<Packet>
- FromInterest (Ptr<const Interest> interest, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
-
- static Ptr<Interest>
- ToInterest (Ptr<Packet> packet, int8_t type = WIRE_FORMAT_AUTODETECT);
-
- static Ptr<Packet>
- FromData (Ptr<const Data> data, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
-
- static Ptr<Data>
- ToData (Ptr<Packet> packet, int8_t type = WIRE_FORMAT_AUTODETECT);
-
-
- // Helper methods for Python
- static std::string
- FromInterestStr (Ptr<const Interest> interest, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
-
- static Ptr<Interest>
- ToInterestStr (const std::string &wire, int8_t type = WIRE_FORMAT_AUTODETECT);
-
- static std::string
- FromDataStr (Ptr<const Data> data, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
-
- static Ptr<Data>
- ToDataStr (const std::string &wire, int8_t type = WIRE_FORMAT_AUTODETECT);
-
- // /*
- // * @brief Get size of buffer to fit wire-formatted name object
- // */
- // static uint32_t
- // FromNameSize (Ptr<const Name> name, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
-
- /**
- * @brief Convert name to wire format
- */
- static std::string
- FromName (Ptr<const Name> name, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
-
- /**
- * @brief Convert name from wire format
- */
- static Ptr<Name>
- ToName (const std::string &wire, int8_t wireFormat = WIRE_FORMAT_DEFAULT);
-};
-
-inline std::string
-PacketToBuffer (Ptr<const Packet> pkt)
-{
- std::string buffer;
- buffer.resize (pkt->GetSize ());
- pkt->CopyData (reinterpret_cast<uint8_t*> (&buffer[0]), buffer.size ());
-
- return buffer;
-}
-
-inline Ptr<Packet>
-BufferToPacket (const std::string &buffer)
-{
- return Create<Packet> (reinterpret_cast<const uint8_t*> (&buffer[0]), buffer.size ());
-}
-
-
-NDN_NAMESPACE_END
-
-#endif // NDN_WIRE_H
diff --git a/model/wire/ndnsim.cc b/model/wire/ndnsim.cc
deleted file mode 100644
index 4668a79..0000000
--- a/model/wire/ndnsim.cc
+++ /dev/null
@@ -1,374 +0,0 @@
-/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU 3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndnsim.h"
-
-using namespace std;
-
-#include <ns3/header.h>
-#include <ns3/packet.h>
-#include <ns3/log.h>
-
-#include "ndnsim/wire-ndnsim.h"
-
-NS_LOG_COMPONENT_DEFINE ("ndn.wire.ndnSIM");
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-namespace ndnSIM {
-
-NS_OBJECT_ENSURE_REGISTERED (Interest);
-NS_OBJECT_ENSURE_REGISTERED (Data);
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-Interest::Interest ()
- : m_interest (Create<ndn::Interest> ())
-{
-}
-
-Interest::Interest (Ptr<ndn::Interest> interest)
- : m_interest (interest)
-{
-}
-
-Ptr<ndn::Interest>
-Interest::GetInterest ()
-{
- return m_interest;
-}
-
-
-TypeId
-Interest::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::Interest::ndnSIM")
- .SetGroupName ("Ndn")
- .SetParent<Header> ()
- .AddConstructor<Interest> ()
- ;
- return tid;
-}
-
-TypeId
-Interest::GetInstanceTypeId (void) const
-{
- return GetTypeId ();
-}
-
-Ptr<Packet>
-Interest::ToWire (Ptr<const ndn::Interest> interest)
-{
- Ptr<const Packet> p = interest->GetWire ();
- if (!p)
- {
- Ptr<Packet> packet = Create<Packet> (*interest->GetPayload ());
- Interest wireEncoding (ConstCast<ndn::Interest> (interest));
- packet->AddHeader (wireEncoding);
- interest->SetWire (packet);
-
- p = packet;
- }
-
- return p->Copy ();
-}
-
-Ptr<ndn::Interest>
-Interest::FromWire (Ptr<Packet> packet)
-{
- Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
- Ptr<Packet> wire = packet->Copy ();
-
- Interest wireEncoding (interest);
- packet->RemoveHeader (wireEncoding);
-
- interest->SetPayload (packet);
- interest->SetWire (wire);
-
- return interest;
-}
-
-uint32_t
-Interest::GetSerializedSize (void) const
-{
- size_t size =
- 1/*version*/ + 1 /*type*/ + 2/*length*/ +
- (4/*nonce*/ + 1/*scope*/ + 1/*nack type*/ + 2/*timestamp*/ +
- NdnSim::SerializedSizeName (m_interest->GetName ()) +
-
- (2 +
- (m_interest->GetExclude () == 0 ? 0 : (1 + NdnSim::SerializedSizeExclude (*m_interest->GetExclude ())))
- )/* selectors */ +
-
- (2 + 0)/* options */);
-
- NS_LOG_INFO ("Serialize size = " << size);
- return size;
-}
-
-void
-Interest::Serialize (Buffer::Iterator start) const
-{
- start.WriteU8 (0x80); // version
- start.WriteU8 (0x00); // packet type
-
- start.WriteU16 (GetSerializedSize () - 4);
-
- start.WriteU32 (m_interest->GetNonce ());
- start.WriteU8 (m_interest->GetScope ());
- start.WriteU8 (m_interest->GetNack ());
-
- NS_ASSERT_MSG (0 <= m_interest->GetInterestLifetime ().ToInteger (Time::S) && m_interest->GetInterestLifetime ().ToInteger (Time::S) < 65535,
- "Incorrect InterestLifetime (should not be smaller than 0 and larger than 65535");
-
- // rounding timestamp value to seconds
- start.WriteU16 (static_cast<uint16_t> (m_interest->GetInterestLifetime ().ToInteger (Time::S)));
-
- NdnSim::SerializeName (start, m_interest->GetName ());
-
- if (m_interest->GetExclude () == 0)
- {
- start.WriteU16 (0); // no selectors
- }
- else
- {
- start.WriteU16 (1 + NdnSim::SerializedSizeExclude (*m_interest->GetExclude ()));
- start.WriteU8 (0x01);
- NdnSim::SerializeExclude (start, *m_interest->GetExclude ());
- }
-
- start.WriteU16 (0); // no options
-}
-
-uint32_t
-Interest::Deserialize (Buffer::Iterator start)
-{
- Buffer::Iterator i = start;
-
- if (i.ReadU8 () != 0x80)
- throw new InterestException ();
-
- if (i.ReadU8 () != 0x00)
- throw new InterestException ();
-
- i.ReadU16 (); // length, don't need it right now
-
- m_interest->SetNonce (i.ReadU32 ());
- m_interest->SetScope (i.ReadU8 ());
- m_interest->SetNack (i.ReadU8 ());
-
- m_interest->SetInterestLifetime (Seconds (i.ReadU16 ()));
-
- m_interest->SetName (NdnSim::DeserializeName (i));
-
- uint32_t selectorsLen = i.ReadU16 ();
- if (selectorsLen > 0)
- {
- if (i.ReadU8 () != 0x01) // exclude filter only
- throw InterestException ();
-
- m_interest->SetExclude (NdnSim::DeserializeExclude (i));
- }
- i.ReadU16 ();
-
- NS_ASSERT (GetSerializedSize () == (i.GetDistanceFrom (start)));
-
- return i.GetDistanceFrom (start);
-}
-
-void
-Interest::Print (std::ostream &os) const
-{
- m_interest->Print (os);
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-TypeId
-Data::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::ndn::Data::ndnSIM")
- .SetGroupName ("Ndn")
- .SetParent<Header> ()
- .AddConstructor<Data> ()
- ;
- return tid;
-}
-
-TypeId
-Data::GetInstanceTypeId (void) const
-{
- return GetTypeId ();
-}
-
-
-Data::Data ()
- : m_data (Create<ndn::Data> ())
-{
-}
-
-Data::Data (Ptr<ndn::Data> data)
- : m_data (data)
-{
-}
-
-Ptr<ndn::Data>
-Data::GetData ()
-{
- return m_data;
-}
-
-Ptr<Packet>
-Data::ToWire (Ptr<const ndn::Data> data)
-{
- Ptr<const Packet> p = data->GetWire ();
- if (!p)
- {
- Ptr<Packet> packet = Create<Packet> (*data->GetPayload ());
- Data wireEncoding (ConstCast<ndn::Data> (data));
- packet->AddHeader (wireEncoding);
- data->SetWire (packet);
-
- p = packet;
- }
-
- return p->Copy ();
-}
-
-Ptr<ndn::Data>
-Data::FromWire (Ptr<Packet> packet)
-{
- Ptr<ndn::Data> data = Create<ndn::Data> ();
- Ptr<Packet> wire = packet->Copy ();
-
- Data wireEncoding (data);
- packet->RemoveHeader (wireEncoding);
-
- data->SetPayload (packet);
- data->SetWire (wire);
-
- return data;
-}
-
-uint32_t
-Data::GetSerializedSize () const
-{
- uint32_t size = 1 + 1 + 2 +
- ((2 + 2) +
- NdnSim::SerializedSizeName (m_data->GetName ()) +
- (2 + 2 + 4 + 2 + 2 + (2 + 0)));
- if (m_data->GetSignature () != 0)
- size += 4;
-
- NS_LOG_INFO ("Serialize size = " << size);
- return size;
-}
-
-void
-Data::Serialize (Buffer::Iterator start) const
-{
- start.WriteU8 (0x80); // version
- start.WriteU8 (0x01); // packet type
- start.WriteU16 (GetSerializedSize () - 4); // length
-
- if (m_data->GetSignature () != 0)
- {
- start.WriteU16 (6); // signature length
- start.WriteU16 (0xFF00); // "fake" simulator signature
- start.WriteU32 (m_data->GetSignature ());
- }
- else
- {
- start.WriteU16 (2); // signature length
- start.WriteU16 (0); // empty signature
- }
-
- // name
- NdnSim::SerializeName (start, m_data->GetName ());
-
- // content
- // for now assume that contentdata length is zero
- start.WriteU16 (2 + 4 + 2 + 2 + (2 + 0));
- start.WriteU16 (4 + 2 + 2 + (2 + 0));
- start.WriteU32 (static_cast<uint32_t> (m_data->GetTimestamp ().ToInteger (Time::S)));
- start.WriteU16 (static_cast<uint16_t> (m_data->GetFreshness ().ToInteger (Time::S)));
- start.WriteU16 (0); // reserved
- start.WriteU16 (0); // Length (ContentInfoOptions)
-
- // that's it folks
-}
-
-uint32_t
-Data::Deserialize (Buffer::Iterator start)
-{
- Buffer::Iterator i = start;
-
- if (i.ReadU8 () != 0x80)
- throw new DataException ();
-
- if (i.ReadU8 () != 0x01)
- throw new DataException ();
-
- i.ReadU16 (); // length
-
- uint32_t signatureLength = i.ReadU16 ();
- if (signatureLength == 6)
- {
- if (i.ReadU16 () != 0xFF00) // signature type
- throw new DataException ();
- m_data->SetSignature (i.ReadU32 ());
- }
- else if (signatureLength == 2)
- {
- if (i.ReadU16 () != 0) // signature type
- throw new DataException ();
- m_data->SetSignature (0);
- }
- else
- throw new DataException ();
-
- m_data->SetName (NdnSim::DeserializeName (i));
-
- if (i.ReadU16 () != (2 + 4 + 2 + 2 + (2 + 0))) // content length
- throw new DataException ();
-
- if (i.ReadU16 () != (4 + 2 + 2 + (2 + 0))) // Length (content Info)
- throw new DataException ();
-
- m_data->SetTimestamp (Seconds (i.ReadU32 ()));
- m_data->SetFreshness (Seconds (i.ReadU16 ()));
-
- if (i.ReadU16 () != 0) // Reserved
- throw new DataException ();
- if (i.ReadU16 () != 0) // Length (ContentInfoOptions)
- throw new DataException ();
-
- NS_ASSERT_MSG (i.GetDistanceFrom (start) == GetSerializedSize (),
- "Something wrong with Data::Deserialize");
-
- return i.GetDistanceFrom (start);
-}
-
-void
-Data::Print (std::ostream &os) const
-{
- m_data->Print (os);
-}
-
-} // ndnSIM
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ndnsim.h b/model/wire/ndnsim.h
deleted file mode 100644
index f247f77..0000000
--- a/model/wire/ndnsim.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU 3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_WIRE_NDNSIM_H
-#define NDN_WIRE_NDNSIM_H
-
-#include "ns3/ndn-common.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
-
-NDN_NAMESPACE_BEGIN
-
-/**
- * @brief Namespace encapsulating wire operations
- */
-namespace wire {
-
-/**
- * @brief Namespace for ndnSIM wire format operations
- */
-namespace ndnSIM {
-
-/**
- * @brief Routines to serialize/deserialize Interest packet in ndnSIM format
- *
- * Optimized and simplified formatting of Interest packets
- *
- * Interest ::= Nonce
- * Scope
- * InterestLifetime
- * Name
- * Selectors
- * Options
- *
- * Minumum size of the Interest packet: 1 + 4 + 2 + 1 + (2 + 0) + (2 + 0) + (2 + 0) = 14
- *
- * Maximum size of the Interest packet: 1 + 4 + 2 + 1 + (2 + 65535) + (2 + 65535) + (2 + 65535) = 196619
- *
- * ::
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Nonce |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Scope | Reserved | InterestLifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Length | |
- * |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
- * ~ ~
- * ~ Name ~
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Length | |
- * |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
- * ~ ~
- * ~ Selectors ~
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Length | |
- * |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
- * ~ ~
- * ~ Options ~
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-class Interest : public Header
-{
-public:
- Interest ();
- Interest (Ptr<ndn::Interest> interest);
-
- Ptr<ndn::Interest>
- GetInterest ();
-
- static Ptr<Packet>
- ToWire (Ptr<const ndn::Interest> interest);
-
- static Ptr<ndn::Interest>
- FromWire (Ptr<Packet> packet);
-
- // from Header
- static TypeId GetTypeId (void);
- virtual TypeId GetInstanceTypeId (void) const;
- virtual void Print (std::ostream &os) const;
- virtual uint32_t GetSerializedSize (void) const;
- virtual void Serialize (Buffer::Iterator start) const;
- virtual uint32_t Deserialize (Buffer::Iterator start);
-
-private:
- Ptr<ndn::Interest> m_interest;
-};
-
-/**
- * @brief Routines to serialize/deserialize Data packet in ndnSIM format
- *
- * Only few important fields are actually implemented in the simulation
- *
- * @see http://ndnsim.net/new-packet-formats.html
- *
- * Data ::= Signature
- * Name
- * Content
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Length | |
- * |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
- * ~ ~
- * ~ Signature ~
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Length | |
- * |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
- * ~ ~
- * ~ Name ~
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Length | |
- * |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
- * ~ ~
- * ~ Content ~
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-class Data : public Header
-{
-public:
- Data ();
- Data (Ptr<ndn::Data> data);
-
- Ptr<ndn::Data>
- GetData ();
-
- static Ptr<Packet>
- ToWire (Ptr<const ndn::Data> data);
-
- static Ptr<ndn::Data>
- FromWire (Ptr<Packet> packet);
-
- // from Header
- static TypeId GetTypeId (void);
- virtual TypeId GetInstanceTypeId (void) const;
- virtual void Print (std::ostream &os) const;
- virtual uint32_t GetSerializedSize (void) const;
- virtual void Serialize (Buffer::Iterator start) const;
- virtual uint32_t Deserialize (Buffer::Iterator start);
-
-private:
- Ptr<ndn::Data> m_data;
-};
-
-} // ndnSIM
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // NDN_WIRE_NDNSIM_H
diff --git a/model/wire/ndnsim/wire-ndnsim.cc b/model/wire/ndnsim/wire-ndnsim.cc
deleted file mode 100644
index 013d78d..0000000
--- a/model/wire/ndnsim/wire-ndnsim.cc
+++ /dev/null
@@ -1,175 +0,0 @@
-/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU 3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "wire-ndnsim.h"
-#include <boost/foreach.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////
-
-size_t
-NdnSim::SerializeName (Buffer::Iterator &i, const Name &name)
-{
- Buffer::Iterator start = i;
-
- i.WriteU16 (static_cast<uint16_t> (SerializedSizeName (name)-2));
-
- for (Name::const_iterator item = name.begin ();
- item != name.end ();
- item++)
- {
- i.WriteU16 (static_cast<uint16_t> (item->size ()));
- i.Write (reinterpret_cast<const uint8_t*> (item->buf ()), item->size ());
- }
-
- return i.GetDistanceFrom (start);
-}
-
-size_t
-NdnSim::SerializedSizeName (const Name &name)
-{
- size_t nameSerializedSize = 2;
-
- for (Name::const_iterator i = name.begin ();
- i != name.end ();
- i++)
- {
- nameSerializedSize += 2 + i->size ();
- }
- NS_ASSERT_MSG (nameSerializedSize < 30000, "Name is too long (> 30kbytes)");
-
- return nameSerializedSize;
-}
-
-Ptr<Name>
-NdnSim::DeserializeName (Buffer::Iterator &i)
-{
- Ptr<Name> name = Create<Name> ();
-
- uint16_t nameLength = i.ReadU16 ();
- while (nameLength > 0)
- {
- uint16_t length = i.ReadU16 ();
- nameLength = nameLength - 2 - length;
-
- uint8_t tmp[length];
- i.Read (tmp, length);
-
- name->append (tmp, length);
- }
-
- return name;
-}
-
-
-size_t
-NdnSim::SerializeExclude (Buffer::Iterator &i, const Exclude &exclude)
-{
- Buffer::Iterator start = i;
-
- i.WriteU16 (static_cast<uint16_t> (SerializedSizeExclude (exclude)-2));
-
- for (Exclude::const_reverse_iterator item = exclude.rbegin ();
- item != exclude.rend ();
- item++)
- {
- if (!item->first.empty ())
- {
- i.WriteU8 (ExcludeNameType);
- i.WriteU16 (static_cast<uint16_t> (item->first.size ()));
- i.Write (reinterpret_cast<const uint8_t*> (item->first.buf ()), item->first.size ());
- }
- if (item->second)
- {
- i.WriteU8 (ExcludeAnyType);
- }
- }
- return i.GetDistanceFrom (start);
-}
-
-size_t
-NdnSim::SerializedSizeExclude (const Exclude &exclude)
-{
- size_t excludeSerializedSize = 2;
-
- for (Exclude::const_reverse_iterator item = exclude.rbegin ();
- item != exclude.rend ();
- item++)
- {
- if (!item->first.empty ())
- {
- excludeSerializedSize += 1 + 2 + item->first.size ();
- }
- if (item->second)
- {
- excludeSerializedSize += 1;
- }
- }
-
- return excludeSerializedSize;
-}
-
-Ptr<Exclude>
-NdnSim::DeserializeExclude (Buffer::Iterator &i)
-{
- Ptr<Exclude> exclude = Create<Exclude> ();
-
- uint16_t excludeLength = i.ReadU16 ();
- while (excludeLength > 0)
- {
- uint8_t type = i.ReadU8 ();
- excludeLength --;
-
- if (type == ExcludeAnyType)
- {
- exclude->appendExclude (name::Component (), true);
- }
- else if (type == ExcludeNameType)
- {
- uint16_t length = i.ReadU16 ();
- excludeLength = excludeLength - 2 - length;
-
- uint8_t tmp[length];
- i.Read (tmp, length);
-
- bool any = false;
- if (excludeLength > 0)
- {
- uint8_t type = i.ReadU8 ();
- if (type != ExcludeAnyType)
- {
- i.Prev ();
- }
- else
- {
- any = true;
- excludeLength --;
- }
- }
-
- exclude->appendExclude (name::Component (tmp, length), any);
- }
- else
- {
- NS_FATAL_ERROR ("Incorrect format of Exclude filter");
- }
- }
- return exclude;
-}
-
-
-} // wire
-
-NDN_NAMESPACE_END
diff --git a/model/wire/ndnsim/wire-ndnsim.h b/model/wire/ndnsim/wire-ndnsim.h
deleted file mode 100644
index 4ddfb3e..0000000
--- a/model/wire/ndnsim/wire-ndnsim.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU 3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_WIRE_NDNSIM_SYNTAX_H
-#define NDN_WIRE_NDNSIM_SYNTAX_H
-
-#include "ns3/ptr.h"
-#include "ns3/nstime.h"
-#include "ns3/buffer.h"
-
-#include "ns3/ndn-common.h"
-#include "ns3/ndnSIM/ndn.cxx/name.h"
-#include "ns3/ndnSIM/ndn.cxx/exclude.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace wire {
-
-/**
- * \brief Helper to encode ndnSIM wire elements
- */
-class NdnSim
-{
-public:
- /**
- * @brief Append Name in ndnSIM encoding
- * @param start Buffer to store serialized Interest
- * @param name constant reference to Name object
- *
- * @returns written length
- */
- static size_t
- SerializeName (Buffer::Iterator &start, const Name &name);
-
- /**
- * @brief Estimate size of Name in ndnSIM encoding
- * @param name constant reference to Name object
- * @returns estimated length
- */
- static size_t
- SerializedSizeName (const Name &name);
-
- /**
- * @brief Deserialize Name from ndnSIM encodeing
- * @param start Buffer that stores serialized Interest
- * @param name Name object
- */
- static Ptr<Name>
- DeserializeName (Buffer::Iterator &start);
-
-
- enum Selectors {
- SelectorExclude = 0x01
- };
-
- enum ExcludeTypes {
- ExcludeNameType = 0x01,
- ExcludeAnyType = 0x02
- };
-
- /**
- * @brief Append Exclude in ndnSIM encoding
- * @param start Buffer to store serialized Interest
- * @param exclude constant reference to Exclude object
- *
- * @returns written length
- */
- static size_t
- SerializeExclude (Buffer::Iterator &start, const Exclude &exclude);
-
- /**
- * @brief Estimate size of Exclude in ndnSIM encoding
- * @param exclude constant reference to Exclude object
- * @returns estimated length
- */
- static size_t
- SerializedSizeExclude (const Exclude &exclude);
-
- /**
- * @brief Deserialize Exclude from ndnSIM encodeing
- * @param start Buffer that stores serialized Interest
- * @param exclude Exclude object
- */
- static Ptr<Exclude>
- DeserializeExclude (Buffer::Iterator &start);
-}; // NdnSim
-
-} // wire
-
-NDN_NAMESPACE_END
-
-#endif // NDN_WIRE_NDNSIM_SYNTAX_H
diff --git a/ndn.cxx/blob.h b/ndn.cxx/blob.h
deleted file mode 100644
index 1b1aa2d..0000000
--- a/ndn.cxx/blob.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- * Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_BLOB_H
-#define NDN_BLOB_H
-
-#include "ns3/ndn-common.h"
-
-#include <vector>
-
-NDN_NAMESPACE_BEGIN
-
-/**
- * @ingroup ndn-cxx
- * @brief Class representing a general-use binary blob
- */
-class Blob
-{
-public:
- typedef std::vector<char> base;
-
- typedef base::value_type value_type;
- typedef base::pointer pointer;
- typedef base::const_pointer const_pointer;
- typedef base::reference reference;
- typedef base::const_reference const_reference;
- typedef base::iterator iterator;
- typedef base::const_iterator const_iterator;
- typedef base::const_reverse_iterator const_reverse_iterator;
- typedef base::reverse_iterator reverse_iterator;
- typedef base::size_type size_type;
- typedef base::difference_type difference_type;
- typedef base::allocator_type allocator_type;
-
-public:
- /**
- * @brief Creates an empty blob
- */
- Blob ()
- {
- }
-
- Blob (const std::string &data)
- : m_data (data.begin (), data.end ())
- {
- }
-
- Blob (const void *buf, size_t length)
- : m_data (reinterpret_cast<const char*> (buf), reinterpret_cast<const char*> (buf) + length)
- {
- }
-
- /**
- * @brief Get pointer to the first byte of the binary blob
- */
- inline char*
- buf ()
- {
- return &m_data.front ();
- }
-
- /**
- * @brief Get const pointer to the first byte of the binary blob
- */
- inline const char*
- buf () const
- {
- return &m_data.front ();
- }
-
- iterator begin () { return m_data.begin (); }
- const_iterator begin () const { return m_data.begin (); }
- iterator end () { return m_data.end (); }
- const_iterator end () const { return m_data.end (); }
- size_t size () const { return m_data.size (); }
-
- void swap (Blob &x) { m_data.swap (x.m_data); }
- void push_back (value_type val) { m_data.push_back (val); }
-
- bool empty () const { return m_data.empty (); }
-
- Blob &
- operator = (const Blob &other) { m_data = other.m_data; return *this; }
-
- reference operator [] (size_type pos) { return m_data [pos]; }
- const_reference operator [] (size_type pos) const { return m_data [pos]; }
-
- char getItem (size_type pos) const { return m_data [pos]; }
-
- void clear () { m_data.clear (); }
-
-private:
- friend bool operator == (const Blob &a, const Blob &b);
- friend bool operator < (const Blob &a, const Blob &b);
- friend bool operator <= (const Blob &a, const Blob &b);
- friend bool operator > (const Blob &a, const Blob &b);
- friend bool operator >= (const Blob &a, const Blob &b);
-
-private:
- std::vector< char > m_data;
-};
-
-inline bool operator == (const Blob &a, const Blob &b) { return a.m_data == b.m_data; }
-inline bool operator < (const Blob &a, const Blob &b) { return a.m_data < b.m_data; }
-inline bool operator <= (const Blob &a, const Blob &b) { return a.m_data <= b.m_data; }
-inline bool operator > (const Blob &a, const Blob &b) { return a.m_data > b.m_data; }
-inline bool operator >= (const Blob &a, const Blob &b) { return a.m_data >= b.m_data; }
-
-NDN_NAMESPACE_END
-
-#include <boost/functional/hash.hpp>
-namespace boost
-{
-inline std::size_t
-hash_value (const ns3::ndn::Blob v)
-{
- return boost::hash_range (v.begin(), v.end());
-}
-}
-
-#endif // NDN_BLOB_H
diff --git a/ndn.cxx/detail/error.h b/ndn.cxx/detail/error.h
deleted file mode 100644
index db6b751..0000000
--- a/ndn.cxx/detail/error.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-/**
- * @file error.h
- * @brief This file defines basic elements for the library reporting
- *
- * The library throws a number of exceptions.
- * In general, the following example shows how to print out diagnostic information
- * when one of the exceptions is thrown
- * @code
- * try
- * {
- * ... operations with ndn::Name
- * }
- * catch (boost::exception &e)
- * {
- * std::cerr << boost::diagnostic_information (e) << std::endl;
- * }
- * @endcode
- */
-
-#ifndef NDN_ERROR2_H
-#define NDN_ERROR2_H
-
-#include "ns3/ndn-common.h"
-#include <boost/exception/all.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-/**
- * @ingroup ndn-cxx
- * @brief Namespace holding all errors from NDN.cxx API
- */
-namespace error
-{
-
-struct Error : public virtual boost::exception, public virtual std::exception {}; ///< @brief Some error with error reporting engine
-struct Uri : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with URI processing
-struct StringTransform : public virtual boost::exception, public virtual std::exception {};
-struct Name : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with Name
-namespace name {
-struct Component : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with name::Component
-}
-struct Exclude : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with Exclude
-struct KeyLocator : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with KeyLocator
-namespace wire {
-struct Ccnb : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with wire::Ccnb encoding
-}
-struct Keychain : public virtual boost::exception, public virtual std::exception {}; ///< @brief An error with security::Keychain
-
-// Diagnostic information fields
-
-/**
- * @brief Free-formatted text message explaining the error
- *
- * @code
- * ...
- * catch (boost::exception &e)
- * {
- * if (const std::string *error = boost::get_error_info<error::msg> (e))
- * ...
- * }
- * @endcode
- *
- * @see get_msg
- */
-typedef boost::error_info<struct tag_msg, std::string> msg;
-
-/**
- * @brief Helper method to get error message from the exception
- *
- * Method assumes that message is present, if not, an exception will be thrown
- */
-inline const std::string &
-get_msg (boost::exception &e)
-{
- const std::string *error = boost::get_error_info<msg> (e);
- if (error == 0)
- BOOST_THROW_EXCEPTION (Error ());
- return *error;
-}
-
-/**
- * @brief Report of the position of the error (error-specific meaning)
- *
- * @code
- * ...
- * catch (boost::exception &e)
- * {
- * if (const int *error = boost::get_error_info<error::pos> (e))
- * ...
- * }
- * @endcode
- *
- * @see get_pos
- */
-typedef boost::error_info<struct tag_pos, int> pos;
-
-/**
- * @brief Helper method to get position of the error from the exception
- *
- * Method assumes that position is present, if not, an exception will be thrown
- */
-inline int
-get_pos (boost::exception &e)
-{
- const int *position = boost::get_error_info<pos> (e);
- if (position == 0)
- BOOST_THROW_EXCEPTION (Error ());
- return *position;
-}
-
-} // error
-
-NDN_NAMESPACE_END
-
-#endif // NDN_ERROR2_H
diff --git a/ndn.cxx/detail/pending-interests-container.h b/ndn.cxx/detail/pending-interests-container.h
deleted file mode 100644
index b790864..0000000
--- a/ndn.cxx/detail/pending-interests-container.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU v3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_NDNCXX_DETAIL_PENDING_INTEREST_CONTAINER_H
-#define NDN_NDNCXX_DETAIL_PENDING_INTEREST_CONTAINER_H
-
-#include <ns3/ndnSIM/utils/trie/trie-with-policy.h>
-#include "timeouts-policy.h"
-
-namespace ns3 {
-namespace ndn {
-namespace detail {
-
-struct PendingInterestEntry : public SimpleRefCount< PendingInterestEntry >
-{
-public:
- PendingInterestEntry (Ptr<const Interest> interest)
- : m_interest (interest)
- {
- }
-
- virtual ~PendingInterestEntry ()
- {
- }
-
- void
- AddCallbacks (ApiFace::DataCallback onData, ApiFace::TimeoutCallback onTimeout)
- {
- if (! onData.IsNull ())
- {
- m_dataCallbacks.push_back (onData);
- }
- if (! onTimeout.IsNull ())
- {
- m_timeoutCallbacks.push_back (onTimeout);
- }
- }
-
- void
- ClearCallbacks ()
- {
- m_dataCallbacks.clear ();
- m_timeoutCallbacks.clear ();
- }
-
- Ptr<const Interest>
- GetInterest () const
- {
- return m_interest;
- }
-
- void
- ProcessOnData (Ptr<const Interest> interest, Ptr<const Data> data)
- {
- for (std::list<ApiFace::DataCallback>::iterator i = m_dataCallbacks.begin ();
- i != m_dataCallbacks.end ();
- i++)
- {
- (*i) (interest, data);
- }
- }
-
- void
- ProcessOnTimeout (Ptr<const Interest> interest)
- {
- for (std::list<ApiFace::TimeoutCallback>::iterator i = m_timeoutCallbacks.begin ();
- i != m_timeoutCallbacks.end ();
- i++)
- {
- (*i) (interest);
- }
- }
-
-private:
- std::list<ApiFace::DataCallback> m_dataCallbacks;
- std::list<ApiFace::TimeoutCallback> m_timeoutCallbacks;
- Ptr<const Interest> m_interest;
-};
-
-
-struct PendingInterestContainer :
- public ndnSIM::trie_with_policy<Name,
- ndnSIM::smart_pointer_payload_traits< PendingInterestEntry >,
- timeouts_policy_traits>
-{
-};
-
-} // detail
-} // ndn
-} // ns3
-
-#endif // NDN_NDNCXX_DETAIL_PENDING_INTEREST_CONTAINER_H
diff --git a/ndn.cxx/detail/registered-prefix-container.h b/ndn.cxx/detail/registered-prefix-container.h
deleted file mode 100644
index 2e6c151..0000000
--- a/ndn.cxx/detail/registered-prefix-container.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU v3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_NDNCXX_DETAIL_REGISTERED_PREFIX_CONTAINER_H
-#define NDN_NDNCXX_DETAIL_REGISTERED_PREFIX_CONTAINER_H
-
-#include <ns3/ndnSIM/utils/trie/trie-with-policy.h>
-#include <ns3/ndnSIM/utils/trie/counting-policy.h>
-
-namespace ns3 {
-namespace ndn {
-namespace detail {
-
-struct RegisteredPrefixEntry : public SimpleRefCount< RegisteredPrefixEntry >
-{
-public:
- RegisteredPrefixEntry (Ptr<const Name> prefix)
- : m_prefix (prefix)
- { }
-
- void
- AddCallback (ApiFace::InterestCallback callback)
- {
- m_callback = callback;
- }
-
- void
- ClearCallback ()
- {
- m_callback = ApiFace::InterestCallback ();
- }
-
- Ptr<const Name>
- GetPrefix () const
- {
- return m_prefix;
- }
-
-public:
- ApiFace::InterestCallback m_callback;
- Ptr<const Name> m_prefix;
-};
-
-
-struct RegisteredPrefixContainer :
- public ndnSIM::trie_with_policy<Name,
- ndnSIM::smart_pointer_payload_traits< RegisteredPrefixEntry >,
- ndnSIM::counting_policy_traits>
-{
-};
-
-} // detail
-} // ndn
-} // ns3
-
-#endif // NDN_NDNCXX_DETAIL_REGISTERED_PREFIX_CONTAINER_H
diff --git a/ndn.cxx/detail/timeouts-policy.h b/ndn.cxx/detail/timeouts-policy.h
deleted file mode 100644
index 7d94be1..0000000
--- a/ndn.cxx/detail/timeouts-policy.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU v3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_NDNCXX_DETAIL_TIMEOUTS_POLICY_H_
-#define NDN_NDNCXX_DETAIL_TIMEOUTS_POLICY_H_
-
-#include <boost/intrusive/options.hpp>
-#include <boost/intrusive/list.hpp>
-
-#include <ns3/nstime.h>
-#include <ns3/simulator.h>
-
-namespace ns3 {
-namespace ndn {
-namespace detail {
-
-/**
- * @brief Traits for timeouts policy
- */
-struct timeouts_policy_traits
-{
- /// @brief Name that can be used to identify the policy (for NS-3 object model and logging)
- static std::string GetName () { return "Timeouts"; }
-
- struct policy_hook_type : public boost::intrusive::set_member_hook<> { Time timeWhenShouldExpire; };
-
- template<class Container>
- struct container_hook
- {
- typedef boost::intrusive::member_hook< Container,
- policy_hook_type,
- &Container::policy_hook_ > type;
- };
-
- template<class Base,
- class Container,
- class Hook>
- struct policy
- {
- static Time& get_timeout (typename Container::iterator item)
- {
- return static_cast<typename policy_container::value_traits::hook_type*>
- (policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
- }
-
- static const Time& get_timeout (typename Container::const_iterator item)
- {
- return static_cast<const typename policy_container::value_traits::hook_type*>
- (policy_container::value_traits::to_node_ptr(*item))->timeWhenShouldExpire;
- }
-
- template<class Key>
- struct MemberHookLess
- {
- bool operator () (const Key &a, const Key &b) const
- {
- return get_timeout (&a) < get_timeout (&b);
- }
- };
-
- typedef boost::intrusive::multiset< Container,
- boost::intrusive::compare< MemberHookLess< Container > >,
- Hook > policy_container;
-
-
- class type : public policy_container
- {
- public:
- typedef policy policy_base; // to get access to get_timeout methods from outside
- typedef Container parent_trie;
-
- type (Base &base)
- : m_base (base)
- {
- }
-
- inline void
- update (typename parent_trie::iterator item)
- {
- // do nothing
- }
-
- inline bool
- insert (typename parent_trie::iterator item)
- {
- Time timeout = item->payload ()->GetInterest ()->GetInterestLifetime ();
- if (timeout.IsZero ()) timeout = Seconds (4.0);
-
- get_timeout (item) = Simulator::Now () + timeout;
- policy_container::insert (*item);
-
- if (policy_container::s_iterator_to (*item) == policy_container::begin ())
- {
- if (m_timeoutEvent.IsRunning ())
- {
- Simulator::Remove (m_timeoutEvent); // just canceling would not clean up list of events
- }
-
- m_timeoutEvent = Simulator::Schedule (timeout, &type::ProcessTimeoutEntry, this, item);
- }
-
- return true;
- }
-
- inline void
- lookup (typename parent_trie::iterator item)
- {
- // do nothing. it's random policy
- }
-
- inline void
- erase (typename parent_trie::iterator item)
- {
- bool needRescheduling = false;
- if (policy_container::s_iterator_to (*item) == policy_container::begin ())
- {
- if (m_timeoutEvent.IsRunning ())
- {
- Simulator::Remove (m_timeoutEvent); // just canceling would not clean up list of events
- }
- needRescheduling = true;
- }
-
- // erase only if freshness is non zero (otherwise an item is not in the policy
- policy_container::erase (policy_container::s_iterator_to (*item));
-
- if (needRescheduling && !policy_container::empty ())
- {
- Time timeout = get_timeout (&*policy_container::begin ()) - Simulator::Now ();
- m_timeoutEvent = Simulator::Schedule (timeout, &type::ProcessTimeoutEntry, this, &*policy_container::begin ());
- }
- }
-
- inline void
- clear ()
- {
- policy_container::clear ();
- }
-
- inline void
- ProcessTimeoutEntry (typename parent_trie::iterator item)
- {
- item->payload ()->ProcessOnTimeout (item->payload ()->GetInterest ());
-
- m_base.erase (item);
- }
-
- private:
- type () : m_base (*((Base*)0)) { };
-
- private:
- Base &m_base;
- EventId m_timeoutEvent;
- };
- };
-};
-
-} // detail
-} // ndn
-} // ns3
-
-#endif // NDN_NDNCXX_DETAIL_TIMEOUTS_STATS_POLICY_H
diff --git a/ndn.cxx/detail/uri.h b/ndn.cxx/detail/uri.h
deleted file mode 100644
index ae3844e..0000000
--- a/ndn.cxx/detail/uri.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_DETAIL_URI_H
-#define NDN_DETAIL_URI_H
-
-#include "ns3/ndn-common.h"
-
-#include "error.h"
-
-#include <boost/archive/iterators/transform_width.hpp>
-#include <boost/iterator/transform_iterator.hpp>
-
-NDN_NAMESPACE_BEGIN
-
-namespace detail
-{
-
-static const bool ESCAPE_CHARACTER [256] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 26
- 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 53
- 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 107
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, // 134
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 161
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 188
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 215
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 242
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 255
-};
-
-/// @cond include_hidden
-template<class CharType>
-struct hex_from_4_bit
-{
- typedef CharType result_type;
- CharType operator () (CharType ch) const
- {
- const char lookup_table [16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
- // cout << "New character: " << (int) ch << " (" << (char) ch << ")" << "\n";
- BOOST_ASSERT (ch < 16);
- return lookup_table[static_cast<size_t>(ch)];
- }
-};
-
-typedef boost::transform_iterator<hex_from_4_bit<std::string::const_iterator::value_type>,
- boost::archive::iterators::transform_width<std::string::const_iterator, 4, 8, std::string::const_iterator::value_type> > string_from_binary;
-
-
-
-template<class CharType>
-struct hex_to_4_bit
-{
- typedef CharType result_type;
- CharType operator () (CharType ch) const
- {
- const signed char lookup_table [] = {
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
- -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
- };
-
- signed char value = -1;
- if ((unsigned)ch < 128)
- value = lookup_table [(unsigned)ch];
- if (value == -1)
- boost::throw_exception (error::StringTransform ());
-
- return value;
- }
-};
-
-typedef boost::archive::iterators::transform_width<boost::transform_iterator<hex_to_4_bit<std::string::const_iterator::value_type>, std::string::const_iterator>, 8, 4> string_to_binary;
-/// @endcond
-
-} // detail
-
-/**
- * @brief A helper class to convert to/from URI
- */
-class Uri
-{
-public:
- template<class Iterator1, class Iterator2>
- inline static void
- fromEscaped (Iterator1 begin, Iterator1 end, Iterator2 inserter)
- {
- Iterator1 i = begin;
- while (i != end)
- {
- if (*i == '%')
- {
- try
- {
- ++i;
- Iterator1 j = i;
- advance (i, 2);
-
- std::copy (detail::string_to_binary (j), detail::string_to_binary (i), inserter);
- }
- catch (ndn::error::StringTransform &e)
- {
- BOOST_THROW_EXCEPTION (error::Uri ()
- << error::pos (std::distance (i, begin)));
- }
- }
- else if (!detail::ESCAPE_CHARACTER[static_cast<unsigned char> (*i)])
- {
- *inserter = *i;
- ++inserter; ++i;
- }
- else
- {
- BOOST_THROW_EXCEPTION (error::Uri ()
- << error::pos (std::distance (i, begin)));
- }
- }
- }
-
- template<class Iterator1, class Iterator2>
- inline static void
- toEscaped (Iterator1 begin, Iterator1 end, Iterator2 inserter)
- {
- const char lookup_table [16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-
- for (Iterator1 i = begin; i != end; i++)
- {
- if (detail::ESCAPE_CHARACTER[static_cast<unsigned char> (*i)])
- {
- *inserter = '%'; ++inserter;
- *inserter = lookup_table [(*i >> 4) & 0x0F]; ++inserter;
- *inserter = lookup_table [(*i & 0x0F)]; ++inserter;
- }
- else
- {
- *inserter = *i; ++inserter;
- }
- }
- }
-};
-
-NDN_NAMESPACE_END
-
-#endif // NDN_DETAIL_URI_H
diff --git a/ndn.cxx/exclude.cc b/ndn.cxx/exclude.cc
deleted file mode 100644
index f8137eb..0000000
--- a/ndn.cxx/exclude.cc
+++ /dev/null
@@ -1,171 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "exclude.h"
-
-#include "detail/error.h"
-
-NDN_NAMESPACE_BEGIN
-
-Exclude::Exclude ()
-{
-}
-
-// example: ANY /b /d ANY /f
-//
-// ordered in map as:
-//
-// /f (false); /d (true); /b (false); / (true)
-//
-// lower_bound (/) -> / (true) <-- excluded (equal)
-// lower_bound (/a) -> / (true) <-- excluded (any)
-// lower_bound (/b) -> /b (false) <--- excluded (equal)
-// lower_bound (/c) -> /b (false) <--- not excluded (not equal and no ANY)
-// lower_bound (/d) -> /d (true) <- excluded
-// lower_bound (/e) -> /d (true) <- excluded
-bool
-Exclude::isExcluded (const name::Component &comp) const
-{
- const_iterator lowerBound = m_exclude.lower_bound (comp);
- if (lowerBound == end ())
- return false;
-
- if (lowerBound->second)
- return true;
- else
- return lowerBound->first == comp;
-
- return false;
-}
-
-Exclude &
-Exclude::excludeOne (const name::Component &comp)
-{
- if (!isExcluded (comp))
- {
- m_exclude.insert (std::make_pair (comp, false));
- }
- return *this;
-}
-
-
-// example: ANY /b0 /d0 ANY /f0
-//
-// ordered in map as:
-//
-// /f0 (false); /d0 (true); /b0 (false); / (true)
-//
-// lower_bound (/) -> / (true) <-- excluded (equal)
-// lower_bound (/a0) -> / (true) <-- excluded (any)
-// lower_bound (/b0) -> /b0 (false) <--- excluded (equal)
-// lower_bound (/c0) -> /b0 (false) <--- not excluded (not equal and no ANY)
-// lower_bound (/d0) -> /d0 (true) <- excluded
-// lower_bound (/e0) -> /d0 (true) <- excluded
-
-
-// examples with desired outcomes
-// excludeRange (/, /f0) -> ANY /f0
-// /f0 (false); / (true)
-// excludeRange (/, /f1) -> ANY /f1
-// /f1 (false); / (true)
-// excludeRange (/a0, /e0) -> ANY /f0
-// /f0 (false); / (true)
-// excludeRange (/a0, /e0) -> ANY /f0
-// /f0 (false); / (true)
-
-// excludeRange (/b1, /c0) -> ANY /b0 /b1 ANY /c0 /d0 ANY /f0
-// /f0 (false); /d0 (true); /c0 (false); /b1 (true); /b0 (false); / (true)
-
-Exclude &
-Exclude::excludeRange (const name::Component &from, const name::Component &to)
-{
- if (from >= to)
- {
- BOOST_THROW_EXCEPTION (error::Exclude ()
- << error::msg ("Invalid exclude range (for single name exclude use Exclude::excludeOne)")
- << error::msg (from.toUri ())
- << error::msg (to.toUri ()));
- }
-
- iterator newFrom = m_exclude.lower_bound (from);
- if (newFrom == end () || !newFrom->second /*without ANY*/)
- {
- std::pair<iterator, bool> fromResult = m_exclude.insert (std::make_pair (from, true));
- newFrom = fromResult.first;
- if (!fromResult.second)
- {
- // this means that the lower bound is equal to the item itself. So, just update ANY flag
- newFrom->second = true;
- }
- }
- // else
- // nothing special if start of the range already exists with ANY flag set
-
- iterator newTo = m_exclude.lower_bound (to); // !newTo cannot be end ()
- if (newTo == newFrom || !newTo->second)
- {
- std::pair<iterator, bool> toResult = m_exclude.insert (std::make_pair (to, false));
- newTo = toResult.first;
- ++ newTo;
- }
- else
- {
- // nothing to do really
- }
-
- m_exclude.erase (newTo, newFrom); // remove any intermediate node, since all of the are excluded
-
- return *this;
-}
-
-Exclude &
-Exclude::excludeAfter (const name::Component &from)
-{
- iterator newFrom = m_exclude.lower_bound (from);
- if (newFrom == end () || !newFrom->second /*without ANY*/)
- {
- std::pair<iterator, bool> fromResult = m_exclude.insert (std::make_pair (from, true));
- newFrom = fromResult.first;
- if (!fromResult.second)
- {
- // this means that the lower bound is equal to the item itself. So, just update ANY flag
- newFrom->second = true;
- }
- }
- // else
- // nothing special if start of the range already exists with ANY flag set
-
- if (newFrom != m_exclude.begin ())
- {
- m_exclude.erase (m_exclude.begin (), newFrom); // remove any intermediate node, since all of the are excluded
- }
-
- return *this;
-}
-
-void
-Exclude::appendExclude (const name::Component &name, bool any)
-{
- m_exclude.insert (std::make_pair (name, any));
-}
-
-std::ostream&
-operator << (std::ostream &os, const Exclude &exclude)
-{
- for (Exclude::const_reverse_iterator i = exclude.rbegin (); i != exclude.rend (); i++)
- {
- os << i->first.toUri () << " ";
- if (i->second)
- os << "----> ";
- }
- return os;
-}
-
-NDN_NAMESPACE_END
diff --git a/ndn.cxx/exclude.h b/ndn.cxx/exclude.h
deleted file mode 100644
index fcdcbb3..0000000
--- a/ndn.cxx/exclude.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_EXCLUDE_H
-#define NDN_EXCLUDE_H
-
-#include <ns3/simple-ref-count.h>
-
-#include "name-component.h"
-#include <map>
-
-NDN_NAMESPACE_BEGIN
-
-/**
- * @ingroup ndn-cxx
- * @brief Class to represent Exclude component in NDN interests
- */
-class Exclude : public SimpleRefCount<Exclude>
-{
-public:
- typedef std::map< name::Component, bool /*any*/, std::greater<name::Component> > exclude_type;
-
- typedef exclude_type::iterator iterator;
- typedef exclude_type::const_iterator const_iterator;
- typedef exclude_type::reverse_iterator reverse_iterator;
- typedef exclude_type::const_reverse_iterator const_reverse_iterator;
-
- /**
- * @brief Default constructor an empty exclude
- */
- Exclude ();
-
- // no need for explicit copy constructor
-
- /**
- * @brief Check if name component is excluded
- * @param comp Name component to check against exclude filter
- */
- bool
- isExcluded (const name::Component &comp) const;
-
- /**
- * @brief Exclude specific name component
- * @param comp component to exclude
- * @returns *this to allow chaining
- */
- Exclude &
- excludeOne (const name::Component &comp);
-
- /**
- * @brief Exclude components from range [from, to]
- * @param from first element of the range
- * @param to last element of the range
- * @returns *this to allow chaining
- */
- Exclude &
- excludeRange (const name::Component &from, const name::Component &to);
-
- /**
- * @brief Exclude all components from range [/, to]
- * @param to last element of the range
- * @returns *this to allow chaining
- */
- inline Exclude &
- excludeBefore (const name::Component &to);
-
- /**
- * @brief Exclude all components from range [from, +Inf]
- * @param to last element of the range
- * @returns *this to allow chaining
- */
- Exclude &
- excludeAfter (const name::Component &from);
-
- /**
- * @brief Method to directly append exclude element
- * @param name excluded name component
- * @param any flag indicating if there is a postfix ANY component after the name
- *
- * This method is used during conversion from wire format of exclude filter
- *
- * If there is an error with ranges (e.g., order of components is wrong) an exception is thrown
- */
- void
- appendExclude (const name::Component &name, bool any);
-
- /**
- * @brief Get number of exclude terms
- */
- inline size_t
- size () const;
-
- /**
- * @brief Get begin iterator of the exclude terms
- */
- inline const_iterator
- begin () const;
-
- /**
- * @brief Get end iterator of the exclude terms
- */
- inline const_iterator
- end () const;
-
- /**
- * @brief Get begin iterator of the exclude terms
- */
- inline const_reverse_iterator
- rbegin () const;
-
- /**
- * @brief Get end iterator of the exclude terms
- */
- inline const_reverse_iterator
- rend () const;
-
-private:
- Exclude &
- excludeRange (iterator fromLowerBound, iterator toLowerBound);
-
-private:
- exclude_type m_exclude;
-};
-
-std::ostream&
-operator << (std::ostream &os, const Exclude &name);
-
-inline Exclude &
-Exclude::excludeBefore (const name::Component &to)
-{
- return excludeRange (name::Component (), to);
-}
-
-inline size_t
-Exclude::size () const
-{
- return m_exclude.size ();
-}
-
-inline Exclude::const_iterator
-Exclude::begin () const
-{
- return m_exclude.begin ();
-}
-
-inline Exclude::const_iterator
-Exclude::end () const
-{
- return m_exclude.end ();
-}
-
-inline Exclude::const_reverse_iterator
-Exclude::rbegin () const
-{
- return m_exclude.rbegin ();
-}
-
-inline Exclude::const_reverse_iterator
-Exclude::rend () const
-{
- return m_exclude.rend ();
-}
-
-NDN_NAMESPACE_END
-
-#endif // NDN_EXCLUDE_H
diff --git a/ndn.cxx/name-component.cc b/ndn.cxx/name-component.cc
deleted file mode 100644
index d889a76..0000000
--- a/ndn.cxx/name-component.cc
+++ /dev/null
@@ -1,224 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#endif
-
-#include "name-component.h"
-
-#include "detail/error.h"
-#include "detail/uri.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace name {
-
-Component::Component ()
-{
-}
-
-Component::Component (const std::string &uri)
-{
- copy (uri.begin (), uri.end (), std::back_inserter (*this));
-}
-
-Component::Component (std::string::const_iterator begin, std::string::const_iterator end)
-{
- copy (begin, end, std::back_inserter (*this));
-}
-
-Component::Component (const void *buf, size_t length)
-{
- copy (static_cast<const char*> (buf),
- static_cast<const char*> (buf)+length,
- std::back_inserter (*this));
-}
-
-Component &
-Component::fromUri (const std::string &uri)
-{
- try
- {
- Uri::fromEscaped (uri.begin (), uri.end (), std::back_inserter (*this));
- }
- catch (error::Uri &err)
- {
- // re-throwing different exception
- BOOST_THROW_EXCEPTION (error::name::Component ()
- << error::msg (uri)
- << error::pos (error::get_pos (err)));
- }
-
- return *this;
-}
-
-Component &
-Component::fromUri (std::string::const_iterator begin, std::string::const_iterator end)
-{
- try
- {
- Uri::fromEscaped (begin, end, std::back_inserter (*this));
- }
- catch (error::Uri &err)
- {
- // re-throwing different exception
- BOOST_THROW_EXCEPTION (error::name::Component ()
- << error::msg (std::string (begin, end))
- << error::pos (error::get_pos (err)));
- }
- return *this;
-}
-
-int
-Component::compare (const Component &other) const
-{
- if (size () < other.size ())
- return -1;
-
- if (size () > other.size ())
- return +1;
-
- // now we know that sizes are equal
-
- std::pair<const_iterator, const_iterator> diff = mismatch (begin (), end (), other.begin ());
- if (diff.first == end ()) // components are actually equal
- return 0;
-
- return (std::lexicographical_compare (diff.first, end (), diff.second, other.end ())) ? -1 : +1;
-}
-
-Component &
-Component::fromNumber (uint64_t number)
-{
- while (number > 0)
- {
- this->push_back (static_cast<unsigned char> (number & 0xFF));
- number >>= 8;
- }
- std::reverse (this->begin (), this->end ());
- return *this;
-}
-
-Component &
-Component::fromNumberWithMarker (uint64_t number, unsigned char marker)
-{
- this->push_back (marker);
-
- while (number > 0)
- {
- this->push_back (static_cast<unsigned char> (number & 0xFF));
- number >>= 8;
- }
-
- std::reverse (this->begin () + 1, this->end ());
- return *this;
-}
-
-std::string
-Component::toBlob () const
-{
- return std::string (begin (), end ());
-}
-
-void
-Component::toBlob (std::ostream &os) const
-{
- os.write (buf (), size ());
-}
-
-std::string
-Component::toUri () const
-{
- std::ostringstream os;
- toUri (os);
- return os.str ();
-}
-
-void
-Component::toUri (std::ostream &os) const
-{
- const uint8_t* valuePtr = reinterpret_cast<const uint8_t*>(buf());
- size_t valueSize = size();
-
- bool gotNonDot = false;
- for (unsigned i = 0; i < valueSize; ++i) {
- if (valuePtr[i] != 0x2e) {
- gotNonDot = true;
- break;
- }
- }
- if (!gotNonDot) {
- // Special case for component of zero or more periods. Add 3 periods.
- os << "...";
- for (size_t i = 0; i < valueSize; ++i)
- os << '.';
- }
- else {
- // In case we need to escape, set to upper case hex and save the previous flags.
- std::ios::fmtflags saveFlags = os.flags(std::ios::hex | std::ios::uppercase);
-
- for (size_t i = 0; i < valueSize; ++i) {
- uint8_t x = valuePtr[i];
- // Check for 0-9, A-Z, a-z, (+), (-), (.), (_)
- if ((x >= 0x30 && x <= 0x39) || (x >= 0x41 && x <= 0x5a) ||
- (x >= 0x61 && x <= 0x7a) || x == 0x2b || x == 0x2d ||
- x == 0x2e || x == 0x5f)
- os << x;
- else {
- os << '%';
- if (x < 16)
- os << '0';
- os << static_cast<unsigned int>(x);
- }
- }
-
- // Restore.
- os.flags(saveFlags);
- }
-}
-
-uint64_t
-Component::toNumber () const
-{
- uint64_t ret = 0;
- for (const_iterator i = begin (); i != end (); i++)
- {
- ret <<= 8;
- ret |= static_cast<unsigned char> (*i);
- }
- return ret;
-}
-
-uint64_t
-Component::toNumberWithMarker (unsigned char marker) const
-{
- if (empty () ||
- static_cast<unsigned char> (*(begin ())) != marker)
- {
- BOOST_THROW_EXCEPTION (error::name::Component ()
- << error::msg ("Name component does not have required marker [" + toUri () + "]"));
- }
-
- uint64_t ret = 0;
- for (const_iterator i = begin () + 1; i != end (); i++)
- {
- ret <<= 8;
- ret |= static_cast<unsigned char> (*i);
- }
- return ret;
-}
-
-} // name
-
-NDN_NAMESPACE_END
diff --git a/ndn.cxx/name-component.h b/ndn.cxx/name-component.h
deleted file mode 100644
index 0de0442..0000000
--- a/ndn.cxx/name-component.h
+++ /dev/null
@@ -1,301 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_NAME_COMPONENT_H
-#define NDN_NAME_COMPONENT_H
-
-#include "blob.h"
-
-NDN_NAMESPACE_BEGIN
-
-namespace name {
-
-/**
- * @ingroup ndn-cxx
- * @brief Class to representing binary blob of NDN name component
- *
- * This class is based on Blob (std::vector<char>) and just provides several helpers
- * to work with name components, as well as operator to apply canonical
- * ordering on name components
- */
-class Component : public Blob
-{
-public:
- /**
- * @brief Default constructor an empty exclude
- */
- Component ();
-
- /**
- * @brief Create component from URI encoded string
- * @param uri URI encoded name component (convert escaped with % characters)
- */
- Component (const std::string &uri);
-
- /**
- * @brief Create component from URI encoded string, with string specified by a pair of iterators
- * @param begin begin iterator pointing to the URI encoded name
- * @param end end iterator
- */
- Component (std::string::const_iterator begin, std::string::const_iterator end);
-
- /**
- * @brief Create component using a binary blob
- * @param buf pointer to first byte of binary blob to store as a name component
- * @param length length of the binary blob
- */
- Component (const void *buf, size_t length);
-
- /**
- * @brief Apply canonical ordering on component comparison
- * @return 0 They compare equal
- * <0 If *this comes before other in the canonical ordering
- * >0 If *this comes after in the canonical ordering
- *
- * @see http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html
- */
- int
- compare (const Component &other) const;
-
- /**
- * @brief Apply canonical ordering on component comparison (less or equal)
- *
- * @see http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html
- */
- inline bool
- operator <= (const Component &other) const;
-
- /**
- * @brief Apply canonical ordering on component comparison (less)
- *
- * @see http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html
- */
- inline bool
- operator < (const Component &other) const;
-
- /**
- * @brief Apply canonical ordering on component comparison (greater or equal)
- *
- * @see http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html
- */
- inline bool
- operator >= (const Component &other) const;
-
- /**
- * @brief Apply canonical ordering on component comparison (greater)
- *
- * @see http://www.ccnx.org/releases/latest/doc/technical/CanonicalOrder.html
- */
- inline bool
- operator > (const Component &other) const;
-
- ////////////////////////////////////
- // Component construction helpers //
- ////////////////////////////////////
-
- /**
- * @brief Create component from URI encoded string
- * @param uri URI encoded name component (convert escaped with % characters)
- * @return *this
- */
- Component &
- fromUri (const std::string &uri);
-
- /**
- * @brief Create component from URI encoded string, with string specified by a pair of iterators
- * @param begin begin iterator pointing to the URI encoded name
- * @param end end iterator
- * @return *this
- */
- Component &
- fromUri (std::string::const_iterator begin, std::string::const_iterator end);
-
- /**
- * @brief Create network-ordered numeric component
- *
- * @param number number to be encoded and added as a component
- * @return *this
- *
- * Number is encoded and added in network order. Tail zero-bytes are not included.
- * For example, if the number is 1, then 1-byte binary blob will be added 0x01.
- * If the number is 256, then 2 binary blob will be added: 0x01 0x01
- *
- * If the number is zero, an empty component will be created
- */
- Component &
- fromNumber (uint64_t number);
-
- /**
- * @brief Create network-ordered numeric component to the name with marker
- *
- * @param number number to be encoded and added as a component
- * @param marker byte marker, specified by the desired naming convention
- *
- * Currently defined naming conventions of the marker:
- * - 0x00 sequence number
- * - 0xC1 control number
- * - 0xFB block id
- * - 0xFD version number
- *
- * This version is almost exactly as appendNumber, with exception that it adds initial marker.
- * The number is formatted in the exactly the same way.
- *
- * @see fromNumber
- */
- Component &
- fromNumberWithMarker (uint64_t number, unsigned char marker);
-
- //////////////////////////////////////////////////////////////////////////////////
- // helpers
- //////////////////////////////////////////////////////////////////////////////////
-
- /**
- * @brief Convert binary blob name component to std::string (no conversion is made)
- * @param comp name component to be converted
- * @see asUriString
- */
- std::string
- toBlob () const;
-
- /**
- * @brief Write blob of the name component to the specified output stream
- * @param os output stream
- */
- void
- toBlob (std::ostream &os) const;
-
- /**
- * @brief Convert binary blob name component to std::string, escaping all non-printable characters in URI format
- * @param comp name component to be converted
- * @see asString
- */
- std::string
- toUri () const;
-
- /**
- * @brief Write name as URI to the specified output stream
- * @param os output stream
- */
- void
- toUri (std::ostream &os) const;
-
- /**
- * @brief Convert binary blob name component (network-ordered number) to number
- * @param comp name component to be converted
- */
- uint64_t
- toNumber () const;
-
- /**
- * @brief Convert binary blob name component (network-ordered number) to number, using appropriate marker from the naming convention
- * @param comp name component to be converted
- * @param marker required marker from the naming convention
- *
- * If the required marker does not exist, an exception will be thrown
- */
- uint64_t
- toNumberWithMarker (unsigned char marker) const;
-
- /**
- * @brief Convert binary blob name component, assuming sequence number naming convention (marker = 0x00)
- * @param comp name component to be converted
- * @see asNumberWithMarker
- */
- inline uint64_t
- toSeqNum () const;
-
- /**
- * @brief Convert binary blob name component, assuming control number naming convention (marker = 0xC1)
- * @param comp name component to be converted
- * @see asNumberWithMarker
- */
- inline uint64_t
- toControlNum () const;
-
- /**
- * @brief Convert binary blob name component, assuming block ID naming convention (marker = 0xFB)
- * @param comp name component to be converted
- * @see asNumberWithMarker
- */
- inline uint64_t
- toBlkId () const;
-
- /**
- * @brief Convert binary blob name component, assuming time-stamping version naming convention (marker = 0xFD)
- * @param comp name component to be converted
- * @see asNumberWithMarker
- */
- inline uint64_t
- toVersion () const;
-};
-
-bool
-Component::operator <= (const Component &other) const
-{
- return (compare (other) <= 0);
-}
-
-bool
-Component::operator < (const Component &other) const
-{
- return (compare (other) < 0);
-}
-
-bool
-Component::operator >= (const Component &other) const
-{
- return (compare (other) >= 0);
-}
-
-bool
-Component::operator > (const Component &other) const
-{
- return (compare (other) > 0);
-}
-
-inline uint64_t
-Component::toSeqNum () const
-{
- return toNumberWithMarker (0x00);
-}
-
-inline uint64_t
-Component::toControlNum () const
-{
- return toNumberWithMarker (0xC1);
-}
-
-inline uint64_t
-Component::toBlkId () const
-{
- return toNumberWithMarker (0xFB);
-}
-
-inline uint64_t
-Component::toVersion () const
-{
- return toNumberWithMarker (0xFD);
-}
-
-/**
- * @brief Stream output operator (output in escaped URI format)
- */
-inline std::ostream&
-operator <<(std::ostream &os, const Component &name)
-{
- name.toUri (os);
- return os;
-}
-
-} // name
-
-NDN_NAMESPACE_END
-
-#endif // NDN_NAME_COMPONENT_H
diff --git a/ndn.cxx/name.cc b/ndn.cxx/name.cc
deleted file mode 100644
index c0a1a57..0000000
--- a/ndn.cxx/name.cc
+++ /dev/null
@@ -1,273 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- * Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Zhenkai Zhu <zhenkai@cs.ucla.edu>
- */
-
-#include "name.h"
-
-#include "detail/error.h"
-#include <boost/algorithm/string.hpp>
-
-#include <ctype.h>
-
-using namespace std;
-
-NDN_NAMESPACE_BEGIN
-
-ATTRIBUTE_HELPER_CPP (Name);
-
-///////////////////////////////////////////////////////////////////////////////
-// CONSTRUCTORS //
-///////////////////////////////////////////////////////////////////////////////
-
-Name::Name ()
-{
-}
-
-Name::Name (const string &uri)
-{
- string::const_iterator i = uri.begin ();
- string::const_iterator end = uri.end ();
-
- string::const_iterator firstSlash = std::find (i, end, '/');
- if (firstSlash == end)
- {
- BOOST_THROW_EXCEPTION (error::Name ()
- << error::msg ("Name should include at least one slash (did you forget to specify initial /?)"));
- }
-
- if (firstSlash != i)
- {
- string schema (i, firstSlash);
- if (*schema.rbegin () != ':')
- {
- BOOST_THROW_EXCEPTION (error::Name ()
- << error::msg ("First component of the name does not start with a slash (did you forget to specify initial /?)"));
- }
-
- i = firstSlash;
-
- if (!boost::iequals (schema, "ccnx:") &&
- !boost::iequals (schema, "ndn:"))
- {
- BOOST_THROW_EXCEPTION (error::Name ()
- << error::msg ("URI schema is not supported (only ccnx: or ndn: is allowed)")
- << error::msg (schema));
- }
- }
-
- string::const_iterator secondSlash = i;
- secondSlash ++;
- if (secondSlash != end && *secondSlash == '/')
- {
- // The authority component (the part after the initial "//" in the familiar http and ftp URI schemes) is present,
- // but it is not relevant to NDN name.
- // skipping it
- secondSlash ++;
- i = std::find (secondSlash, end, '/');
- }
-
- if (i == end)
- {
- BOOST_THROW_EXCEPTION (error::Name ()
- << error::msg ("Invalid URI")
- << error::msg (uri));
- }
-
- while (i != end)
- {
- // skip any extra slashes
- while (i != end && *i == '/')
- {
- i ++;
- }
- if (i == end)
- break;
-
- string::const_iterator endOfComponent = std::find (i, end, '/');
- name::Component comp;
- appendBySwap (comp.fromUri (i, endOfComponent));
-
- i = endOfComponent;
- }
-}
-
-Name::Name (const Name &other)
-{
- m_comps = other.m_comps;
-}
-
-Name &
-Name::operator= (const Name &other)
-{
- m_comps = other.m_comps;
- return *this;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// SETTERS //
-///////////////////////////////////////////////////////////////////////////////
-
-Name &
-Name::appendVersion (uint64_t version/* = Name::nversion*/)
-{
- if (version != Name::nversion)
- return appendNumberWithMarker (version, 0xFD);
- else
- {
- TimeInterval now = time::NowUnixTimestamp ();
-#ifdef NDNSIM_MODE
- int64_t seconds = now.GetSeconds ();
- int64_t microseconds = now.GetMicroSeconds () - seconds * 1000000;
-
- version = (seconds << 12) | (0xFFF & (microseconds / 244 /*( 1000,000 microseconds / 4096.0 resolution = last 12 bits)*/));
-#else
- version = (now.total_seconds () << 12) | (0xFFF & (now.fractional_seconds () / 244 /*( 1000,000 microseconds / 4096.0 resolution = last 12 bits)*/));
-#endif
- return appendNumberWithMarker (version, 0xFD);
- }
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// GETTERS //
-///////////////////////////////////////////////////////////////////////////////
-
-const name::Component &
-Name::get (int index) const
-{
- if (index < 0)
- {
- index = size () - (-index);
- }
-
- if (static_cast<unsigned int> (index) >= size ())
- {
- BOOST_THROW_EXCEPTION (error::Name ()
- << error::msg ("Index out of range")
- << error::pos (index));
- }
- return m_comps [index];
-}
-
-name::Component &
-Name::get (int index)
-{
- if (index < 0)
- {
- index = size () - (-index);
- }
-
- if (static_cast<unsigned int> (index) >= size())
- {
- BOOST_THROW_EXCEPTION (error::Name ()
- << error::msg ("Index out of range")
- << error::pos (index));
- }
- return m_comps [index];
-}
-
-
-/////
-///// Static helpers to convert name component to appropriate value
-/////
-
-
-Name
-Name::getSubName (size_t pos/* = 0*/, size_t len/* = Name::npos*/) const
-{
- Name retval;
-
- if (len == npos)
- {
- len = size () - pos;
- }
-
- if (pos + len > size ())
- {
- BOOST_THROW_EXCEPTION (error::Name ()
- << error::msg ("getSubName parameter out of range")
- << error::pos (pos)
- << error::pos (len));
- }
-
- for (size_t i = pos; i < pos + len; i++)
- {
- retval.append (get (i));
- }
-
- return retval;
-}
-
-Name
-Name::operator+ (const Name &name) const
-{
- Name newName;
- newName
- .append (*this)
- .append (name);
-
- return newName;
-}
-
-std::string
-Name::toUri () const
-{
- ostringstream os;
- toUri (os);
- return os.str ();
-}
-
-void
-Name::toUri (std::ostream &os) const
-{
- for (Name::const_iterator comp = begin (); comp != end (); comp++)
- {
- os << "/";
- comp->toUri (os);
- }
- if (size () == 0)
- os << "/";
-}
-
-// ostream &
-// operator << (ostream &os, const Name &name)
-// {
-// for (Name::const_iterator comp = name.begin (); comp != name.end (); comp++)
-// {
-// os << "/" << *comp;
-// }
-// if (name.size () == 0)
-// os << "/";
-// return os;
-// }
-
-int
-Name::compare (const Name &name) const
-{
- Name::const_iterator i = this->begin ();
- Name::const_iterator j = name.begin ();
-
- for (; i != this->end () && j != name.end (); i++, j++)
- {
- int res = i->compare (*j);
- if (res == 0)
- continue;
- else
- return res;
- }
-
- if (i == this->end () && j == name.end ())
- return 0; // prefixes are equal
-
- return (i == this->end ()) ? -1 : +1;
-}
-
-NDN_NAMESPACE_END
diff --git a/ndn.cxx/name.h b/ndn.cxx/name.h
deleted file mode 100644
index 731202d..0000000
--- a/ndn.cxx/name.h
+++ /dev/null
@@ -1,649 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- * Zhenkai Zhu
- *
- * BSD license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Zhenkai Zhu <zhenkai@cs.ucla.edu>
- */
-
-#ifndef NDN_NAME_H
-#define NDN_NAME_H
-
-#include "ns3/ndn-common.h"
-#include "ns3/simple-ref-count.h"
-#include "ns3/attribute.h"
-#include "ns3/attribute-helper.h"
-
-#include "name-component.h"
-
-NDN_NAMESPACE_BEGIN
-
-/**
- * @ingroup ndn-cxx
- * @brief Class for NDN Name
- */
-class Name : public SimpleRefCount<Name>
-{
-public:
- typedef std::vector<name::Component>::iterator iterator;
- typedef std::vector<name::Component>::const_iterator const_iterator;
- typedef std::vector<name::Component>::reverse_iterator reverse_iterator;
- typedef std::vector<name::Component>::const_reverse_iterator const_reverse_iterator;
- typedef std::vector<name::Component>::reference reference;
- typedef std::vector<name::Component>::const_reference const_reference;
-
- typedef name::Component partial_type;
-
- ///////////////////////////////////////////////////////////////////////////////
- // CONSTRUCTORS //
- ///////////////////////////////////////////////////////////////////////////////
-
- /**
- * @brief Default constructor to create an empty name (zero components, or "/")
- */
- Name ();
-
- /**
- * @brief Copy constructor
- *
- * @param other reference to a NDN name object
- */
- Name (const Name &other);
-
- /**
- * @brief Create a name from URL string
- *
- * @param url URI-represented name
- */
- Name (const std::string &url);
-
- /**
- * @brief Create a name from a container of elements [begin, end)
- *
- * @param begin begin iterator of the container
- * @param end end iterator of the container
- */
- template<class Iterator>
- Name (Iterator begin, Iterator end);
-
- /**
- * @brief Assignment operator
- */
- Name &
- operator= (const Name &other);
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // SETTERS //
- ///////////////////////////////////////////////////////////////////////////////
-
- /**
- * @brief Append a binary blob as a name component
- *
- * @param comp a binary blob
- * @returns reference to self (to allow chaining of append methods)
- */
- inline Name &
- append (const name::Component &comp);
-
- /**
- * @brief Append a binary blob as a name component
- * @param comp a binary blob
- *
- * This version is a little bit more efficient, since it swaps contents of comp and newly added component
- *
- * Attention!!! This method has an intended side effect: content of comp becomes empty
- */
- inline Name &
- appendBySwap (name::Component &comp);
-
- /**
- * @brief Append components a container of elements [begin, end)
- *
- * @param begin begin iterator of the container
- * @param end end iterator of the container
- * @returns reference to self (to allow chaining of append methods)
- */
- template<class Iterator>
- inline Name &
- append (Iterator begin, Iterator end);
-
- /**
- * @brief Append components from another ndn::Name object
- *
- * @param comp reference to Name object
- * @returns reference to self (to allow chaining of append methods)
- */
- inline Name &
- append (const Name &comp);
-
- /**
- * @brief Append a string as a name component
- *
- * @param compStr a string
- * @returns reference to self (to allow chaining of append methods)
- *
- * No conversions will be done to the string. The string is included in raw form,
- * without any leading '\0' symbols.
- */
- inline Name &
- append (const std::string &compStr);
-
- /**
- * @brief Append a binary blob as a name component
- *
- * @param buf pointer to the first byte of the binary blob
- * @param size length of the binary blob
- * @returns reference to self (to allow chaining of append methods)
- */
- inline Name &
- append (const void *buf, size_t size);
-
- /**
- * @brief Append network-ordered numeric component to the name
- *
- * @param number number to be encoded and added as a component
- *
- * Number is encoded and added in network order. Tail zero-bytes are not included.
- * For example, if the number is 1, then 1-byte binary blob will be added 0x01.
- * If the number is 256, then 2 binary blob will be added: 0x01 0x01
- *
- * If the number is zero, an empty component will be added
- */
- inline Name &
- appendNumber (uint64_t number);
-
- /**
- * @brief Append network-ordered numeric component to the name with marker
- *
- * @param number number to be encoded and added as a component
- * @param marker byte marker, specified by the desired naming convention
- *
- * Currently defined naming conventions of the marker:
- * - 0x00 sequence number
- * - 0xC1 control number
- * - 0xFB block id
- * - 0xFD version number
- *
- * This version is almost exactly as appendNumber, with exception that it adds initial marker.
- * The number is formatted in the exactly the same way.
- *
- * @see appendNumber
- */
- inline Name &
- appendNumberWithMarker (uint64_t number, unsigned char marker);
-
- /**
- * @brief Helper method to add sequence number to the name (marker = 0x00)
- * @param seqno sequence number
- * @see appendNumberWithMarker
- */
- inline Name &
- appendSeqNum (uint64_t seqno);
-
- /**
- * @brief Helper method to add control number to the name (marker = 0xC1)
- * @param control control number
- * @see appendNumberWithMarker
- */
- inline Name &
- appendControlNum (uint64_t control);
-
- /**
- * @brief Helper method to add block ID to the name (marker = 0xFB)
- * @param blkid block ID
- * @see appendNumberWithMarker
- */
- inline Name &
- appendBlkId (uint64_t blkid);
-
- /**
- * @brief Helper method to add version to the name (marker = 0xFD)
- * @param version fully formatted version in a desired format (e.g., timestamp).
- * If version is Name::nversion, then the version number is automatically
- * assigned based on UTC timestamp
- * @see appendNumberWithMarker
- */
- Name &
- appendVersion (uint64_t version = Name::nversion);
-
- ///////////////////////////////////////////////////////////////////////////////
- // GETTERS //
- ///////////////////////////////////////////////////////////////////////////////
-
- /**
- * @brief Get number of the name components
- * @return number of name components
- */
- inline size_t
- size () const;
-
- /**
- * @brief Get binary blob of name component
- * @param index index of the name component. If less than 0, then getting component from the back:
- * get(-1) getting the last component, get(-2) is getting second component from back, etc.
- * @returns const reference to binary blob of the requested name component
- *
- * If index is out of range, an exception will be thrown
- */
- const name::Component &
- get (int index) const;
-
- /**
- * @brief Get binary blob of name component
- * @param index index of the name component. If less than 0, then getting component from the back
- * @returns reference to binary blob of the requested name component
- *
- * If index is out of range, an exception will be thrown
- */
- name::Component &
- get (int index);
-
- /////
- ///// Iterator interface to name components
- /////
- inline Name::const_iterator
- begin () const; ///< @brief Begin iterator (const)
-
- inline Name::iterator
- begin (); ///< @brief Begin iterator
-
- inline Name::const_iterator
- end () const; ///< @brief End iterator (const)
-
- inline Name::iterator
- end (); ///< @brief End iterator
-
- inline Name::const_reverse_iterator
- rbegin () const; ///< @brief Reverse begin iterator (const)
-
- inline Name::reverse_iterator
- rbegin (); ///< @brief Reverse begin iterator
-
- inline Name::const_reverse_iterator
- rend () const; ///< @brief Reverse end iterator (const)
-
- inline Name::reverse_iterator
- rend (); ///< @brief Reverse end iterator
-
-
- /////
- ///// Static helpers to convert name component to appropriate value
- /////
-
- /**
- * @brief Get a new name, constructed as a subset of components
- * @param pos Position of the first component to be copied to the subname
- * @param len Number of components to be copied. Value Name::npos indicates that all components till the end of the name.
- */
- Name
- getSubName (size_t pos = 0, size_t len = npos) const;
-
- /**
- * @brief Get prefix of the name
- * @param len length of the prefix
- * @param skip number of components to skip from beginning of the name
- */
- inline Name
- getPrefix (size_t len, size_t skip = 0) const;
-
- /**
- * @brief Get postfix of the name
- * @param len length of the postfix
- * @param skip number of components to skip from end of the name
- */
- inline Name
- getPostfix (size_t len, size_t skip = 0) const;
-
- /**
- * @brief Get text representation of the name (URI)
- */
- std::string
- toUri () const;
-
- /**
- * @brief Write name as URI to the specified output stream
- * @param os output stream
- */
- void
- toUri (std::ostream &os) const;
-
- /////////////////////////////////////////////////
- // Helpers and compatibility wrappers
- /////////////////////////////////////////////////
-
- /**
- * @brief Compare two names, using canonical ordering for each component
- * @return 0 They compare equal
- * <0 If *this comes before other in the canonical ordering
- * >0 If *this comes after in the canonical ordering
- */
- int
- compare (const Name &name) const;
-
- /**
- * @brief Check if to Name objects are equal (have the same number of components with the same binary data)
- */
- inline bool
- operator == (const Name &name) const;
-
- /**
- * @brief Check if two Name objects are not equal
- */
- inline bool
- operator != (const Name &name) const;
-
- /**
- * @brief Less or equal comparison of two name objects
- */
- inline bool
- operator <= (const Name &name) const;
-
- /**
- * @brief Less comparison of two name objects
- */
- inline bool
- operator < (const Name &name) const;
-
- /**
- * @brief Great or equal comparison of two name objects
- */
- inline bool
- operator >= (const Name &name) const;
-
- /**
- * @brief Great comparison of two name objects
- */
- inline bool
- operator > (const Name &name) const;
-
- /**
- * @brief Operator [] to simplify access to name components
- * @see get
- */
- inline name::Component &
- operator [] (int index);
-
- /**
- * @brief Operator [] to simplify access to name components
- * @see get
- */
- inline const name::Component &
- operator [] (int index) const;
-
- /**
- * @brief Create a new Name object, by copying components from first and second name
- */
- Name
- operator + (const Name &name) const;
-
- /**
- * @brief A wrapper for append method
- */
- template<class T>
- inline void
- push_back (const T &comp);
-
-public:
- // Data Members (public):
- /// Value returned by various member functions when they fail.
- const static size_t npos = static_cast<size_t> (-1);
- const static uint64_t nversion = static_cast<uint64_t> (-1);
-
-private:
- std::vector<name::Component> m_comps;
-};
-
-inline std::ostream &
-operator << (std::ostream &os, const Name &name)
-{
- name.toUri (os);
- return os;
-}
-
-inline std::istream &
-operator >> (std::istream &is, Name &name)
-{
- std::string line;
- is >> line;
- name = Name (line);
-
- return is;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////
-// Definition of inline methods
-/////////////////////////////////////////////////////////////////////////////////////
-
-template<class Iterator>
-Name::Name (Iterator begin, Iterator end)
-{
- append (begin, end);
-}
-
-inline Name &
-Name::append (const name::Component &comp)
-{
- if (comp.size () != 0)
- m_comps.push_back (comp);
- return *this;
-}
-
-inline Name &
-Name::appendBySwap (name::Component &comp)
-{
- if (comp.size () != 0)
- {
- Name::iterator newComp = m_comps.insert (end (), name::Component ());
- newComp->swap (comp);
- }
- return *this;
-}
-
-template<class Iterator>
-inline Name &
-Name::append (Iterator begin, Iterator end)
-{
- for (Iterator i = begin; i != end; i++)
- {
- append (*i);
- }
- return *this;
-}
-
-Name &
-Name::append (const Name &comp)
-{
- if (this == &comp)
- {
- // have to double-copy if the object is self, otherwise results very frustrating (because we use vector...)
- return append (Name (comp.begin (), comp.end ()));
- }
- return append (comp.begin (), comp.end ());
-}
-
-Name &
-Name::append (const std::string &compStr)
-{
- name::Component comp (compStr);
- return appendBySwap (comp);
-}
-
-Name &
-Name::append (const void *buf, size_t size)
-{
- name::Component comp (buf, size);
- return appendBySwap (comp);
-}
-
-Name &
-Name::appendNumber (uint64_t number)
-{
- name::Component comp;
- return appendBySwap (comp.fromNumber (number));
-}
-
-Name &
-Name::appendNumberWithMarker (uint64_t number, unsigned char marker)
-{
- name::Component comp;
- return appendBySwap (comp.fromNumberWithMarker (number, marker));
-}
-
-inline Name &
-Name::appendSeqNum (uint64_t seqno)
-{
- return appendNumberWithMarker (seqno, 0x00);
-}
-
-inline Name &
-Name::appendControlNum (uint64_t control)
-{
- return appendNumberWithMarker (control, 0xC1);
-}
-
-inline Name &
-Name::appendBlkId (uint64_t blkid)
-{
- return appendNumberWithMarker (blkid, 0xFB);
-}
-
-inline size_t
-Name::size () const
-{
- return m_comps.size ();
-}
-
-/////
-///// Iterator interface to name components
-/////
-inline Name::const_iterator
-Name::begin () const
-{
- return m_comps.begin ();
-}
-
-inline Name::iterator
-Name::begin ()
-{
- return m_comps.begin ();
-}
-
-inline Name::const_iterator
-Name::end () const
-{
- return m_comps.end ();
-}
-
-inline Name::iterator
-Name::end ()
-{
- return m_comps.end ();
-}
-
-inline Name::const_reverse_iterator
-Name::rbegin () const
-{
- return m_comps.rbegin ();
-}
-
-inline Name::reverse_iterator
-Name::rbegin ()
-{
- return m_comps.rbegin ();
-}
-
-inline Name::const_reverse_iterator
-Name::rend () const
-{
- return m_comps.rend ();
-}
-
-
-inline Name::reverse_iterator
-Name::rend ()
-{
- return m_comps.rend ();
-}
-
-
-//// helpers
-
-
-inline Name
-Name::getPrefix (size_t len, size_t skip/* = 0*/) const
-{
- return getSubName (skip, len);
-}
-
-inline Name
-Name::getPostfix (size_t len, size_t skip/* = 0*/) const
-{
- return getSubName (size () - len - skip, len);
-}
-
-
-template<class T>
-inline void
-Name::push_back (const T &comp)
-{
- append (comp);
-}
-
-inline bool
-Name::operator ==(const Name &name) const
-{
- return (compare (name) == 0);
-}
-
-inline bool
-Name::operator !=(const Name &name) const
-{
- return (compare (name) != 0);
-}
-
-inline bool
-Name::operator <= (const Name &name) const
-{
- return (compare (name) <= 0);
-}
-
-inline bool
-Name::operator < (const Name &name) const
-{
- return (compare (name) < 0);
-}
-
-inline bool
-Name::operator >= (const Name &name) const
-{
- return (compare (name) >= 0);
-}
-
-inline bool
-Name::operator > (const Name &name) const
-{
- return (compare (name) > 0);
-}
-
-inline name::Component &
-Name::operator [] (int index)
-{
- return get (index);
-}
-
-inline const name::Component &
-Name::operator [] (int index) const
-{
- return get (index);
-}
-
-ATTRIBUTE_HELPER_HEADER (Name);
-
-NDN_NAMESPACE_END
-
-#endif
diff --git a/ndn.cxx/ndn-api-face.cc b/ndn.cxx/ndn-api-face.cc
deleted file mode 100644
index fd78763..0000000
--- a/ndn.cxx/ndn-api-face.cc
+++ /dev/null
@@ -1,242 +0,0 @@
-/* -*- 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-api-face.h"
-#include "detail/pending-interests-container.h"
-#include "detail/registered-prefix-container.h"
-
-#include <ns3/random-variable.h>
-
-#include <ns3/ndn-l3-protocol.h>
-#include <ns3/ndn-interest.h>
-#include <ns3/ndn-data.h>
-#include <ns3/ndn-face.h>
-#include <ns3/ndn-fib.h>
-
-#include <ns3/packet.h>
-#include <ns3/log.h>
-
-using namespace std;
-using namespace boost;
-using namespace ns3;
-
-NS_LOG_COMPONENT_DEFINE ("ndn.ApiFace");
-
-namespace ns3 {
-namespace ndn {
-
-using namespace detail;
-
-class ApiFacePriv
-{
-public:
- ApiFacePriv ()
- : m_rand (0, std::numeric_limits<uint32_t>::max ())
- {
- }
-
- ns3::UniformVariable m_rand; // nonce generator
-
- PendingInterestContainer m_pendingInterests;
- RegisteredPrefixContainer m_expectedInterests;
-};
-
-
-ApiFace::ApiFace (Ptr<Node> node)
- : Face (node)
- , m_this (new ApiFacePriv ())
-{
- NS_LOG_FUNCTION (this << boost::cref (*this));
-
- NS_ASSERT_MSG (GetNode ()->GetObject<L3Protocol> () != 0,
- "NDN stack should be installed on the node " << GetNode ());
-
- GetNode ()->GetObject<L3Protocol> ()->AddFace (this);
- this->SetUp (true);
- this->SetFlags (APPLICATION);
-}
-
-ApiFace::~ApiFace ()
-{
- NS_LOG_FUNCTION (this << boost::cref (*this));
-
- delete m_this;
-}
-
-void
-ApiFace::Shutdown ()
-{
- NS_LOG_FUNCTION (this << boost::cref (*this));
-
- if (!IsUp ())
- {
- return;
- }
-
- this->SetUp (false);
-
- m_this->m_pendingInterests.clear ();
- m_this->m_expectedInterests.clear ();
-
- GetNode ()->GetObject<L3Protocol> ()->RemoveFace (this);
-}
-
-void
-ApiFace::ExpressInterest (Ptr<Interest> interest,
- DataCallback onData,
- TimeoutCallback onTimeout/* = MakeNullCallback< void, Ptr<Interest> > ()*/)
-{
- NS_LOG_INFO (">> I " << interest->GetName ());
-
- if (interest->GetNonce () == 0)
- {
- interest->SetNonce (m_this->m_rand.GetValue ());
- }
-
- // Record the callback
- bool needToActuallyExpressInterest = false;
- PendingInterestContainer::iterator entry = m_this->m_pendingInterests.find_exact (interest->GetName ());
- if (entry == m_this->m_pendingInterests.end ())
- {
- pair<PendingInterestContainer::iterator, bool> status =
- m_this->m_pendingInterests.insert (interest->GetName (), Create <PendingInterestEntry> (interest));
-
- entry = status.first;
-
- needToActuallyExpressInterest = true;
- }
- entry->payload ()->AddCallbacks (onData, onTimeout);
-
- if (needToActuallyExpressInterest)
- {
- Simulator::ScheduleNow (&Face::ReceiveInterest, this, interest);
- }
-}
-
-void
-ApiFace::SetInterestFilter (Ptr<const Name> prefix, InterestCallback onInterest)
-{
- NS_LOG_DEBUG ("== setInterestFilter " << *prefix << " (" << GetNode ()->GetId () << ")");
-
- RegisteredPrefixContainer::iterator entry = m_this->m_expectedInterests.find_exact (*prefix);
- if (entry == m_this->m_expectedInterests.end ())
- {
- pair<RegisteredPrefixContainer::iterator, bool> status =
- m_this->m_expectedInterests.insert (*prefix, Create < RegisteredPrefixEntry > (prefix));
-
- entry = status.first;
- }
-
- entry->payload ()->AddCallback (onInterest);
-
- // creating actual face
- Ptr<ndn::Fib> fib = GetNode ()->GetObject<ndn::Fib> ();
- Ptr<ndn::fib::Entry> fibEntry = fib->Add (prefix, this, 0);
- fibEntry->UpdateStatus (this, ndn::fib::FaceMetric::NDN_FIB_GREEN);
-}
-
-void
-ApiFace::ClearInterestFilter (Ptr<const Name> prefix)
-{
- RegisteredPrefixContainer::iterator entry = m_this->m_expectedInterests.find_exact (*prefix);
- if (entry == m_this->m_expectedInterests.end ())
- return;
-
- entry->payload ()->ClearCallback ();
- m_this->m_expectedInterests.erase (entry);
-}
-
-void
-ApiFace::Put (Ptr<Data> data)
-{
- NS_LOG_INFO (">> D " << data->GetName ());
-
- Simulator::ScheduleNow (&Face::ReceiveData, this, data);
-}
-
-
-///////////////////////////////////////////////
-// private stuff
-
-
-bool
-ApiFace::SendInterest (Ptr<const Interest> interest)
-{
- NS_LOG_FUNCTION (this << interest);
-
- NS_LOG_DEBUG ("<< I " << interest->GetName ());
-
- if (!IsUp ())
- {
- return false;
- }
-
- // the app cannot set several filters for the same prefix
- RegisteredPrefixContainer::iterator entry = m_this->m_expectedInterests.longest_prefix_match (interest->GetName ());
- if (entry == m_this->m_expectedInterests.end ())
- {
- return false;
- }
-
- if (!entry->payload ()->m_callback.IsNull ())
- entry->payload ()->m_callback (entry->payload ()->GetPrefix (), interest);
- return true;
-}
-
-bool
-ApiFace::SendData (Ptr<const Data> data)
-{
- // data has been send out from NDN stack towards the application
- NS_LOG_DEBUG ("<< D " << data->GetName ());
- // NS_LOG_FUNCTION (this << data);
-
- if (!IsUp ())
- {
- return false;
- }
-
- PendingInterestContainer::iterator entry = m_this->m_pendingInterests.longest_prefix_match (data->GetName ());
- if (entry == m_this->m_pendingInterests.end ())
- {
- return false;
- }
-
- while (entry != m_this->m_pendingInterests.end ())
- {
- entry->payload ()->ProcessOnData (entry->payload ()->GetInterest (), data);
- m_this->m_pendingInterests.erase (entry);
-
- entry = m_this->m_pendingInterests.longest_prefix_match (data->GetName ());
- }
- m_this->m_pendingInterests.erase (entry);
-
- return true;
-}
-
-std::ostream&
-ApiFace::Print (std::ostream &os) const
-{
- os << "dev=ApiFace(" << GetId () << ")";
- return os;
-}
-
-
-}
-}
diff --git a/ndn.cxx/ndn-api-face.h b/ndn.cxx/ndn-api-face.h
deleted file mode 100644
index fda34d1..0000000
--- a/ndn.cxx/ndn-api-face.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Zhenkai Zhu <zhenkai@cs.ucla.edu>
- * Chaoyi Bian <bcy@pku.edu.cn>
- */
-
-#ifndef NDN_API_FACE_H
-#define NDN_API_FACE_H
-
-#include <ns3/ptr.h>
-#include <ns3/node.h>
-#include <ns3/callback.h>
-#include <ns3/ndn-face.h>
-#include <ns3/ndn-name.h>
-#include <ns3/ndn-interest.h>
-#include <ns3/ndn-data.h>
-
-namespace ns3 {
-namespace ndn {
-
-class ApiFacePriv;
-
-/**
- * @ingroup ndn
- * @defgroup ndn-cxx NDN.cxx API
- */
-
-/**
- * @ingroup ndn-face
- * @ingroup ndn-cxx
- * @brief An application NDN face, providing richer API interface, compared to ndn::AppFace
- *
- * @see ndn::AppFace
- */
-class ApiFace
- : public ns3::ndn::Face
-{
-public:
- typedef Callback<void, Ptr<const Name>, Ptr<const Interest> > InterestCallback;
- typedef Callback<void, Ptr<const Interest>, Ptr<const Data> > DataCallback;
- typedef Callback<void, Ptr<const Interest> > TimeoutCallback;
-
- /**
- * @brief initialize the handler; a lot of things needs to be done. 1) init
- * keystore 2) init keylocator 3) start a thread to hold a loop of ccn_run
- *
- */
- ApiFace (Ptr<Node> node);
- ~ApiFace ();
-
- /**
- * @brief Shutdown the API face
- */
- virtual void
- Shutdown ();
-
- /**
- * @brief Express Interest
- *
- * @param name the Interest name
- * @param onData the callback function to deal with the returned data
- * @param onTimeout the callback function to deal with timeouts
- */
- void
- ExpressInterest (Ptr<Interest> interest,
- DataCallback onData,
- TimeoutCallback onTimeout); // = MakeNullCallback< void, Ptr<Interest> > ()
-
- /**
- * @brief set Interest filter (specify what interest you want to receive)
- *
- * @param prefix the prefix of Interest
- * @param onInterest the callback function to deal with the returned data
- */
- void
- SetInterestFilter (Ptr<const Name> prefix, InterestCallback onInterest);
-
- /**
- * @brief clear Interest filter
- * @param prefix the prefix of Interest
- */
- void
- ClearInterestFilter (Ptr<const Name> prefix);
-
- /**
- * @brief Publish data
- * @param data Data packet to publish
- */
- void
- Put (Ptr<Data> data);
-
-public:
- virtual bool
- SendInterest (Ptr<const Interest> interest);
-
- virtual bool
- SendData (Ptr<const Data> data);
-
- virtual std::ostream&
- Print (std::ostream &os) const;
-
-private:
- ApiFace () : Face (0) {}
- ApiFace (const ApiFace &) : Face (0) {}
- ApiFace& operator= (const ApiFace &) { return *this; }
-
-private:
- ApiFacePriv *m_this;
-};
-
-} // ndn
-} // ns3
-
-#endif // NDN_API_HANDLER_H
diff --git a/plugins/README b/plugins/README
deleted file mode 100644
index b8eb740..0000000
--- a/plugins/README
+++ /dev/null
@@ -1,13 +0,0 @@
-This folder contains several extensions that can be used in simulation scenarios.
-
-tracers/
- an extensive set of tracers that can be used in NDN scenarios
- * Some tracers require patching of NDN module code (patch provided)
-
-topology/
- extension of topology reader
- * requires patching of topology module (patch provided)
-
-mobility/
- several custom mobility models and position allocator.
- * necessary for topology extensions
diff --git a/plugins/mobility/highway-position-allocator.cc b/plugins/mobility/highway-position-allocator.cc
deleted file mode 100644
index 03c9d27..0000000
--- a/plugins/mobility/highway-position-allocator.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * 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: Lucas Wang <lucas@cs.ucla.edu>
- */
-
-
-#include "highway-position-allocator.h"
-#include "ns3/random-variable.h"
-#include "ns3/log.h"
-#include "ns3/double.h"
-#include <math.h>
-
-NS_LOG_COMPONENT_DEFINE ("HighwayPositionAllocator");
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (HighwayPositionAllocator);
-
-TypeId HighwayPositionAllocator::GetTypeId (void){
- static TypeId tid = TypeId("ns3::HighwayPositionAllocator").
- SetParent<PositionAllocator> ().
- SetGroupName("Mobility").
- AddConstructor<HighwayPositionAllocator>().
- AddAttribute("Start", "the start position of the highway",
- VectorValue (Vector(0.0, 0.0, 0.0)),
- MakeVectorAccessor(&HighwayPositionAllocator::SetStartPosition,
- &HighwayPositionAllocator::GetStartPosition),
- MakeVectorChecker ()).
- AddAttribute("Direction", "the direction of the highway",
- DoubleValue (0.0),
- MakeDoubleAccessor(&HighwayPositionAllocator::SetDirection,
- &HighwayPositionAllocator::GetDirection),
- MakeDoubleChecker<double> ()).
- AddAttribute("Length", "the length of the highway",
- DoubleValue (0.0),
- MakeDoubleAccessor(&HighwayPositionAllocator::SetLength,
- &HighwayPositionAllocator::GetLength),
- MakeDoubleChecker<double> ());
-
- return tid;
-}
-
-HighwayPositionAllocator::HighwayPositionAllocator ()
- : m_previous_position (Vector (0.0, 0.0, 0.0))
-{
-}
-
-Vector HighwayPositionAllocator::GetNext (void) const{
- double random_gap = m_random_gap_var.GetValue (1.0, 10.0);
-
- double delta_x = random_gap * cos(m_direction);
- double delta_y = random_gap * sin(m_direction);
-
-
- Vector new_position(m_previous_position.x - delta_x, m_previous_position.y - delta_y, m_previous_position.z);
- m_previous_position.x = new_position.x;
- m_previous_position.y = new_position.y;
- m_previous_position.z = new_position.z;
-
- return new_position;
-}
-
-void HighwayPositionAllocator::SetStartPosition(Vector start){
- m_start = start;
- m_previous_position = m_start; // initialize the m_previous_position to be start of the highway
-}
-
-Vector HighwayPositionAllocator::GetStartPosition(void) const {
- return m_start;
-}
-
-void HighwayPositionAllocator::SetDirection(double direction){
- m_direction = direction;
-}
-
-double HighwayPositionAllocator::GetDirection(void) const {
- return m_direction;
-}
-
-void HighwayPositionAllocator::SetLength(double length){
- m_length = length;
-}
-
-double HighwayPositionAllocator::GetLength(void) const {
- return m_length;
-}
-
-
-int64_t
-HighwayPositionAllocator::AssignStreams (int64_t stream)
-{
- m_random_gap_var.SetStream (stream);
- return 1;
-}
-
-}
diff --git a/plugins/mobility/highway-position-allocator.h b/plugins/mobility/highway-position-allocator.h
deleted file mode 100644
index be0b219..0000000
--- a/plugins/mobility/highway-position-allocator.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * 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: Lucas Wang <lucas@cs.ucla.edu>
- */
-#ifndef HIGHWAY_POSITION_ALLOCATOR_H
-#define HIGHWAY_POSITION_ALLOCATOR_H
-
-#include "ns3/position-allocator.h"
-
-namespace ns3 {
-
-/**
- * This position allocator is used to generate positions for cars
- * on a highway.
- */
-
-class HighwayPositionAllocator : public PositionAllocator
-{
-public:
- static TypeId GetTypeId (void);
- HighwayPositionAllocator ();
- virtual Vector GetNext (void) const;
- void SetStartPosition(Vector start);
- Vector GetStartPosition(void) const;
- void SetDirection(double direction); // the angle in terms of radian degrees
- double GetDirection(void) const ;
- void SetLength(double length);
- double GetLength(void) const ;
-
- virtual int64_t AssignStreams (int64_t stream);
-
-private:
- mutable Vector m_previous_position; // previously generated vehicle position
- Vector m_start; // highway starting point
- double m_direction; //highway direction
- double m_length; // highway length
-
- mutable UniformRandomVariable m_random_gap_var;
-};
-}
-
-#endif
diff --git a/plugins/mobility/spring-mobility-helper.cc b/plugins/mobility/spring-mobility-helper.cc
deleted file mode 100644
index 5e4b4f6..0000000
--- a/plugins/mobility/spring-mobility-helper.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006, 2007 INRIA
- *
- * 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 "spring-mobility-helper.h"
-#include "spring-mobility-model.h"
-
-namespace ns3 {
-
-void
-SpringMobilityHelper::InstallSprings (Ptr<Node> node1, Ptr<Node> node2)
-{
- Ptr<SpringMobilityModel> model1, model2;
- model1 = node1->GetObject<SpringMobilityModel> ();
- model2 = node2->GetObject<SpringMobilityModel> ();
-
- NS_ASSERT (model1 != 0 && model2 != 0);
-
- model1->AddSpring (model2);
- model2->AddSpring (model1);
-}
-
-void
-SpringMobilityHelper::InstallSprings (TopologyReader::ConstLinksIterator first,
- TopologyReader::ConstLinksIterator end)
-{
- for (; first != end; first++)
- {
- InstallSprings (first->GetFromNode (),
- first->GetToNode ());
- }
-}
-
-} // namespace ns3
-
diff --git a/plugins/mobility/spring-mobility-helper.h b/plugins/mobility/spring-mobility-helper.h
deleted file mode 100644
index 7285d25..0000000
--- a/plugins/mobility/spring-mobility-helper.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006, 2007 INRIA
- *
- * 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 SPRING_MOBILITY_HELPER_H
-#define SPRING_MOBILITY_HELPER_H
-
-#include "ns3/topology-reader.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- *
- * \brief
- */
-class SpringMobilityHelper
-{
-public:
- static void
- InstallSprings (Ptr<Node> node1, Ptr<Node> node2);
-
- static void
- InstallSprings (TopologyReader::ConstLinksIterator first,
- TopologyReader::ConstLinksIterator end);
-};
-
-} // namespace ns3
-
-#endif // SPRING_MOBILITY_HELPER_H
diff --git a/plugins/mobility/spring-mobility-model.cc b/plugins/mobility/spring-mobility-model.cc
deleted file mode 100644
index 170b428..0000000
--- a/plugins/mobility/spring-mobility-model.cc
+++ /dev/null
@@ -1,214 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006, 2007 INRIA
- *
- * 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 "spring-mobility-model.h"
-#include "ns3/simulator.h"
-#include "ns3/double.h"
-#include "ns3/log.h"
-#include "ns3/node-list.h"
-#include "ns3/node.h"
-
-#include <boost/foreach.hpp>
-
-NS_LOG_COMPONENT_DEFINE ("SpringMobilityModel");
-
-namespace ns3 {
-
-NS_OBJECT_ENSURE_REGISTERED (SpringMobilityModel);
-
-double SpringMobilityModel::m_totalKineticEnergy = 0.0;
-bool SpringMobilityModel::m_stable = false;
-EventId SpringMobilityModel::m_updateEvent;
-double SpringMobilityModel::m_epsilon = 100.0;
-
-const double COLOUMB_K = 200;
-
-TypeId SpringMobilityModel::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::SpringMobilityModel")
- .SetParent<MobilityModel> ()
- .AddConstructor<SpringMobilityModel> ()
- // .AddAttribute ("Epsilon", "Bound for kinetic energy when system is considered stable",
- // DoubleValue (100.0),
- // MakeDoubleAccessor (&SpringMobilityModel::m_epsilon),
- // MakeDoubleChecker<double> ())
- .AddAttribute ("NodeMass", "Node mass",
- DoubleValue (10),
- MakeDoubleAccessor (&SpringMobilityModel::m_nodeMass),
- MakeDoubleChecker<double> ())
- .AddAttribute ("NodeCharge", "Node charge",
- DoubleValue (2),
- MakeDoubleAccessor (&SpringMobilityModel::m_nodeCharge),
- MakeDoubleChecker<double> ())
- .AddAttribute ("SpringNormalLength", "Normal length of spring length",
- DoubleValue (10),
- MakeDoubleAccessor (&SpringMobilityModel::m_springNormalLength),
- MakeDoubleChecker<double> ())
- .AddAttribute ("SpringConstant", "Spring constant",
- DoubleValue (0.2),
- MakeDoubleAccessor (&SpringMobilityModel::m_springConstant),
- MakeDoubleChecker<double> ())
- .AddAttribute ("DampingFactor", "Dumping factor",
- DoubleValue (0.8),
- MakeDoubleAccessor (&SpringMobilityModel::m_dampingFactor),
- MakeDoubleChecker<double> ())
- ;
-
- return tid;
-}
-
-SpringMobilityModel::SpringMobilityModel ()
- : m_position (0,0,0)
- , m_velocity (0,0,0)
-{
-}
-
-SpringMobilityModel::~SpringMobilityModel ()
-{
-}
-
-void
-SpringMobilityModel::AddSpring (Ptr<MobilityModel> node)
-{
- m_springs.push_back (node);
-}
-
-void
-SpringMobilityModel::DoStart ()
-{
- if (!m_updateEvent.IsRunning ())
- m_updateEvent = Simulator::Schedule (Seconds(0.05), SpringMobilityModel::UpdateAll);
-}
-
-void
-SpringMobilityModel::UpdateAll ()
-{
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- Ptr<SpringMobilityModel> model = (*node)->GetObject<SpringMobilityModel> ();
- if (model != 0)
- model->Update ();
- }
-
- if (m_totalKineticEnergy < m_epsilon)
- {
- m_stable = true;
- NS_LOG_INFO ("Stabilized with " << m_totalKineticEnergy);
- }
- else
- m_updateEvent = Simulator::Schedule (Seconds(0.05), SpringMobilityModel::UpdateAll);
-}
-
-void
-SpringMobilityModel::Update () const
-{
- NS_LOG_FUNCTION (this << m_stable << m_position << m_velocity);
- if (m_stable) return;
- Time now = Simulator::Now ();
-
- if (now <= m_lastTime)
- {
- m_lastTime = now;
- return;
- }
-
- double time_step_s = (now - m_lastTime).ToDouble (Time::S);
- m_lastTime = now;
-
- Vector force (0.0, 0.0, 0.0);
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- if ((*node)->GetId () == GetObject<Node> ()->GetId ()) continue;
- Ptr<SpringMobilityModel> model = (*node)->GetObject<SpringMobilityModel> ();
- if (model == 0) continue;
- if (model == this) continue;
-
- double distance = GetDistanceFrom (model);
- if (distance < 0.1) continue;
-
- Vector direction = (GetPosition () - model->GetPosition ()) / distance; // direction vector of size 1, force trying to take nodes apart
-
- force += direction * COLOUMB_K * m_nodeCharge * m_nodeCharge / distance / distance;
- }
-
- BOOST_FOREACH (Ptr<MobilityModel> model, m_springs)
- {
- double distance = GetDistanceFrom (model);
- Vector direction = (model->GetPosition () - GetPosition ()) / distance; // direction vector of size 1, force trying to take nodes closer, if they are more than distance apart
-
- force += direction * (- m_springNormalLength + distance) / m_springConstant;
- }
-
- // NS_LOG_DEBUG ("force: " << force);
-
- // subtract previous value of kinetic energy for the node
- double velocityValue = CalculateDistance (m_velocity, Vector(0,0,0));
- m_totalKineticEnergy -= m_nodeMass * velocityValue * velocityValue;
-
- // Correct velocity and position
- m_velocity = (m_velocity + force * time_step_s) * m_dampingFactor;
- m_position += m_velocity * time_step_s;
-
- // Add new value for the kinetic energy
- velocityValue = CalculateDistance (m_velocity, Vector(0,0,0));
- m_totalKineticEnergy += m_nodeMass * velocityValue * velocityValue;
-
- NotifyCourseChange ();
-}
-
-Vector
-SpringMobilityModel::DoGetPosition (void) const
-{
- // NS_LOG_FUNCTION (this << m_position);
- return m_position;
-}
-void
-SpringMobilityModel::DoSetPosition (const Vector &position)
-{
- // NS_LOG_FUNCTION (this << position);
- m_position = position;
-
- NotifyCourseChange ();
- m_stable = false;
-
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- Ptr<SpringMobilityModel> model = (*node)->GetObject<SpringMobilityModel> ();
- if (model != 0)
- model->m_lastTime = Simulator::Now ();
- }
-
- if (!m_updateEvent.IsRunning ())
- m_updateEvent = Simulator::Schedule (Seconds(0.05), SpringMobilityModel::UpdateAll);
-}
-Vector
-SpringMobilityModel::DoGetVelocity (void) const
-{
- return m_velocity;
-}
-
-} // namespace ns3
diff --git a/plugins/mobility/spring-mobility-model.h b/plugins/mobility/spring-mobility-model.h
deleted file mode 100644
index 700c994..0000000
--- a/plugins/mobility/spring-mobility-model.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006, 2007 INRIA
- *
- * 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:
- */
-#ifndef SPRING_MOBILITY_MODEL_H
-#define SPRING_MOBILITY_MODEL_H
-
-#include "ns3/mobility-model.h"
-#include "ns3/nstime.h"
-#include "ns3/event-id.h"
-
-namespace ns3 {
-
-/**
- * \ingroup mobility
- *
- * \brief
- */
-class SpringMobilityModel : public MobilityModel
-{
-public:
- static TypeId GetTypeId (void);
-
- /**
- * Create a position located at coordinates (0,0,0) with velocity (0,0,0)
- */
- SpringMobilityModel ();
- virtual ~SpringMobilityModel ();
-
- /**
- * \brief Attach node by a spring
- * \param node MobilityModel layer of the attaching node
- */
- void
- AddSpring (Ptr<MobilityModel> node);
-
-private:
- // from Object
- virtual void
- DoStart ();
-
- // from MobilityModel
- virtual Vector
- DoGetPosition (void) const;
-
- virtual void
- DoSetPosition (const Vector &position);
-
- virtual Vector
- DoGetVelocity (void) const;
-
- // Updating positions
- void
- Update (void) const;
-
- static void
- UpdateAll ();
-
-private:
- static double m_epsilon;
-
- double m_nodeMass;
- double m_nodeCharge;
- double m_springNormalLength;
- double m_springConstant;
- double m_dampingFactor;
-
- static double m_totalKineticEnergy;
- static bool m_stable;
- static EventId m_updateEvent;
-
- mutable Vector m_position;
- mutable Vector m_velocity;
- mutable Time m_lastTime;
-
- std::list<Ptr<MobilityModel> > m_springs;
-};
-
-} // namespace ns3
-
-#endif // SPRING_MOBILITY_MODEL_H
diff --git a/plugins/topology/patches/0001-topology-read-Several-extensions-of-TopologyReader.patch b/plugins/topology/patches/0001-topology-read-Several-extensions-of-TopologyReader.patch
deleted file mode 100644
index ffaefe7..0000000
--- a/plugins/topology/patches/0001-topology-read-Several-extensions-of-TopologyReader.patch
+++ /dev/null
@@ -1,146 +0,0 @@
-From 19ebf81e3d32dbdda4ef06406c28566c6d771f9d Mon Sep 17 00:00:00 2001
-From: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-Date: Mon, 12 Dec 2011 18:01:12 -0800
-Subject: [PATCH 1/3] topology-read: Several extensions of TopologyReader
-
----
- src/topology-read/model/topology-reader.cc | 17 ++++++++++++++
- src/topology-read/model/topology-reader.h | 35 +++++++++++++++++++++++-----
- 2 files changed, 46 insertions(+), 6 deletions(-)
-
-diff --git a/src/topology-read/model/topology-reader.cc b/src/topology-read/model/topology-reader.cc
-index b531a6d..82a8343 100644
---- a/src/topology-read/model/topology-reader.cc
-+++ b/src/topology-read/model/topology-reader.cc
-@@ -106,12 +106,23 @@ TopologyReader::Link::Link ()
- {
- }
-
-+void
-+TopologyReader::Link::SetNetDevices (Ptr<NetDevice> from, Ptr<NetDevice> to)
-+{
-+ m_fromNetDevice = from;
-+ m_toNetDevice = to;
-+}
-
- Ptr<Node> TopologyReader::Link::GetFromNode (void) const
- {
- return m_fromPtr;
- }
-
-+Ptr<NetDevice> TopologyReader::Link::GetFromNetDevice (void) const
-+{
-+ return m_fromNetDevice;
-+}
-+
- std::string
- TopologyReader::Link::GetFromNodeName (void) const
- {
-@@ -124,6 +135,12 @@ TopologyReader::Link::GetToNode (void) const
- return m_toPtr;
- }
-
-+Ptr<NetDevice>
-+TopologyReader::Link::GetToNetDevice (void) const
-+{
-+ return m_toNetDevice;
-+}
-+
- std::string
- TopologyReader::Link::GetToNodeName (void) const
- {
-diff --git a/src/topology-read/model/topology-reader.h b/src/topology-read/model/topology-reader.h
-index 865b7d3..48c0c1d 100644
---- a/src/topology-read/model/topology-reader.h
-+++ b/src/topology-read/model/topology-reader.h
-@@ -32,6 +32,8 @@
-
- namespace ns3 {
-
-+class NetDevice;
-+
- /**
- * \ingroup topology
- *
-@@ -53,7 +55,7 @@ public:
- */
- class Link
- {
--public:
-+ public:
- /**
- * \brief Constant iterator to scan the map of link attributes.
- */
-@@ -66,14 +68,27 @@ public:
- * \param toPtr Ptr to the node the link is directed to
- * \param toName name of the node the link is directed to
- */
-- Link ( Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName );
-+ Link (Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName);
-
- /**
-+ * \brief Set netdevices associated with the link
-+ * \param from NetDevice associated with From node
-+ * \param to NetDevice associated with To node
-+ */
-+ void
-+ SetNetDevices (Ptr<NetDevice> from, Ptr<NetDevice> to);
-+
-+ /**
- * \brief Returns a Ptr<Node> to the "from" node of the link
- * \return a Ptr<Node> to the "from" node of the link
- */
- Ptr<Node> GetFromNode (void) const;
- /**
-+ * \brief Returns a Ptr<NetDevice> of the "from" node of the link
-+ * \return a Ptr<NetDevice> of the "from" node of the link
-+ */
-+ Ptr<NetDevice> GetFromNetDevice (void) const;
-+ /**
- * \brief Returns the name of the "from" node of the link
- * \return the name of the "from" node of the link
- */
-@@ -84,6 +99,11 @@ public:
- */
- Ptr<Node> GetToNode (void) const;
- /**
-+ * \brief Returns a Ptr<NetDevice> of the "to" node of the link
-+ * \return a Ptr<NetDevice> of the "to" node of the link
-+ */
-+ Ptr<NetDevice> GetToNetDevice (void) const;
-+ /**
- * \brief Returns the name of the "to" node of the link
- * \return the name of the "to" node of the link
- */
-@@ -127,7 +147,9 @@ private:
- Ptr< Node > m_fromPtr;
- std::string m_toName;
- Ptr< Node > m_toPtr;
-- std::map<std::string, std::string> m_linkAttr;
-+ Ptr< NetDevice > m_fromNetDevice;
-+ Ptr< NetDevice > m_toNetDevice;
-+ std::map<std::string, std::string > m_linkAttr;
- };
-
- /**
-@@ -195,13 +217,14 @@ private:
- */
- void AddLink (Link link);
-
-+protected:
-+ std::string m_fileName;
-+ std::list<Link> m_linksList;
-+
- private:
- TopologyReader (const TopologyReader&);
- TopologyReader& operator= (const TopologyReader&);
-
-- std::string m_fileName;
-- std::list<Link> m_linksList;
--
- // end class TopologyReader
- };
-
---
-1.7.10.2
-
diff --git a/plugins/topology/patches/0002-topology-read-TopologyReader-and-derivatives-are-no-.patch b/plugins/topology/patches/0002-topology-read-TopologyReader-and-derivatives-are-no-.patch
deleted file mode 100644
index db3f957..0000000
--- a/plugins/topology/patches/0002-topology-read-TopologyReader-and-derivatives-are-no-.patch
+++ /dev/null
@@ -1,299 +0,0 @@
-From cd1527f264045510fd79f3a6bd44ce5c48a8278d Mon Sep 17 00:00:00 2001
-From: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-Date: Tue, 13 Dec 2011 13:17:25 -0800
-Subject: [PATCH 2/3] topology-read: TopologyReader and derivatives are no
- longer Objects
-
-To allow smart pointers, TopologyReader is just inherited from
-SimpleRefCount<TopologyReader> class
----
- src/topology-read/helper/topology-reader-helper.cc | 7 +++----
- src/topology-read/helper/topology-reader-helper.h | 5 ++---
- src/topology-read/model/inet-topology-reader.cc | 20 ++++++++++----------
- src/topology-read/model/inet-topology-reader.h | 2 +-
- src/topology-read/model/orbis-topology-reader.cc | 20 ++++++++++----------
- src/topology-read/model/orbis-topology-reader.h | 2 +-
- .../model/rocketfuel-topology-reader.cc | 20 ++++++++++----------
- .../model/rocketfuel-topology-reader.h | 3 +--
- src/topology-read/model/topology-reader.cc | 19 +++++++++----------
- src/topology-read/model/topology-reader.h | 8 +++-----
- 10 files changed, 50 insertions(+), 56 deletions(-)
-
-diff --git a/src/topology-read/helper/topology-reader-helper.cc b/src/topology-read/helper/topology-reader-helper.cc
-index ea4a9b2..c4678d1 100644
---- a/src/topology-read/helper/topology-reader-helper.cc
-+++ b/src/topology-read/helper/topology-reader-helper.cc
-@@ -47,7 +47,6 @@ TopologyReaderHelper::SetFileType (const std::string fileType)
- m_fileType = fileType;
- }
-
--
- Ptr<TopologyReader>
- TopologyReaderHelper::GetTopologyReader ()
- {
-@@ -59,17 +58,17 @@ TopologyReaderHelper::GetTopologyReader ()
- if (m_fileType == "Orbis")
- {
- NS_LOG_INFO ("Creating Orbis formatted data input.");
-- m_inFile = CreateObject<OrbisTopologyReader> ();
-+ m_inFile = Create<OrbisTopologyReader> ();
- }
- else if (m_fileType == "Inet")
- {
- NS_LOG_INFO ("Creating Inet formatted data input.");
-- m_inFile = CreateObject<InetTopologyReader> ();
-+ m_inFile = Create<InetTopologyReader> ();
- }
- else if (m_fileType == "Rocketfuel")
- {
- NS_LOG_INFO ("Creating Rocketfuel formatted data input.");
-- m_inFile = CreateObject<RocketfuelTopologyReader> ();
-+ m_inFile = Create<RocketfuelTopologyReader> ();
- }
- else
- {
-diff --git a/src/topology-read/helper/topology-reader-helper.h b/src/topology-read/helper/topology-reader-helper.h
-index c4bfbbe..c1cc198 100644
---- a/src/topology-read/helper/topology-reader-helper.h
-+++ b/src/topology-read/helper/topology-reader-helper.h
-@@ -22,11 +22,10 @@
- #ifndef TOPOLOGY_READER_HELPER_H
- #define TOPOLOGY_READER_HELPER_H
-
--#include "ns3/topology-reader.h"
--#include <string>
--
- namespace ns3 {
-
-+class TopologyReader;
-+
- /**
- * \ingroup topology
- *
-diff --git a/src/topology-read/model/inet-topology-reader.cc b/src/topology-read/model/inet-topology-reader.cc
-index ab1cc5d..10d1ac3 100644
---- a/src/topology-read/model/inet-topology-reader.cc
-+++ b/src/topology-read/model/inet-topology-reader.cc
-@@ -28,19 +28,19 @@
-
- using namespace std;
-
--namespace ns3 {
--
- NS_LOG_COMPONENT_DEFINE ("InetTopologyReader");
-
--NS_OBJECT_ENSURE_REGISTERED (InetTopologyReader);
-+namespace ns3 {
-+
-+// NS_OBJECT_ENSURE_REGISTERED (InetTopologyReader);
-
--TypeId InetTopologyReader::GetTypeId (void)
--{
-- static TypeId tid = TypeId ("ns3::InetTopologyReader")
-- .SetParent<Object> ()
-- ;
-- return tid;
--}
-+// TypeId InetTopologyReader::GetTypeId (void)
-+// {
-+// static TypeId tid = TypeId ("ns3::InetTopologyReader")
-+// .SetParent<Object> ()
-+// ;
-+// return tid;
-+// }
-
- InetTopologyReader::InetTopologyReader ()
- {
-diff --git a/src/topology-read/model/inet-topology-reader.h b/src/topology-read/model/inet-topology-reader.h
-index 31aa4a0..d235370 100644
---- a/src/topology-read/model/inet-topology-reader.h
-+++ b/src/topology-read/model/inet-topology-reader.h
-@@ -47,7 +47,7 @@ namespace ns3 {
- class InetTopologyReader : public TopologyReader
- {
- public:
-- static TypeId GetTypeId (void);
-+ // static TypeId GetTypeId (void);
-
- InetTopologyReader ();
- virtual ~InetTopologyReader ();
-diff --git a/src/topology-read/model/orbis-topology-reader.cc b/src/topology-read/model/orbis-topology-reader.cc
-index 04dbaf9..bdcd139 100644
---- a/src/topology-read/model/orbis-topology-reader.cc
-+++ b/src/topology-read/model/orbis-topology-reader.cc
-@@ -29,19 +29,19 @@
-
- using namespace std;
-
--namespace ns3 {
--
- NS_LOG_COMPONENT_DEFINE ("OrbisTopologyReader");
-
--NS_OBJECT_ENSURE_REGISTERED (OrbisTopologyReader);
-+namespace ns3 {
-+
-+// NS_OBJECT_ENSURE_REGISTERED (OrbisTopologyReader);
-
--TypeId OrbisTopologyReader::GetTypeId (void)
--{
-- static TypeId tid = TypeId ("ns3::OrbisTopologyReader")
-- .SetParent<Object> ()
-- ;
-- return tid;
--}
-+// TypeId OrbisTopologyReader::GetTypeId (void)
-+// {
-+// static TypeId tid = TypeId ("ns3::OrbisTopologyReader")
-+// .SetParent<Object> ()
-+// ;
-+// return tid;
-+// }
-
- OrbisTopologyReader::OrbisTopologyReader ()
- {
-diff --git a/src/topology-read/model/orbis-topology-reader.h b/src/topology-read/model/orbis-topology-reader.h
-index 21b32cf..b25db15 100644
---- a/src/topology-read/model/orbis-topology-reader.h
-+++ b/src/topology-read/model/orbis-topology-reader.h
-@@ -44,7 +44,7 @@ namespace ns3 {
- class OrbisTopologyReader : public TopologyReader
- {
- public:
-- static TypeId GetTypeId (void);
-+ // static TypeId GetTypeId (void);
-
- OrbisTopologyReader ();
- virtual ~OrbisTopologyReader ();
-diff --git a/src/topology-read/model/rocketfuel-topology-reader.cc b/src/topology-read/model/rocketfuel-topology-reader.cc
-index d048148..c103271 100644
---- a/src/topology-read/model/rocketfuel-topology-reader.cc
-+++ b/src/topology-read/model/rocketfuel-topology-reader.cc
-@@ -28,19 +28,19 @@
- #include "ns3/unused.h"
- #include "rocketfuel-topology-reader.h"
-
--namespace ns3 {
--
- NS_LOG_COMPONENT_DEFINE ("RocketfuelTopologyReader");
-
--NS_OBJECT_ENSURE_REGISTERED (RocketfuelTopologyReader);
-+namespace ns3 {
-+
-+// NS_OBJECT_ENSURE_REGISTERED (RocketfuelTopologyReader);
-
--TypeId RocketfuelTopologyReader::GetTypeId (void)
--{
-- static TypeId tid = TypeId ("ns3::RocketfuelTopologyReader")
-- .SetParent<Object> ()
-- ;
-- return tid;
--}
-+// TypeId RocketfuelTopologyReader::GetTypeId (void)
-+// {
-+// static TypeId tid = TypeId ("ns3::RocketfuelTopologyReader")
-+// .SetParent<Object> ()
-+// ;
-+// return tid;
-+// }
-
- RocketfuelTopologyReader::RocketfuelTopologyReader ()
- {
-diff --git a/src/topology-read/model/rocketfuel-topology-reader.h b/src/topology-read/model/rocketfuel-topology-reader.h
-index afb667d..c512ea0 100644
---- a/src/topology-read/model/rocketfuel-topology-reader.h
-+++ b/src/topology-read/model/rocketfuel-topology-reader.h
-@@ -21,7 +21,6 @@
- #ifndef ROCKETFUEL_TOPOLOGY_READER_H
- #define ROCKETFUEL_TOPOLOGY_READER_H
-
--#include "ns3/nstime.h"
- #include "topology-reader.h"
-
- namespace ns3 {
-@@ -43,7 +42,7 @@ namespace ns3 {
- class RocketfuelTopologyReader : public TopologyReader
- {
- public:
-- static TypeId GetTypeId (void);
-+ // static TypeId GetTypeId (void);
-
- RocketfuelTopologyReader ();
- virtual ~RocketfuelTopologyReader ();
-diff --git a/src/topology-read/model/topology-reader.cc b/src/topology-read/model/topology-reader.cc
-index 82a8343..a2e66cb 100644
---- a/src/topology-read/model/topology-reader.cc
-+++ b/src/topology-read/model/topology-reader.cc
-@@ -19,24 +19,23 @@
- * Author: Valerio Sartini (valesar@gmail.com)
- */
-
--#include "ns3/log.h"
--
- #include "topology-reader.h"
-
-+#include "ns3/log.h"
-
- namespace ns3 {
-
- NS_LOG_COMPONENT_DEFINE ("TopologyReader");
-
--NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
-+// NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
-
--TypeId TopologyReader::GetTypeId (void)
--{
-- static TypeId tid = TypeId ("ns3::TopologyReader")
-- .SetParent<Object> ()
-- ;
-- return tid;
--}
-+// TypeId TopologyReader::GetTypeId (void)
-+// {
-+// static TypeId tid = TypeId ("ns3::TopologyReader")
-+// .SetParent<Object> ()
-+// ;
-+// return tid;
-+// }
-
- TopologyReader::TopologyReader ()
- {
-diff --git a/src/topology-read/model/topology-reader.h b/src/topology-read/model/topology-reader.h
-index 48c0c1d..94eb37a 100644
---- a/src/topology-read/model/topology-reader.h
-+++ b/src/topology-read/model/topology-reader.h
-@@ -22,13 +22,11 @@
- #ifndef TOPOLOGY_READER_H
- #define TOPOLOGY_READER_H
-
--#include <string>
- #include <map>
- #include <list>
-
--#include "ns3/object.h"
- #include "ns3/node-container.h"
--
-+#include "ns3/simple-ref-count.h"
-
- namespace ns3 {
-
-@@ -42,7 +40,7 @@ class NetDevice;
- * This interface perform the shared tasks among all possible input file readers.
- * Each different file format is handled by its own topology reader.
- */
--class TopologyReader : public Object
-+class TopologyReader : public SimpleRefCount<TopologyReader>
- {
-
- public:
-@@ -157,7 +155,7 @@ private:
- */
- typedef std::list< Link >::const_iterator ConstLinksIterator;
-
-- static TypeId GetTypeId (void);
-+ // static TypeId GetTypeId (void);
-
- TopologyReader ();
- virtual ~TopologyReader ();
---
-1.7.10.2
-
diff --git a/plugins/topology/patches/0003-topology-read-Making-default-constructor-for-Topolog.patch b/plugins/topology/patches/0003-topology-read-Making-default-constructor-for-Topolog.patch
deleted file mode 100644
index 1dcafa3..0000000
--- a/plugins/topology/patches/0003-topology-read-Making-default-constructor-for-Topolog.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-From 4fd8af52681dc3ab641e93a28b8f2c044272bb16 Mon Sep 17 00:00:00 2001
-From: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
-Date: Thu, 19 Jan 2012 16:57:13 -0800
-Subject: [PATCH 3/3] topology-read: Making default constructor for
- TopologyReader::Link public.
-
-This is necessary for some STL containers operations.
----
- src/topology-read/model/topology-reader.h | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/src/topology-read/model/topology-reader.h b/src/topology-read/model/topology-reader.h
-index 94eb37a..d748989 100644
---- a/src/topology-read/model/topology-reader.h
-+++ b/src/topology-read/model/topology-reader.h
-@@ -59,6 +59,8 @@ public:
- */
- typedef std::map<std::string, std::string>::const_iterator ConstAttributesIterator;
-
-+ Link (); // default constructor
-+
- /**
- * \brief Constructor
- * \param fromPtr Ptr to the node the link is orginating from
-@@ -140,7 +142,6 @@ public:
- ConstAttributesIterator AttributesEnd (void);
-
- private:
-- Link ();
- std::string m_fromName;
- Ptr< Node > m_fromPtr;
- std::string m_toName;
---
-1.7.10.2
-
diff --git a/plugins/tracers-broken/README b/plugins/tracers-broken/README
deleted file mode 100644
index 9d4a069..0000000
--- a/plugins/tracers-broken/README
+++ /dev/null
@@ -1,2 +0,0 @@
-A set of tracers that can be useful for NDN and IP scenarios
-
diff --git a/plugins/tracers-broken/ccnx-trace-helper.cc b/plugins/tracers-broken/ccnx-trace-helper.cc
deleted file mode 100644
index 5e98c6f..0000000
--- a/plugins/tracers-broken/ccnx-trace-helper.cc
+++ /dev/null
@@ -1,415 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ccnx-trace-helper.h"
-
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/ccnx-app.h"
-#include "ns3/ccnx-face.h"
-#include "ns3/packet.h"
-#include "ns3/log.h"
-#include "ns3/assert.h"
-#include "ns3/node-list.h"
-#include "ns3/object-vector.h"
-#include "ns3/simulator.h"
-#include "ns3/names.h"
-#include "ns3/tcp-l4-protocol.h"
-#include "ns3/node.h"
-
-#include <boost/ref.hpp>
-#include <boost/lexical_cast.hpp>
-
-#include "tracers/ccnx-aggregate-app-tracer.h"
-#include "tracers/ccnx-aggregate-l3-tracer.h"
-#include "tracers/ccnx-rate-l3-tracer.h"
-#include "tracers/ccnx-seqs-app-tracer.h"
-#include "tracers/ipv4-rate-l3-tracer.h"
-#include "tracers/ipv4-seqs-app-tracer.h"
-#include "tracers/ccnx-consumer-window-tracer.h"
-#include "tracers/ccnx-path-weight-tracer.h"
-
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-content-object-header.h"
-
-#include <fstream>
-
-using namespace std;
-using namespace boost;
-
-NS_LOG_COMPONENT_DEFINE ("CcnxTraceHelper");
-
-namespace ns3 {
-
-CcnxTraceHelper::CcnxTraceHelper ()
- : m_l3RateTrace (0)
- , m_appSeqsTrace (0)
- , m_ipv4RateTrace (0)
- , m_ipv4AppSeqsTrace (0)
- , m_windowsTrace (0)
- , m_windowsTcpTrace (0)
- , m_pathWeightsTrace (0)
-{
-}
-
-CcnxTraceHelper::~CcnxTraceHelper ()
-{
- NS_LOG_FUNCTION (this);
- if (m_l3RateTrace != 0) delete m_l3RateTrace;
- if (m_appSeqsTrace != 0) delete m_appSeqsTrace;
- if (m_ipv4AppSeqsTrace != 0) delete m_ipv4AppSeqsTrace;
- if (m_windowsTrace != 0) delete m_windowsTrace;
- if (m_windowsTcpTrace != 0) delete m_windowsTcpTrace;
- if (m_pathWeightsTrace != 0) delete m_pathWeightsTrace;
- if (m_ipv4RateTrace != 0) delete m_ipv4RateTrace;
-
- if (m_apps.size () > 0)
- {
- ofstream of;
- if (!m_appTrace.empty ())
- {
- of.open (m_appTrace.c_str (), ios_base::trunc | ios_base::out);
- of << "# ";
- m_apps.front ()->PrintHeader (of);
- of << "\n";
- }
-
- for (std::list<Ptr<CcnxAppTracer> >::iterator app = m_apps.begin ();
- app != m_apps.end ();
- app++)
- {
- if (!m_appTrace.empty ())
- {
- (*app)->Print (of);
- of << "\n";
- }
- else
- {
- NS_LOG_INFO (*(*app));
- }
- }
- }
-
- if (m_l3s.size () > 0)
- {
- ofstream of;
- if (!m_l3Trace.empty ())
- {
- of.open (m_l3Trace.c_str (), ios_base::trunc | ios_base::out);
- of << "# ";
- m_l3s.front ()->PrintHeader (of);
- of << "\n";
- }
-
- for (std::list<Ptr<CcnxL3Tracer> >::iterator l3 = m_l3s.begin ();
- l3 != m_l3s.end ();
- l3++)
- {
- if (!m_l3Trace.empty ())
- {
- (*l3)->Print (of);
- of << "\n";
- }
- else
- {
- NS_LOG_INFO (*(*l3));
- }
- }
- }
-}
-
-void
-CcnxTraceHelper::SetAppTraceFile (const std::string &appTrace)
-{
- NS_LOG_FUNCTION (this << appTrace);
- m_appTrace = appTrace;
-}
-
-void
-CcnxTraceHelper::SetL3TraceFile (const std::string &l3Trace)
-{
- NS_LOG_FUNCTION (this << l3Trace);
- m_l3Trace = l3Trace;
-}
-
-void
-CcnxTraceHelper::EnableAggregateAppAll (const std::string &appName)
-{
- NS_LOG_FUNCTION (this << appName);
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- ObjectVectorValue apps;
- (*node)->GetAttribute ("ApplicationList", apps);
-
- NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ()));
-
- uint32_t appId = 0;
- for (ObjectVectorValue::Iterator app = apps.Begin ();
- app != apps.End ();
- app++, appId++)
- {
- NS_LOG_DEBUG ("App: " << lexical_cast<string> (appId) << ", typeId: " << (*app).second->GetInstanceTypeId ().GetName ());
- if ((*app).second->GetInstanceTypeId ().GetName () == appName)
- {
- m_apps.push_back (Create<CcnxAggregateAppTracer> (appName,
- *node,
- lexical_cast<string> (appId)));
- }
- }
- }
-}
-
-void
-CcnxTraceHelper::EnableAggregateL3All ()
-{
- NS_LOG_FUNCTION (this);
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ()));
-
- m_l3s.push_back (Create<CcnxAggregateL3Tracer> (*node));
- }
-}
-
-void
-CcnxTraceHelper::EnableRateL3All (const std::string &l3RateTrace)
-{
- NS_LOG_FUNCTION (this);
- m_l3RateTrace = new ofstream (l3RateTrace.c_str (), ios::trunc);
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ()));
-
- Ptr<CcnxRateL3Tracer> trace = Create<CcnxRateL3Tracer> (boost::ref(*m_l3RateTrace), *node);
- trace->SetAveragingPeriod (Seconds (0.2));
- m_l3Rates.push_back (trace);
- }
-
- if (m_l3Rates.size () > 0)
- {
- // *m_l3RateTrace << "# "; // not necessary for R's read.table
- m_l3Rates.front ()->PrintHeader (*m_l3RateTrace);
- *m_l3RateTrace << "\n";
- }
-}
-
-void
-CcnxTraceHelper::EnableIpv4RateL3All (const std::string &file)
-{
- NS_LOG_FUNCTION (this);
- m_ipv4RateTrace = new ofstream (file.c_str (), ios::trunc);
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ()));
-
- Ptr<Ipv4RateL3Tracer> trace = Create<Ipv4RateL3Tracer> (boost::ref(*m_ipv4RateTrace), *node);
- trace->SetAveragingPeriod (Seconds (0.2));
- m_ipv4Rates.push_back (trace);
- }
-
- if (m_ipv4Rates.size () > 0)
- {
- // *m_ipv4RateTrace << "# "; // not necessary for R's read.table
- m_ipv4Rates.front ()->PrintHeader (*m_ipv4RateTrace);
- *m_ipv4RateTrace << "\n";
- }
-}
-
-
-void
-CcnxTraceHelper::EnableSeqsAppAll (const std::string &appName, const std::string &trace)
-{
- NS_LOG_FUNCTION (this);
- m_appSeqsTrace = new ofstream (trace.c_str (), ios::trunc);
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- ObjectVectorValue apps;
- (*node)->GetAttribute ("ApplicationList", apps);
-
- NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ()));
-
- uint32_t appId = 0;
- for (ObjectVectorValue::Iterator app = apps.Begin ();
- app != apps.End ();
- app++, appId++)
- {
- NS_LOG_DEBUG ("App: " << lexical_cast<string> (appId) << ", typeId: " << (*app).second->GetInstanceTypeId ().GetName ());
- if ((*app).second->GetInstanceTypeId ().GetName () == appName)
- {
- Ptr<CcnxSeqsAppTracer> trace = Create<CcnxSeqsAppTracer> (boost::ref(*m_appSeqsTrace),
- appName,
- *node,
- lexical_cast<string> (appId));
- m_appSeqs.push_back (trace);
- }
- }
-
- }
-
- if (m_appSeqs.size () > 0)
- {
- // *m_l3RateTrace << "# "; // not necessary for R's read.table
- m_appSeqs.front ()->PrintHeader (*m_appSeqsTrace);
- *m_appSeqsTrace << "\n";
- }
-}
-
-void
-CcnxTraceHelper::EnableIpv4SeqsAppAll (const std::string &trace)
-{
- NS_LOG_FUNCTION (this);
- m_ipv4AppSeqsTrace = new ofstream (trace.c_str (), ios::trunc);
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- ObjectVectorValue apps;
- (*node)->GetAttribute ("ApplicationList", apps);
-
- NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ()));
-
- uint32_t appId = 0;
- for (ObjectVectorValue::Iterator app = apps.Begin ();
- app != apps.End ();
- app++, appId++)
- {
- NS_LOG_DEBUG ("App: " << lexical_cast<string> (appId) << ", typeId: " << (*app).second->GetInstanceTypeId ().GetName ());
- if ((*app).second->GetInstanceTypeId ().GetName () == "ns3::PacketSink" ||
- (*app).second->GetInstanceTypeId ().GetName () == "ns3::BulkSendApplication")
- {
- Ptr<Ipv4SeqsAppTracer> trace = Create<Ipv4SeqsAppTracer> (boost::ref(*m_ipv4AppSeqsTrace),
- *node,
- lexical_cast<string> (appId));
- m_ipv4AppSeqs.push_back (trace);
- }
- }
-
- }
-
- if (m_ipv4AppSeqs.size () > 0)
- {
- m_ipv4AppSeqs.front ()->PrintHeader (*m_ipv4AppSeqsTrace);
- *m_ipv4AppSeqsTrace << "\n";
- }
-}
-
-void
-CcnxTraceHelper::EnableWindowsAll (const std::string &windowTrace)
-{
- NS_LOG_FUNCTION (this);
- m_windowsTrace = new ofstream (windowTrace.c_str (), ios::trunc);
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- ObjectVectorValue apps;
- (*node)->GetAttribute ("ApplicationList", apps);
-
- NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ()));
-
- uint32_t appId = 0;
- for (ObjectVectorValue::Iterator app = apps.Begin ();
- app != apps.End ();
- app++, appId++)
- {
- if ((*app).second->GetInstanceTypeId ().GetName () == "ns3::CcnxConsumerWindow")
- {
- Ptr<CcnxConsumerWindowTracer> trace = Create<CcnxConsumerWindowTracer> (boost::ref(*m_windowsTrace),
- *node,
- lexical_cast<string> (appId));
- m_windows.push_back (trace);
- }
- }
-
- }
-
- if (m_windows.size () > 0)
- {
- m_windows.front ()->PrintHeader (*m_windowsTrace);
- *m_windowsTrace << "\n";
- }
-}
-
-void
-CcnxTraceHelper::TcpConnect (Ptr<Node> node)
-{
- ObjectVectorValue sockets;
- node->GetObject<TcpL4Protocol> ()->GetAttribute ("SocketList", sockets);
-
- uint32_t sockId = 0;
- for (ObjectVectorValue::Iterator socket = sockets.Begin ();
- socket != sockets.End ();
- socket++, sockId++)
- {
- // std::cout << "Node: " << node->GetId () << ", Socket " << sockId << "\n";
-
- Ptr<TcpCongestionWindowTracer> trace = Create<TcpCongestionWindowTracer> (boost::ref(*m_windowsTcpTrace),
- node,
- lexical_cast<string> (sockId));
- m_windowsTcp.push_back (trace);
- }
-}
-
-void
-CcnxTraceHelper::EnableWindowsTcpAll (const std::string &windowTrace)
-{
- NS_LOG_FUNCTION (this);
- m_windowsTcpTrace = new ofstream (windowTrace.c_str (), ios::trunc);
-
- WindowTracer::PrintHeader (*m_windowsTcpTrace);
- *m_windowsTcpTrace << "\n";
-}
-
-void
-CcnxTraceHelper::EnablePathWeights (const std::string &pathWeights)
-{
- NS_LOG_FUNCTION (this);
- m_pathWeightsTrace = new ofstream (pathWeights.c_str (), ios::trunc);
-
- CcnxPathWeightTracer::PrintHeader (*m_pathWeightsTrace);
- *m_pathWeightsTrace << "\n";
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- Ptr<CcnxPathWeightTracer> trace = Create<CcnxPathWeightTracer> (boost::ref(*m_pathWeightsTrace),
- *node);
- m_pathWeights.push_back (trace);
- }
-}
-
-} // namespace ns3
diff --git a/plugins/tracers-broken/ccnx-trace-helper.h b/plugins/tracers-broken/ccnx-trace-helper.h
deleted file mode 100644
index aa9cd30..0000000
--- a/plugins/tracers-broken/ccnx-trace-helper.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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_TRACE_HELPER_H
-#define CCNX_TRACE_HELPER_H
-
-#include "ns3/nstime.h"
-#include "ns3/event-id.h"
-
-#include <list>
-
-namespace ns3 {
-
-class Node;
-class CcnxAppTracer;
-class CcnxL3Tracer;
-class Ipv4L3Tracer;
-class Ipv4AppTracer;
-class WindowTracer;
-class CcnxPathWeightTracer;
-class Application;
-
-class CcnxTraceHelper
-{
-public:
- CcnxTraceHelper ();
-
- /**
- * @brief Destructor that invokes trace output procedures
- */
- ~CcnxTraceHelper ();
-
- /**
- * @brief Set filename to output app trace.
- *
- * By default, trace is output to NS_LOG_INFO stream
- *
- * @param file File where trace will be written to
- */
- void
- SetAppTraceFile (const std::string &appTrace = "apps.log");
-
- /**
- * @brief Set filename to output app trace.
- *
- * By default, trace is output to NS_LOG_INFO stream
- *
- * @param file File where trace will be written to
- */
- void
- SetL3TraceFile (const std::string &l3Trace = "l3.log");
-
- /**
- * @brief Enable aggregate app-level CCNx tracing on all CCNx applications
- *
- * @param app Class name of the application of interest
- */
- void
- EnableAggregateAppAll (const std::string &app);
-
- /**
- * @brief Enable aggregate network-level CCNx tracing on all CCNx node
- */
- void
- EnableAggregateL3All ();
-
- /**
- * @brief Enable network-level CCNx rate tracing on all CCNx nodes
- */
- void
- EnableRateL3All (const std::string &l3RateTrace = "l3-rate.log");
-
- /**
- * @brief Enable app-level CCNx sequence tracing on all CCNx applications
- */
- void
- EnableSeqsAppAll (const std::string &app, const std::string &appSeqsTrace = "app-seqs.log");
-
- /**
- * @brief Enable app-level IPv4 sequence tracing on all nodes (BulkSender + PacketSink)
- */
- void
- EnableIpv4SeqsAppAll (const std::string &appSeqsTrace = "app-seqs.log");
-
- /**
- * @brief Enable network-level IPv4 rate tracing on all IPv4-enabled nodes
- */
- void
- EnableIpv4RateL3All (const std::string &ipv4RateTrace = "ipv4-rate.log");
-
- /**
- * @brief Enable tracing of window changes in CcnxConsumerWindow
- */
- void
- EnableWindowsAll (const std::string &windowTrace = "windows.log");
-
- /**
- * @brief Enable tracing of congestion window changes in TcpNewReno
- */
- void
- EnableWindowsTcpAll (const std::string &windowTrace);
-
- /**
- * @brief Should be called with node pointer after TCP application
- *
- * Workaround because NS-3 needs object to exist before connecting trace
- */
- void TcpConnect (Ptr<Node> node);
-
- /**
- * @brief Enable tracing of path weights
- */
- void
- EnablePathWeights (const std::string &pathWeights);
-
-private:
- std::string m_appTrace;
- std::list<Ptr<CcnxAppTracer> > m_apps;
-
- std::string m_l3Trace;
- std::list<Ptr<CcnxL3Tracer> > m_l3s;
-
- std::list<Ptr<CcnxL3Tracer> > m_l3Rates;
- std::ostream *m_l3RateTrace;
-
- std::list<Ptr<CcnxAppTracer> > m_appSeqs;
- std::ostream *m_appSeqsTrace;
-
- std::list<Ptr<Ipv4L3Tracer> > m_ipv4Rates;
- std::ostream *m_ipv4RateTrace;
-
- std::list<Ptr<Ipv4AppTracer> > m_ipv4AppSeqs;
- std::ostream *m_ipv4AppSeqsTrace;
-
- std::list<Ptr<WindowTracer> > m_windows;
- std::ostream *m_windowsTrace;
-
- std::list<Ptr<WindowTracer> > m_windowsTcp;
- std::ostream *m_windowsTcpTrace;
-
- std::list<Ptr<CcnxPathWeightTracer> > m_pathWeights;
- std::ostream *m_pathWeightsTrace;
-};
-
-
-} // namespace ns3
-
-#endif /* CCNX_TRACE_HELPER_H */
diff --git a/plugins/tracers-broken/patches/enable-path-stretch-trace.patch b/plugins/tracers-broken/patches/enable-path-stretch-trace.patch
deleted file mode 100644
index 1be4ef1..0000000
--- a/plugins/tracers-broken/patches/enable-path-stretch-trace.patch
+++ /dev/null
@@ -1,105 +0,0 @@
-diff --git a/apps/ccnx-consumer.cc b/apps/ccnx-consumer.cc
-index 1ddc0b1..ac60412 100644
---- a/apps/ccnx-consumer.cc
-+++ b/apps/ccnx-consumer.cc
-@@ -33,7 +33,7 @@
- #include "../model/ccnx-local-face.h"
- #include "ns3/ccnx-interest-header.h"
- #include "ns3/ccnx-content-object-header.h"
--// #include "ns3/weights-path-stretch-tag.h"
-+#include "ns3/weights-path-stretch-tag.h"
-
- #include <boost/ref.hpp>
- #include <boost/lexical_cast.hpp>
-@@ -288,14 +288,14 @@ CcnxConsumer::OnContentObject (const Ptr<const CcnxContentObject> &content
-
- m_rtt->AckSeq (SequenceNumber32 (seq));
-
-- // Ptr<const WeightsPathStretchTag> tag = payload->RemovePacketTag<WeightsPathStretchTag> ();
-- // if (tag != 0)
-- // {
-- // // Notify trace about path weights vector (e.g., for path-stretch calculation)
-- // m_pathWeightsTrace (GetNode (), tag->GetSourceNode (), seq, tag->GetTotalWeight ());
-- // // if (Names::FindName (GetNode ()) == "36")// || Names::FindName (GetNode ()) == "40"|| Names::FindName (GetNode ()) == "5")
-- // // std::cout << Simulator::Now () << "\t" << boost::cref(*tag) << " = " << tag->GetTotalWeight () << "\n";
-- // }
-+ Ptr<const WeightsPathStretchTag> tag = payload->RemovePacketTag<WeightsPathStretchTag> ();
-+ if (tag != 0)
-+ {
-+ // Notify trace about path weights vector (e.g., for path-stretch calculation)
-+ m_pathWeightsTrace (GetNode (), tag->GetSourceNode (), seq, tag->GetTotalWeight ());
-+ // if (Names::FindName (GetNode ()) == "36")// || Names::FindName (GetNode ()) == "40"|| Names::FindName (GetNode ()) == "5")
-+ // std::cout << Simulator::Now () << "\t" << boost::cref(*tag) << " = " << tag->GetTotalWeight () << "\n";
-+}
- }
-
- void
-diff --git a/model/ccnx-face.cc b/model/ccnx-face.cc
-index 86daa26..25cc0a5 100644
---- a/model/ccnx-face.cc
-+++ b/model/ccnx-face.cc
-@@ -30,7 +30,7 @@
- #include "ns3/boolean.h"
- #include "ns3/simulator.h"
-
--// #include "ns3/weights-path-stretch-tag.h"
-+#include "ns3/weights-path-stretch-tag.h"
-
- #include <boost/ref.hpp>
-
-@@ -59,10 +59,10 @@ CcnxFace::GetTypeId ()
- MakeDoubleAccessor (&CcnxFace::m_bucketLeak),
- MakeDoubleChecker<double> ())
-
-- // .AddAttribute ("MetricTagging", "Enable metric tagging (path-stretch calculation)",
-- // BooleanValue (false),
-- // MakeBooleanAccessor (&CcnxFace::m_enableMetricTagging),
-- // MakeBooleanChecker ())
-+ .AddAttribute ("MetricTagging", "Enable metric tagging (path-stretch calculation)",
-+ BooleanValue (false),
-+ MakeBooleanAccessor (&CcnxFace::m_enableMetricTagging),
-+ MakeBooleanChecker ())
- ;
- return tid;
- }
-@@ -157,23 +157,23 @@ CcnxFace::Send (Ptr<Packet> packet)
- if (!IsUp ())
- return false;
-
-- // if (m_enableMetricTagging)
-- // {
-- // // update path information
-- // Ptr<const WeightsPathStretchTag> origTag = packet->RemovePacketTag<WeightsPathStretchTag> ();
-- // Ptr<WeightsPathStretchTag> tag;
-- // if (origTag == 0)
-- // {
-- // tag = CreateObject<WeightsPathStretchTag> (); // create a new tag
-- // }
-- // else
-- // {
-- // tag = CreateObject<WeightsPathStretchTag> (*origTag); // will update existing tag
-- // }
--
-- // tag->AddPathInfo (m_node, GetMetric ());
-- // packet->AddPacketTag (tag);
-- // }
-+ if (m_enableMetricTagging)
-+ {
-+ // update path information
-+ Ptr<const WeightsPathStretchTag> origTag = packet->RemovePacketTag<WeightsPathStretchTag> ();
-+ Ptr<WeightsPathStretchTag> tag;
-+ if (origTag == 0)
-+ {
-+ tag = CreateObject<WeightsPathStretchTag> (); // create a new tag
-+ }
-+ else
-+ {
-+ tag = CreateObject<WeightsPathStretchTag> (*origTag); // will update existing tag
-+ }
-+
-+ tag->AddPathInfo (m_node, GetMetric ());
-+ packet->AddPacketTag (tag);
-+ }
-
- SendImpl (packet);
- return true;
diff --git a/plugins/tracers-broken/tracers/ccnx-aggregate-app-tracer.cc b/plugins/tracers-broken/tracers/ccnx-aggregate-app-tracer.cc
deleted file mode 100644
index a7f254b..0000000
--- a/plugins/tracers-broken/tracers/ccnx-aggregate-app-tracer.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ccnx-aggregate-app-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/ccnx-app.h"
-#include "ns3/ccnx-face.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-content-object-header.h"
-
-namespace ns3 {
-
-CcnxAggregateAppTracer::CcnxAggregateAppTracer (const std::string &app, Ptr<Node> node, const std::string &appId)
- : CcnxAppTracer (app, node, appId)
- , m_inInterests (0)
- , m_outInterests (0)
- , m_inNacks (0)
- , m_inData (0)
- , m_outData (0)
-
- , m_inInterestsBytes (0)
- , m_outInterestsBytes (0)
- , m_inNacksBytes (0)
- , m_inDataBytes (0)
- , m_outDataBytes (0)
-{
-}
-
-CcnxAggregateAppTracer::CcnxAggregateAppTracer (const std::string &app, const std::string &node, const std::string &appId)
- : CcnxAppTracer (app, node, appId)
- , m_inInterests (0)
- , m_outInterests (0)
- , m_inNacks (0)
- , m_inData (0)
- , m_outData (0)
-
- , m_inInterestsBytes (0)
- , m_outInterestsBytes (0)
- , m_inNacksBytes (0)
- , m_inDataBytes (0)
- , m_outDataBytes (0)
-{
-}
-
-void
-CcnxAggregateAppTracer::Reset ()
-{
- m_inInterests = 0;
- m_outInterests = 0;
- m_inNacks = 0;
- m_inData = 0;
- m_outData = 0;
-
- m_inInterestsBytes = 0;
- m_outInterestsBytes = 0;
- m_inNacksBytes = 0;
- m_inDataBytes = 0;
- m_outDataBytes = 0;
-}
-
-void
-CcnxAggregateAppTracer::PrintHeader (std::ostream &os) const
-{
- os << "NodeId" << "\t"
- << "App" << "\t"
- << "AppId" << "\t"
- << "InInterests" << "\t"
- << "OutInterests" << "\t"
-
- << "InNacks" << "\t"
-
- << "InData" << "\t"
- << "OutData" << "\t"
-
- << "InInterestsBytes" << "\t"
- << "OutInterestsBytes" << "\t"
-
- << "InNacksBytes" << "\t"
-
- << "InDataBytes" << "\t"
- << "OutDataBytes";
-}
-
-void
-CcnxAggregateAppTracer::Print (std::ostream &os) const
-{
- os << m_node << "\t"
- << m_app << "\t"
- << m_appId << "\t"
-
- << m_inInterests << "\t"
- << m_outInterests << "\t"
-
- << m_inNacks << "\t"
-
- << m_inData << "\t"
- << m_outData << "\t"
-
- << m_inInterestsBytes << "\t"
- << m_outInterestsBytes << "\t"
-
- << m_inNacksBytes << "\t"
-
- << m_inDataBytes << "\t"
- << m_outDataBytes;
-}
-
-void
-CcnxAggregateAppTracer::OutInterests (std::string context,
- Ptr<const CcnxInterest> header, Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- m_outInterests++;
- m_outInterestsBytes += header->GetSerializedSize ();
-}
-
-void
-CcnxAggregateAppTracer::OutData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet> payload,
- Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- m_outData++;
- m_outDataBytes += header->GetSerializedSize () + payload->GetSerializedSize ();
-}
-
-void
-CcnxAggregateAppTracer::InInterests (std::string context,
- Ptr<const CcnxInterest> header,
- Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- m_inInterests++;
- m_inInterestsBytes += header->GetSerializedSize ();
-}
-
-void
-CcnxAggregateAppTracer::InNacks (std::string context,
- Ptr<const CcnxInterest> header,
- Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- m_inNacks++;
- m_inNacksBytes += header->GetSerializedSize ();
-}
-
-void
-CcnxAggregateAppTracer::InData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet> payload,
- Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- m_inData++;
- m_inDataBytes += header->GetSerializedSize () + payload->GetSerializedSize ();
-}
-
-} // namespace ns3
diff --git a/plugins/tracers-broken/tracers/ccnx-aggregate-app-tracer.h b/plugins/tracers-broken/tracers/ccnx-aggregate-app-tracer.h
deleted file mode 100644
index a0e52fb..0000000
--- a/plugins/tracers-broken/tracers/ccnx-aggregate-app-tracer.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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_AGGREGATE_APP_TRACER_H
-#define CCNX_AGGREGATE_APP_TRACER_H
-
-#include "ns3/ccnx-app-tracer.h"
-
-namespace ns3 {
-
-class CcnxAggregateAppTracer : public CcnxAppTracer
-{
-public:
- CcnxAggregateAppTracer (const std::string &app, Ptr<Node> node, const std::string &appId = "*");
- CcnxAggregateAppTracer (const std::string &app, const std::string &node, const std::string &appId = "*");
- virtual ~CcnxAggregateAppTracer () { };
-
- virtual void
- PrintHeader (std::ostream &os) const;
-
- virtual void
- Print (std::ostream &os) const;
-
- virtual void
- OutInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
- virtual void
- InInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
- virtual void
- InNacks (std::string context,
- Ptr<const CcnxInterest>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
- virtual void
- OutData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
- virtual void
- InData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
-protected:
- void
- Reset ();
-
-protected:
- uint64_t m_inInterests;
- uint64_t m_outInterests;
- uint64_t m_inNacks;
- uint64_t m_inData;
- uint64_t m_outData;
-
- uint64_t m_inInterestsBytes;
- uint64_t m_outInterestsBytes;
- uint64_t m_inNacksBytes;
- uint64_t m_inDataBytes;
- uint64_t m_outDataBytes;
-};
-
-} // namespace ns3
-
-#endif // CCNX_AGGREGATE_APP_TRACER_H
diff --git a/plugins/tracers-broken/tracers/ccnx-aggregate-l3-tracer.cc b/plugins/tracers-broken/tracers/ccnx-aggregate-l3-tracer.cc
deleted file mode 100644
index 030d308..0000000
--- a/plugins/tracers-broken/tracers/ccnx-aggregate-l3-tracer.cc
+++ /dev/null
@@ -1,201 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ccnx-aggregate-l3-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/ccnx-app.h"
-#include "ns3/ccnx-face.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-content-object-header.h"
-
-namespace ns3 {
-
-CcnxAggregateL3Tracer::CcnxAggregateL3Tracer (Ptr<Node> node)
- : CcnxL3Tracer (node)
-{
- Reset ();
-}
-
-CcnxAggregateL3Tracer::CcnxAggregateL3Tracer (const std::string &node)
- : CcnxL3Tracer (node)
-{
- Reset ();
-}
-
-void
-CcnxAggregateL3Tracer::Stats::Reset ()
-{
- m_inInterests = 0;
- m_outInterests = 0;
- m_dropInterests = 0;
- m_inNacks = 0;
- m_outNacks = 0;
- m_dropNacks = 0;
- m_inData = 0;
- m_outData = 0;
- m_dropData = 0;
-}
-
-
-void
-CcnxAggregateL3Tracer::Reset ()
-{
- m_packets.Reset ();
- m_bytes.Reset ();
-}
-
-
-void
-CcnxAggregateL3Tracer::PrintHeader (std::ostream &os) const
-{
- os << "Node" << "\t"
- << "InInterests" << "\t"
- << "OutInterests" << "\t"
- << "DropInterests" << "\t"
-
- << "InNacks" << "\t"
- << "OutNacks" << "\t"
- << "DropNacks" << "\t"
-
- << "InData" << "\t"
- << "OutData" << "\t"
- << "DropData" << "\t"
-
- << "InInterestsBytes" << "\t"
- << "OutInterestsBytes" << "\t"
- << "DropInterestsBytes" << "\t"
-
- << "InNacksBytes" << "\t"
- << "OutNacksBytes" << "\t"
- << "DropNacksBytes" << "\t"
-
- << "InDataBytes" << "\t"
- << "OutDataBytes" << "\t"
- << "DropDataBytes";
-}
-
-void
-CcnxAggregateL3Tracer::Print (std::ostream &os) const
-{
- os << m_node << "\t"
- << m_packets.m_inInterests << "\t"
- << m_packets.m_outInterests << "\t"
- << m_packets.m_dropInterests << "\t"
-
- << m_packets.m_inNacks << "\t"
- << m_packets.m_outNacks << "\t"
- << m_packets.m_dropNacks << "\t"
-
- << m_packets.m_inData << "\t"
- << m_packets.m_outData << "\t"
- << m_packets.m_dropData << "\t"
-
- << m_bytes.m_inInterests << "\t"
- << m_bytes.m_outInterests << "\t"
- << m_bytes.m_dropInterests << "\t"
-
- << m_bytes.m_inNacks << "\t"
- << m_bytes.m_outNacks << "\t"
- << m_bytes.m_dropNacks << "\t"
-
- << m_bytes.m_inData << "\t"
- << m_bytes.m_outData << "\t"
- << m_bytes.m_dropData;
-}
-
-void
-CcnxAggregateL3Tracer::OutInterests (std::string context,
- Ptr<const CcnxInterest> header, Ptr<const CcnxFace>)
-{
- m_packets.m_outInterests++;
- m_bytes.m_outInterests += header->GetSerializedSize ();
-}
-
-void
-CcnxAggregateL3Tracer::InInterests (std::string context,
- Ptr<const CcnxInterest> header, Ptr<const CcnxFace>)
-{
- m_packets.m_inInterests++;
- m_bytes.m_inInterests += header->GetSerializedSize ();
-}
-
-void
-CcnxAggregateL3Tracer::DropInterests (std::string context,
- Ptr<const CcnxInterest> header, Ccnx::DropReason, Ptr<const CcnxFace>)
-{
- m_packets.m_dropInterests++;
- m_bytes.m_dropInterests += header->GetSerializedSize ();
-}
-
-void
-CcnxAggregateL3Tracer::OutNacks (std::string context,
- Ptr<const CcnxInterest> header, Ptr<const CcnxFace>)
-{
- m_packets.m_outNacks++;
- m_bytes.m_outNacks += header->GetSerializedSize ();
-}
-
-void
-CcnxAggregateL3Tracer::InNacks (std::string context,
- Ptr<const CcnxInterest> header, Ptr<const CcnxFace>)
-{
- m_packets.m_inNacks++;
- m_bytes.m_inNacks += header->GetSerializedSize ();
-}
-
-void
-CcnxAggregateL3Tracer::DropNacks (std::string context,
- Ptr<const CcnxInterest> header, Ccnx::DropReason, Ptr<const CcnxFace>)
-{
- m_packets.m_dropNacks++;
- m_bytes.m_dropNacks += header->GetSerializedSize ();
-}
-
-void
-CcnxAggregateL3Tracer::OutData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet> payload,
- bool fromCache, Ptr<const CcnxFace>)
-{
- m_packets.m_outData++;
- m_bytes.m_outData += header->GetSerializedSize () + payload->GetSize ();
-}
-
-void
-CcnxAggregateL3Tracer::InData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet> payload,
- Ptr<const CcnxFace>)
-{
- m_packets.m_inData++;
- m_bytes.m_inData += header->GetSerializedSize () + payload->GetSize ();
-}
-
-void
-CcnxAggregateL3Tracer::DropData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet> payload,
- Ccnx::DropReason, Ptr<const CcnxFace>)
-{
- m_packets.m_dropData++;
- m_bytes.m_dropData += header->GetSerializedSize () + payload->GetSize ();
-}
-
-} // namespace ns3
diff --git a/plugins/tracers-broken/tracers/ccnx-aggregate-l3-tracer.h b/plugins/tracers-broken/tracers/ccnx-aggregate-l3-tracer.h
deleted file mode 100644
index f64062c..0000000
--- a/plugins/tracers-broken/tracers/ccnx-aggregate-l3-tracer.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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_AGGREGATE_L3_TRACER_H
-#define CCNX_AGGREGATE_L3_TRACER_H
-
-#include "ns3/ccnx-l3-tracer.h"
-
-namespace ns3 {
-
-class CcnxAggregateL3Tracer : public CcnxL3Tracer
-{
-public:
- CcnxAggregateL3Tracer (Ptr<Node> node);
- CcnxAggregateL3Tracer (const std::string &node);
- virtual ~CcnxAggregateL3Tracer () { };
-
- virtual void
- PrintHeader (std::ostream &os) const;
-
- virtual void
- Print (std::ostream &os) const;
-
- virtual void
- OutInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>);
-
- virtual void
- InInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>);
-
- virtual void
- DropInterests (std::string context,
- Ptr<const CcnxInterest>, Ccnx::DropReason, Ptr<const CcnxFace>);
-
- virtual void
- OutNacks (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>);
-
- virtual void
- InNacks (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>);
-
- virtual void
- DropNacks (std::string context,
- Ptr<const CcnxInterest>, Ccnx::DropReason, Ptr<const CcnxFace>);
-
- virtual void
- OutData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, bool fromCache, Ptr<const CcnxFace>);
-
- virtual void
- InData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ptr<const CcnxFace>);
-
- virtual void
- DropData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ccnx::DropReason, Ptr<const CcnxFace>);
-
-protected:
- void
- Reset ();
-
-protected:
- Stats m_packets;
- Stats m_bytes;
-};
-
-} // namespace ns3
-
-#endif // CCNX_AGGREGATE_L3_TRACER_H
diff --git a/plugins/tracers-broken/tracers/ccnx-app-tracer.cc b/plugins/tracers-broken/tracers/ccnx-app-tracer.cc
deleted file mode 100644
index 879e48e..0000000
--- a/plugins/tracers-broken/tracers/ccnx-app-tracer.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ccnx-app-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/names.h"
-
-#include "ns3/ccnx-app.h"
-#include "ns3/ccnx-face.h"
-
-#include <boost/lexical_cast.hpp>
-
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-content-object-header.h"
-
-using namespace std;
-using namespace boost;
-
-namespace ns3 {
-
-CcnxAppTracer::CcnxAppTracer (const std::string &app, Ptr<Node> node, const std::string &appId)
- : m_app (app)
- , m_appId (appId)
- , m_nodePtr (node)
-{
- m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
-
- Connect ();
-
- string name = Names::FindName (node);
- if (!name.empty ())
- {
- m_node = name;
- }
-}
-
-CcnxAppTracer::CcnxAppTracer (const std::string &app, const std::string &node, const std::string &appId)
- : m_app (app)
- , m_appId (appId)
- , m_node (node)
-{
- Connect ();
-}
-
-void
-CcnxAppTracer::Connect ()
-{
- Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/TransmittedInterests",
- MakeCallback (&CcnxAppTracer::OutInterests, this));
-
- Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/ReceivedNacks",
- MakeCallback (&CcnxAppTracer::InNacks, this));
-
- Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/ReceivedInterests",
- MakeCallback (&CcnxAppTracer::InInterests, this));
-
- Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/TransmittedDatas",
- MakeCallback (&CcnxAppTracer::OutData, this));
-
- Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$"+m_app+"/ReceivedDatas",
- MakeCallback (&CcnxAppTracer::InData, this));
-}
-
-} // namespace ns3
diff --git a/plugins/tracers-broken/tracers/ccnx-app-tracer.h b/plugins/tracers-broken/tracers/ccnx-app-tracer.h
deleted file mode 100644
index affb98b..0000000
--- a/plugins/tracers-broken/tracers/ccnx-app-tracer.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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_APP_TRACER_H
-#define CCNX_APP_TRACER_H
-
-#include "ns3/ptr.h"
-#include "ns3/simple-ref-count.h"
-#include "ns3/ccnx.h"
-
-namespace ns3 {
-
-class CcnxApp;
-
-class CcnxAppTracer : public SimpleRefCount<CcnxAppTracer>
-{
-public:
- CcnxAppTracer (const std::string &app, Ptr<Node> node, const std::string &appId = "*");
- CcnxAppTracer (const std::string &app, const std::string &node, const std::string &appId = "*");
- virtual ~CcnxAppTracer () { };
-
- void
- Connect ();
-
- virtual void
- PrintHeader (std::ostream &os) const = 0;
-
- virtual void
- Print (std::ostream &os) const = 0;
-
- virtual void
- OutInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<CcnxApp>, Ptr<CcnxFace>) = 0;
-
- virtual void
- InInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<CcnxApp>, Ptr<CcnxFace>) = 0;
-
- virtual void
- InNacks (std::string context,
- Ptr<const CcnxInterest>, Ptr<CcnxApp>, Ptr<CcnxFace>) = 0;
-
- virtual void
- OutData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ptr<CcnxApp>, Ptr<CcnxFace>) = 0;
-
- virtual void
- InData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ptr<CcnxApp>, Ptr<CcnxFace>) = 0;
-
-protected:
- std::string m_app;
- std::string m_appId;
- std::string m_node;
- Ptr<Node> m_nodePtr;
-};
-
-inline std::ostream&
-operator << (std::ostream &os, const CcnxAppTracer &tracer)
-{
- os << "# ";
- tracer.PrintHeader (os);
- os << "\n";
- tracer.Print (os);
- return os;
-}
-
-} // namespace ns3
-
-#endif // CCNX_APP_TRACER_H
diff --git a/plugins/tracers-broken/tracers/ccnx-consumer-window-tracer.cc b/plugins/tracers-broken/tracers/ccnx-consumer-window-tracer.cc
deleted file mode 100644
index eea664a..0000000
--- a/plugins/tracers-broken/tracers/ccnx-consumer-window-tracer.cc
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ccnx-consumer-window-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/names.h"
-#include "ns3/simulator.h"
-
-#include <boost/lexical_cast.hpp>
-
-using namespace std;
-using namespace boost;
-
-namespace ns3 {
-
-void
-CcnxConsumerWindowTracer::Connect ()
-{
- Config::Connect ("/NodeList/"+m_node+"/ApplicationList/"+m_appId+"/$ns3::CcnxConsumerWindow/WindowTrace",
- MakeCallback (&WindowTracer::OnWindowChange, this));
-}
-
-void
-TcpCongestionWindowTracer::Connect ()
-{
- Config::Connect ("/NodeList/"+m_node+"/$ns3::TcpL4Protocol/SocketList/*/CongestionWindow",
- MakeCallback (&WindowTracer::OnWindowChange, this));
-}
-
-
-WindowTracer::WindowTracer (std::ostream &os, Ptr<Node> node, const std::string &appId)
- : m_appId (appId)
- , m_nodePtr (node)
- , m_os (os)
-{
- m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
-
- string name = Names::FindName (node);
- if (!name.empty ())
- {
- m_nodeName = name;
- }
- else
- m_nodeName = m_node;
-}
-
-
-void
-WindowTracer::PrintHeader (std::ostream &os)
-{
- os << "Time\t"
- << "Node\t"
- << "AppId\t"
- << "Window";
-}
-
-void
-WindowTracer::OnWindowChange (std::string context,
- uint32_t oldValue, uint32_t newValue)
-{
- m_os
- << Simulator::Now ().ToDouble (Time::S) << "\t"
- << m_nodeName << "\t"
- << m_appId << "\t"
- << newValue << endl;
-}
-
-} // namespace ns3
diff --git a/plugins/tracers-broken/tracers/ccnx-consumer-window-tracer.h b/plugins/tracers-broken/tracers/ccnx-consumer-window-tracer.h
deleted file mode 100644
index c538931..0000000
--- a/plugins/tracers-broken/tracers/ccnx-consumer-window-tracer.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 UCLA
- *
- * 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_CONSUMER_WINDOW_TRACER_H
-#define CCNX_CONSUMER_WINDOW_TRACER_H
-
-#include "ns3/ptr.h"
-#include "ns3/simple-ref-count.h"
-
-namespace ns3 {
-
-class Node;
-
-class WindowTracer : public SimpleRefCount<WindowTracer>
-{
-public:
- WindowTracer (std::ostream &os, Ptr<Node> node, const std::string &appId = "*");
- virtual ~WindowTracer () { };
-
- static void
- PrintHeader (std::ostream &os);
-
- virtual void
- OnWindowChange (std::string context,
- uint32_t oldValue, uint32_t newValue);
-
-protected:
- std::string m_appId;
- std::string m_node;
- std::string m_nodeName;
- Ptr<Node> m_nodePtr;
- std::ostream& m_os;
-};
-
-class CcnxConsumerWindowTracer : public WindowTracer
-{
-public:
- CcnxConsumerWindowTracer (std::ostream &os, Ptr<Node> node, const std::string &appId = "*")
- : WindowTracer (os, node, appId)
- { Connect (); }
-
- void
- Connect ();
-};
-
-class TcpCongestionWindowTracer : public WindowTracer
-{
-public:
- TcpCongestionWindowTracer (std::ostream &os, Ptr<Node> node, const std::string &appId = "*")
- : WindowTracer (os, node, appId)
- { Connect (); }
-
- void
- Connect ();
-};
-
-
-} // namespace ns3
-
-#endif // CCNX_CONSUMER_WINDOW_TRACER_H
diff --git a/plugins/tracers-broken/tracers/ccnx-l3-tracer.cc b/plugins/tracers-broken/tracers/ccnx-l3-tracer.cc
deleted file mode 100644
index 415105b..0000000
--- a/plugins/tracers-broken/tracers/ccnx-l3-tracer.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ccnx-l3-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/names.h"
-#include "ns3/callback.h"
-#include "ns3/ccnx-app.h"
-#include "ns3/ccnx-face.h"
-
-#include <boost/lexical_cast.hpp>
-
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-content-object-header.h"
-
-using namespace std;
-
-namespace ns3 {
-
-CcnxL3Tracer::CcnxL3Tracer (Ptr<Node> node)
-: m_nodePtr (node)
-{
- m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
-
- Connect ();
-
- string name = Names::FindName (node);
- if (!name.empty ())
- {
- m_node = name;
- }
-}
-
-CcnxL3Tracer::CcnxL3Tracer (const std::string &node)
-: m_node (node)
-{
- Connect ();
-}
-
-void
-CcnxL3Tracer::Connect ()
-{
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/ForwardingStrategy/OutInterests",
- MakeCallback (&CcnxL3Tracer::OutInterests, this));
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/InInterests",
- MakeCallback (&CcnxL3Tracer::InInterests, this));
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/DropInterests",
- MakeCallback (&CcnxL3Tracer::DropInterests, this));
-
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/OutNacks",
- MakeCallback (&CcnxL3Tracer::OutNacks, this));
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/InNacks",
- MakeCallback (&CcnxL3Tracer::InNacks, this));
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/DropNacks",
- MakeCallback (&CcnxL3Tracer::DropNacks, this));
-
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/OutData",
- MakeCallback (&CcnxL3Tracer::OutData, this));
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/InData",
- MakeCallback (&CcnxL3Tracer::InData, this));
- Config::Connect ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/DropData",
- MakeCallback (&CcnxL3Tracer::DropData, this));
-}
-
-} // namespace ns3
diff --git a/plugins/tracers-broken/tracers/ccnx-l3-tracer.h b/plugins/tracers-broken/tracers/ccnx-l3-tracer.h
deleted file mode 100644
index ae4cea1..0000000
--- a/plugins/tracers-broken/tracers/ccnx-l3-tracer.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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_L3_TRACER_H
-#define CCNX_L3_TRACER_H
-
-#include "ns3/ptr.h"
-#include "ns3/simple-ref-count.h"
-#include "ns3/ccnx.h"
-
-namespace ns3 {
-
-class Node;
-
-class CcnxL3Tracer : public SimpleRefCount<CcnxL3Tracer>
-{
-public:
- CcnxL3Tracer (Ptr<Node> node);
- CcnxL3Tracer (const std::string &node);
- virtual ~CcnxL3Tracer () { };
-
- void
- Connect ();
-
- virtual void
- PrintHeader (std::ostream &os) const = 0;
-
- virtual void
- Print (std::ostream &os) const = 0;
-
- virtual void
- OutInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>) = 0;
-
- virtual void
- InInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>) = 0;
-
- virtual void
- DropInterests (std::string context,
- Ptr<const CcnxInterest>, Ccnx::DropReason, Ptr<const CcnxFace>) = 0;
-
- virtual void
- OutNacks (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>) = 0;
-
- virtual void
- InNacks (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>) = 0;
-
- virtual void
- DropNacks (std::string context,
- Ptr<const CcnxInterest>, Ccnx::DropReason, Ptr<const CcnxFace>) = 0;
-
-
- virtual void
- OutData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, bool fromCache, Ptr<const CcnxFace>) = 0;
-
- virtual void
- InData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ptr<const CcnxFace>) = 0;
-
- virtual void
- DropData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ccnx::DropReason, Ptr<const CcnxFace>) = 0;
-
-protected:
- std::string m_node;
- Ptr<Node> m_nodePtr;
-
- struct Stats
- {
- void Reset ();
-
- uint64_t m_inInterests;
- uint64_t m_outInterests;
- uint64_t m_dropInterests;
- uint64_t m_inNacks;
- uint64_t m_outNacks;
- uint64_t m_dropNacks;
- uint64_t m_inData;
- uint64_t m_outData;
- uint64_t m_dropData;
- };
-};
-
-inline std::ostream&
-operator << (std::ostream &os, const CcnxL3Tracer &tracer)
-{
- os << "# ";
- tracer.PrintHeader (os);
- os << "\n";
- tracer.Print (os);
- return os;
-}
-
-} // namespace ns3
-
-#endif // CCNX_L3_TRACER_H
diff --git a/plugins/tracers-broken/tracers/ccnx-path-weight-tracer.cc b/plugins/tracers-broken/tracers/ccnx-path-weight-tracer.cc
deleted file mode 100644
index b2685bd..0000000
--- a/plugins/tracers-broken/tracers/ccnx-path-weight-tracer.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ccnx-path-weight-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/names.h"
-#include "ns3/callback.h"
-#include "ns3/ccnx-app.h"
-#include "ns3/ccnx-face.h"
-#include "ns3/boolean.h"
-#include "ns3/simulator.h"
-
-#include <boost/lexical_cast.hpp>
-#include <boost/foreach.hpp>
-
-using namespace std;
-
-namespace ns3 {
-
-CcnxPathWeightTracer::CcnxPathWeightTracer (std::ostream &os, Ptr<Node> node)
- : m_os (os)
- , m_nodePtr (node)
-{
- m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
-
- Connect ();
-
- string name = Names::FindName (node);
- if (!name.empty ())
- {
- m_node = name;
- }
-}
-
-void
-CcnxPathWeightTracer::Connect ()
-{
- Config::Set ("/NodeList/"+m_node+"/$ns3::CcnxL3Protocol/FaceList/*/MetricTagging",
- BooleanValue (true));
-
- Config::Connect ("/NodeList/"+m_node+"/ApplicationList/*/PathWeightsTrace",
- MakeCallback (&CcnxPathWeightTracer::InLocalFace, this));
-}
-
-void
-CcnxPathWeightTracer::PrintHeader (std::ostream &os)
-{
- os << "Time\t"
- << "Src\t"
- << "Dst\t"
- << "SeqNo\t"
- << "Weight";
-}
-
-void
-CcnxPathWeightTracer::InLocalFace (std::string context,
- Ptr<Node> src, Ptr<Node> dst, uint32_t seqno, uint32_t weight)
-{
- std::string srcName = Names::FindName (src);
- std::string dstName = Names::FindName (dst);
- if (srcName == "") srcName = boost::lexical_cast<std::string> (src->GetId ());
- if (dstName == "") srcName = boost::lexical_cast<std::string> (dst->GetId ());
- // std::cout << "Path weights from " << Names::FindName (src) << " to "<< Names::FindName (dst) <<" : " << weight << "\n";
-
- m_os << Simulator::Now ().ToDouble (Time::S) << "\t"
- << srcName << "\t"
- << dstName << "\t"
- << seqno << "\t"
- << weight << "\n";
-}
-
-} // namespace ns3
diff --git a/plugins/tracers-broken/tracers/ccnx-path-weight-tracer.h b/plugins/tracers-broken/tracers/ccnx-path-weight-tracer.h
deleted file mode 100644
index 303197d..0000000
--- a/plugins/tracers-broken/tracers/ccnx-path-weight-tracer.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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_PATH_WEIGHT_TRACER_H
-#define CCNX_PATH_WEIGHT_TRACER_H
-
-#include "ns3/ptr.h"
-#include "ns3/simple-ref-count.h"
-#include "ns3/weights-path-stretch-tag.h"
-#include <list>
-
-namespace ns3 {
-
-class Node;
-class Packet;
-class CcnxApp;
-
-class CcnxPathWeightTracer : public SimpleRefCount<CcnxPathWeightTracer>
-{
-public:
- CcnxPathWeightTracer (std::ostream &os, Ptr<Node> node);
- virtual ~CcnxPathWeightTracer () { };
-
- void
- Connect ();
-
- static void
- PrintHeader (std::ostream &os);
-
- /**
- * \brief Process packet weight upon reception of packet on a local face
- */
- virtual void
- InLocalFace (std::string context,
- Ptr<Node> src, Ptr<Node> dst, uint32_t seqno, uint32_t weight);
-
-protected:
- std::ostream &m_os;
- std::string m_node;
- Ptr<Node> m_nodePtr;
-};
-
-} // namespace ns3
-
-#endif // CCNX_PATH_WEIGHT_TRACER_H
diff --git a/plugins/tracers-broken/tracers/ccnx-rate-l3-tracer.cc b/plugins/tracers-broken/tracers/ccnx-rate-l3-tracer.cc
deleted file mode 100644
index 9d79d72..0000000
--- a/plugins/tracers-broken/tracers/ccnx-rate-l3-tracer.cc
+++ /dev/null
@@ -1,213 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ccnx-rate-l3-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/simulator.h"
-
-#include "ns3/ccnx-app.h"
-#include "ns3/ccnx-face.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-content-object-header.h"
-
-namespace ns3 {
-
-CcnxRateL3Tracer::CcnxRateL3Tracer (std::ostream &os, Ptr<Node> node)
- : CcnxL3Tracer (node)
- , m_os (os)
-{
- SetAveragingPeriod (Seconds (1.0));
-}
-
-CcnxRateL3Tracer::CcnxRateL3Tracer (std::ostream &os, const std::string &node)
- : CcnxL3Tracer (node)
- , m_os (os)
-{
- SetAveragingPeriod (Seconds (1.0));
-}
-
-CcnxRateL3Tracer::~CcnxRateL3Tracer ()
-{
- m_printEvent.Cancel ();
-}
-
-void
-CcnxRateL3Tracer::SetAveragingPeriod (const Time &period)
-{
- m_period = period;
- m_printEvent.Cancel ();
- m_printEvent = Simulator::Schedule (m_period, &CcnxRateL3Tracer::PeriodicPrinter, this);
-}
-
-void
-CcnxRateL3Tracer::PeriodicPrinter ()
-{
- Print (m_os);
- Reset ();
-
- m_printEvent = Simulator::Schedule (m_period, &CcnxRateL3Tracer::PeriodicPrinter, this);
-}
-
-void
-CcnxRateL3Tracer::PrintHeader (std::ostream &os) const
-{
- os << "Time" << "\t"
-
- << "Node" << "\t"
- << "FaceId" << "\t"
- << "FaceDescr" << "\t"
-
- << "Type" << "\t"
- << "Packets" << "\t"
- << "Kilobytes";
-}
-
-void
-CcnxRateL3Tracer::Reset ()
-{
- for (std::map<Ptr<const CcnxFace>, boost::tuple<Stats, Stats, Stats, Stats> >::iterator stats = m_stats.begin ();
- stats != m_stats.end ();
- stats++)
- {
- stats->second.get<0> ().Reset ();
- stats->second.get<1> ().Reset ();
- }
-}
-
-const double alpha = 0.8;
-
-#define STATS(INDEX) stats->second.get<INDEX> ()
-#define RATE(INDEX, fieldName) STATS(INDEX).fieldName / m_period.ToDouble (Time::S)
-
-#define PRINTER(printName, fieldName) \
-STATS(2).fieldName = /*new value*/alpha * RATE(0, fieldName) + /*old value*/(1-alpha) * STATS(2).fieldName; \
- STATS(3).fieldName = /*new value*/alpha * RATE(1, fieldName) / 1024.0 + /*old value*/(1-alpha) * STATS(3).fieldName; \
- \
-os << time.ToDouble (Time::S) << "\t" \
- << m_node << "\t" \
- << stats->first->GetId () << "\t" \
- << *stats->first << "\t" \
- << printName << "\t" \
- << STATS(2).fieldName << "\t" \
- << STATS(3).fieldName << "\n";
-
-void
-CcnxRateL3Tracer::Print (std::ostream &os) const
-{
- for (std::map<Ptr<const CcnxFace>, boost::tuple<Stats, Stats, Stats, Stats> >::iterator stats = m_stats.begin ();
- stats != m_stats.end ();
- stats++)
- {
- Time time = Simulator::Now ();
-
- PRINTER ("InInterests", m_inInterests);
- PRINTER ("OutInterests", m_outInterests);
- PRINTER ("DropInterests", m_dropInterests);
-
- PRINTER ("InNacks", m_inNacks);
- PRINTER ("OutNacks", m_outNacks);
- PRINTER ("DropNacks", m_dropNacks);
-
- PRINTER ("InData", m_inData);
- PRINTER ("OutData", m_outData);
- PRINTER ("DropData", m_dropData);
- }
-}
-
-
-void
-CcnxRateL3Tracer::OutInterests (std::string context,
- Ptr<const CcnxInterest> header, Ptr<const CcnxFace> face)
-{
- m_stats[face].get<0> ().m_outInterests ++;
- m_stats[face].get<1> ().m_outInterests += header->GetSerializedSize ();
-}
-
-void
-CcnxRateL3Tracer::InInterests (std::string context,
- Ptr<const CcnxInterest> header, Ptr<const CcnxFace> face)
-{
- m_stats[face].get<0> ().m_inInterests ++;
- m_stats[face].get<1> ().m_inInterests += header->GetSerializedSize ();
-}
-
-void
-CcnxRateL3Tracer::DropInterests (std::string context,
- Ptr<const CcnxInterest> header, Ccnx::DropReason, Ptr<const CcnxFace> face)
-{
- m_stats[face].get<0> ().m_dropInterests ++;
- m_stats[face].get<1> ().m_dropInterests += header->GetSerializedSize ();
-}
-
-void
-CcnxRateL3Tracer::OutNacks (std::string context,
- Ptr<const CcnxInterest> header, Ptr<const CcnxFace> face)
-{
- m_stats[face].get<0> ().m_outNacks ++;
- m_stats[face].get<1> ().m_outNacks += header->GetSerializedSize ();
-}
-
-void
-CcnxRateL3Tracer::InNacks (std::string context,
- Ptr<const CcnxInterest> header, Ptr<const CcnxFace> face)
-{
- m_stats[face].get<0> ().m_inNacks ++;
- m_stats[face].get<1> ().m_inNacks += header->GetSerializedSize ();
-}
-
-void
-CcnxRateL3Tracer::DropNacks (std::string context,
- Ptr<const CcnxInterest> header, Ccnx::DropReason, Ptr<const CcnxFace> face)
-{
- m_stats[face].get<0> ().m_dropNacks ++;
- m_stats[face].get<1> ().m_dropNacks += header->GetSerializedSize ();
-}
-
-void
-CcnxRateL3Tracer::OutData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet> payload,
- bool fromCache, Ptr<const CcnxFace> face)
-{
- m_stats[face].get<0> ().m_inData ++;
- m_stats[face].get<1> ().m_inData += header->GetSerializedSize () + payload->GetSize ();
-}
-
-void
-CcnxRateL3Tracer::InData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet> payload,
- Ptr<const CcnxFace> face)
-{
- m_stats[face].get<0> ().m_outData ++;
- m_stats[face].get<1> ().m_outData += header->GetSerializedSize () + payload->GetSize ();
-}
-
-void
-CcnxRateL3Tracer::DropData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet> payload,
- Ccnx::DropReason, Ptr<const CcnxFace> face)
-{
- m_stats[face].get<0> ().m_dropData ++;
- m_stats[face].get<1> ().m_dropData += header->GetSerializedSize () + payload->GetSize ();
-}
-
-} // namespace ns3
diff --git a/plugins/tracers-broken/tracers/ccnx-rate-l3-tracer.h b/plugins/tracers-broken/tracers/ccnx-rate-l3-tracer.h
deleted file mode 100644
index a93a305..0000000
--- a/plugins/tracers-broken/tracers/ccnx-rate-l3-tracer.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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_RATE_L3_TRACER_H
-#define CCNX_RATE_L3_TRACER_H
-
-#include "ns3/ccnx-l3-tracer.h"
-
-#include "ns3/nstime.h"
-#include "ns3/event-id.h"
-
-#include <boost/tuple/tuple.hpp>
-#include <map>
-
-namespace ns3 {
-
-/**
- * @ingroup ccnx
- * @brief CCNx network-layer rate tracer
- */
-class CcnxRateL3Tracer : public CcnxL3Tracer
-{
-public:
- /**
- * @brief Network layer tracer constructor
- */
- CcnxRateL3Tracer (std::ostream &os, Ptr<Node> node);
- CcnxRateL3Tracer (std::ostream &os, const std::string &node);
- virtual ~CcnxRateL3Tracer ();
-
- void
- SetAveragingPeriod (const Time &period);
-
- virtual void
- PrintHeader (std::ostream &os) const;
-
- virtual void
- Print (std::ostream &os) const;
-
- virtual void
- OutInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>);
-
- virtual void
- InInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>);
-
- virtual void
- DropInterests (std::string context,
- Ptr<const CcnxInterest>, Ccnx::DropReason, Ptr<const CcnxFace>);
-
- virtual void
- OutNacks (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>);
-
- virtual void
- InNacks (std::string context,
- Ptr<const CcnxInterest>, Ptr<const CcnxFace>);
-
- virtual void
- DropNacks (std::string context,
- Ptr<const CcnxInterest>, Ccnx::DropReason, Ptr<const CcnxFace>);
-
- virtual void
- OutData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, bool fromCache, Ptr<const CcnxFace>);
-
- virtual void
- InData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ptr<const CcnxFace>);
-
- virtual void
- DropData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ccnx::DropReason, Ptr<const CcnxFace>);
-
-private:
- void
- PeriodicPrinter ();
-
- void
- Reset ();
-
-private:
- std::ostream& m_os;
- Time m_period;
- EventId m_printEvent;
-
- mutable std::map<Ptr<const CcnxFace>, boost::tuple<Stats, Stats, Stats, Stats> > m_stats;
-};
-
-} // namespace ns3
-
-#endif // CCNX_RATE_L3_TRACER_H
diff --git a/plugins/tracers-broken/tracers/ccnx-seqs-app-tracer.cc b/plugins/tracers-broken/tracers/ccnx-seqs-app-tracer.cc
deleted file mode 100644
index f974976..0000000
--- a/plugins/tracers-broken/tracers/ccnx-seqs-app-tracer.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ccnx-seqs-app-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/simulator.h"
-
-#include "ns3/ccnx-app.h"
-#include "ns3/ccnx-face.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-content-object-header.h"
-
-namespace ns3 {
-
-CcnxSeqsAppTracer::CcnxSeqsAppTracer (std::ostream &os, const std::string &app, Ptr<Node> node, const std::string &appId)
- : CcnxAppTracer (app, node, appId)
- , m_os (os)
-{
-}
-
-CcnxSeqsAppTracer::CcnxSeqsAppTracer (std::ostream &os, const std::string &app, const std::string &node, const std::string &appId)
- : CcnxAppTracer (app, node, appId)
- , m_os (os)
-{
-}
-
-void
-CcnxSeqsAppTracer::Reset ()
-{
-}
-
-void
-CcnxSeqsAppTracer::PrintHeader (std::ostream &os) const
-{
- os << "Time\t"
- << "Node\t"
- << "AppName\t"
- << "AppId\t"
- << "Type\t"
- << "SeqNo";
-}
-
-void
-CcnxSeqsAppTracer::Print (std::ostream &os) const
-{
-}
-
-#define PRINTER(type) \
- m_os \
- << Simulator::Now ().ToDouble (Time::S) << "\t" \
- << m_node << "\t" \
- << m_app << "\t" \
- << m_appId << "\t" \
- << type << "\t" \
- << header->GetName ().GetLastComponent () << std::endl;
-
-void
-CcnxSeqsAppTracer::OutInterests (std::string context,
- Ptr<const CcnxInterest> header, Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- PRINTER ("OutInterest");
-}
-
-void
-CcnxSeqsAppTracer::OutData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet>,
- Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- PRINTER ("OutData");
-}
-
-void
-CcnxSeqsAppTracer::InInterests (std::string context,
- Ptr<const CcnxInterest> header,
- Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- PRINTER ("InInterest");
-}
-
-void
-CcnxSeqsAppTracer::InNacks (std::string context,
- Ptr<const CcnxInterest> header,
- Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- PRINTER ("InNacks");
-}
-
-void
-CcnxSeqsAppTracer::InData (std::string context,
- Ptr<const CcnxData> header, Ptr<const Packet>,
- Ptr<CcnxApp>, Ptr<CcnxFace>)
-{
- PRINTER ("InData");
-}
-
-} // namespace ns3
diff --git a/plugins/tracers-broken/tracers/ccnx-seqs-app-tracer.h b/plugins/tracers-broken/tracers/ccnx-seqs-app-tracer.h
deleted file mode 100644
index 404c7a2..0000000
--- a/plugins/tracers-broken/tracers/ccnx-seqs-app-tracer.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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_SEQS_APP_TRACER_H
-#define CCNX_SEQS_APP_TRACER_H
-
-#include "ns3/ccnx-app-tracer.h"
-
-namespace ns3 {
-
-class CcnxSeqsAppTracer : public CcnxAppTracer
-{
-public:
- CcnxSeqsAppTracer (std::ostream &os, const std::string &app, Ptr<Node> node, const std::string &appId = "*");
- CcnxSeqsAppTracer (std::ostream &os, const std::string &app, const std::string &node, const std::string &appId = "*");
- virtual ~CcnxSeqsAppTracer () { };
-
- virtual void
- PrintHeader (std::ostream &os) const;
-
- virtual void
- Print (std::ostream &os) const;
-
- virtual void
- OutInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
- virtual void
- InInterests (std::string context,
- Ptr<const CcnxInterest>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
- virtual void
- InNacks (std::string context,
- Ptr<const CcnxInterest>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
- virtual void
- OutData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
- virtual void
- InData (std::string context,
- Ptr<const CcnxData>, Ptr<const Packet>, Ptr<CcnxApp>, Ptr<CcnxFace>);
-
-protected:
- void
- Reset ();
-
-protected:
- std::ostream& m_os;
-};
-
-} // namespace ns3
-
-#endif // CCNX_AGGREGATE_APP_TRACER_H
diff --git a/plugins/tracers-broken/weights-path-stretch-tag.cc b/plugins/tracers-broken/weights-path-stretch-tag.cc
deleted file mode 100644
index fe3e41c..0000000
--- a/plugins/tracers-broken/weights-path-stretch-tag.cc
+++ /dev/null
@@ -1,120 +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>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "weights-path-stretch-tag.h"
-#include "ns3/node.h"
-#include "ns3/names.h"
-
-namespace ns3 {
-
-WeightsPathStretchTag::WeightsPathStretchTag ()
-{
-}
-
-void
-WeightsPathStretchTag::AddPathInfo (Ptr<Node> node, uint32_t weight)
-{
- m_infos.push_back (NodeWeightPair (node, weight));
-}
-
-
-TypeId WeightsPathStretchTag::GetTypeId ()
-{
- static TypeId tid = TypeId("ns3::WeightsPathStretchTag")
- .SetParent<Tag>()
- .AddConstructor<WeightsPathStretchTag>()
- ;
- return tid;
-}
-
-// TypeId
-// WeightsPathStretchTag::GetInstanceTypeId () const
-// {
-// return GetTypeId ();
-// }
-
-uint64_t
-WeightsPathStretchTag::GetTotalWeight () const
-{
- uint64_t total = 0;
- for (std::list<NodeWeightPair>::const_iterator info = m_infos.begin (); info != m_infos.end (); info++)
- {
- total += info->weight;
- }
- return total;
-}
-
-Ptr<Node>
-WeightsPathStretchTag::GetSourceNode () const
-{
- NS_ASSERT (m_infos.size () > 0);
- return m_infos.front ().node;
-}
-
-Ptr<Node>
-WeightsPathStretchTag::GetDestinationNode () const
-{
- NS_ASSERT (m_infos.size () > 0);
- return m_infos.back ().node;
-}
-
-uint32_t WeightsPathStretchTag::GetSerializedSize (void) const
-{
- return 0;
- // return sizeof (GetPointer (m_value.node)) + sizeof (m_value.weight);
-}
-
-void WeightsPathStretchTag::Serialize (TagBuffer i) const
-{
- NS_FATAL_ERROR ("Serialization is not supported for this tag");
- // m_value.node->Ref ();
- // i.WriteU64 (reinterpret_cast<uint64_t> (GetPointer (m_value.node)));
- // i.WriteU32 (m_value.weight);
-}
-
-void WeightsPathStretchTag::Deserialize (TagBuffer i)
-{
- NS_FATAL_ERROR ("Deserialization is not supported for this tag");
- // m_value.node = Ptr<Node> (reinterpret_cast<Node*> (i.ReadU64 ()), false);
- // m_value.weight = i.ReadU32 ();
-}
-
-void WeightsPathStretchTag::Print (std::ostream &os) const
-{
- for (std::list<NodeWeightPair>::const_iterator info = m_infos.begin ();
- info != m_infos.end ();
- info ++)
- {
- if (info != m_infos.begin ()) os << ",";
- NS_ASSERT (info->node != 0);
-
- os << info->node->GetId () << "(" << Names::FindName (info->node) << ")";
- // std::string name = Names::FindName (info->node);
- // if (!name.empty ())
- // os << name;
- // else
- // os << info->node->GetId ();
- os << ":" << info->weight;
- }
-}
-
-} // namespace ns3
-
diff --git a/plugins/tracers-broken/weights-path-stretch-tag.h b/plugins/tracers-broken/weights-path-stretch-tag.h
deleted file mode 100644
index 644871f..0000000
--- a/plugins/tracers-broken/weights-path-stretch-tag.h
+++ /dev/null
@@ -1,118 +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 "ns3/tag.h"
-
-#ifndef PATH_STRETCH_TAG_H
-#define PATH_STRETCH_TAG_H
-
-namespace ns3 {
-
-class Node;
-class Packet;
-
-//#define PATH_SPLICING_MAX_N_HOPS 38
-//#define PATH_SPLICING_MAX_SLICE_INDEX 16
-
-class WeightsPathStretchTag : public Tag
-{
-public:
- struct NodeWeightPair
- {
- NodeWeightPair () : node (0), weight (0) { }
- NodeWeightPair (Ptr<Node> _node, uint32_t _weight) : node (_node), weight (_weight) { }
-
- Ptr<Node> node;
- uint32_t weight;
- };
-
- static TypeId
- GetTypeId ();
-
- WeightsPathStretchTag ();
- virtual ~WeightsPathStretchTag () { };
-
- void
- AddPathInfo (Ptr<Node> node, uint32_t weight);
-
- uint64_t
- GetTotalWeight () const;
-
- Ptr<Node>
- GetSourceNode () const;
-
- Ptr<Node>
- GetDestinationNode () const;
-
- const std::list<NodeWeightPair> &
- GetInfos () const
- { return m_infos; }
-
- // from Tag
- virtual uint32_t
- GetSerializedSize (void) const;
-
- virtual void
- Serialize (TagBuffer i) const;
-
- virtual void
- Deserialize (TagBuffer i);
-
- virtual void
- Print (std::ostream &os) const;
-
-private:
- std::list<NodeWeightPair> m_infos;
-};
-
-// class DelaysPathStretchTag : public Tag
-// {
-// public:
-// DelaysPathStretchTag();
-
-// static TypeId GetTypeId(void);
-// virtual TypeId GetInstanceTypeId(void) const;
-
-// virtual uint32_t GetSerializedSize(void) const;
-// virtual void Serialize(TagBuffer i) const;
-// virtual void Deserialize(TagBuffer i);
-// virtual void Print(std::ostream &os) const;
-
-// int GetNHops();
-// void AddNewHop(double delay);
-// int GetCurrentHop();
-// void RemoveCurrentHop();
-// //void RandomizeTags(UniformVariable &rand, uint32_t max);
-
-// private:
-// //PathSplicingPathTag(const PathSplicingPathTag &o);
-// //PathSplicingPathTag &operator = (const PathSplicingPathTag &o);
-
-// //bool operator == (PathSplicingPathTag const &o) const;
-
-// private:
-// std::list<double> m_delays;
-// };
-
-
-} // namespace ns3
-
-
-#endif /* PATH_STRETCH_TAG_H */
diff --git a/test/ndnSIM-api.cc b/test/ndnSIM-api.cc
deleted file mode 100644
index e1bd2aa..0000000
--- a/test/ndnSIM-api.cc
+++ /dev/null
@@ -1,162 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU v3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndnSIM-api.h"
-#include "ns3/core-module.h"
-#include "ns3/ndnSIM-module.h"
-#include "ns3/point-to-point-module.h"
-
-#include <boost/lexical_cast.hpp>
-
-NS_LOG_COMPONENT_DEFINE ("ndn.ApiTest");
-
-namespace ns3
-{
-
-class ApiTestClient : public Application
-{
-public:
- static TypeId
- GetTypeId ()
- {
- static TypeId tid = TypeId ("ns3::ndn::test::ApiTestClient")
- .SetParent<Application> ()
- .AddConstructor<ApiTestClient> ()
- ;
-
- return tid;
- }
-
- ApiTestClient ()
- : datas (0)
- , timeouts (0)
- {
- }
-
-protected:
- void
- StartApplication ()
- {
- m_face = Create<ndn::ApiFace> (GetNode ());
-
- Simulator::Schedule (Seconds (0.1), &ApiTestClient::SendPacket, this, std::string ("/1"));
- Simulator::Schedule (Seconds (5.0), &ApiTestClient::SendPacket, this, std::string ("/2"));
- }
-
- void
- StopApplication ()
- {
- m_face->Shutdown ();
- m_face = 0;
- }
-
-private:
- void
- GotData (Ptr<const ndn::Interest>, Ptr<const ndn::Data>)
- {
- datas++;
- }
-
- void
- GotTimeout (Ptr<const ndn::Interest>)
- {
- timeouts++;
- }
-
- void
- SendPacket (const std::string &prefix)
- {
- Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
- interest->SetName (Create<ndn::Name> (prefix));
- interest->SetInterestLifetime (Seconds (0.5));
-
- m_face->ExpressInterest (interest,
- MakeCallback (&ApiTestClient::GotData, this),
- MakeCallback (&ApiTestClient::GotTimeout, this));
- }
-
-public:
- uint32_t datas;
- uint32_t timeouts;
-
-private:
- Ptr<ndn::ApiFace> m_face;
-};
-
-NS_OBJECT_ENSURE_REGISTERED (ApiTestClient);
-
-void
-ApiTest::Check0 (Ptr<Application> app)
-{
- NS_TEST_ASSERT_MSG_EQ (DynamicCast<ApiTestClient> (app)->datas, 0, "");
- NS_TEST_ASSERT_MSG_EQ (DynamicCast<ApiTestClient> (app)->timeouts, 0, "");
-}
-
-void
-ApiTest::Check1 (Ptr<Application> app)
-{
- NS_TEST_ASSERT_MSG_EQ (DynamicCast<ApiTestClient> (app)->datas, 1, "");
- NS_TEST_ASSERT_MSG_EQ (DynamicCast<ApiTestClient> (app)->timeouts, 0, "");
-}
-
-void
-ApiTest::Check2 (Ptr<Application> app)
-{
- NS_TEST_ASSERT_MSG_EQ (DynamicCast<ApiTestClient> (app)->datas, 1, "");
- NS_TEST_ASSERT_MSG_EQ (DynamicCast<ApiTestClient> (app)->timeouts, 1, "");
-}
-
-
-void
-ApiTest::DoRun ()
-{
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
-
- // Creating nodes
- NodeContainer nodes;
- nodes.Create (3);
-
- // Connecting nodes using two links
- PointToPointHelper p2p;
- p2p.Install (nodes.Get (0), nodes.Get (1));
- p2p.Install (nodes.Get (1), nodes.Get (2));
-
- // Install NDN stack on all nodes
- ndn::StackHelper ndnHelper;
- ndnHelper.SetDefaultRoutes (true);
- ndnHelper.InstallAll ();
-
- // Installing applications
-
- // Consumer
- ndn::AppHelper consumerHelper ("ns3::ndn::test::ApiTestClient");
- ApplicationContainer apps = consumerHelper.Install (nodes.Get (0)); // first node
-
- // Producer
- ndn::AppHelper producerHelper ("ns3::ndn::Producer");
- // Producer will reply to all requests starting with /prefix
- producerHelper.SetPrefix ("/");
- producerHelper.SetAttribute ("Postfix", StringValue ("/unique/postfix"));
- producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
- producerHelper.Install (nodes.Get (2)).Stop (Seconds (4.0)); // last node
-
- Simulator::Schedule (Seconds (0.0001), &ApiTest::Check0, this, apps.Get (0));
- Simulator::Schedule (Seconds (0.2000), &ApiTest::Check1, this, apps.Get (0));
- Simulator::Schedule (Seconds (5.6100), &ApiTest::Check2, this, apps.Get (0));
-
- Simulator::Stop (Seconds (20.0));
-
- Simulator::Run ();
- Simulator::Destroy ();
-}
-
-}
diff --git a/test/ndnSIM-api.h b/test/ndnSIM-api.h
deleted file mode 100644
index 7df0112..0000000
--- a/test/ndnSIM-api.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- * Alexander Afanasyev
- *
- * GNU v3.0 license, See the LICENSE file for more information
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDNSIM_TEST_API_H
-#define NDNSIM_TEST_API_H
-
-#include "ns3/test.h"
-#include "ns3/ptr.h"
-
-namespace ns3 {
-
-class Application;
-
-namespace ndn {
-}
-
-class ApiTest : public TestCase
-{
-public:
- ApiTest ()
- : TestCase ("API test")
- {
- }
-
-private:
- virtual void DoRun ();
-
- void Check0 (Ptr<Application> app);
- void Check1 (Ptr<Application> app);
- void Check2 (Ptr<Application> app);
-};
-
-}
-
-#endif // NDNSIM_TEST_API_H
diff --git a/test/ndnSIM-fib-entry.cc b/test/ndnSIM-fib-entry.cc
deleted file mode 100644
index c57cf4d..0000000
--- a/test/ndnSIM-fib-entry.cc
+++ /dev/null
@@ -1,152 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011,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 "ndnSIM-fib-entry.h"
-#include "ns3/core-module.h"
-#include "ns3/ndnSIM-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/node-list.h"
-
-#include <boost/lexical_cast.hpp>
-#include <boost/foreach.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/make_shared.hpp>
-
-#include "ns3/ndn-fib-entry.h"
-
-NS_LOG_COMPONENT_DEFINE ("ndn.FibEntryTest");
-
-namespace ns3
-{
-
-class FibEntryTestApp : public ndn::App
-{
-protected:
- void
- StartApplication ()
- {
- ndn::App::StartApplication ();
-
- // add default route
- Ptr<ndn::fib::Entry> fibEntry = GetNode ()->GetObject<ndn::Fib> ()->Add (ndn::Name ("/"), m_face, 0);
- fibEntry->UpdateStatus (m_face, ndn::fib::FaceMetric::NDN_FIB_GREEN);
-
- Simulator::Schedule (Seconds (0.5), &FibEntryTestApp::SendPacket, this, std::string("/1"), 1);
- Simulator::Schedule (Seconds (4.0), &FibEntryTestApp::SendPacket, this, std::string("/2"), 1);
- }
-
- void
- StopApplication ()
- {
- ndn::App::StopApplication ();
- }
-
-private:
- void
- SendPacket (const std::string &prefix, uint32_t nonce)
- {
- Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
- interest->SetName (Create<ndn::Name> (prefix));
- interest->SetNonce (nonce);
- interest->SetInterestLifetime (Seconds (0.5));
-
- m_face->ReceiveInterest (interest);
- }
-};
-
-struct StatusRecorder
-{
- StatusRecorder (Ptr<Node> node, Ptr<ndn::fib::Entry> fibEntry, Ptr<ndn::Face> face)
- : m_node (node)
- , m_fibEntry (fibEntry)
- , m_face (face)
- {
- count = 0;
- }
-
- void
- StatusChange (ndn::fib::FaceMetric::Status oldStatus, ndn::fib::FaceMetric::Status newStatus)
- {
- count ++;
- // std::cout << Simulator::Now ().ToDouble (Time::S) << "s\tnode " << m_node->GetId () << " has changed fibEntry " << m_fibEntry->GetPrefix () << " face " << *m_face << " to " << newStatus << " from " << oldStatus << std::endl;
- }
-
- int count;
-
-private:
- Ptr<Node> m_node;
- Ptr<ndn::fib::Entry> m_fibEntry;
- Ptr<ndn::Face> m_face;
-};
-
-void
-FibEntryTest::DoRun ()
-{
- Ptr<Node> node = CreateObject<Node> ();
- Ptr<Node> nodeSink = CreateObject<Node> ();
- PointToPointHelper p2p;
- p2p.Install (node, nodeSink);
-
- ndn::StackHelper ndn;
- ndn.SetForwardingStrategy ("ns3::ndn::fw::BestRoute");
- ndn.Install (node);
- ndn.Install (nodeSink);
-
- ndn::StackHelper::AddRoute (node, "/", 0, 0);
-
- Ptr<Application> app1 = CreateObject<FibEntryTestApp> ();
- node->AddApplication (app1);
-
- ndn::AppHelper sinkHelper ("ns3::ndn::Producer");
- sinkHelper.SetPrefix ("/");
- sinkHelper.Install (nodeSink)
- .Stop (Seconds (2.0));
-
- std::list< boost::shared_ptr<StatusRecorder> > recorders;
-
- for (NodeList::Iterator anode = NodeList::Begin ();
- anode != NodeList::End ();
- anode ++)
- {
- Ptr<ndn::Fib> fib = (*anode)->GetObject<ndn::Fib> ();
-
- for (Ptr<ndn::fib::Entry> entry = fib->Begin ();
- entry != fib->End ();
- entry = fib->Next (entry))
- {
- BOOST_FOREACH (const ndn::fib::FaceMetric & faceMetric, entry->m_faces)
- {
- boost::shared_ptr<StatusRecorder> recorder = boost::make_shared<StatusRecorder> (*anode, entry, faceMetric.GetFace ());
- recorders.push_back (recorder);
-
- const_cast<ndn::fib::FaceMetric &> (faceMetric).GetStatusTrace ().ConnectWithoutContext (MakeCallback (&StatusRecorder::StatusChange, recorder.get ()));
- }
- }
- }
-
- Simulator::Stop (Seconds (10.0));
- Simulator::Run ();
- Simulator::Destroy ();
-
- NS_TEST_ASSERT_MSG_EQ (recorders.size (), 1, "only one recorder should be: only one real FIB record should have existed");
- NS_TEST_ASSERT_MSG_EQ (recorders.front ()->count, 2, "two events should have been reported");
-}
-
-}
diff --git a/test/ndnSIM-fib-entry.h b/test/ndnSIM-fib-entry.h
deleted file mode 100644
index 4f78f53..0000000
--- a/test/ndnSIM-fib-entry.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011-2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDNSIM_TEST_FIB_ENTRY_H
-#define NDNSIM_TEST_FIB_ENTRY_H
-
-#include "ns3/test.h"
-#include "ns3/ptr.h"
-
-namespace ns3 {
-
-namespace ndn {
-class Fib;
-class Pit;
-}
-
-class FibEntryTest : public TestCase
-{
-public:
- FibEntryTest ()
- : TestCase ("FIB entry test")
- {
- }
-
-private:
- virtual void DoRun ();
-};
-
-}
-
-#endif // NDNSIM_TEST_FIB_ENTRY_H
diff --git a/test/ndnSIM-pit.cc b/test/ndnSIM-pit.cc
deleted file mode 100644
index db94f6f..0000000
--- a/test/ndnSIM-pit.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011,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 "ndnSIM-pit.h"
-#include "ns3/core-module.h"
-#include "ns3/ndnSIM-module.h"
-#include "ns3/point-to-point-module.h"
-
-#include <boost/lexical_cast.hpp>
-
-NS_LOG_COMPONENT_DEFINE ("ndn.PitTest");
-
-namespace ns3
-{
-
-class PitTestClient : public ndn::App
-{
-protected:
- void
- StartApplication ()
- {
- ndn::App::StartApplication ();
-
- // add default route
- Ptr<ndn::fib::Entry> fibEntry = GetNode ()->GetObject<ndn::Fib> ()->Add (ndn::Name ("/"), m_face, 0);
- fibEntry->UpdateStatus (m_face, ndn::fib::FaceMetric::NDN_FIB_GREEN);
-
- Simulator::Schedule (Seconds (0.1), &PitTestClient::SendPacket, this, std::string("/1"), 1);
- Simulator::Schedule (Seconds (0.2), &PitTestClient::SendPacket, this, std::string("/2"), 1);
- Simulator::Schedule (Seconds (0.3), &PitTestClient::SendPacket, this, std::string("/3"), 1);
- Simulator::Schedule (Seconds (0.4), &PitTestClient::SendPacket, this, std::string("/1"), 2);
- }
-
- void
- StopApplication ()
- {
- ndn::App::StopApplication ();
- }
-
-private:
- void
- SendPacket (const std::string &prefix, uint32_t nonce)
- {
- Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
- interest->SetName (Create<ndn::Name> (prefix));
- interest->SetNonce (nonce);
- interest->SetInterestLifetime (Seconds (0.5));
-
- m_face->ReceiveInterest (interest);
- }
-};
-
-void
-PitTest::Test (Ptr<ndn::Fib> fib)
-{
- NS_TEST_ASSERT_MSG_EQ (fib->GetSize (), 1, "There should be only one entry");
-
- Ptr<const ndn::fib::Entry> fibEntry = fib->Begin ();
- NS_TEST_ASSERT_MSG_EQ (fibEntry->GetPrefix (), ndn::Name ("/"), "prefix should be /");
-}
-
-void
-PitTest::Check0 (Ptr<ndn::Pit> pit)
-{
- // NS_LOG_DEBUG (*GetNode ()->GetObject<ndn::Pit> ());
- NS_TEST_ASSERT_MSG_EQ (pit->GetSize (), 0, "There should 0 entries in PIT");
-}
-
-void
-PitTest::Check1 (Ptr<ndn::Pit> pit)
-{
- NS_TEST_ASSERT_MSG_EQ (pit->GetSize (), 1, "There should 1 entry in PIT");
-}
-
-void
-PitTest::Check2 (Ptr<ndn::Pit> pit)
-{
- // NS_LOG_DEBUG (*GetNode ()->GetObject<ndn::Pit> ());
- NS_TEST_ASSERT_MSG_EQ (pit->GetSize (), 2, "There should 2 entries in PIT");
-}
-
-void
-PitTest::Check3 (Ptr<ndn::Pit> pit)
-{
- // NS_LOG_DEBUG (*GetNode ()->GetObject<ndn::Pit> ());
- NS_TEST_ASSERT_MSG_EQ (pit->GetSize (), 3, "There should 3 entries in PIT");
-}
-
-
-void
-PitTest::DoRun ()
-{
- Ptr<Node> node = CreateObject<Node> ();
- Ptr<Node> nodeSink = CreateObject<Node> ();
- PointToPointHelper p2p;
- p2p.Install (node, nodeSink);
-
- ndn::StackHelper ndn;
- ndn.Install (node);
- ndn.Install (nodeSink);
-
- ndn::StackHelper::AddRoute (node, "/", 0, 0);
-
- Ptr<Application> app1 = CreateObject<PitTestClient> ();
- app1->SetStartTime (Seconds (0.0));
- node->AddApplication (app1);
-
- Simulator::Schedule (Seconds (0.0001), &PitTest::Test, this, node->GetObject<ndn::Fib> ());
-
- Simulator::Schedule (Seconds (0.01), &PitTest::Check0, this, node->GetObject<ndn::Pit> ());
-
- Simulator::Schedule (Seconds (0.11), &PitTest::Check1, this, node->GetObject<ndn::Pit> ());
- Simulator::Schedule (Seconds (0.21), &PitTest::Check2, this, node->GetObject<ndn::Pit> ());
- Simulator::Schedule (Seconds (0.31), &PitTest::Check3, this, node->GetObject<ndn::Pit> ());
-
- Simulator::Schedule (Seconds (0.61), &PitTest::Check3, this, node->GetObject<ndn::Pit> ());
- Simulator::Schedule (Seconds (0.71), &PitTest::Check2, this, node->GetObject<ndn::Pit> ());
- Simulator::Schedule (Seconds (0.81), &PitTest::Check1, this, node->GetObject<ndn::Pit> ());
-
- Simulator::Schedule (Seconds (0.91), &PitTest::Check0, this, node->GetObject<ndn::Pit> ());
-
- Simulator::Stop (Seconds (10.0));
- Simulator::Run ();
- Simulator::Destroy ();
-}
-
-}
diff --git a/test/ndnSIM-pit.h b/test/ndnSIM-pit.h
deleted file mode 100644
index bd8ad3d..0000000
--- a/test/ndnSIM-pit.h
+++ /dev/null
@@ -1,54 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDNSIM_TEST_PIT_H
-#define NDNSIM_TEST_PIT_H
-
-#include "ns3/test.h"
-#include "ns3/ptr.h"
-
-namespace ns3 {
-
-namespace ndn {
-class Fib;
-class Pit;
-}
-
-class PitTest : public TestCase
-{
-public:
- PitTest ()
- : TestCase ("PIT test")
- {
- }
-
-private:
- virtual void DoRun ();
-
- void Test (Ptr<ndn::Fib> fib);
- void Check0 (Ptr<ndn::Pit> pit);
- void Check1 (Ptr<ndn::Pit> pit);
- void Check2 (Ptr<ndn::Pit> pit);
- void Check3 (Ptr<ndn::Pit> pit);
-};
-
-}
-
-#endif // NDNSIM_TEST_PIT_H
diff --git a/test/ndnSIM-serialization.cc b/test/ndnSIM-serialization.cc
deleted file mode 100644
index fee40b1..0000000
--- a/test/ndnSIM-serialization.cc
+++ /dev/null
@@ -1,133 +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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-#include "ns3/core-module.h"
-#include "ns3/ndnSIM-module.h"
-#include "ndnSIM-serialization.h"
-
-#include <boost/lexical_cast.hpp>
-#include "ns3/ndnSIM/model/wire/ndnsim.h"
-
-using namespace std;
-
-namespace ns3 {
-
-using namespace ndn;
-
-NS_LOG_COMPONENT_DEFINE ("ndn.Serialization");
-
-void
-InterestSerializationTest::DoRun ()
-{
- Ptr<Interest> source = Create<Interest> ();
-
- source->SetName (Create<Name> (boost::lexical_cast<Name> ("/test/test2")));
- NS_TEST_ASSERT_MSG_EQ (source->GetName (), boost::lexical_cast<Name> ("/test/test2"), "set/get name failed");
-
- source->SetScope (2);
- NS_TEST_ASSERT_MSG_EQ (source->GetScope (), 2, "set/get scope failed");
-
- source->SetInterestLifetime (Seconds (100));
- NS_TEST_ASSERT_MSG_EQ (source->GetInterestLifetime (), Seconds (100), "set/get interest lifetime failed");
-
- source->SetNonce (200);
- NS_TEST_ASSERT_MSG_EQ (source->GetNonce (), 200, "set/get nonce failed");
-
- source->SetNack (10);
- NS_TEST_ASSERT_MSG_EQ (source->GetNack (), 10, "set/get NACK failed");
-
- NS_TEST_ASSERT_MSG_EQ (source->GetWire (), 0, "Wire should be empty");
- NS_TEST_ASSERT_MSG_NE (source->GetPayload (), 0, "Payload should not be empty");
-
- Ptr<Packet> packet = wire::ndnSIM::Interest::ToWire (source);
-
- NS_TEST_ASSERT_MSG_NE (source->GetWire (), 0, "Wire should not be empty now");
-
- Ptr<Interest> target = wire::ndnSIM::Interest::FromWire (packet);
-
- NS_TEST_ASSERT_MSG_EQ (source->GetName () , target->GetName () , "source/target name failed");
- NS_TEST_ASSERT_MSG_EQ (source->GetScope () , target->GetScope () , "source/target scope failed");
- NS_TEST_ASSERT_MSG_EQ (source->GetInterestLifetime (), target->GetInterestLifetime (), "source/target interest lifetime failed");
- NS_TEST_ASSERT_MSG_EQ (source->GetNonce () , target->GetNonce () , "source/target nonce failed");
- NS_TEST_ASSERT_MSG_EQ (source->GetNack () , target->GetNack () , "source/target NACK failed");
-
- NS_TEST_ASSERT_MSG_EQ (source->GetExclude () , 0, "exclude should be empty");
- NS_TEST_ASSERT_MSG_EQ (target->GetExclude () , 0, "exclude should be empty");
-
- Ptr<Exclude> exclude = Create<Exclude> ();
- exclude->excludeAfter (name::Component ());
- source->SetExclude (exclude);
-
- NS_TEST_ASSERT_MSG_EQ (boost::lexical_cast<std::string> (*source->GetExclude ()),
- " ----> ", "exclude should contain only <ANY/>");
-
- exclude->appendExclude (name::Component ("alex"), false);
- exclude->excludeAfter (name::Component ("zhenkai"));
-
- source->SetExclude (exclude);
- NS_TEST_ASSERT_MSG_EQ (boost::lexical_cast<std::string> (*source->GetExclude ()),
- " ----> alex zhenkai ----> ", "exclude should contain only <ANY/>");
-
- NS_TEST_ASSERT_MSG_EQ (source->GetWire (), 0, "Wire should be empty");
- NS_TEST_ASSERT_MSG_NE (source->GetPayload (), 0, "Payload should not be empty");
-
- packet = wire::ndnSIM::Interest::ToWire (source);
- target = wire::ndnSIM::Interest::FromWire (packet);
- NS_TEST_ASSERT_MSG_NE (target->GetExclude (), 0, "exclude should not be empty");
-
- NS_TEST_ASSERT_MSG_EQ (boost::lexical_cast<std::string> (*target->GetExclude ()),
- " ----> alex zhenkai ----> ", "exclude should contain only <ANY/>");
-}
-
-void
-DataSerializationTest::DoRun ()
-{
- Ptr<Data> source = Create<Data> (Create<Packet> (1024));
-
- source->SetName (Create<Name> (boost::lexical_cast<Name> ("/test/test2/1")));
- NS_TEST_ASSERT_MSG_EQ (source->GetName (), boost::lexical_cast<Name> ("/test/test2/1"), "set/get name failed");
-
- source->SetFreshness (Seconds (10));
- NS_TEST_ASSERT_MSG_EQ (source->GetFreshness (), Seconds (10), "set/get freshness failed");
-
- source->SetTimestamp (Seconds (100));
- NS_TEST_ASSERT_MSG_EQ (source->GetTimestamp (), Seconds (100), "set/get timestamp failed");
-
- NS_TEST_ASSERT_MSG_EQ (source->GetSignature (), 0, "initialization of signature failed");
-
- Ptr<Packet> packet = wire::ndnSIM::Data::ToWire (source);
- int size = packet->GetSize ();
-
- source->SetSignature (10);
- NS_TEST_ASSERT_MSG_EQ (source->GetSignature (), 10, "set/get signature failed");
-
- packet = wire::ndnSIM::Data::ToWire (source);
- NS_TEST_ASSERT_MSG_EQ (packet->GetSize (), static_cast<unsigned int> (size + 4), "Signature size should have increased by 4");
-
- Ptr<Data> target = wire::ndnSIM::Data::FromWire (packet);
-
- NS_TEST_ASSERT_MSG_EQ (source->GetName () , target->GetName () , "source/target name failed");
- NS_TEST_ASSERT_MSG_EQ (source->GetFreshness (), target->GetFreshness (), "source/target freshness failed");
- NS_TEST_ASSERT_MSG_EQ (source->GetTimestamp (), target->GetTimestamp (), "source/target timestamp failed");
- NS_TEST_ASSERT_MSG_EQ (source->GetSignature (), target->GetSignature (), "source/target signature failed");
-}
-
-}
diff --git a/test/ndnSIM-serialization.h b/test/ndnSIM-serialization.h
deleted file mode 100644
index 6d2015b..0000000
--- a/test/ndnSIM-serialization.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011,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: Ilya Moiseenko <iliamo@cs.ucla.edu>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDNSIM_SERIALIZATION_H
-#define NDNSIM_SERIALIZATION_H
-
-#include "ns3/test.h"
-
-namespace ns3
-{
-
-class InterestSerializationTest : public TestCase
-{
-public:
- InterestSerializationTest ()
- : TestCase ("Interest Serialization Test")
- {
- }
-
-private:
- virtual void DoRun ();
-};
-
-class DataSerializationTest : public TestCase
-{
-public:
- DataSerializationTest ()
- : TestCase ("Data Serialization Test")
- {
- }
-
-private:
- virtual void DoRun ();
-};
-
-}
-
-#endif // NDNSIM_SERIALIZATION_H
diff --git a/test/ndnSIM-tests.cc b/test/ndnSIM-tests.cc
deleted file mode 100644
index c6b4d6e..0000000
--- a/test/ndnSIM-tests.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011,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: Ilya Moiseenko <iliamo@cs.ucla.edu>
- * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ns3/test.h"
-
-#include "ndnSIM-serialization.h"
-#include "ndnSIM-pit.h"
-#include "ndnSIM-fib-entry.h"
-#include "ndnSIM-api.h"
-
-namespace ns3
-{
-
-class NdnSimTestSuite : public TestSuite
-{
-public:
- NdnSimTestSuite ()
- : TestSuite ("ndnSIM", UNIT)
- {
- SetDataDir (NS_TEST_SOURCEDIR);
-
- AddTestCase (new InterestSerializationTest (), TestCase::QUICK);
- AddTestCase (new DataSerializationTest (), TestCase::QUICK);
- AddTestCase (new FibEntryTest (), TestCase::QUICK);
- AddTestCase (new PitTest (), TestCase::QUICK);
- AddTestCase (new ApiTest (), TestCase::QUICK);
- }
-};
-
-static NdnSimTestSuite suite;
-
-}
diff --git a/test/ndnSIM-trie.cc b/test/ndnSIM-trie.cc
deleted file mode 100644
index ee53ad4..0000000
--- a/test/ndnSIM-trie.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-/* -*- 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 "ns3/core-module.h"
-#include "ns3/ndnSIM-module.h"
-
-#include "ndnSIM-trie.h"
-
-#include "../utils/trie/trie-with-policy.h"
-#include "../utils/trie/lru-policy.h"
-#include "../utils/trie/random-policy.h"
-#include "../utils/trie/fifo-policy.h"
-#include "../utils/trie/multi-policy.h"
-
-#include <boost/lexical_cast.hpp>
-
-using namespace std;
-using namespace ns3;
-using namespace ndn::ndnSIM;
-using namespace boost;
-
-NS_LOG_COMPONENT_DEFINE ("ndn.Trie");
-
-// class Integer : public ns3::SimpleRefCount<Integer>
-// {
-// public:
-// ::Integer (int value) : value_ (value) {}
-
-// operator int () const { return value_; }
-// private:
-// int value_;
-// };
-
-// std::ostream &
-// operator << (std::ostream &os, const ::Integer &i)
-// {
-// os << (int)i;
-// return os;
-// }
-
-void
-TrieTest::DoRun ()
-{
- cerr << "TrieTest is temporarily broken" << endl;
- // typedef trie_with_policy<
- // ns3::NdnName,
- // smart_pointer_payload_traits<Integer>,
- // multi_policy_traits<
- // mpl::vector2<lru_policy_traits,random_policy_traits>
- // > > trie;
-
- // trie x;
- // x.getPolicy ().get<0> ().set_max_size (100);
- // x.getPolicy ().get<1> ().set_max_size (3);
- // // // x.getPolicy ().get<1> ().set_max_size (3);
- // // // // x.getPolicy ().get1 ().set_max_size (10);
- // // // // x.getPolicy ().get2 ().set_max_size (3);
-
- // // // // x.getTrie ().PrintStat (std::cout);
-
- // ns3::NdnName n1,n2,n3,n4;
- // // // // n1("a")("b")("c");
- // // // // n2("a")("b")("d");
- // // // // n3("a")("b")("f");
- // // // // n4("a")("b");
-
- // n1("a");
- // n2("b");
- // n3("c");
- // n4("d");
-
- // x.insert (n1, ns3::Create<Integer> (1));
- // x.insert (n2, ns3::Create<Integer> (2));
- // // // // x.longest_prefix_match (n1);
- // x.insert (n3, ns3::Create<Integer> (3));
- // x.insert (n4, ns3::Create<Integer> (4));
- // x.insert (n4, ns3::Create<Integer> (4));
-
- // std::cout << "digraph trie {\n";
- // std::cout << x.getTrie ();
- // std::cout << "}\n";
-
- // Ptr<Node> node = CreateObject<Node> ();
- // Names::Add ("TestNode", node);
- // Ptr<ndn::App> app = CreateObject<ndn::App> ();
- // node->AddApplication (app);
-
- // ObjectFactory factory ("ns3::ndn::fib::Default");
-
- // Ptr<ndn::Fib> fib = factory.Create<ndn::Fib> ();
- // node->AggregateObject (fib);
- // Ptr<ndn::Face> face = CreateObject<ndn::AppFace> (app);
-
- // fib->Add (lexical_cast<ndn::Name> ("/bla"), face, 1);
- // fib->Add (lexical_cast<ndn::Name> ("/bla/1"), face, 1);
- // fib->Add (lexical_cast<ndn::Name> ("/bla/2"), face, 1);
- // fib->Add (lexical_cast<ndn::Name> ("/bla/3"), face, 1);
- // fib->Add (lexical_cast<ndn::Name> ("/bla/1/1"), face, 1);
- // fib->Add (lexical_cast<ndn::Name> ("/bla/1/2"), face, 1);
-
- // cout << *fib << endl;
-
- // fib->RemoveFromAll (face);
-
- // cout << *fib << endl;
- // BOOST_FOREACH (const trie::parent_trie &item, x.getPolicy ())
- // {
- // std::cout << *item.payload () << " " << std::endl;
- // }
-
- // ns3::NdnName n4;
- // n4("a")("c");
-
- // // std::cout << *x->find (n4).get<0> ();
-
- // x->prune ();
- // // x->find (n5).get<0> ()->erase ();
- // x->find (n1).get<0> ()->erase ();
-
- // std::cout << "digraph trie {\n";
- // std::cout << *x;
- // std::cout << "}\n";
-
- // x->PrintStat (std::cout);
-
- // delete x;
-}
-
diff --git a/test/ndnSIM-trie.h b/test/ndnSIM-trie.h
deleted file mode 100644
index 6cf5190..0000000
--- a/test/ndnSIM-trie.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- 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>
- *
- */
-
-#ifndef NDNSIM_TRIE_H
-#define NDNSIM_TRIE_H
-
-#include "ns3/test.h"
-
-namespace ns3
-{
-
-class TrieTest : public TestCase
-{
-public:
- TrieTest ()
- : TestCase ("Trie Test")
- {
- }
-
-private:
- virtual void DoRun ();
-};
-
-}
-
-#endif // NDNSIM_TRIE_H
diff --git a/tools/rocketfuel-maps-cch-to-annotaded.cc b/tools/rocketfuel-maps-cch-to-annotaded.cc
deleted file mode 100644
index 13b4ddd..0000000
--- a/tools/rocketfuel-maps-cch-to-annotaded.cc
+++ /dev/null
@@ -1,165 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- * Ilya Moiseenko <iliamo@ucla.edu>
- */
-
-#include "ns3/core-module.h"
-#include "ns3/log.h"
-#include "ns3/ndnSIM-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/random-variable.h"
-
-#include <boost/foreach.hpp>
-
-#include "ns3/ndnSIM/plugins/topology/rocketfuel-map-reader.h"
-
-using namespace ns3;
-using namespace std;
-
-int main (int argc, char**argv)
-{
- string topology = "";
- string output_prefix = "";
- uint32_t run = 0;
- int clientNodeDegrees = -1;
- bool buildGraphvizGraph = false;
- bool keepLargestComponent = false;
- bool connectBackbones = false;
-
- CommandLine cmd;
- cmd.AddValue ("topology", "Topology filename (.ccn)", topology);
- cmd.AddValue ("output", "Prefix for output files", output_prefix);
- cmd.AddValue ("run", "Run for ranged parameter randomization", run);
- cmd.AddValue ("clients", "Maximum degree of client nodes", clientNodeDegrees);
- cmd.AddValue ("buildGraph", "Whether or not build a graphviz graph (using neato)", buildGraphvizGraph);
- cmd.AddValue ("keepLargestComponent", "Keep only largest connected component of the network graph", keepLargestComponent);
- cmd.AddValue ("connectBackbones", "Make sure that ``backbone'' nodes are connected (adding extra links)", connectBackbones);
- cmd.Parse (argc, argv);
-
- /**
- * @todo Make range parameters as command line arguments
- */
-
- if (topology == "")
- {
- cerr << "ERROR: topology needs to be specified" << endl;
- cerr << endl;
-
- cmd.PrintHelp (cerr);
- return 1;
- }
-
- if (output_prefix == "")
- {
- cerr << "ERROR: output needs to be specified" << endl;
- cerr << endl;
-
- cmd.PrintHelp (cerr);
- return 1;
- }
-
- if (run == 0)
- {
- cerr << "ERROR: run needs to be specified" << endl;
- cerr << endl;
-
- cmd.PrintHelp (cerr);
- return 1;
- }
-
- if (clientNodeDegrees < 0)
- {
- cerr << "ERROR: clients needs to be specified" << endl;
- cerr << endl;
-
- cmd.PrintHelp (cerr);
- return 1;
- }
-
- Config::SetGlobal ("RngRun", IntegerValue (run));
- GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::VisualSimulatorImpl"));
-
- string input = topology;
- string output = output_prefix+"-conv-annotated.txt";
- string graph = output_prefix+"-conv-annotated.dot";
- string graph_pdf = output_prefix+"-conv-annotated.pdf";
-
- RocketfuelParams params;
- params.clientNodeDegrees = clientNodeDegrees;
- params.averageRtt = 0.25; // 250ms
- //parameters for links Backbone<->Backbone
- params.minb2bBandwidth = "40Mbps";
- params.minb2bDelay = "5ms";
-
- params.maxb2bBandwidth = "100Mbps";
- params.maxb2bDelay = "10ms";
-
- //parameters for links Backbone<->Gateway and Gateway <-> Gateway
- params.minb2gBandwidth = "10Mbps";
- params.minb2gDelay = "5ms";
-
- params.maxb2gBandwidth = "20Mbps";
- params.maxb2gDelay = "10ms";
-
- //parameters for links Gateway <-> Customer
- params.ming2cBandwidth ="1Mbps";
- params.ming2cDelay = "70ms";
-
- params.maxg2cBandwidth ="3Mbps";
- params.maxg2cDelay = "10ms";
-
- RocketfuelMapReader topologyReader ("/", 1.0);
- topologyReader.SetFileName (input);
- NodeContainer nodes = topologyReader.Read (params, keepLargestComponent, connectBackbones);
- NodeContainer backboneRouters = topologyReader.GetBackboneRouters();
- NodeContainer gatewayRouters = topologyReader.GetGatewayRouters();
- NodeContainer customerRouters = topologyReader.GetCustomerRouters();
- list<TopologyReader::Link> links = topologyReader.GetLinks();
-
- topologyReader.SaveGraphviz (graph);
- if (buildGraphvizGraph)
- {
- int ret = system (("neato -Tpdf \"" + graph + "\" > \"" + graph_pdf + "\"").c_str ());
- if (ret != 0)
- {
- std::cerr << "WARN: failed to build a graph for the topology. Check if `neato' command is installed (part of graphviz package)" << std::endl;
- }
- }
-
- topologyReader.SaveTopology (output);
-
- // Names::Clear ();
- // Simulator::Destroy ();
-
- // // assign weights
- // AnnotatedTopologyReader topologyReader2 ("", 1.0);
- // topologyReader2.SetFileName (output);
- // topologyReader2.Read ();
-
- // char env[] = "NS_VIS_ASSIGN=1";
- // putenv (env);
-
- // Simulator::Stop (Seconds (0.0));
- // Simulator::Run ();
-
- // topologyReader2.SaveTopology (output);
-
- // Simulator::Destroy ();
- return 0;
-}
diff --git a/tools/wscript b/tools/wscript
deleted file mode 100644
index 6ebf98e..0000000
--- a/tools/wscript
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-
-def build(bld):
- if 'topology' in bld.env['NDN_plugins']:
- obj = bld.create_ns3_program('rocketfuel-maps-cch-to-annotaded', ['ndnSIM'])
- obj.source = 'rocketfuel-maps-cch-to-annotaded.cc'
diff --git a/utils/ndn-local-info-tag.cc b/utils/ndn-local-info-tag.cc
deleted file mode 100644
index 15466b4..0000000
--- a/utils/ndn-local-info-tag.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#include "ndn-local-info-tag.h"
-#include <ns3/ndn-face.h>
-
-namespace ns3 {
-namespace ndn {
-
-LocalInfoTag::LocalInfoTag (Ptr<Face> inFace)
-{
- if (inFace != 0)
- {
- m_faceId = inFace->GetId ();
- }
- else
- m_faceId = CACHE_FACE;
-}
-
-LocalInfoTag::~LocalInfoTag ()
-{
-}
-
-
-TypeId
-LocalInfoTag::GetTypeId ()
-{
- static TypeId tid = TypeId("ns3::ndn::LocalInfo")
- .SetParent<Tag>()
- ;
- return tid;
-}
-
-TypeId
-LocalInfoTag::GetInstanceTypeId () const
-{
- return LocalInfoTag::GetTypeId ();
-}
-
-uint32_t
-LocalInfoTag::GetSerializedSize () const
-{
- return sizeof (uint32_t);
-}
-
-void
-LocalInfoTag::Serialize (TagBuffer i) const
-{
- i.WriteU32 (m_faceId);
-}
-
-void
-LocalInfoTag::Deserialize (TagBuffer i)
-{
- m_faceId = i.ReadU32 ();
-}
-
-void
-LocalInfoTag::Print (std::ostream &os) const
-{
- os << m_faceId;
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/utils/ndn-local-info-tag.h b/utils/ndn-local-info-tag.h
deleted file mode 100644
index ba7aa92..0000000
--- a/utils/ndn-local-info-tag.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_LOCAL_INFO_TAG_H
-#define NDN_LOCAL_INFO_TAG_H
-
-#include "ns3/tag.h"
-#include "ns3/ptr.h"
-
-namespace ns3 {
-namespace ndn {
-
-class Face;
-
-/**
- * @ingroup ndn-fw
- * @brief Packet tag that is used to keep information about face from which packet was received
- *
- * This tag may be extended later to include more information, if necessary
- */
-class LocalInfoTag : public Tag
-{
-public:
- static TypeId
- GetTypeId ();
-
- /**
- * @brief Constructor
- */
- LocalInfoTag (Ptr<Face> inFace);
-
- /**
- * @brief Destructor
- */
- ~LocalInfoTag ();
-
- /**
- * @brief Get smart pointer to the face
- *
- * @returns 0 or a valid smart pointer to a face
- */
- uint32_t
- Get () const
- {
- return m_faceId;
- }
-
- ////////////////////////////////////////////////////////
- // from ObjectBase
- ////////////////////////////////////////////////////////
- virtual TypeId
- GetInstanceTypeId () const;
-
- ////////////////////////////////////////////////////////
- // from Tag
- ////////////////////////////////////////////////////////
-
- virtual uint32_t
- GetSerializedSize () const;
-
- virtual void
- Serialize (TagBuffer i) const;
-
- virtual void
- Deserialize (TagBuffer i);
-
- virtual void
- Print (std::ostream &os) const;
-
-public:
- static const uint32_t CACHE_FACE = static_cast<uint32_t> (-1);
-
-private:
- uint32_t m_faceId;
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_LOCAL_INFO_TAG_H
diff --git a/utils/tracers/ipv4-app-tracer.cc b/utils/tracers/ipv4-app-tracer.cc
deleted file mode 100644
index 75c8b87..0000000
--- a/utils/tracers/ipv4-app-tracer.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 UCLA
- *
- * 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 "ipv4-app-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/names.h"
-
-#include <boost/lexical_cast.hpp>
-
-using namespace std;
-using namespace boost;
-
-namespace ns3 {
-
-Ipv4AppTracer::Ipv4AppTracer (Ptr<Node> node)
- : m_nodePtr (node)
-{
- m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
-
- Connect ();
-
- string name = Names::FindName (node);
- if (!name.empty ())
- {
- m_node = name;
- }
-}
-
-void
-Ipv4AppTracer::Connect ()
-{
- Config::Connect ("/NodeList/"+m_node+"/$ns3::Ipv4L3Protocol/SendOutgoing",
- MakeCallback (&Ipv4AppTracer::Tx, this));
-
- Config::Connect ("/NodeList/"+m_node+"/$ns3::Ipv4L3Protocol/LocalDeliver",
- MakeCallback (&Ipv4AppTracer::Rx, this));
-}
-
-
-} // namespace ns3
diff --git a/utils/tracers/ipv4-app-tracer.h b/utils/tracers/ipv4-app-tracer.h
deleted file mode 100644
index d574117..0000000
--- a/utils/tracers/ipv4-app-tracer.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012 UCLA
- *
- * 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 IPV4_APP_TRACER_H
-#define IPV4_APP_TRACER_H
-
-#include "ns3/ptr.h"
-#include "ns3/simple-ref-count.h"
-#include "ns3/ipv4.h"
-
-namespace ns3 {
-
-class Ipv4Header;
-
-/**
- * @ingroup ndn-tracers
- * @brief Base class for IPv4/TCP based applications
- */
-class Ipv4AppTracer : public SimpleRefCount<Ipv4AppTracer>
-{
-public:
- Ipv4AppTracer (Ptr<Node> node);
- virtual ~Ipv4AppTracer () { };
-
- void
- Connect ();
-
- virtual void
- PrintHeader (std::ostream &os) const = 0;
-
- virtual void
- Print (std::ostream &os) const = 0;
-
- virtual void
- Rx (std::string context,
- const Ipv4Header &, Ptr<const Packet>, uint32_t) = 0;
-
- virtual void
- Tx (std::string context,
- const Ipv4Header &, Ptr<const Packet>, uint32_t) = 0;
-
-protected:
- std::string m_node;
- Ptr<Node> m_nodePtr;
-};
-
-inline std::ostream&
-operator << (std::ostream &os, const Ipv4AppTracer &tracer)
-{
- os << "# ";
- tracer.PrintHeader (os);
- os << "\n";
- tracer.Print (os);
- return os;
-}
-
-} // namespace ns3
-
-#endif // IPV4_APP_TRACER_H
diff --git a/utils/tracers/ipv4-l3-tracer.cc b/utils/tracers/ipv4-l3-tracer.cc
deleted file mode 100644
index 384d177..0000000
--- a/utils/tracers/ipv4-l3-tracer.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ipv4-l3-tracer.h"
-#include "ns3/node.h"
-#include "ns3/config.h"
-#include "ns3/names.h"
-#include "ns3/callback.h"
-#include "ns3/ipv4-l3-protocol.h"
-
-#include <boost/lexical_cast.hpp>
-
-using namespace std;
-
-namespace ns3 {
-
-Ipv4L3Tracer::Ipv4L3Tracer (Ptr<Node> node)
-: m_nodePtr (node)
-{
- m_node = boost::lexical_cast<string> (m_nodePtr->GetId ());
-
- Connect ();
-
- string name = Names::FindName (node);
- if (!name.empty ())
- {
- m_node = name;
- }
-}
-
-void
-Ipv4L3Tracer::Connect ()
-{
- Ptr<Ipv4L3Protocol> ip = m_nodePtr->GetObject<Ipv4L3Protocol> ();
- ip->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv4L3Tracer::Tx, this));
- ip->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3Tracer::Rx, this));
- ip->TraceConnectWithoutContext ("Drop", MakeCallback (&Ipv4L3Tracer::Drop, this));
-}
-
-} // namespace ns3
diff --git a/utils/tracers/ipv4-l3-tracer.h b/utils/tracers/ipv4-l3-tracer.h
deleted file mode 100644
index b63dc01..0000000
--- a/utils/tracers/ipv4-l3-tracer.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 IPV4_L3_TRACER_H
-#define IPV4_L3_TRACER_H
-
-#include "ns3/ptr.h"
-#include "ns3/simple-ref-count.h"
-#include "ns3/ipv4-l3-protocol.h"
-
-namespace ns3 {
-
-class Node;
-
-/**
- * @ingroup ndn-tracers
- * @brief Base class for IPv4 network-layer tracers
- */
-class Ipv4L3Tracer : public SimpleRefCount<Ipv4L3Tracer>
-{
-public:
- Ipv4L3Tracer (Ptr<Node> node);
- virtual ~Ipv4L3Tracer () { };
-
- void
- Connect ();
-
- virtual void
- PrintHeader (std::ostream &os) const = 0;
-
- virtual void
- Print (std::ostream &os) const = 0;
-
- virtual void
- Rx (Ptr<const Packet>, Ptr<Ipv4>, uint32_t) = 0;
-
- virtual void
- Tx (Ptr<const Packet>, Ptr<Ipv4>, uint32_t) = 0;
-
- virtual void
- Drop (const Ipv4Header &, Ptr<const Packet>, Ipv4L3Protocol::DropReason, Ptr<Ipv4>, uint32_t) = 0;
-
-protected:
- std::string m_node;
- Ptr<Node> m_nodePtr;
-
- struct Stats
- {
- void Reset ()
- {
- m_in = 0;
- m_out = 0;
- m_drop = 0;
- }
-
- uint64_t m_in;
- uint64_t m_out;
- uint64_t m_drop;
- };
-};
-
-inline std::ostream&
-operator << (std::ostream &os, const Ipv4L3Tracer &tracer)
-{
- os << "# ";
- tracer.PrintHeader (os);
- os << "\n";
- tracer.Print (os);
- return os;
-}
-
-} // namespace ns3
-
-#endif // IPV4_L3_TRACER_H
diff --git a/utils/tracers/ipv4-rate-l3-tracer.cc b/utils/tracers/ipv4-rate-l3-tracer.cc
deleted file mode 100644
index 0e2db8d..0000000
--- a/utils/tracers/ipv4-rate-l3-tracer.cc
+++ /dev/null
@@ -1,285 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ipv4-rate-l3-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/simulator.h"
-#include "ns3/node-list.h"
-#include "ns3/node.h"
-#include "ns3/log.h"
-
-#include "ns3/ipv4-header.h"
-
-#include <boost/lexical_cast.hpp>
-
-using namespace boost;
-using namespace std;
-
-NS_LOG_COMPONENT_DEFINE ("Ipv4RateL3Tracer");
-
-namespace ns3 {
-
-template<class T>
-static inline void
-NullDeleter (T *ptr)
-{
-}
-
-boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4RateL3Tracer> > >
-Ipv4RateL3Tracer::InstallAll (const std::string &file, Time averagingPeriod/* = Seconds (0.5)*/)
-{
- std::list<Ptr<Ipv4RateL3Tracer> > tracers;
- boost::shared_ptr<std::ostream> outputStream;
- if (file != "-")
- {
- boost::shared_ptr<std::ofstream> os (new std::ofstream ());
- os->open (file.c_str (), std::ios_base::out | std::ios_base::trunc);
-
- if (!os->is_open ())
- return boost::make_tuple (outputStream, tracers);
-
- outputStream = os;
- }
- else
- {
- outputStream = boost::shared_ptr<std::ostream> (&std::cout, NullDeleter<std::ostream>);
- }
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- Ptr<Ipv4RateL3Tracer> trace = Install (*node, outputStream, averagingPeriod);
- tracers.push_back (trace);
- }
-
- if (tracers.size () > 0)
- {
- // *m_l3RateTrace << "# "; // not necessary for R's read.table
- tracers.front ()->PrintHeader (*outputStream);
- *outputStream << "\n";
- }
-
- return boost::make_tuple (outputStream, tracers);
-}
-
-boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4RateL3Tracer> > >
-Ipv4RateL3Tracer::Install (const NodeContainer &nodes, const std::string &file, Time averagingPeriod/* = Seconds (0.5)*/)
-{
- using namespace boost;
- using namespace std;
-
- std::list<Ptr<Ipv4RateL3Tracer> > tracers;
- boost::shared_ptr<std::ostream> outputStream;
- if (file != "-")
- {
- boost::shared_ptr<std::ofstream> os (new std::ofstream ());
- os->open (file.c_str (), std::ios_base::out | std::ios_base::trunc);
-
- if (!os->is_open ())
- return boost::make_tuple (outputStream, tracers);
-
- outputStream = os;
- }
- else
- {
- outputStream = boost::shared_ptr<std::ostream> (&std::cout, NullDeleter<std::ostream>);
- }
-
- for (NodeContainer::Iterator node = nodes.Begin ();
- node != nodes.End ();
- node++)
- {
- Ptr<Ipv4RateL3Tracer> trace = Install (*node, outputStream, averagingPeriod);
- tracers.push_back (trace);
- }
-
- if (tracers.size () > 0)
- {
- // *m_l3RateTrace << "# "; // not necessary for R's read.table
- tracers.front ()->PrintHeader (*outputStream);
- *outputStream << "\n";
- }
-
- return boost::make_tuple (outputStream, tracers);
-}
-
-boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4RateL3Tracer> > >
-Ipv4RateL3Tracer::Install (Ptr<Node> node, const std::string &file, Time averagingPeriod/* = Seconds (0.5)*/)
-{
- using namespace boost;
- using namespace std;
-
- std::list<Ptr<Ipv4RateL3Tracer> > tracers;
- boost::shared_ptr<std::ostream> outputStream;
- if (file != "-")
- {
- boost::shared_ptr<std::ofstream> os (new std::ofstream ());
- os->open (file.c_str (), std::ios_base::out | std::ios_base::trunc);
-
- if (!os->is_open ())
- return boost::make_tuple (outputStream, tracers);
-
- outputStream = os;
- }
- else
- {
- outputStream = boost::shared_ptr<std::ostream> (&std::cout, NullDeleter<std::ostream>);
- }
-
- Ptr<Ipv4RateL3Tracer> trace = Install (node, outputStream, averagingPeriod);
- tracers.push_back (trace);
-
- if (tracers.size () > 0)
- {
- // *m_l3RateTrace << "# "; // not necessary for R's read.table
- tracers.front ()->PrintHeader (*outputStream);
- *outputStream << "\n";
- }
-
- return boost::make_tuple (outputStream, tracers);
-}
-
-
-Ptr<Ipv4RateL3Tracer>
-Ipv4RateL3Tracer::Install (Ptr<Node> node,
- boost::shared_ptr<std::ostream> outputStream,
- Time averagingPeriod/* = Seconds (0.5)*/)
-{
- NS_LOG_DEBUG ("Node: " << node->GetId ());
-
- Ptr<Ipv4RateL3Tracer> trace = Create<Ipv4RateL3Tracer> (outputStream, node);
- trace->SetAveragingPeriod (averagingPeriod);
-
- return trace;
-}
-
-
-Ipv4RateL3Tracer::Ipv4RateL3Tracer (boost::shared_ptr<std::ostream> os, Ptr<Node> node)
- : Ipv4L3Tracer (node)
- , m_os (os)
-{
- SetAveragingPeriod (Seconds (1.0));
-}
-
-Ipv4RateL3Tracer::~Ipv4RateL3Tracer ()
-{
- m_printEvent.Cancel ();
-}
-
-void
-Ipv4RateL3Tracer::SetAveragingPeriod (const Time &period)
-{
- m_period = period;
- m_printEvent.Cancel ();
- m_printEvent = Simulator::Schedule (m_period, &Ipv4RateL3Tracer::PeriodicPrinter, this);
-}
-
-void
-Ipv4RateL3Tracer::PeriodicPrinter ()
-{
- Print (*m_os);
- Reset ();
-
- m_printEvent = Simulator::Schedule (m_period, &Ipv4RateL3Tracer::PeriodicPrinter, this);
-}
-
-void
-Ipv4RateL3Tracer::PrintHeader (std::ostream &os) const
-{
- os << "Time" << "\t"
-
- << "Node" << "\t"
- << "Interface" << "\t"
-
- << "Type" << "\t"
- << "Packets" << "\t"
- << "Kilobytes";
-}
-
-void
-Ipv4RateL3Tracer::Reset ()
-{
- for (std::map<uint32_t, boost::tuple<Stats, Stats, Stats, Stats> >::iterator stats = m_stats.begin ();
- stats != m_stats.end ();
- stats++)
- {
- stats->second.get<0> ().Reset ();
- stats->second.get<1> ().Reset ();
- }
-}
-
-const double alpha = 0.8;
-
-#define STATS(INDEX) stats->second.get<INDEX> ()
-#define RATE(INDEX, fieldName) STATS(INDEX).fieldName / m_period.ToDouble (Time::S)
-
-#define PRINTER(printName, fieldName) \
-STATS(2).fieldName = /*new value*/alpha * RATE(0, fieldName) + /*old value*/(1-alpha) * STATS(2).fieldName; \
-STATS(3).fieldName = /*new value*/alpha * RATE(1, fieldName) / 1024.0 + /*old value*/(1-alpha) * STATS(3).fieldName; \
- \
-os << time.ToDouble (Time::S) << "\t" \
- << m_node << "\t" \
- << stats->first << "\t" \
- << printName << "\t" \
- << STATS(2).fieldName << "\t" \
- << STATS(3).fieldName << "\n";
-
-void
-Ipv4RateL3Tracer::Print (std::ostream &os) const
-{
- for (std::map<uint32_t, boost::tuple<Stats, Stats, Stats, Stats> >::iterator stats = m_stats.begin ();
- stats != m_stats.end ();
- stats++)
- {
- Time time = Simulator::Now ();
-
- PRINTER ("In", m_in);
- PRINTER ("Out", m_out);
- PRINTER ("Drop", m_drop);
- }
-}
-
-void
-Ipv4RateL3Tracer::Rx (Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t iface)
-{
- m_stats[iface].get<0> ().m_in ++;
- m_stats[iface].get<1> ().m_in += packet->GetSize ();
-}
-
-void
-Ipv4RateL3Tracer::Tx (Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t iface)
-{
- m_stats[iface].get<0> ().m_out ++;
- m_stats[iface].get<1> ().m_out += packet->GetSize ();
-}
-
-void
-Ipv4RateL3Tracer::Drop (const Ipv4Header &header, Ptr<const Packet> packet, Ipv4L3Protocol::DropReason, Ptr<Ipv4> ipv4, uint32_t iface)
-{
- m_stats[iface].get<0> ().m_drop ++;
- m_stats[iface].get<1> ().m_drop += packet->GetSize ();
-}
-
-
-} // namespace ns3
diff --git a/utils/tracers/ipv4-rate-l3-tracer.h b/utils/tracers/ipv4-rate-l3-tracer.h
deleted file mode 100644
index b039822..0000000
--- a/utils/tracers/ipv4-rate-l3-tracer.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 IPV4_RATE_L3_TRACER_H
-#define IPV4_RATE_L3_TRACER_H
-
-#include "ipv4-l3-tracer.h"
-
-#include "ns3/nstime.h"
-#include "ns3/event-id.h"
-#include "ns3/node-container.h"
-
-#include <boost/tuple/tuple.hpp>
-#include <boost/shared_ptr.hpp>
-#include <map>
-
-namespace ns3 {
-
-/**
- * @ingroup ndn-tracers
- * @brief IPv4 network-layer rate tracer
- */
-class Ipv4RateL3Tracer : public Ipv4L3Tracer
-{
-public:
- /**
- * @brief Network layer tracer constructor
- */
- Ipv4RateL3Tracer (boost::shared_ptr<std::ostream> os, Ptr<Node> node);
- virtual ~Ipv4RateL3Tracer ();
-
- /**
- * @brief Helper method to install tracers on all simulation nodes
- *
- * @param file File to which traces will be written
- * @param averagingPeriod Defines averaging period for the rate calculation,
- * as well as how often data will be written into the trace file (default, every half second)
- *
- * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This tuple needs to be preserved
- * for the lifetime of simulation, otherwise SEGFAULTs are inevitable
- *
- */
- static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4RateL3Tracer> > >
- InstallAll (const std::string &file, Time averagingPeriod = Seconds (0.5));
-
- /**
- * @brief Helper method to install tracers on the selected simulation nodes
- *
- * @param nodes Nodes on which to install tracer
- * @param file File to which traces will be written. If filename is -, then std::out is used
- * @param averagingPeriod How often data will be written into the trace file (default, every half second)
- *
- * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This tuple needs to be preserved
- * for the lifetime of simulation, otherwise SEGFAULTs are inevitable
- *
- */
- static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4RateL3Tracer> > >
- Install (const NodeContainer &nodes, const std::string &file, Time averagingPeriod = Seconds (0.5));
-
- /**
- * @brief Helper method to install tracers on a specific simulation node
- *
- * @param nodes Nodes on which to install tracer
- * @param file File to which traces will be written. If filename is -, then std::out is used
- * @param averagingPeriod How often data will be written into the trace file (default, every half second)
- *
- * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This tuple needs to be preserved
- * for the lifetime of simulation, otherwise SEGFAULTs are inevitable
- *
- */
- static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4RateL3Tracer> > >
- Install (Ptr<Node> node, const std::string &file, Time averagingPeriod = Seconds (0.5));
-
- /**
- * @brief Helper method to install tracers on a specific simulation node
- *
- * @param nodes Nodes on which to install tracer
- * @param outputStream Smart pointer to a stream
- * @param averagingPeriod How often data will be written into the trace file (default, every half second)
- *
- * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This tuple needs to be preserved
- * for the lifetime of simulation, otherwise SEGFAULTs are inevitable
- */
- static Ptr<Ipv4RateL3Tracer>
- Install (Ptr<Node> node, boost::shared_ptr<std::ostream> outputStream, Time averagingPeriod = Seconds (0.5));
-
- void
- SetAveragingPeriod (const Time &period);
-
- virtual void
- PrintHeader (std::ostream &os) const;
-
- virtual void
- Print (std::ostream &os) const;
-
- virtual void
- Rx (Ptr<const Packet>, Ptr<Ipv4>, uint32_t);
-
- virtual void
- Tx (Ptr<const Packet>, Ptr<Ipv4>, uint32_t);
-
- virtual void
- Drop (const Ipv4Header &, Ptr<const Packet>, Ipv4L3Protocol::DropReason, Ptr<Ipv4>, uint32_t);
-
-private:
- void
- PeriodicPrinter ();
-
- void
- Reset ();
-
-private:
- boost::shared_ptr<std::ostream> m_os;
- Time m_period;
- EventId m_printEvent;
-
- mutable std::map<uint32_t, boost::tuple<Stats, Stats, Stats, Stats> > m_stats;
-};
-
-} // namespace ns3
-
-#endif // IPV4_RATE_L3_TRACER_H
diff --git a/utils/tracers/ipv4-seqs-app-tracer.cc b/utils/tracers/ipv4-seqs-app-tracer.cc
deleted file mode 100644
index 170f280..0000000
--- a/utils/tracers/ipv4-seqs-app-tracer.cc
+++ /dev/null
@@ -1,133 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 "ipv4-seqs-app-tracer.h"
-#include "ns3/node.h"
-#include "ns3/packet.h"
-#include "ns3/config.h"
-#include "ns3/callback.h"
-#include "ns3/simulator.h"
-#include "ns3/node-list.h"
-#include "ns3/node.h"
-#include "ns3/log.h"
-
-#include "ns3/tcp-l4-protocol.h"
-#include "ns3/tcp-header.h"
-#include "ns3/ipv4-header.h"
-
-#include <boost/lexical_cast.hpp>
-#include <fstream>
-
-NS_LOG_COMPONENT_DEFINE ("Ipv4SeqsAppTracer");
-
-using namespace boost;
-using namespace std;
-
-namespace ns3 {
-
-Ipv4SeqsAppTracer::Ipv4SeqsAppTracer (boost::shared_ptr<std::ostream> os, Ptr<Node> node)
- : Ipv4AppTracer (node)
- , m_os (os)
-{
-}
-
-boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4SeqsAppTracer> > >
-Ipv4SeqsAppTracer::InstallAll (const std::string &file)
-{
- std::list<Ptr<Ipv4SeqsAppTracer> > tracers;
- boost::shared_ptr<std::ofstream> outputStream (new std::ofstream ());
- outputStream->open (file.c_str (), std::ios_base::out | std::ios_base::trunc);
-
- if (!outputStream->is_open ())
- return boost::make_tuple (outputStream, tracers);
-
- for (NodeList::Iterator node = NodeList::Begin ();
- node != NodeList::End ();
- node++)
- {
- NS_LOG_DEBUG ("Node: " << lexical_cast<string> ((*node)->GetId ()));
-
- Ptr<Ipv4SeqsAppTracer> trace = Create<Ipv4SeqsAppTracer> (outputStream, *node);
- tracers.push_back (trace);
- }
-
- if (tracers.size () > 0)
- {
- // *m_l3RateTrace << "# "; // not necessary for R's read.table
- tracers.front ()->PrintHeader (*outputStream);
- *outputStream << "\n";
- }
-
- return boost::make_tuple (outputStream, tracers);
-}
-
-void
-Ipv4SeqsAppTracer::Reset ()
-{
-}
-
-void
-Ipv4SeqsAppTracer::PrintHeader (std::ostream &os) const
-{
- os << "Time\t"
- << "Node\t"
- << "Type\t"
- << "SeqNo";
-}
-
-void
-Ipv4SeqsAppTracer::Print (std::ostream &os) const
-{
-}
-
-#define PRINTER(type,size) \
- *m_os \
- << Simulator::Now ().ToDouble (Time::S) << "\t" \
- << m_node << "\t" \
- << type << "\t" \
- << static_cast<uint32_t> (size / 1040.0) << std::endl;
-
-void
-Ipv4SeqsAppTracer::Tx (std::string context,
- const Ipv4Header &ip, Ptr<const Packet>, uint32_t)
-{
- if (ip.GetProtocol () != TcpL4Protocol::PROT_NUMBER) return;
-}
-
-void
-Ipv4SeqsAppTracer::Rx (std::string context,
- const Ipv4Header &ip, Ptr<const Packet> pktOrig, uint32_t)
-{
- if (ip.GetProtocol () != TcpL4Protocol::PROT_NUMBER) return;
-
- TcpHeader tcp;
- Ptr<Packet> packet = pktOrig->Copy ();
- packet->RemoveHeader (tcp);
-
- if (tcp.GetFlags () | TcpHeader::ACK)
- {
- if (tcp.GetAckNumber ().GetValue () > 1000) // a little bit more cheating
- {
- PRINTER("InAck", tcp.GetAckNumber ().GetValue ());
- }
- }
-}
-
-} // namespace ns3
diff --git a/utils/tracers/ipv4-seqs-app-tracer.h b/utils/tracers/ipv4-seqs-app-tracer.h
deleted file mode 100644
index 5a64a5a..0000000
--- a/utils/tracers/ipv4-seqs-app-tracer.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 UCLA
- *
- * 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 IPV4_SEQS_APP_TRACER_H
-#define IPV4_SEQS_APP_TRACER_H
-
-#include "ipv4-app-tracer.h"
-#include <boost/shared_ptr.hpp>
-#include <boost/tuple/tuple.hpp>
-
-namespace ns3 {
-
-/**
- * @ingroup ndn-tracers
- * @brief Helper to track application-level sequence numbers (approximated from TCP ACKs)
- */
-class Ipv4SeqsAppTracer : public Ipv4AppTracer
-{
-public:
- Ipv4SeqsAppTracer (boost::shared_ptr<std::ostream> os, Ptr<Node> node);
- virtual ~Ipv4SeqsAppTracer () { };
-
- /**
- * @brief Helper method to install tracers on all simulation nodes
- *
- * @param file File to which traces will be written
- *
- * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This tuple needs to be preserved
- * for the lifetime of simulation, otherwise SEGFAULTs are inevitable
- *
- */
- static boost::tuple< boost::shared_ptr<std::ostream>, std::list<Ptr<Ipv4SeqsAppTracer> > >
- InstallAll (const std::string &file);
-
-
- virtual void
- PrintHeader (std::ostream &os) const;
-
- virtual void
- Print (std::ostream &os) const;
-
- virtual void
- Rx (std::string context,
- const Ipv4Header &, Ptr<const Packet>, uint32_t);
-
- virtual void
- Tx (std::string context,
- const Ipv4Header &, Ptr<const Packet>, uint32_t);
-
-protected:
- void
- Reset ();
-
-protected:
- boost::shared_ptr<std::ostream> m_os;
-};
-
-} // namespace ns3
-
-#endif // IPV4_AGGREGATE_APP_TRACER_H