model: Removing more legacy code and make code to compile
diff --git a/helper/ndn-face-container.cpp b/helper/ndn-face-container.cpp
index 150eea3..bd03ed0 100644
--- a/helper/ndn-face-container.cpp
+++ b/helper/ndn-face-container.cpp
@@ -87,12 +87,12 @@
// }
void
-FaceContainer::Add(const Ptr<Face>& face)
+FaceContainer::Add(const shared_ptr<Face>& face)
{
m_faces.push_back(face);
}
-Ptr<Face>
+shared_ptr<Face>
FaceContainer::Get(FaceContainer::Iterator i) const
{
return *i;
diff --git a/helper/ndn-face-container.hpp b/helper/ndn-face-container.hpp
index b5dd2c0..fc90ad6 100644
--- a/helper/ndn-face-container.hpp
+++ b/helper/ndn-face-container.hpp
@@ -44,7 +44,7 @@
*/
class FaceContainer : public SimpleRefCount<FaceContainer> {
private:
- typedef std::vector<Ptr<Face>> Container;
+ typedef std::vector<shared_ptr<Face>> Container;
public:
typedef Container::const_iterator Iterator; ///< \brief Iterator over FaceContainer
@@ -128,7 +128,7 @@
* @see Face
*/
void
- Add(const Ptr<Face>& face);
+ Add(const shared_ptr<Face>& face);
/**
* Get a smart pointer to Face-derived object stored in the container
@@ -139,7 +139,7 @@
*
* @see Face
*/
- Ptr<Face>
+ shared_ptr<Face>
Get(Iterator i) const;
private:
diff --git a/helper/ndn-global-routing-helper.cpp b/helper/ndn-global-routing-helper.cpp
index 972f1d8..54b032b 100644
--- a/helper/ndn-global-routing-helper.cpp
+++ b/helper/ndn-global-routing-helper.cpp
@@ -29,7 +29,6 @@
#include "ns3/ndn-l3-protocol.hpp"
#include "../model/ndn-net-device-face.hpp"
#include "../model/ndn-global-router.hpp"
-#include "ns3/ndn-fib.hpp"
#include "ns3/node.h"
#include "ns3/node-container.h"
@@ -79,7 +78,7 @@
node->AggregateObject(gr);
for (uint32_t faceId = 0; faceId < ndn->GetNFaces(); faceId++) {
- Ptr<NetDeviceFace> face = DynamicCast<NetDeviceFace>(ndn->GetFace(faceId));
+ shared_ptr<NetDeviceFace> face = DynamicCast<NetDeviceFace>(ndn->GetFace(faceId));
if (face == 0) {
NS_LOG_DEBUG("Skipping non-netdevice face");
continue;
@@ -249,13 +248,14 @@
.distance_combine(boost::WeightCombine()));
// NS_LOG_DEBUG (predecessors.size () << ", " << distances.size ());
-
- Ptr<Fib> fib = source->GetObject<Fib>();
- if (invalidatedRoutes) {
- fib->InvalidateAll();
- }
- NS_ASSERT(fib != 0);
-
+ /*
+ Ptr<Fib> fib = source->GetObject<Fib> ();
+ if (invalidatedRoutes)
+ {
+ fib->InvalidateAll ();
+ }
+ NS_ASSERT (fib != 0);
+*/
NS_LOG_DEBUG("Reachability from Node: " << source->GetObject<Node>()->GetId());
for (DistancesMap::iterator i = distances.begin(); i != distances.end(); i++) {
if (i->first == source)
@@ -271,20 +271,21 @@
<< " with distance " << i->second.get<1>() << " with delay "
<< i->second.get<2>());
- Ptr<fib::Entry> entry = fib->Add(prefix, i->second.get<0>(), i->second.get<1>());
- entry->SetRealDelayToProducer(i->second.get<0>(), Seconds(i->second.get<2>()));
+ // Ptr<fib::Entry> entry = fib->Add (prefix, i->second.get<0> (), i->second.get<1> ());
+ // entry->SetRealDelayToProducer (i->second.get<0> (), Seconds (i->second.get<2> ()));
- Ptr<Limits> faceLimits = i->second.get<0>()->GetObject<Limits>();
+ // Ptr<Limits> faceLimits = i->second.get<0> ()->GetObject<Limits> ();
- Ptr<Limits> fibLimits = entry->GetObject<Limits>();
- if (fibLimits != 0) {
- // if it was created by the forwarding strategy via DidAddFibEntry event
- fibLimits->SetLimits(faceLimits->GetMaxRate(), 2 * i->second.get<2>() /*exact RTT*/);
- NS_LOG_DEBUG("Set limit for prefix "
- << *prefix << " " << faceLimits->GetMaxRate() << " / "
- << 2 * i->second.get<2>() << "s ("
- << faceLimits->GetMaxRate() * 2 * i->second.get<2>() << ")");
- }
+ // Ptr<Limits> fibLimits = entry->GetObject<Limits> ();
+ // if (fibLimits != 0)
+ //{
+ // if it was created by the forwarding strategy via DidAddFibEntry event
+ // fibLimits->SetLimits (faceLimits->GetMaxRate (), 2 * i->second.get<2> () /*exact
+ // RTT*/);
+ // NS_LOG_DEBUG ("Set limit for prefix " << *prefix << " " << faceLimits->GetMaxRate ()
+ // << " / " << 2*i->second.get<2> () << "s (" << faceLimits->GetMaxRate () * 2 *
+ // i->second.get<2> () << ")");
+ //}
}
}
}
@@ -317,11 +318,11 @@
continue;
}
- Ptr<Fib> fib = source->GetObject<Fib>();
+ // Ptr<Fib> fib = source->GetObject<Fib> ();
if (invalidatedRoutes) {
- fib->InvalidateAll();
+ // fib->InvalidateAll ();
}
- NS_ASSERT(fib != 0);
+ // NS_ASSERT (fib != 0);
NS_LOG_DEBUG("===========");
NS_LOG_DEBUG("Reachability from Node: " << source->GetObject<Node>()->GetId() << " ("
@@ -379,21 +380,22 @@
if (i->second.get<0>()->GetMetric() == std::numeric_limits<uint16_t>::max() - 1)
continue;
- Ptr<fib::Entry> entry = fib->Add(prefix, i->second.get<0>(), i->second.get<1>());
- entry->SetRealDelayToProducer(i->second.get<0>(), Seconds(i->second.get<2>()));
+ // Ptr<fib::Entry> entry = fib->Add (prefix, i->second.get<0> (), i->second.get<1>
+ // ());
+ // entry->SetRealDelayToProducer (i->second.get<0> (), Seconds (i->second.get<2> ()));
- Ptr<Limits> faceLimits = i->second.get<0>()->GetObject<Limits>();
+ // Ptr<Limits> faceLimits = i->second.get<0> ()->GetObject<Limits> ();
- Ptr<Limits> fibLimits = entry->GetObject<Limits>();
- if (fibLimits != 0) {
- // if it was created by the forwarding strategy via DidAddFibEntry event
- fibLimits->SetLimits(faceLimits->GetMaxRate(),
- 2 * i->second.get<2>() /*exact RTT*/);
- NS_LOG_DEBUG("Set limit for prefix "
- << *prefix << " " << faceLimits->GetMaxRate() << " / "
- << 2 * i->second.get<2>() << "s ("
- << faceLimits->GetMaxRate() * 2 * i->second.get<2>() << ")");
- }
+ // Ptr<Limits> fibLimits = entry->GetObject<Limits> ();
+ // if (fibLimits != 0)
+ //{
+ // if it was created by the forwarding strategy via DidAddFibEntry event
+ // fibLimits->SetLimits (faceLimits->GetMaxRate (), 2 * i->second.get<2> () /*exact
+ // RTT*/);
+ // NS_LOG_DEBUG ("Set limit for prefix " << *prefix << " " << faceLimits->GetMaxRate
+ // () << " / " << 2*i->second.get<2> () << "s (" << faceLimits->GetMaxRate () * 2 *
+ // i->second.get<2> () << ")");
+ //}
}
}
}
diff --git a/helper/ndn-stack-helper.cpp b/helper/ndn-stack-helper.cpp
index 5559d2e..b548844 100644
--- a/helper/ndn-stack-helper.cpp
+++ b/helper/ndn-stack-helper.cpp
@@ -39,11 +39,6 @@
#include "../model/ndn-net-device-face.hpp"
#include "../model/ndn-l3-protocol.hpp"
-#include "ns3/ndn-forwarding-strategy.hpp"
-#include "ns3/ndn-fib.hpp"
-#include "ns3/ndn-pit.hpp"
-#include "ns3/ndn-content-store.hpp"
-
#include "ns3/node-list.h"
#include "ns3/data-rate.h"
@@ -218,17 +213,17 @@
Ptr<L3Protocol> ndn = m_ndnFactory.Create<L3Protocol>();
// Create and aggregate FIB
- Ptr<Fib> fib = m_fibFactory.Create<Fib>();
- ndn->AggregateObject(fib);
+ // Ptr<Fib> fib = m_fibFactory.Create<Fib> ();
+ // ndn->AggregateObject (fib);
// Create and aggregate PIT
- ndn->AggregateObject(m_pitFactory.Create<Pit>());
+ // ndn->AggregateObject (m_pitFactory.Create<Pit> ());
// Create and aggregate forwarding strategy
- ndn->AggregateObject(m_strategyFactory.Create<ForwardingStrategy>());
+ // ndn->AggregateObject (m_strategyFactory.Create<ForwardingStrategy> ());
// Create and aggregate content store
- ndn->AggregateObject(m_contentStoreFactory.Create<ContentStore>());
+ // ndn->AggregateObject (m_contentStoreFactory.Create<ContentStore> ());
// Aggregate L3Protocol on node
node->AggregateObject(ndn);
@@ -240,7 +235,7 @@
// if (DynamicCast<LoopbackNetDevice> (device) != 0)
// continue; // don't create face for a LoopbackNetDevice
- Ptr<NetDeviceFace> face;
+ shared_ptr<NetDeviceFace> face;
for (std::list<std::pair<TypeId, NetDeviceFaceCreateCallback>>::const_iterator item =
m_netDeviceCallbacks.begin();
@@ -301,13 +296,13 @@
}
}
-Ptr<NetDeviceFace>
+shared_ptr<NetDeviceFace>
StackHelper::DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
Ptr<NetDevice> netDevice) const
{
NS_LOG_DEBUG("Creating default NetDeviceFace on node " << node->GetId());
- Ptr<NetDeviceFace> face = CreateObject<NetDeviceFace>(node, netDevice);
+ shared_ptr<NetDeviceFace> face = CreateObject<NetDeviceFace>(node, netDevice);
ndn->AddFace(face);
NS_LOG_LOGIC("Node " << node->GetId() << ": added NetDeviceFace as face #" << *face);
@@ -315,24 +310,25 @@
return face;
}
-Ptr<NetDeviceFace>
+shared_ptr<NetDeviceFace>
StackHelper::PointToPointNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
Ptr<NetDevice> device) const
{
NS_LOG_DEBUG("Creating point-to-point NetDeviceFace on node " << node->GetId());
- Ptr<NetDeviceFace> face = CreateObject<NetDeviceFace>(node, device);
+ shared_ptr<NetDeviceFace> face = CreateObject<NetDeviceFace>(node, device);
ndn->AddFace(face);
NS_LOG_LOGIC("Node " << node->GetId() << ": added NetDeviceFace as face #" << *face);
if (m_limitsEnabled) {
- Ptr<Limits> limits = face->GetObject<Limits>();
- if (limits == 0) {
- NS_FATAL_ERROR("Limits are enabled, but the selected forwarding strategy does not support "
- "limits. Please revise your scenario");
- exit(1);
- }
+ // Ptr<Limits> limits = face->GetObject<Limits> ();
+ /*if (limits == 0)
+ {
+ NS_FATAL_ERROR ("Limits are enabled, but the selected forwarding strategy does not support
+ limits. Please revise your scenario");
+ exit (1);
+ }*/
NS_LOG_INFO("Limits are enabled");
Ptr<PointToPointNetDevice> p2p = DynamicCast<PointToPointNetDevice>(device);
@@ -352,11 +348,12 @@
1.0 * dataRate.Get().GetBitRate() / 8.0 / (m_avgDataSize + m_avgInterestSize);
// NS_LOG_INFO ("Max packets per second: " << maxInterestPackets);
// NS_LOG_INFO ("Max burst: " << m_avgRtt.ToDouble (Time::S) * maxInterestPackets);
- NS_LOG_INFO("MaxLimit: " << (int)(m_avgRtt.ToDouble(Time::S) * maxInterestPackets));
-
+ // NS_LOG_INFO ("MaxLimit: " << (int)(m_avgRtt.ToDouble (Time::S) *
+ // maxInterestPackets));
+ /*
// Set max to BDP
- limits->SetLimits(maxInterestPackets, m_avgRtt.ToDouble(Time::S));
- limits->SetLinkDelay(linkDelay.Get().ToDouble(Time::S));
+ limits->SetLimits (maxInterestPackets, m_avgRtt.ToDouble (Time::S));
+ limits->SetLinkDelay (linkDelay.Get ().ToDouble (Time::S)); */
}
}
@@ -371,16 +368,17 @@
}
void
-StackHelper::AddRoute(Ptr<Node> node, const std::string& prefix, Ptr<Face> face, int32_t metric)
+StackHelper::AddRoute(Ptr<Node> node, const std::string& prefix, shared_ptr<Face> face, int32_t metric)
{
NS_LOG_LOGIC("[" << node->GetId() << "]$ route add " << prefix << " via " << *face << " metric "
<< metric);
- Ptr<Fib> fib = node->GetObject<Fib>();
+ // Ptr<Fib> fib = node->GetObject<Fib> ();
- NameValue prefixValue;
- prefixValue.DeserializeFromString(prefix, MakeNameChecker());
- fib->Add(prefixValue.Get(), face, metric);
+ // NameValue prefixValue;
+ // prefixValue.DeserializeFromString (prefix, MakeNameChecker ());
+ ::ndn::Name name(prefix);
+ // fib->Add (name, face, metric);
}
void
@@ -389,7 +387,7 @@
Ptr<L3Protocol> ndn = node->GetObject<L3Protocol>();
NS_ASSERT_MSG(ndn != 0, "Ndn stack should be installed on the node");
- Ptr<Face> face = ndn->GetFace(faceId);
+ shared_ptr<Face> face = ndn->GetFace(faceId);
NS_ASSERT_MSG(face != 0, "Face with ID [" << faceId << "] does not exist on node ["
<< node->GetId() << "]");
@@ -406,7 +404,7 @@
Ptr<L3Protocol> ndn = node->GetObject<L3Protocol>();
NS_ASSERT_MSG(ndn != 0, "Ndn stack should be installed on the node");
- Ptr<Face> face = ndn->GetFace(faceId);
+ shared_ptr<Face> face = ndn->GetFace(faceId);
NS_ASSERT_MSG(face != 0, "Face with ID [" << faceId << "] does not exist on node [" << nodeName
<< "]");
@@ -432,7 +430,7 @@
Ptr<L3Protocol> ndn = node->GetObject<L3Protocol>();
NS_ASSERT_MSG(ndn != 0, "Ndn stack should be installed on the node");
- Ptr<Face> face = ndn->GetFaceByNetDevice(netDevice);
+ shared_ptr<Face> face = ndn->GetFaceByNetDevice(netDevice);
NS_ASSERT_MSG(face != 0, "There is no face associated with the p2p link");
AddRoute(node, prefix, face, metric);
diff --git a/helper/ndn-stack-helper.hpp b/helper/ndn-stack-helper.hpp
index bad1234..d32769c 100644
--- a/helper/ndn-stack-helper.hpp
+++ b/helper/ndn-stack-helper.hpp
@@ -128,7 +128,7 @@
const std::string& attr3 = "", const std::string& value3 = "",
const std::string& attr4 = "", const std::string& value4 = "");
- typedef Callback<Ptr<NetDeviceFace>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice>>
+ typedef Callback<shared_ptr<NetDeviceFace>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice>>
NetDeviceFaceCreateCallback;
/**
@@ -260,7 +260,7 @@
* \param metric Routing metric
*/
static void
- AddRoute(Ptr<Node> node, const std::string& prefix, Ptr<Face> face, int32_t metric);
+ AddRoute(Ptr<Node> node, const std::string& prefix, shared_ptr<Face> face, int32_t metric);
/**
* @brief Add forwarding entry to FIB (work only with point-to-point links)
@@ -293,10 +293,10 @@
SetDefaultRoutes(bool needSet);
private:
- Ptr<NetDeviceFace>
+ shared_ptr<NetDeviceFace>
DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const;
- Ptr<NetDeviceFace>
+ shared_ptr<NetDeviceFace>
PointToPointNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
Ptr<NetDevice> netDevice) const;