model: Removing more legacy code and make code to compile
diff --git a/apps/ndn-app.cpp b/apps/ndn-app.cpp
index b5d3e35..4202111 100644
--- a/apps/ndn-app.cpp
+++ b/apps/ndn-app.cpp
@@ -24,9 +24,7 @@
#include "ns3/packet.h"
#include "ns3/ndn-l3-protocol.hpp"
-#include "ns3/ndn-fib.hpp"
#include "ns3/ndn-app-face.hpp"
-#include "ns3/ndn-forwarding-strategy.hpp"
NS_LOG_COMPONENT_DEFINE("ndn.App");
diff --git a/apps/ndn-app.hpp b/apps/ndn-app.hpp
index f0ac19b..7a3cfd7 100644
--- a/apps/ndn-app.hpp
+++ b/apps/ndn-app.hpp
@@ -98,19 +98,19 @@
protected:
bool m_active; ///< @brief Flag to indicate that application is active (set by StartApplication
/// and StopApplication)
- Ptr<Face> m_face; ///< @brief automatically created application face through which application
+ shared_ptr<Face> m_face; ///< @brief automatically created application face through which application
/// communicates
- TracedCallback<shared_ptr<const Interest>, Ptr<App>, Ptr<Face>>
+ TracedCallback<shared_ptr<const Interest>, Ptr<App>, shared_ptr<Face>>
m_receivedInterests; ///< @brief App-level trace of received Interests
- TracedCallbackshared_ptr<const Data>, Ptr<App>,
- Ptr<Face>> m_receivedDatas; ///< @brief App-level trace of received Data
+ TracedCallback<shared_ptr<const Data>, Ptr<App>,
+ shared_ptr<Face>> m_receivedDatas; ///< @brief App-level trace of received Data
- TracedCallback<shared_ptr<const Interest>, Ptr<App>, Ptr<Face>>
+ TracedCallback<shared_ptr<const Interest>, Ptr<App>, shared_ptr<Face>>
m_transmittedInterests; ///< @brief App-level trace of transmitted Interests
- TracedCallback<shared_ptr<const Data>, Ptr<App>, Ptr<Face>>
+ TracedCallback<shared_ptr<const Data>, Ptr<App>, shared_ptr<Face>>
m_transmittedDatas; ///< @brief App-level trace of transmitted Data
};
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;
diff --git a/model/ip-faces/ndn-ip-face-stack.cpp b/model/ip-faces/ndn-ip-face-stack.cpp
deleted file mode 100644
index 3481b94..0000000
--- a/model/ip-faces/ndn-ip-face-stack.cpp
+++ /dev/null
@@ -1,219 +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-ip-face-stack.hpp"
-#include "ndn-tcp-face.hpp"
-#include "ndn-udp-face.hpp"
-
-#include "ns3/ndn-l3-protocol.hpp"
-
-#include "ns3/log.h"
-#include "ns3/assert.h"
-#include "ns3/packet.h"
-#include "ns3/boolean.h"
-
-#include "ns3/socket.h"
-#include "ns3/tcp-socket-factory.h"
-#include "ns3/udp-socket-factory.h"
-#include "ns3/simulator.h"
-
-NS_LOG_COMPONENT_DEFINE("ndn.IpFaceStack");
-
-namespace ns3 {
-namespace ndn {
-
-NS_OBJECT_ENSURE_REGISTERED(IpFaceStack);
-
-const Callback<void, Ptr<Face>> IpFaceStack::NULL_CREATE_CALLBACK =
- MakeNullCallback<void, Ptr<Face>>();
-
-TypeId
-IpFaceStack::GetTypeId(void)
-{
- static TypeId tid =
- TypeId("ns3::ndn::IpFaceStack")
- .SetGroupName("Ndn")
- .SetParent<Object>()
- .AddConstructor<IpFaceStack>()
-
- .AddAttribute("EnableTCP", "Enable ability to create TCP faces", BooleanValue(true),
- MakeBooleanAccessor(&IpFaceStack::m_enableTcp), MakeBooleanChecker())
-
- .AddAttribute("EnableUDP", "Enable ability to create UDP faces", BooleanValue(true),
- MakeBooleanAccessor(&IpFaceStack::m_enableUdp), MakeBooleanChecker());
- return tid;
-}
-
-IpFaceStack::IpFaceStack()
-{
-}
-
-IpFaceStack::~IpFaceStack()
-{
-}
-
-void
-IpFaceStack::NotifyNewAggregate()
-{
- if (m_node == 0) {
- m_node = GetObject<Node>();
- if (m_node != 0) {
- Simulator::ScheduleWithContext(m_node->GetId(), Seconds(0.1), &IpFaceStack::StartServer,
- this);
- }
- }
-}
-
-// Application Methods
-void
-IpFaceStack::StartServer() // Called at time specified by Start
-{
- NS_LOG_FUNCTION(this);
-
- if (m_enableTcp) {
- m_tcpServer = Socket::CreateSocket(m_node, TcpSocketFactory::GetTypeId());
-
- m_tcpServer->Bind(InetSocketAddress(Ipv4Address::GetAny(), L3Protocol::IP_STACK_PORT));
- m_tcpServer->Listen();
-
- m_tcpServer->SetAcceptCallback(MakeCallback(&IpFaceStack::OnTcpConnectionRequest, this),
- MakeCallback(&IpFaceStack::OnTcpConnectionAccept, this));
- }
-
- if (m_enableUdp) {
- m_udpServer = Socket::CreateSocket(m_node, UdpSocketFactory::GetTypeId());
- m_udpServer->Bind(InetSocketAddress(Ipv4Address::GetAny(), L3Protocol::IP_STACK_PORT));
-
- m_udpServer->SetRecvCallback(MakeCallback(&IpFaceStack::OnUdpPacket, this));
- }
-}
-
-bool
-IpFaceStack::OnTcpConnectionRequest(Ptr<Socket> sock, const Address& addr)
-{
- NS_LOG_FUNCTION(this << sock << InetSocketAddress::ConvertFrom(addr));
- return true; // accept all connections from anybody
-}
-
-void
-IpFaceStack::OnTcpConnectionAccept(Ptr<Socket> socket, const Address& addr)
-{
- NS_LOG_FUNCTION(this << socket << InetSocketAddress::ConvertFrom(addr));
-
- Ptr<L3Protocol> ndn = m_node->GetObject<L3Protocol>();
- Ptr<TcpFace> face =
- CreateObject<TcpFace>(m_node, socket, InetSocketAddress::ConvertFrom(addr).GetIpv4());
-
- ndn->AddFace(face);
- face->SetUp(true);
-
- socket->SetCloseCallbacks(MakeCallback(&TcpFace::OnTcpConnectionClosed, face),
- MakeCallback(&TcpFace::OnTcpConnectionClosed, face));
-}
-
-void
-IpFaceStack::OnUdpPacket(Ptr<Socket> socket)
-{
- NS_LOG_FUNCTION(this << socket);
-
- Ptr<Packet> packet;
- Address from;
- while ((packet = socket->RecvFrom(from))) {
- Ptr<UdpFace> face = CreateOrGetUdpFace(InetSocketAddress::ConvertFrom(from).GetIpv4());
- face->ReceiveFromUdp(packet);
- }
-}
-
-Ptr<TcpFace>
-IpFaceStack::GetTcpFaceByAddress(const Ipv4Address& address)
-{
- TcpFaceMap::iterator i = m_tcpFaceMap.find(address);
- if (i != m_tcpFaceMap.end())
- return i->second;
- else
- return 0;
-}
-
-void
-IpFaceStack::DestroyTcpFace(Ptr<TcpFace> face)
-{
- m_tcpFaceMap.erase(face->GetAddress());
-}
-
-Ptr<UdpFace>
-IpFaceStack::GetUdpFaceByAddress(const Ipv4Address& address)
-{
- UdpFaceMap::iterator i = m_udpFaceMap.find(address);
- if (i != m_udpFaceMap.end())
- return i->second;
- else
- return 0;
-}
-
-Ptr<TcpFace>
-IpFaceStack::CreateOrGetTcpFace(Ipv4Address address, Callback<void, Ptr<Face>> onCreate)
-{
- NS_LOG_FUNCTION(address);
-
- TcpFaceMap::iterator i = m_tcpFaceMap.find(address);
- if (i != m_tcpFaceMap.end())
- return i->second;
-
- Ptr<Socket> socket = Socket::CreateSocket(m_node, TcpSocketFactory::GetTypeId());
- Ptr<TcpFace> face = CreateObject<TcpFace>(m_node, socket, address);
-
- face->SetCreateCallback(onCreate);
-
- socket->SetConnectCallback(MakeCallback(&TcpFace::OnConnect, face),
- MakeNullCallback<void, Ptr<Socket>>());
- socket->Connect(InetSocketAddress(address, L3Protocol::IP_STACK_PORT));
-
- m_tcpFaceMap.insert(std::make_pair(address, face));
-
- return face;
-}
-
-Ptr<UdpFace>
-IpFaceStack::CreateOrGetUdpFace(Ipv4Address address)
-{
- NS_LOG_FUNCTION(address);
-
- UdpFaceMap::iterator i = m_udpFaceMap.find(address);
- if (i != m_udpFaceMap.end())
- return i->second;
-
- Ptr<Socket> socket = Socket::CreateSocket(m_node, UdpSocketFactory::GetTypeId());
- socket->Bind(InetSocketAddress(Ipv4Address::GetAny(),
- L3Protocol::IP_STACK_PORT)); // not sure if it going to work...
- // socket->Bind ();
- socket->Connect(InetSocketAddress(address, L3Protocol::IP_STACK_PORT));
-
- Ptr<UdpFace> face = CreateObject<UdpFace>(m_node, socket, address);
- Ptr<L3Protocol> ndn = m_node->GetObject<L3Protocol>();
-
- ndn->AddFace(face);
- face->SetUp(true);
-
- m_udpFaceMap.insert(std::make_pair(address, face));
- return face;
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/model/ip-faces/ndn-ip-face-stack.hpp b/model/ip-faces/ndn-ip-face-stack.hpp
deleted file mode 100644
index 577ad5a..0000000
--- a/model/ip-faces/ndn-ip-face-stack.hpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- * Alexander Afanasyev
- *
- * 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_IP_FACE_STACK_H
-#define NDN_IP_FACE_STACK_H
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "ns3/application.h"
-#include "ns3/socket.h"
-#include "ns3/inet-socket-address.h"
-#include "ns3/ptr.h"
-
-#include <map>
-
-namespace ns3 {
-
-class Packet;
-
-namespace ndn {
-
-class Face;
-class TcpFace;
-class UdpFace;
-
-/**
- * @ingroup ndn
- * @brief Application that provides functionality of creating IP-based faces on NDN nodes
- *
- * The class implements virtual calls onInterest, onNack, and onData
- */
-class IpFaceStack : public Object {
-public:
- static TypeId
- GetTypeId();
-
- /**
- * @brief Default constructor
- */
- IpFaceStack();
- virtual ~IpFaceStack();
-
- /**
- * @brief Lookup TcpFace for a given address
- */
- Ptr<TcpFace>
- GetTcpFaceByAddress(const Ipv4Address& addr);
-
- /**
- * @brief Destroy TcpFace, e.g., after TCP connection got dropped
- */
- void
- DestroyTcpFace(Ptr<TcpFace> face);
-
- /**
- * @brief Lookup UdpFace for a given address
- */
- Ptr<UdpFace>
- GetUdpFaceByAddress(const Ipv4Address& addr);
-
- /**
- * @brief Method allowing creation and lookup of faces
- *
- * All created UDP faces are stored internally in the map, and if the same face is created, it
- *will simply be looked up
- */
- Ptr<TcpFace>
- CreateOrGetTcpFace(Ipv4Address address,
- Callback<void, Ptr<Face>> onCreate = NULL_CREATE_CALLBACK);
-
- /**
- * @brief Method allowing creation and lookup of faces
- *
- * All created TCP faces are stored internally in the map, and if the same face is created, it
- *will simply be looked up
- */
- Ptr<UdpFace>
- CreateOrGetUdpFace(Ipv4Address address);
-
-protected:
- void
- NotifyNewAggregate();
-
-private:
- void
- StartServer();
-
- bool
- OnTcpConnectionRequest(Ptr<Socket> sock, const Address& addr);
-
- void
- OnTcpConnectionAccept(Ptr<Socket> sock, const Address& addr);
-
- void
- OnTcpConnectionClosed(Ptr<Socket> sock);
-
- void
- OnUdpPacket(Ptr<Socket> sock);
-
-public:
- const static Callback<void, Ptr<Face>> NULL_CREATE_CALLBACK;
-
-protected:
- Ptr<Node> m_node;
-
- bool m_enableTcp;
- bool m_enableUdp;
-
- Ptr<Socket> m_tcpServer;
- Ptr<Socket> m_udpServer;
-
- typedef std::map<Ipv4Address, Ptr<TcpFace>> TcpFaceMap;
- typedef std::map<Ipv4Address, Ptr<UdpFace>> UdpFaceMap;
- TcpFaceMap m_tcpFaceMap;
- UdpFaceMap m_udpFaceMap;
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_IP_FACE_STACK_H
diff --git a/model/ip-faces/ndn-ip-faces-helper.cpp b/model/ip-faces/ndn-ip-faces-helper.cpp
deleted file mode 100644
index f265262..0000000
--- a/model/ip-faces/ndn-ip-faces-helper.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- * Alexander Afanasyev
- *
- * 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-ip-faces-helper.hpp"
-#include "ndn-ip-face-stack.hpp"
-
-#include "ns3/ndn-stack-helper.hpp"
-#include "ns3/node-container.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ndn-tcp-face.hpp"
-#include "ndn-udp-face.hpp"
-
-NS_LOG_COMPONENT_DEFINE("ndn.IpFacesHelper");
-
-using namespace std;
-
-namespace ns3 {
-namespace ndn {
-
-void
-IpFacesHelper::Install(Ptr<Node> node)
-{
- Ptr<IpFaceStack> stack = CreateObject<IpFaceStack>();
- node->AggregateObject(stack);
-}
-
-void
-IpFacesHelper::Install(const NodeContainer& nodes)
-{
- for (NodeContainer::Iterator node = nodes.Begin(); node != nodes.End(); node++) {
- Install(*node);
- }
-}
-
-void
-IpFacesHelper::InstallAll()
-{
- Install(NodeContainer::GetGlobal());
-}
-
-struct TcpPrefixRegistrator : SimpleRefCount<TcpPrefixRegistrator> {
- TcpPrefixRegistrator(Ptr<Node> node, const std::string& prefix, int16_t metric)
- : m_node(node)
- , m_prefix(prefix)
- , m_metric(metric)
- {
- }
-
- void
- Run(Ptr<Face> face)
- {
- ndn::StackHelper::AddRoute(m_node, m_prefix, face, m_metric);
- }
-
-private:
- Ptr<Node> m_node;
- std::string m_prefix;
- int16_t m_metric;
-};
-
-static void
-ScheduledCreateTcp(Ptr<Node> node, Ipv4Address address, const std::string& prefix, int16_t metric)
-{
- Ptr<IpFaceStack> stack = node->GetObject<IpFaceStack>();
- NS_ASSERT_MSG(stack != 0, "ndn::IpFaceStack needs to be installed on the node");
-
- Ptr<Face> face = stack->GetTcpFaceByAddress(address);
- if (face == 0) {
- Ptr<TcpPrefixRegistrator> registrator = Create<TcpPrefixRegistrator>(node, prefix, metric);
- stack->CreateOrGetTcpFace(address, MakeCallback(&TcpPrefixRegistrator::Run, registrator));
- }
- else {
- ndn::StackHelper::AddRoute(node, prefix, face, metric);
- }
-}
-
-void
-IpFacesHelper::CreateTcpFace(const Time& when, Ptr<Node> node, Ipv4Address address,
- const std::string& prefix, int16_t metric /* = 1*/)
-{
- Simulator::ScheduleWithContext(node->GetId(), when, ScheduledCreateTcp, node, address, prefix,
- metric);
-}
-
-static void
-ScheduledCreateUdp(Ptr<Node> node, Ipv4Address address, const std::string& prefix, int16_t metric)
-{
- Ptr<IpFaceStack> stack = node->GetObject<IpFaceStack>();
- NS_ASSERT_MSG(stack != 0, "ndn::IpFaceStack needs to be installed on the node");
-
- Ptr<Face> face = stack->CreateOrGetUdpFace(address);
- ndn::StackHelper::AddRoute(node, prefix, face, metric);
-}
-
-void
-IpFacesHelper::CreateUdpFace(const Time& when, Ptr<Node> node, Ipv4Address address,
- const std::string& prefix, int16_t metric /* = 1*/)
-{
- Simulator::ScheduleWithContext(node->GetId(), when, ScheduledCreateUdp, node, address, prefix,
- metric);
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/model/ip-faces/ndn-ip-faces-helper.hpp b/model/ip-faces/ndn-ip-faces-helper.hpp
deleted file mode 100644
index b167437..0000000
--- a/model/ip-faces/ndn-ip-faces-helper.hpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013 University of California, Los Angeles
- * Alexander Afanasyev
- *
- * 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_IP_FACES_HELPER_H
-#define NDN_IP_FACES_HELPER_H
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "ns3/ptr.h"
-#include "ns3/nstime.h"
-#include "ns3/ipv4-address.h"
-
-namespace ns3 {
-
-class Node;
-class NodeContainer;
-class Channel;
-
-namespace ndn {
-
-/**
- * @ingroup ndn-helpers
- * @brief Helper for NDN IP-based face creation
- */
-class IpFacesHelper {
-public:
- /**
- * @brief Install IpFaceStack interface on a node
- * @param node Node to install IpFaceStack interface
- */
- static void
- Install(Ptr<Node> node);
-
- /**
- * @brief Install IpFaceStack interface on nodes
- * @param nodes NodeContainer to install IpFaceStack interface
- */
- static void
- Install(const NodeContainer& nodes);
-
- /**
- * @brief Install IpFaceStack interface on all nodes
- */
- static void
- InstallAll();
-
- /**
- * @brief Create TCP face
- * @param when Time when to create face (use `Seconds (0)' if face should be created right
- *away)
- * @param node Node to add TCP face (will initiate connection)
- * @param address IP address to connect (using standard 9695 port)
- * @param prefix Prefix to associate with the face
- * @param metric Metric that will be assigned to the face
- *
- * This call schedules connection initiation and after successful connection it will add new face
- * to NDN stack and add the requested route
- *
- * If face has been already created before (same IP address), then this call will simply
- * update FIB with requested prefix
- */
- static void
- CreateTcpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix,
- int16_t metric = 1);
-
- /**
- * @brief Create TCP face
- */
- static void
- CreateUdpFace(const Time& when, Ptr<Node> node, Ipv4Address address, const std::string& prefix,
- int16_t metric = 1);
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_IP_FACES_HELPER_H
diff --git a/model/ip-faces/ndn-tcp-face.cpp b/model/ip-faces/ndn-tcp-face.cpp
deleted file mode 100644
index 9f24986..0000000
--- a/model/ip-faces/ndn-tcp-face.cpp
+++ /dev/null
@@ -1,272 +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-tcp-face.hpp"
-#include "ndn-ip-face-stack.hpp"
-
-#include "ns3/ndn-l3-protocol.hpp"
-
-#include "ns3/log.h"
-#include "ns3/packet.h"
-#include "ns3/node.h"
-#include "ns3/pointer.h"
-#include "ns3/tcp-socket-factory.h"
-
-using namespace std;
-
-NS_LOG_COMPONENT_DEFINE("ndn.TcpFace");
-
-namespace ns3 {
-namespace ndn {
-
-class TcpBoundaryHeader : public Header {
-public:
- static TypeId
- GetTypeId(void)
- {
- static TypeId tid =
- TypeId("ns3::ndn::TcpFace::BoundaryHeader").SetGroupName("Ndn").SetParent<Header>();
- return tid;
- }
-
- TcpBoundaryHeader()
- : m_length(0)
- {
- }
-
- TcpBoundaryHeader(Ptr<Packet> packet)
- : m_length(packet->GetSize())
- {
- }
-
- TcpBoundaryHeader(uint32_t length)
- : m_length(length)
- {
- }
-
- uint32_t
- GetLength() const
- {
- return m_length;
- }
-
- virtual TypeId
- GetInstanceTypeId(void) const
- {
- return TcpBoundaryHeader::GetTypeId();
- }
-
- virtual void
- Print(std::ostream& os) const
- {
- os << "[" << m_length << "]";
- }
-
- virtual uint32_t
- GetSerializedSize(void) const
- {
- return 4;
- }
-
- virtual void
- Serialize(Buffer::Iterator start) const
- {
- start.WriteU32(m_length);
- }
-
- virtual uint32_t
- Deserialize(Buffer::Iterator start)
- {
- m_length = start.ReadU32();
- return 4;
- }
-
-private:
- uint32_t m_length;
-};
-
-NS_OBJECT_ENSURE_REGISTERED(TcpFace);
-
-TypeId
-TcpFace::GetTypeId()
-{
- static TypeId tid = TypeId("ns3::ndn::TcpFace").SetParent<Face>().SetGroupName("Ndn");
- return tid;
-}
-
-/**
- * By default, Ndn face are created in the "down" state. Before
- * becoming useable, the user must invoke SetUp on the face
- */
-TcpFace::TcpFace(Ptr<Node> node, Ptr<Socket> socket, Ipv4Address address)
- : Face(node)
- , m_socket(socket)
- , m_address(address)
- , m_pendingPacketLength(0)
-{
- SetMetric(1); // default metric
-}
-
-TcpFace::~TcpFace()
-{
- NS_LOG_FUNCTION_NOARGS();
-}
-
-TcpFace& TcpFace::operator= (const TcpFace &)
-{
- return *this;
-}
-
-void
-TcpFace::RegisterProtocolHandlers(const InterestHandler& interestHandler,
- const DataHandler& dataHandler)
-{
- NS_LOG_FUNCTION(this);
-
- Face::RegisterProtocolHandlers(interestHandler, dataHandler);
- m_socket->SetRecvCallback(MakeCallback(&TcpFace::ReceiveFromTcp, this));
-}
-
-void
-TcpFace::UnRegisterProtocolHandlers()
-{
- m_socket->SetRecvCallback(MakeNullCallback<void, Ptr<Socket>>());
- Face::UnRegisterProtocolHandlers();
-}
-
-bool
-TcpFace::Send(Ptr<Packet> packet)
-{
- if (!Face::Send(packet)) {
- return false;
- }
-
- NS_LOG_FUNCTION(this << packet);
-
- Ptr<Packet> boundary = Create<Packet>();
- TcpBoundaryHeader hdr(packet);
- boundary->AddHeader(hdr);
-
- m_socket->Send(boundary);
- m_socket->Send(packet);
-
- return true;
-}
-
-void
-TcpFace::ReceiveFromTcp(Ptr<Socket> clientSocket)
-{
- NS_LOG_FUNCTION(this << clientSocket);
- TcpBoundaryHeader hdr;
-
- if (m_pendingPacketLength > 0) {
- if (clientSocket->GetRxAvailable() >= m_pendingPacketLength) {
- Ptr<Packet> realPacket = clientSocket->Recv(m_pendingPacketLength, 0);
- NS_LOG_DEBUG("+++ Expected " << m_pendingPacketLength << " bytes, got "
- << realPacket->GetSize() << " bytes");
- if (realPacket == 0)
- return;
-
- Receive(realPacket);
- }
- else
- return; // still not ready
- }
-
- m_pendingPacketLength = 0;
-
- while (clientSocket->GetRxAvailable() >= hdr.GetSerializedSize()) {
- Ptr<Packet> boundary = clientSocket->Recv(hdr.GetSerializedSize(), 0);
- if (boundary == 0)
- return; // no idea why it would happen...
-
- NS_LOG_DEBUG("Expected 4 bytes, got " << boundary->GetSize() << " bytes");
-
- boundary->RemoveHeader(hdr);
- NS_LOG_DEBUG("Header specifies length: " << hdr.GetLength());
- m_pendingPacketLength = hdr.GetLength();
-
- if (clientSocket->GetRxAvailable() >= hdr.GetLength()) {
- Ptr<Packet> realPacket = clientSocket->Recv(hdr.GetLength(), 0);
- if (realPacket == 0) {
- NS_LOG_DEBUG("Got nothing, but requested at least " << hdr.GetLength());
- return;
- }
-
- NS_LOG_DEBUG("Receiving data " << hdr.GetLength() << " bytes, got " << realPacket->GetSize()
- << " bytes");
-
- Receive(realPacket);
- m_pendingPacketLength = 0;
- }
- else {
- return;
- }
- }
-}
-
-void
-TcpFace::OnTcpConnectionClosed(Ptr<Socket> socket)
-{
- NS_LOG_FUNCTION(this << socket);
- GetNode()->GetObject<IpFaceStack>()->DestroyTcpFace(this);
-}
-
-Ipv4Address
-TcpFace::GetAddress() const
-{
- return m_address;
-}
-
-void
-TcpFace::SetCreateCallback(Callback<void, Ptr<Face>> callback)
-{
- m_onCreateCallback = callback;
-}
-
-void
-TcpFace::OnConnect(Ptr<Socket> socket)
-{
- NS_LOG_FUNCTION(this << socket);
-
- Ptr<L3Protocol> ndn = GetNode()->GetObject<L3Protocol>();
-
- ndn->AddFace(this);
- this->SetUp(true);
-
- socket->SetCloseCallbacks(MakeCallback(&TcpFace::OnTcpConnectionClosed, this),
- MakeCallback(&TcpFace::OnTcpConnectionClosed, this));
-
- if (!m_onCreateCallback.IsNull()) {
- m_onCreateCallback(this);
- m_onCreateCallback = IpFaceStack::NULL_CREATE_CALLBACK;
- }
-}
-
-std::ostream&
-TcpFace::Print(std::ostream& os) const
-{
- os << "dev=tcp(" << GetId() << ", " << m_address << ")";
- return os;
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/model/ip-faces/ndn-tcp-face.hpp b/model/ip-faces/ndn-tcp-face.hpp
deleted file mode 100644
index 9f1ad88..0000000
--- a/model/ip-faces/ndn-tcp-face.hpp
+++ /dev/null
@@ -1,104 +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
- *
- * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_TCP_FACE_H
-#define NDN_TCP_FACE_H
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "ns3/ndn-face.hpp"
-#include "ns3/socket.h"
-#include "ns3/ptr.h"
-#include "ns3/callback.h"
-
-#include <map>
-
-namespace ns3 {
-namespace ndn {
-
-/**
- * \ingroup ndn-face
- * \brief Implementation of TCP/IP NDN face
- *
- * \see NdnAppFace, NdnNetDeviceFace, NdnIpv4Face, NdnUdpFace
- */
-class TcpFace : public Face {
-public:
- static TypeId
- GetTypeId();
-
- /**
- * \brief Constructor
- *
- * @param node Node associated with the face
- */
- TcpFace(Ptr<Node> node, Ptr<Socket> socket, Ipv4Address address);
- virtual ~TcpFace();
-
- void
- OnTcpConnectionClosed(Ptr<Socket> socket);
-
- Ipv4Address
- GetAddress() const;
-
- static Ptr<TcpFace>
- GetFaceByAddress(const Ipv4Address& addr);
-
- void
- SetCreateCallback(Callback<void, Ptr<Face>> callback);
-
- void
- OnConnect(Ptr<Socket> socket);
-
- ////////////////////////////////////////////////////////////////////
- // methods overloaded from ndn::Face
- virtual void
- RegisterProtocolHandlers(const InterestHandler& interestHandler, const DataHandler& dataHandler);
-
- virtual void
- UnRegisterProtocolHandlers();
-
- virtual std::ostream&
- Print(std::ostream& os) const;
-
-protected:
- // also from ndn::Face
- virtual bool
- Send(Ptr<Packet> p);
-
-private:
- TcpFace(const TcpFace&); ///< \brief Disabled copy constructor
- TcpFace&
- operator=(const TcpFace&); ///< \brief Disabled copy operator
-
- void
- ReceiveFromTcp(Ptr<Socket> clientSocket);
-
-private:
- Ptr<Socket> m_socket;
- Ipv4Address m_address;
- uint32_t m_pendingPacketLength;
- Callback<void, Ptr<Face>> m_onCreateCallback;
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_TCP_FACE_H
diff --git a/model/ip-faces/ndn-udp-face.cpp b/model/ip-faces/ndn-udp-face.cpp
deleted file mode 100644
index 414ccd8..0000000
--- a/model/ip-faces/ndn-udp-face.cpp
+++ /dev/null
@@ -1,102 +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-udp-face.hpp"
-#include "ns3/ndn-l3-protocol.hpp"
-
-#include "ns3/log.h"
-#include "ns3/packet.h"
-#include "ns3/node.h"
-#include "ns3/pointer.h"
-#include "ns3/udp-socket-factory.h"
-
-using namespace std;
-
-NS_LOG_COMPONENT_DEFINE("ndn.UdpFace");
-
-namespace ns3 {
-namespace ndn {
-
-NS_OBJECT_ENSURE_REGISTERED(UdpFace);
-
-TypeId
-UdpFace::GetTypeId()
-{
- static TypeId tid = TypeId("ns3::ndn::UdpFace").SetParent<Face>().SetGroupName("Ndn");
- return tid;
-}
-
-/**
- * By default, Ndn face are created in the "down" state. Before
- * becoming useable, the user must invoke SetUp on the face
- */
-UdpFace::UdpFace(Ptr<Node> node, Ptr<Socket> socket, Ipv4Address address)
- : Face(node)
- , m_socket(socket)
- , m_address(address)
-{
- SetMetric(1); // default metric
-}
-
-UdpFace::~UdpFace()
-{
- NS_LOG_FUNCTION_NOARGS();
-}
-
-UdpFace& UdpFace::operator= (const UdpFace &)
-{
- return *this;
-}
-
-bool
-UdpFace::ReceiveFromUdp(Ptr<const Packet> p)
-{
- return Face::Receive(p);
-}
-
-bool
-UdpFace::Send(Ptr<Packet> packet)
-{
- if (!Face::Send(packet)) {
- return false;
- }
-
- NS_LOG_FUNCTION(this << packet);
- m_socket->Send(packet);
-
- return true;
-}
-
-Ipv4Address
-UdpFace::GetAddress() const
-{
- return m_address;
-}
-
-std::ostream&
-UdpFace::Print(std::ostream& os) const
-{
- os << "dev=udp(" << GetId() << "," << GetAddress() << ")";
- return os;
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/model/ip-faces/ndn-udp-face.hpp b/model/ip-faces/ndn-udp-face.hpp
deleted file mode 100644
index ec97c99..0000000
--- a/model/ip-faces/ndn-udp-face.hpp
+++ /dev/null
@@ -1,83 +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
- *
- * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
-
-#ifndef NDN_UDP_FACE_H
-#define NDN_UDP_FACE_H
-
-#include "ns3/ndnSIM/model/ndn-common.hpp"
-
-#include "ns3/ndn-face.hpp"
-#include "ns3/socket.h"
-#include "ns3/ptr.h"
-
-#include <map>
-
-namespace ns3 {
-namespace ndn {
-
-/**
- * \ingroup ndn-face
- * \brief Implementation of UDP/IP NDN face
- *
- * \see ndn::AppFace, ndn::NetDeviceFace, ndn::Ipv4Face, ndn::TcpFace
- */
-class UdpFace : public Face {
-public:
- static TypeId
- GetTypeId();
-
- /**
- * \brief Constructor
- *
- * @param node Node associated with the face
- */
- UdpFace(Ptr<Node> node, Ptr<Socket> socket, Ipv4Address address);
- virtual ~UdpFace();
-
- Ipv4Address
- GetAddress() const;
-
- virtual bool
- ReceiveFromUdp(Ptr<const Packet> p);
-
- ////////////////////////////////////////////////////////////////////
- // methods overloaded from ndn::Face
- virtual std::ostream&
- Print(std::ostream& os) const;
-
-protected:
- // also from ndn::Face
- virtual bool
- Send(Ptr<Packet> p);
-
-private:
- UdpFace(const UdpFace&); ///< \brief Disabled copy constructor
- UdpFace&
- operator=(const UdpFace&); ///< \brief Disabled copy operator
-
-private:
- Ptr<Socket> m_socket;
- Ipv4Address m_address;
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // NDN_UDP_FACE_H
diff --git a/model/ndn-app-face.cpp b/model/ndn-app-face.cpp
index bc788e9..0af1432 100644
--- a/model/ndn-app-face.cpp
+++ b/model/ndn-app-face.cpp
@@ -28,31 +28,20 @@
#include "ns3/assert.h"
#include "ns3/simulator.h"
-#include "ns3/ndn-header-helper.hpp"
-#include "ns3/ndn-app.hpp"
+#include "apps/ndn-app.hpp"
NS_LOG_COMPONENT_DEFINE("ndn.AppFace");
namespace ns3 {
namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED(AppFace);
-
-TypeId
-AppFace::GetTypeId()
-{
- static TypeId tid = TypeId("ns3::ndn::AppFace").SetParent<Face>().SetGroupName("Ndn");
- return tid;
-}
-
AppFace::AppFace(Ptr<App> app)
- : Face(app->GetNode())
- , m_app(app)
+ // : Face(app->GetNode())
+ : m_app(app)
{
NS_LOG_FUNCTION(this << app);
NS_ASSERT(m_app != 0);
- SetFlags(Face::APPLICATION);
}
AppFace::~AppFace()
@@ -60,54 +49,18 @@
NS_LOG_FUNCTION_NOARGS();
}
-AppFace::AppFace()
- : Face(0)
-{
-}
-
-AppFace::AppFace(const AppFace&)
- : Face(0)
-{
-}
-
-AppFace&
-AppFace::operator= (const AppFace &)
-{
- return *((AppFace*)0);
-}
-
bool
AppFace::SendInterest(shared_ptr<const Interest> interest)
{
NS_LOG_FUNCTION(this << interest);
-
- if (!IsUp()) {
- return false;
- }
-
- m_app->OnInterest(interest);
-
- return true;
+ return false;
}
bool
AppFace::SendData(shared_ptr<const Data> data)
{
NS_LOG_FUNCTION(this << data);
-
- if (!IsUp()) {
- return false;
- }
-
- m_app->OnData(data);
- return true;
-}
-
-std::ostream&
-AppFace::Print(std::ostream& os) const
-{
- os << "dev=local(" << GetId() << ")";
- return os;
+ return false;
}
} // namespace ndn
diff --git a/model/ndn-app-face.hpp b/model/ndn-app-face.hpp
index 3e06597..9abc4cf 100644
--- a/model/ndn-app-face.hpp
+++ b/model/ndn-app-face.hpp
@@ -47,9 +47,6 @@
*/
class AppFace : public Face {
public:
- static TypeId
- GetTypeId();
-
/**
* \brief Default constructor
*/
@@ -64,18 +61,6 @@
virtual bool
SendData(shared_ptr<const Data> data);
-public:
- virtual std::ostream&
- Print(std::ostream& os) const;
- ////////////////////////////////////////////////////////////////////
-
-private:
- AppFace();
- AppFace(const AppFace&); ///< \brief Disabled copy constructor
-
- AppFace&
- operator=(const AppFace&); ///< \brief Disabled copy operator
-
private:
Ptr<App> m_app;
};
diff --git a/model/ndn-common.hpp b/model/ndn-common.hpp
index 32fd44f..6489981 100644
--- a/model/ndn-common.hpp
+++ b/model/ndn-common.hpp
@@ -23,8 +23,6 @@
#include "ns3/nstime.h"
#include "ns3/simulator.h"
-#include "ndn-ns3.hpp"
-
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/encoding/block.hpp>
#include <ndn-cxx/signature.hpp>
diff --git a/model/ndn-face.hpp b/model/ndn-face.hpp
index 2eeb969..73d4fb3 100644
--- a/model/ndn-face.hpp
+++ b/model/ndn-face.hpp
@@ -20,12 +20,20 @@
#ifndef NDNSIM_NDN_FACE_HPP
#define NDNSIM_NDN_FACE_HPP
+#include <boost/noncopyable.hpp>
+
namespace ns3 {
namespace ndn {
-class Face {
+class Face : boost::noncopyable {
};
+inline std::ostream&
+operator<<(std::ostream& os, const Face& face)
+{
+ return os;
+}
+
} // namespace ndn
} // namespace ns3
diff --git a/model/ndn-global-router.cpp b/model/ndn-global-router.cpp
index 19d5654..b718689 100644
--- a/model/ndn-global-router.cpp
+++ b/model/ndn-global-router.cpp
@@ -20,8 +20,8 @@
#include "ndn-global-router.hpp"
-#include "ns3/ndn-l3-protocol.hpp"
-#include "ns3/ndn-face.hpp"
+#include "ndn-l3-protocol.hpp"
+#include "ndn-face.hpp"
#include "ns3/channel.h"
@@ -73,7 +73,7 @@
}
void
-GlobalRouter::AddIncidency(Ptr<Face> face, Ptr<GlobalRouter> gr)
+GlobalRouter::AddIncidency(shared_ptr<Face> face, Ptr<GlobalRouter> gr)
{
m_incidencies.push_back(boost::make_tuple(this, face, gr));
}
diff --git a/model/ndn-global-router.hpp b/model/ndn-global-router.hpp
index f742656..74cf5f1 100644
--- a/model/ndn-global-router.hpp
+++ b/model/ndn-global-router.hpp
@@ -47,7 +47,7 @@
/**
* @brief Graph edge
*/
- typedef boost::tuple<Ptr<GlobalRouter>, Ptr<Face>, Ptr<GlobalRouter>> Incidency;
+ typedef boost::tuple<Ptr<GlobalRouter>, shared_ptr<Face>, Ptr<GlobalRouter>> Incidency;
/**
* @brief List of graph edges
*/
@@ -95,7 +95,7 @@
* @param ndn GlobalRouter of another node
*/
void
- AddIncidency(Ptr<Face> face, Ptr<GlobalRouter> ndn);
+ AddIncidency(shared_ptr<Face> face, Ptr<GlobalRouter> ndn);
/**
* @brief Get list of edges that are connected to this node
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index 07d38f3..4ea8189 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -32,11 +32,7 @@
#include "ns3/simulator.h"
#include "ns3/random-variable.h"
-#include "ns3/ndn-pit.hpp"
-
-#include "ns3/ndn-face.hpp"
-#include "ns3/ndn-forwarding-strategy.hpp"
-
+#include "ndn-face.hpp"
#include "ndn-net-device-face.hpp"
#include <boost/foreach.hpp>
@@ -59,14 +55,14 @@
.SetGroupName("ndn")
.SetParent<Object>()
.AddConstructor<L3Protocol>()
- .AddAttribute("FaceList", "List of faces associated with ndn stack", ObjectVectorValue(),
- MakeObjectVectorAccessor(&L3Protocol::m_faces),
- MakeObjectVectorChecker<Face>());
+ ;
+ // .AddAttribute("FaceList", "List of faces associated with ndn stack", ObjectVectorValue(),
+ // MakeObjectVectorAccessor(&L3Protocol::m_faces),
+ // MakeObjectVectorChecker<Face>());
return tid;
}
L3Protocol::L3Protocol()
- : m_faceCounter(0)
{
NS_LOG_FUNCTION(this);
}
@@ -87,15 +83,10 @@
if (m_node == 0) {
m_node = GetObject<Node>();
if (m_node != 0) {
- NS_ASSERT_MSG(m_forwardingStrategy != 0,
- "Forwarding strategy should be aggregated before L3Protocol");
}
}
- if (m_forwardingStrategy == 0) {
- m_forwardingStrategy = GetObject<ForwardingStrategy>();
- }
- Object::NotifyNewAggregate();
+ Object::NotifyNewAggregate ();
}
void
@@ -103,112 +94,47 @@
{
NS_LOG_FUNCTION(this);
- // for (FaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
- // {
- // *i = 0;
- // }
- m_faces.clear();
m_node = 0;
- // Force delete on objects
- m_forwardingStrategy = 0; // there is a reference to PIT stored in here
-
Object::DoDispose();
}
uint32_t
-L3Protocol::AddFace(const Ptr<Face>& face)
+L3Protocol::AddFace(const shared_ptr<Face>& face)
{
NS_LOG_FUNCTION(this << &face);
- face->SetId(
- m_faceCounter); // sets a unique ID of the face. This ID serves only informational purposes
-
- // ask face to register in lower-layer stack
- face->RegisterProtocolHandlers(MakeCallback(&ForwardingStrategy::OnInterest,
- m_forwardingStrategy),
- MakeCallback(&ForwardingStrategy::OnData, m_forwardingStrategy));
-
- m_faces.push_back(face);
- m_faceCounter++;
-
- m_forwardingStrategy->AddFace(face); // notify that face is added
- return face->GetId();
+ return 0;
}
void
-L3Protocol::RemoveFace(Ptr<Face> face)
+L3Protocol::RemoveFace(shared_ptr<Face> face)
{
- NS_LOG_FUNCTION(this << boost::cref(*face));
- // ask face to register in lower-layer stack
- face->UnRegisterProtocolHandlers();
- Ptr<Pit> pit = GetObject<Pit>();
-
- // just to be on a safe side. Do the process in two steps
- std::list<Ptr<pit::Entry>> entriesToRemoves;
- for (Ptr<pit::Entry> pitEntry = pit->Begin(); pitEntry != 0; pitEntry = pit->Next(pitEntry)) {
- pitEntry->RemoveAllReferencesToFace(face);
-
- // If this face is the only for the associated FIB entry, then FIB entry will be removed soon.
- // Thus, we have to remove the whole PIT entry
- if (pitEntry->GetFibEntry()->m_faces.size() == 1
- && pitEntry->GetFibEntry()->m_faces.begin()->GetFace() == face) {
- entriesToRemoves.push_back(pitEntry);
- }
- }
- BOOST_FOREACH (Ptr<pit::Entry> removedEntry, entriesToRemoves) {
- pit->MarkErased(removedEntry);
- }
-
- FaceList::iterator face_it = find(m_faces.begin(), m_faces.end(), face);
- if (face_it == m_faces.end()) {
- return;
- }
- m_faces.erase(face_it);
-
- GetObject<Fib>()->RemoveFromAll(face);
- m_forwardingStrategy->RemoveFace(face); // notify that face is removed
+ NS_LOG_FUNCTION(this << std::cref(*face));
}
-Ptr<Face>
+shared_ptr<Face>
L3Protocol::GetFace(uint32_t index) const
{
- NS_ASSERT(0 <= index && index < m_faces.size());
- return m_faces[index];
+ return nullptr;
}
-Ptr<Face>
+shared_ptr<Face>
L3Protocol::GetFaceById(uint32_t index) const
{
- BOOST_FOREACH (const Ptr<Face>& face, m_faces) // this function is not supposed to be called
- // often, so linear search is fine
- {
- if (face->GetId() == index)
- return face;
- }
- return 0;
+ return nullptr;
}
-Ptr<Face>
+shared_ptr<Face>
L3Protocol::GetFaceByNetDevice(Ptr<NetDevice> netDevice) const
{
- BOOST_FOREACH (const Ptr<Face>& face, m_faces) // this function is not supposed to be called
- // often, so linear search is fine
- {
- Ptr<NetDeviceFace> netDeviceFace = DynamicCast<NetDeviceFace>(face);
- if (netDeviceFace == 0)
- continue;
-
- if (netDeviceFace->GetNetDevice() == netDevice)
- return face;
- }
- return 0;
+ return nullptr;
}
uint32_t
L3Protocol::GetNFaces(void) const
{
- return m_faces.size();
+ return 0;
}
} // namespace ndn
diff --git a/model/ndn-l3-protocol.hpp b/model/ndn-l3-protocol.hpp
index cf3d19a..73ca77b 100644
--- a/model/ndn-l3-protocol.hpp
+++ b/model/ndn-l3-protocol.hpp
@@ -40,7 +40,6 @@
namespace ndn {
class Face;
-class ForwardingStrategy;
/**
* \defgroup ndn ndnSIM: NDN simulation module
@@ -65,7 +64,7 @@
*/
class L3Protocol : public Object {
public:
- typedef std::vector<Ptr<Face>> FaceList;
+ typedef std::vector<shared_ptr<Face>> FaceList;
/**
* \brief Interface ID
@@ -95,7 +94,7 @@
* \see NdnLocalFace, NdnNetDeviceFace, NdnUdpFace
*/
virtual uint32_t
- AddFace(const Ptr<Face>& face);
+ AddFace(const shared_ptr<Face>& face);
/**
* \brief Get current number of faces added to Ndn stack
@@ -110,7 +109,7 @@
* \param face The face number (number in face list)
* \returns The NdnFace associated with the Ndn face number.
*/
- virtual Ptr<Face>
+ virtual shared_ptr<Face>
GetFace(uint32_t face) const;
/**
@@ -118,19 +117,19 @@
* \param face The face ID number
* \returns The NdnFace associated with the Ndn face number.
*/
- virtual Ptr<Face>
+ virtual shared_ptr<Face>
GetFaceById(uint32_t face) const;
/**
* \brief Remove face from ndn stack (remove callbacks)
*/
virtual void
- RemoveFace(Ptr<Face> face);
+ RemoveFace(shared_ptr<Face> face);
/**
* \brief Get face for NetDevice
*/
- virtual Ptr<Face>
+ virtual shared_ptr<Face>
GetFaceByNetDevice(Ptr<NetDevice> netDevice) const;
protected:
@@ -148,18 +147,12 @@
private:
L3Protocol(const L3Protocol&); ///< copy constructor is disabled
+
L3Protocol&
operator=(const L3Protocol&); ///< copy operator is disabled
private:
- uint32_t m_faceCounter; ///< \brief counter of faces. Increased every time a new face is added to
- /// the stack
- FaceList m_faces; ///< \brief list of faces that belongs to ndn stack on this node
-
- // These objects are aggregated, but for optimization, get them here
Ptr<Node> m_node; ///< \brief node on which ndn stack is installed
- Ptr<ForwardingStrategy>
- m_forwardingStrategy; ///< \brief smart pointer to the selected forwarding strategy
};
} // namespace ndn
diff --git a/model/ndn-net-device-face.cpp b/model/ndn-net-device-face.cpp
index 71c23ce..ae9de5d 100644
--- a/model/ndn-net-device-face.cpp
+++ b/model/ndn-net-device-face.cpp
@@ -37,26 +37,17 @@
namespace ns3 {
namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED(NetDeviceFace);
-
-TypeId
-NetDeviceFace::GetTypeId()
-{
- static TypeId tid = TypeId("ns3::ndn::NetDeviceFace").SetParent<Face>().SetGroupName("Ndn");
- return tid;
-}
-
/**
* By default, Ndn face are created in the "down" state. Before
* becoming useable, the user must invoke SetUp on the face
*/
NetDeviceFace::NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice)
- : Face(node)
- , m_netDevice(netDevice)
+ // : Face(node)
+ : m_netDevice(netDevice)
{
NS_LOG_FUNCTION(this << netDevice);
- SetMetric(1); // default metric
+ // SetMetric(1); // default metric
NS_ASSERT_MSG(m_netDevice != 0, "NetDeviceFace needs to be assigned a valid NetDevice");
}
@@ -66,52 +57,16 @@
NS_LOG_FUNCTION_NOARGS();
}
-NetDeviceFace& NetDeviceFace::operator= (const NetDeviceFace &)
-{
- return *this;
-}
-
Ptr<NetDevice>
NetDeviceFace::GetNetDevice() const
{
return m_netDevice;
}
-void
-NetDeviceFace::RegisterProtocolHandlers(const InterestHandler& interestHandler,
- const DataHandler& dataHandler)
-{
- NS_LOG_FUNCTION(this);
-
- Face::RegisterProtocolHandlers(interestHandler, dataHandler);
-
- m_node->RegisterProtocolHandler(MakeCallback(&NetDeviceFace::ReceiveFromNetDevice, this),
- L3Protocol::ETHERNET_FRAME_TYPE, m_netDevice,
- true /*promiscuous mode*/);
-}
-
-void
-NetDeviceFace::UnRegisterProtocolHandlers()
-{
- m_node->UnregisterProtocolHandler(MakeCallback(&NetDeviceFace::ReceiveFromNetDevice, this));
- Face::UnRegisterProtocolHandlers();
-}
-
bool
NetDeviceFace::Send(Ptr<Packet> packet)
{
- if (!Face::Send(packet)) {
- return false;
- }
-
- NS_LOG_FUNCTION(this << packet);
-
- NS_ASSERT_MSG(packet->GetSize() <= m_netDevice->GetMtu(),
- "Packet size " << packet->GetSize() << " exceeds device MTU "
- << m_netDevice->GetMtu() << " for Ndn; fragmentation not supported");
-
- bool ok = m_netDevice->Send(packet, m_netDevice->GetBroadcast(), L3Protocol::ETHERNET_FRAME_TYPE);
- return ok;
+ return false;
}
// callback
@@ -121,35 +76,7 @@
NetDevice::PacketType packetType)
{
NS_LOG_FUNCTION(device << p << protocol << from << to << packetType);
- Receive(p);
-}
-
-std::ostream&
-NetDeviceFace::Print(std::ostream& os) const
-{
-#ifdef NS3_LOG_ENABLE
- os << "dev[" << GetNode()->GetId() << "]=net(" << GetId();
-
- if (DynamicCast<PointToPointNetDevice>(m_netDevice)) {
- // extra debugging information which available ONLY for PointToPointNetDevice's
- os << ",";
- os << DynamicCast<PointToPointNetDevice>(m_netDevice)
- ->GetChannel()
- ->GetDevice(0)
- ->GetNode()
- ->GetId();
- os << "-";
- os << DynamicCast<PointToPointNetDevice>(m_netDevice)
- ->GetChannel()
- ->GetDevice(1)
- ->GetNode()
- ->GetId();
- }
- os << ")";
-#else
- os << "dev=net(" << GetId() << ")";
-#endif
- return os;
+ // Receive(p);
}
} // namespace ndnsim
diff --git a/model/ndn-net-device-face.hpp b/model/ndn-net-device-face.hpp
index 05acb60..f832b52 100644
--- a/model/ndn-net-device-face.hpp
+++ b/model/ndn-net-device-face.hpp
@@ -45,9 +45,6 @@
*/
class NetDeviceFace : public Face {
public:
- static TypeId
- GetTypeId();
-
/**
* \brief Constructor
*
@@ -58,27 +55,12 @@
NetDeviceFace(Ptr<Node> node, const Ptr<NetDevice>& netDevice);
virtual ~NetDeviceFace();
- ////////////////////////////////////////////////////////////////////
- // methods overloaded from NdnFace
- virtual void
- RegisterProtocolHandlers(const InterestHandler& interestHandler, const DataHandler& dataHandler);
-
- virtual void
- UnRegisterProtocolHandlers();
-
protected:
virtual bool
Send(Ptr<Packet> p);
public:
/**
- * @brief Print out name of the NdnFace to the stream
- */
- virtual std::ostream&
- Print(std::ostream& os) const;
- ////////////////////////////////////////////////////////////////////
-
- /**
* \brief Get NetDevice associated with the face
*
* \returns smart pointer to NetDevice associated with the face
@@ -87,10 +69,6 @@
GetNetDevice() const;
private:
- NetDeviceFace(const NetDeviceFace&); ///< \brief Disabled copy constructor
- NetDeviceFace&
- operator=(const NetDeviceFace&); ///< \brief Disabled copy operator
-
/// \brief callback from lower layers
void
ReceiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
diff --git a/utils/ndn-limits-rate.cpp b/utils/ndn-limits-rate.cpp
deleted file mode 100644
index 8729231..0000000
--- a/utils/ndn-limits-rate.cpp
+++ /dev/null
@@ -1,157 +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-limits-rate.hpp"
-
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ns3/random-variable.h"
-#include "ns3/ndn-face.hpp"
-#include "ns3/node.h"
-
-NS_LOG_COMPONENT_DEFINE("ndn.Limits.Rate");
-
-namespace ns3 {
-namespace ndn {
-
-NS_OBJECT_ENSURE_REGISTERED(LimitsRate);
-
-TypeId
-LimitsRate::GetTypeId()
-{
- static TypeId tid =
- TypeId("ns3::ndn::Limits::Rate")
- .SetGroupName("Ndn")
- .SetParent<Limits>()
- .AddConstructor<LimitsRate>()
-
- .AddAttribute("RandomizeLeak", "Randomize start time for token bucket leakage. May be "
- "helpful to prevent leak synchronizations",
- TimeValue(Seconds(0.001)),
- MakeTimeAccessor(&LimitsRate::m_leakRandomizationInteral), MakeTimeChecker())
-
- ;
- return tid;
-}
-
-void
-LimitsRate::NotifyNewAggregate()
-{
- super::NotifyNewAggregate();
-
- if (!m_isLeakScheduled) {
- if (GetObject<Face>() != 0) {
- NS_ASSERT_MSG(GetObject<Face>()->GetNode() != 0, "Node object should exist on the face");
-
- m_isLeakScheduled = true;
-
- if (!m_leakRandomizationInteral.IsZero()) {
- UniformVariable r(0.0, m_leakRandomizationInteral.ToDouble(Time::S));
- Simulator::ScheduleWithContext(GetObject<Face>()->GetNode()->GetId(), Seconds(r.GetValue()),
- &LimitsRate::LeakBucket, this, 0.0);
- }
- else {
- Simulator::ScheduleWithContext(GetObject<Face>()->GetNode()->GetId(), Seconds(0),
- &LimitsRate::LeakBucket, this, 0.0);
- }
- }
- }
-}
-
-void
-LimitsRate::SetLimits(double rate, double delay)
-{
- super::SetLimits(rate, delay);
-
- // maximum allowed burst
- m_bucketMax = GetMaxRate() * GetMaxDelay();
-
- // amount of packets allowed every second (leak rate)
- m_bucketLeak = GetMaxRate();
-}
-
-void
-LimitsRate::UpdateCurrentLimit(double limit)
-{
- NS_ASSERT_MSG(limit >= 0.0, "Limit should be greater or equal to zero");
-
- m_bucketLeak = std::min(limit, GetMaxRate());
- m_bucketMax = m_bucketLeak * GetMaxDelay();
-}
-
-bool
-LimitsRate::IsBelowLimit()
-{
- if (!IsEnabled())
- return true;
-
- return (m_bucketMax - m_bucket >= 1.0);
-}
-
-void
-LimitsRate::BorrowLimit()
-{
- if (!IsEnabled())
- return;
-
- NS_ASSERT_MSG(m_bucketMax - m_bucket >= 1.0,
- "Should not be possible, unless we IsBelowLimit was not checked correctly");
- m_bucket += 1;
-}
-
-void
-LimitsRate::ReturnLimit()
-{
- // do nothing
-}
-
-void
-LimitsRate::LeakBucket(double interval)
-{
- const double leak = m_bucketLeak * interval;
-
-#ifdef NS3_LOG_ENABLE
- if (m_bucket > 1) {
- NS_LOG_DEBUG("Leak from " << m_bucket << " to " << std::max(0.0, m_bucket - leak));
- }
-#endif
-
- double bucketOld = m_bucket;
-
- m_bucket = std::max(0.0, m_bucket - leak);
-
- // calculate interval so next time we will leak by 1.001, unless such interval would be more than
- // 1 second
- double newInterval = 1.0;
- if (m_bucketLeak > 1.0) {
- newInterval = 1.001 / m_bucketLeak;
- }
-
- if (m_bucketMax - bucketOld < 1.0
- && m_bucketMax - m_bucket >= 1.0) // limit number of times this stuff is called
- {
- this->FireAvailableSlotCallback();
- }
-
- Simulator::Schedule(Seconds(newInterval), &LimitsRate::LeakBucket, this, newInterval);
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/utils/ndn-limits-rate.hpp b/utils/ndn-limits-rate.hpp
deleted file mode 100644
index a476247..0000000
--- a/utils/ndn-limits-rate.hpp
+++ /dev/null
@@ -1,136 +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_LIMITS_RATE_H_
-#define _NDN_LIMITS_RATE_H_
-
-#include "ndn-limits.hpp"
-#include <ns3/nstime.h>
-
-namespace ns3 {
-namespace ndn {
-
-/**
- * \ingroup ndn-fw
- * \brief Structure to manage limits for outstanding interests
- */
-class LimitsRate : public Limits {
-public:
- typedef Limits super;
-
- static TypeId
- GetTypeId();
-
- /**
- * \brief Constructor
- * \param prefix smart pointer to the prefix for the FIB entry
- */
- LimitsRate()
- : m_isLeakScheduled(false)
- , m_bucketMax(0)
- , m_bucketLeak(1)
- , m_bucket(0)
- {
- }
-
- virtual ~LimitsRate()
- {
- }
-
- virtual void
- SetLimits(double rate, double delay);
-
- virtual double
- GetMaxLimit() const
- {
- return GetMaxRate();
- }
-
- /**
- * @brief Check if Interest limit is reached (token bucket is not empty)
- */
- virtual bool
- IsBelowLimit();
-
- /**
- * @brief Get token from the bucket
- */
- virtual void
- BorrowLimit();
-
- /**
- * @brief Does nothing (token bucket leakage is time-dependent only)
- */
- virtual void
- ReturnLimit();
-
- /**
- * @brief Update normalized amount that should be leaked every second (token bucket leak rate) and
- * leak rate
- */
- virtual void
- UpdateCurrentLimit(double limit);
-
- /**
- * @brief Get normalized amount that should be leaked every second (token bucket leak rate)
- */
- virtual double
- GetCurrentLimit() const
- {
- return m_bucketLeak;
- }
-
- virtual double
- GetCurrentLimitRate() const
- {
- return m_bucketLeak;
- }
-
-protected:
- // from Node
- void
- NotifyNewAggregate();
-
-private:
- /**
- * @brief Leak bucket, assuming `interval' seconds between leakages
- *
- * @param interval Time interval for leakage. Used to calculate size of the leak
- */
- void
- LeakBucket(double interval);
-
-private:
- bool m_isLeakScheduled;
-
- double m_bucketMax; ///< \brief Maximum Interest allowance for this face (maximum tokens that can
- /// be issued at the same time)
- double m_bucketLeak; ///< \brief Normalized amount that should be leaked every second (token
- /// bucket leak rate)
- double m_bucket; ///< \brief Value representing current size of the Interest allowance for this
- /// face (current size of token bucket)
-
- Time m_leakRandomizationInteral;
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // _NDN_LIMITS_RATE_H_
diff --git a/utils/ndn-limits-window.cpp b/utils/ndn-limits-window.cpp
deleted file mode 100644
index c5c5098..0000000
--- a/utils/ndn-limits-window.cpp
+++ /dev/null
@@ -1,90 +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-limits-window.hpp"
-
-#include "ns3/log.h"
-
-NS_LOG_COMPONENT_DEFINE("ndn.Limits.Window");
-
-namespace ns3 {
-namespace ndn {
-
-NS_OBJECT_ENSURE_REGISTERED(LimitsWindow);
-
-TypeId
-LimitsWindow::GetTypeId()
-{
- static TypeId tid = TypeId("ns3::ndn::Limits::Window")
- .SetGroupName("Ndn")
- .SetParent<Limits>()
- .AddConstructor<LimitsWindow>()
-
- .AddTraceSource("CurMaxLimit", "Current maximum limit",
- MakeTraceSourceAccessor(&LimitsWindow::m_curMaxLimit))
-
- .AddTraceSource("Outstanding", "Number of outstanding interests",
- MakeTraceSourceAccessor(&LimitsWindow::m_outstanding));
- return tid;
-}
-
-void
-LimitsWindow::UpdateCurrentLimit(double limit)
-{
- NS_ASSERT_MSG(limit >= 0.0, "Limit should be greater or equal to zero");
-
- m_curMaxLimit = std::min(limit, GetMaxRate() * GetMaxDelay());
-}
-
-bool
-LimitsWindow::IsBelowLimit()
-{
- if (!IsEnabled())
- return true;
-
- return (m_curMaxLimit - m_outstanding >= 1.0);
-}
-
-void
-LimitsWindow::BorrowLimit()
-{
- if (!IsEnabled())
- return;
-
- NS_ASSERT_MSG(m_curMaxLimit - m_outstanding >= 1.0,
- "Should not be possible, unless we IsBelowLimit was not checked correctly");
- m_outstanding += 1;
-}
-
-void
-LimitsWindow::ReturnLimit()
-{
- if (!IsEnabled())
- return;
-
- NS_ASSERT_MSG(m_outstanding >= (uint32_t)1,
- "Should not be possible, unless we decreasing this number twice somewhere");
- m_outstanding -= 1;
-
- FireAvailableSlotCallback();
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/utils/ndn-limits-window.hpp b/utils/ndn-limits-window.hpp
deleted file mode 100644
index b407e02..0000000
--- a/utils/ndn-limits-window.hpp
+++ /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_LIMITS_WINDOW_H_
-#define _NDN_LIMITS_WINDOW_H_
-
-#include "ndn-limits.hpp"
-
-namespace ns3 {
-namespace ndn {
-
-/**
- * \ingroup ndn-fw
- * \brief Structure to manage limits for outstanding interests (window-based limiting)
- */
-class LimitsWindow : public Limits {
-public:
- typedef Limits super;
-
- static TypeId
- GetTypeId();
-
- /**
- * @brief Default Constructor
- */
- LimitsWindow()
- : m_outstanding(0)
- {
- }
-
- /**
- * @brief Virtual destructor
- */
- virtual ~LimitsWindow()
- {
- }
-
- // from ndn::Limits
-
- virtual void
- SetLimits(double rate, double delay)
- {
- super::SetLimits(rate, delay);
-
- m_curMaxLimit = GetMaxRate() * GetMaxDelay();
- }
-
- virtual double
- GetMaxLimit() const
- {
- return GetMaxRate() * GetMaxDelay();
- }
-
- virtual void
- UpdateCurrentLimit(double limit);
-
- virtual double
- GetCurrentLimit() const
- {
- return m_curMaxLimit;
- }
-
- virtual double
- GetCurrentLimitRate() const
- {
- return m_curMaxLimit / GetMaxDelay();
- }
-
- /**
- * @brief Check if current interest window (number of pending interests) if less than maximum
- */
- virtual bool
- IsBelowLimit();
-
- /**
- * @brief Increase current window of outstanding interests
- */
- virtual void
- BorrowLimit();
-
- /**
- * @brief Decrease current window of outstanding interests
- */
- virtual void
- ReturnLimit();
-
-private:
- TracedValue<double> m_curMaxLimit;
- TracedValue<double> m_outstanding;
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // _NDN_LIMITS_WINDOW_H_
diff --git a/utils/ndn-limits.cpp b/utils/ndn-limits.cpp
deleted file mode 100644
index 037b313..0000000
--- a/utils/ndn-limits.cpp
+++ /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>
- */
-
-#include "ndn-limits.hpp"
-
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-#include "ns3/random-variable.h"
-
-NS_LOG_COMPONENT_DEFINE("ndn.Limits");
-
-namespace ns3 {
-namespace ndn {
-
-TypeId
-Limits::GetTypeId()
-{
- static TypeId tid = TypeId("ns3::ndn::Limits").SetGroupName("Ndn").SetParent<Object>()
-
- ;
- return tid;
-}
-
-Limits::Limits()
- : m_maxRate(-1)
- , m_maxDelay(1.0)
- , m_handler(MakeNullCallback<void>())
- , m_linkDelay(0)
-{
-}
-
-void
-Limits::RegisterAvailableSlotCallback(CallbackHandler handler)
-{
- m_handler = handler;
-}
-
-void
-Limits::FireAvailableSlotCallback()
-{
- if (!m_handler.IsNull())
- m_handler();
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/utils/ndn-limits.hpp b/utils/ndn-limits.hpp
deleted file mode 100644
index ebb8d15..0000000
--- a/utils/ndn-limits.hpp
+++ /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>
- */
-
-#ifndef _NDN_LIMITS_H_
-#define _NDN_LIMITS_H_
-
-#include "ns3/ptr.h"
-#include "ns3/object.h"
-#include "ns3/traced-value.h"
-
-namespace ns3 {
-namespace ndn {
-
-/**
- * \ingroup ndn-fw
- * \brief Abstract class to manage Interest limits
- */
-class Limits : public Object {
-public:
- typedef Callback<void> CallbackHandler;
-
- static TypeId
- GetTypeId();
-
- /**
- * @brief Default constructor
- */
- Limits();
-
- /**
- * @brief Virtual destructor
- */
- virtual ~Limits()
- {
- }
-
- /**
- * @brief Set limit for the number of outstanding interests
- * @param rate Maximum rate that needs to be enforced
- * @param delay Maximum delay for BDP product for window-based limits
- */
- virtual void
- SetLimits(double rate, double delay)
- {
- m_maxRate = rate;
- m_maxDelay = delay;
- }
-
- /**
- * @brief Get maximum rate that needs to be enforced
- */
- virtual double
- GetMaxRate() const
- {
- return m_maxRate;
- }
-
- /**
- * @brief Get maximum delay for BDP product for window-based limits
- */
- virtual double
- GetMaxDelay() const
- {
- return m_maxDelay;
- }
-
- /**
- * @brief Get maximum limit (interpretation of the limit depends on realization)
- */
- virtual double
- GetMaxLimit() const = 0;
-
- /**
- * @brief Check whether limits are enabled or not
- */
- virtual inline bool
- IsEnabled() const
- {
- return m_maxRate > 0.0;
- }
-
- /**
- * @brief Update a current value of the limit
- * @param limit Value of current limit.
- *
- * Note that interpretation of this value may be different in different ndn::Limit realizations
- *
- * All realizations will try to guarantee that if limit is larger than previously set value of
- *maximum limit,
- * then the current limit will be limited to that maximum value
- */
- virtual void
- UpdateCurrentLimit(double limit) = 0;
-
- /**
- * @brief Get value of the current limit
- *
- * Note that interpretation of this value may be different in different ndn::Limit realizations
- */
- virtual double
- GetCurrentLimit() const = 0;
-
- /**
- * @brief Get value of the current limit in terms of maximum rate that needs to be enforced
- *
- * Compared to GetCurrentLimit, this method guarantees that the returned value is maximum number
- *of packets
- * that can be send out within one second (max "rate")
- */
- virtual double
- GetCurrentLimitRate() const = 0;
-
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
-
- /**
- * @brief Realization-specific method called to check availability of the limit
- */
- virtual bool
- IsBelowLimit() = 0;
-
- /**
- * @brief "Borrow" limit
- *
- * IsBelowLimit **must** be true, otherwise assert fail
- */
- virtual void
- BorrowLimit() = 0;
-
- /**
- * @brief "Return" limit
- */
- virtual void
- ReturnLimit() = 0;
-
- /**
- * @brief Set link delay (in seconds)
- *
- * This is a supplementary information that may or may not be useful for limits
- */
- virtual void
- SetLinkDelay(double delay)
- {
- m_linkDelay = delay;
- }
-
- /**
- * @brief Get link delay (in seconds)
- */
- virtual double
- GetLinkDelay() const
- {
- return m_linkDelay;
- }
-
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////
-
- /**
- * @brief Set callback which will be called when exhausted limit gets a new slot
- */
- void
- RegisterAvailableSlotCallback(CallbackHandler handler);
-
-protected:
- void
- FireAvailableSlotCallback();
-
-private:
- double m_maxRate;
- double m_maxDelay;
-
- CallbackHandler m_handler;
-
- double m_linkDelay;
-};
-
-} // namespace ndn
-} // namespace ns3
-
-#endif // _NDN_LIMITS_H_
diff --git a/utils/tracers/ndn-l3-aggregate-tracer.cpp b/utils/tracers/ndn-l3-aggregate-tracer.cpp
index 708640b..5f0dca6 100644
--- a/utils/tracers/ndn-l3-aggregate-tracer.cpp
+++ b/utils/tracers/ndn-l3-aggregate-tracer.cpp
@@ -24,9 +24,8 @@
#include "ns3/packet.h"
#include "ns3/config.h"
#include "ns3/callback.h"
-#include "ns3/ndn-app.hpp"
-#include "ns3/ndn-face.hpp"
-#include "ns3/ndn-pit-entry.hpp"
+#include "apps/ndn-app.hpp"
+#include "model/ndn-face.hpp"
#include "ns3/simulator.h"
#include "ns3/node-list.h"
@@ -233,7 +232,7 @@
void
L3AggregateTracer::Reset()
{
- for (std::map<Ptr<const Face>, boost::tuple<Stats, Stats>>::iterator stats = m_stats.begin();
+ for (std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats>>::iterator stats = m_stats.begin();
stats != m_stats.end(); stats++) {
stats->second.get<0>().Reset();
stats->second.get<1>().Reset();
@@ -257,7 +256,7 @@
{
Time time = Simulator::Now();
- for (std::map<Ptr<const Face>, boost::tuple<Stats, Stats>>::iterator stats = m_stats.begin();
+ for (std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats>>::iterator stats = m_stats.begin();
stats != m_stats.end(); stats++) {
if (!stats->first)
continue;
@@ -276,8 +275,8 @@
}
{
- std::map<Ptr<const Face>, boost::tuple<Stats, Stats>>::iterator stats =
- m_stats.find(Ptr<const Face>(0));
+ std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats>>::iterator stats =
+ m_stats.find(shared_ptr<const Face>(0));
if (stats != m_stats.end()) {
PRINTER("SatisfiedInterests", m_satisfiedInterests);
PRINTER("TimedOutInterests", m_timedOutInterests);
@@ -286,7 +285,7 @@
}
void
-L3AggregateTracer::OutInterests(shared_ptr<const Interest> interest, Ptr<const Face> face)
+L3AggregateTracer::OutInterests(shared_ptr<const Interest> interest, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_outInterests++;
if (interest->GetWire()) {
@@ -295,7 +294,7 @@
}
void
-L3AggregateTracer::InInterests(shared_ptr<const Interest> interest, Ptr<const Face> face)
+L3AggregateTracer::InInterests(shared_ptr<const Interest> interest, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_inInterests++;
if (interest->GetWire()) {
@@ -304,7 +303,7 @@
}
void
-L3AggregateTracer::DropInterests(shared_ptr<const Interest> interest, Ptr<const Face> face)
+L3AggregateTracer::DropInterests(shared_ptr<const Interest> interest, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_dropInterests++;
if (interest->GetWire()) {
@@ -313,7 +312,7 @@
}
void
-L3AggregateTracer::OutNacks(shared_ptr<const Interest> nack, Ptr<const Face> face)
+L3AggregateTracer::OutNacks(shared_ptr<const Interest> nack, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_outNacks++;
if (nack->GetWire()) {
@@ -322,7 +321,7 @@
}
void
-L3AggregateTracer::InNacks(shared_ptr<const Interest> nack, Ptr<const Face> face)
+L3AggregateTracer::InNacks(shared_ptr<const Interest> nack, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_inNacks++;
if (nack->GetWire()) {
@@ -331,7 +330,7 @@
}
void
-L3AggregateTracer::DropNacks(shared_ptr<const Interest> nack, Ptr<const Face> face)
+L3AggregateTracer::DropNacks(shared_ptr<const Interest> nack, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_dropNacks++;
if (nack->GetWire()) {
@@ -340,7 +339,7 @@
}
void
-L3AggregateTracer::OutData(shared_ptr<const Data> data, bool fromCache, Ptr<const Face> face)
+L3AggregateTracer::OutData(shared_ptr<const Data> data, bool fromCache, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_outData++;
if (data->GetWire()) {
@@ -349,7 +348,7 @@
}
void
-L3AggregateTracer::InData(shared_ptr<const Data> data, Ptr<const Face> face)
+L3AggregateTracer::InData(shared_ptr<const Data> data, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_inData++;
if (data->GetWire()) {
@@ -358,7 +357,7 @@
}
void
-L3AggregateTracer::DropData(shared_ptr<const Data> data, Ptr<const Face> face)
+L3AggregateTracer::DropData(shared_ptr<const Data> data, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_dropData++;
if (data->GetWire()) {
diff --git a/utils/tracers/ndn-l3-aggregate-tracer.hpp b/utils/tracers/ndn-l3-aggregate-tracer.hpp
index aa5d82f..35bf917 100644
--- a/utils/tracers/ndn-l3-aggregate-tracer.hpp
+++ b/utils/tracers/ndn-l3-aggregate-tracer.hpp
@@ -143,31 +143,31 @@
Print(std::ostream& os) const;
virtual void
- OutInterests(shared_ptr<const Interest>, Ptr<const Face>);
+ OutInterests(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- InInterests(shared_ptr<const Interest>, Ptr<const Face>);
+ InInterests(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- DropInterests(shared_ptr<const Interest>, Ptr<const Face>);
+ DropInterests(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- OutNacks(shared_ptr<const Interest>, Ptr<const Face>);
+ OutNacks(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- InNacks(shared_ptr<const Interest>, Ptr<const Face>);
+ InNacks(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- DropNacks(shared_ptr<const Interest>, Ptr<const Face>);
+ DropNacks(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- OutData(shared_ptr<const Data>, bool fromCache, Ptr<const Face>);
+ OutData(shared_ptr<const Data>, bool fromCache, shared_ptr<const Face>);
virtual void
- InData(shared_ptr<const Data>, Ptr<const Face>);
+ InData(shared_ptr<const Data>, shared_ptr<const Face>);
virtual void
- DropData(shared_ptr<const Data>, Ptr<const Face>);
+ DropData(shared_ptr<const Data>, shared_ptr<const Face>);
virtual void
SatisfiedInterests(Ptr<const pit::Entry>);
@@ -191,7 +191,7 @@
Time m_period;
EventId m_printEvent;
- mutable std::map<Ptr<const Face>, boost::tuple<Stats, Stats>> m_stats;
+ mutable std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats>> m_stats;
};
} // namespace ndn
diff --git a/utils/tracers/ndn-l3-rate-tracer.cpp b/utils/tracers/ndn-l3-rate-tracer.cpp
index 6bba93b..1b91c46 100644
--- a/utils/tracers/ndn-l3-rate-tracer.cpp
+++ b/utils/tracers/ndn-l3-rate-tracer.cpp
@@ -240,7 +240,7 @@
void
L3RateTracer::Reset()
{
- for (std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
+ for (std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
m_stats.begin();
stats != m_stats.end(); stats++) {
stats->second.get<0>().Reset();
@@ -274,7 +274,7 @@
{
Time time = Simulator::Now();
- for (std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
+ for (std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
m_stats.begin();
stats != m_stats.end(); stats++) {
if (!stats->first)
@@ -300,8 +300,8 @@
}
{
- std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
- m_stats.find(Ptr<const Face>(0));
+ std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>>::iterator stats =
+ m_stats.find(shared_ptr<const Face>(0));
if (stats != m_stats.end()) {
PRINTER("SatisfiedInterests", m_satisfiedInterests);
PRINTER("TimedOutInterests", m_timedOutInterests);
@@ -310,7 +310,7 @@
}
void
-L3RateTracer::OutInterests(shared_ptr<const Interest> interest, Ptr<const Face> face)
+L3RateTracer::OutInterests(shared_ptr<const Interest> interest, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_outInterests++;
if (interest->GetWire()) {
@@ -319,7 +319,7 @@
}
void
-L3RateTracer::InInterests(shared_ptr<const Interest> interest, Ptr<const Face> face)
+L3RateTracer::InInterests(shared_ptr<const Interest> interest, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_inInterests++;
if (interest->GetWire()) {
@@ -328,7 +328,7 @@
}
void
-L3RateTracer::DropInterests(shared_ptr<const Interest> interest, Ptr<const Face> face)
+L3RateTracer::DropInterests(shared_ptr<const Interest> interest, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_dropInterests++;
if (interest->GetWire()) {
@@ -337,7 +337,7 @@
}
void
-L3RateTracer::OutNacks(shared_ptr<const Interest> interest, Ptr<const Face> face)
+L3RateTracer::OutNacks(shared_ptr<const Interest> interest, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_outNacks++;
if (interest->GetWire()) {
@@ -346,7 +346,7 @@
}
void
-L3RateTracer::InNacks(shared_ptr<const Interest> interest, Ptr<const Face> face)
+L3RateTracer::InNacks(shared_ptr<const Interest> interest, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_inNacks++;
if (interest->GetWire()) {
@@ -355,7 +355,7 @@
}
void
-L3RateTracer::DropNacks(shared_ptr<const Interest> interest, Ptr<const Face> face)
+L3RateTracer::DropNacks(shared_ptr<const Interest> interest, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_dropNacks++;
if (interest->GetWire()) {
@@ -364,7 +364,7 @@
}
void
-L3RateTracer::OutData(shared_ptr<const Data> data, bool fromCache, Ptr<const Face> face)
+L3RateTracer::OutData(shared_ptr<const Data> data, bool fromCache, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_outData++;
if (data->GetWire()) {
@@ -373,7 +373,7 @@
}
void
-L3RateTracer::InData(shared_ptr<const Data> data, Ptr<const Face> face)
+L3RateTracer::InData(shared_ptr<const Data> data, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_inData++;
if (data->GetWire()) {
@@ -382,7 +382,7 @@
}
void
-L3RateTracer::DropData(shared_ptr<const Data> data, Ptr<const Face> face)
+L3RateTracer::DropData(shared_ptr<const Data> data, shared_ptr<const Face> face)
{
m_stats[face].get<0>().m_dropData++;
if (data->GetWire()) {
diff --git a/utils/tracers/ndn-l3-rate-tracer.hpp b/utils/tracers/ndn-l3-rate-tracer.hpp
index 41adf26..1dc8118 100644
--- a/utils/tracers/ndn-l3-rate-tracer.hpp
+++ b/utils/tracers/ndn-l3-rate-tracer.hpp
@@ -130,31 +130,31 @@
protected:
// from L3Tracer
virtual void
- OutInterests(shared_ptr<const Interest>, Ptr<const Face>);
+ OutInterests(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- InInterests(shared_ptr<const Interest>, Ptr<const Face>);
+ InInterests(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- DropInterests(shared_ptr<const Interest>, Ptr<const Face>);
+ DropInterests(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- OutNacks(shared_ptr<const Interest>, Ptr<const Face>);
+ OutNacks(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- InNacks(shared_ptr<const Interest>, Ptr<const Face>);
+ InNacks(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- DropNacks(shared_ptr<const Interest>, Ptr<const Face>);
+ DropNacks(shared_ptr<const Interest>, shared_ptr<const Face>);
virtual void
- OutData(shared_ptr<const Data>, bool fromCache, Ptr<const Face>);
+ OutData(shared_ptr<const Data>, bool fromCache, shared_ptr<const Face>);
virtual void
- InData(shared_ptr<const Data>, Ptr<const Face>);
+ InData(shared_ptr<const Data>, shared_ptr<const Face>);
virtual void
- DropData(shared_ptr<const Data>, Ptr<const Face>);
+ DropData(shared_ptr<const Data>, shared_ptr<const Face>);
virtual void
SatisfiedInterests(Ptr<const pit::Entry>);
@@ -177,7 +177,7 @@
Time m_period;
EventId m_printEvent;
- mutable std::map<Ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>> m_stats;
+ mutable std::map<shared_ptr<const Face>, boost::tuple<Stats, Stats, Stats, Stats>> m_stats;
};
} // namespace ndn
diff --git a/utils/tracers/ndn-l3-tracer.hpp b/utils/tracers/ndn-l3-tracer.hpp
index f916bd4..4b2cc5a 100644
--- a/utils/tracers/ndn-l3-tracer.hpp
+++ b/utils/tracers/ndn-l3-tracer.hpp
@@ -88,31 +88,16 @@
Connect();
virtual void
- OutInterests(shared_ptr<const Interest>, Ptr<const Face>) = 0;
+ OutInterests(shared_ptr<const Interest>, shared_ptr<const Face>) = 0;
virtual void
- InInterests(shared_ptr<const Interest>, Ptr<const Face>) = 0;
+ InInterests(shared_ptr<const Interest>, shared_ptr<const Face>) = 0;
virtual void
- DropInterests(shared_ptr<const Interest>, Ptr<const Face>) = 0;
+ OutData(shared_ptr<const Data>, bool fromCache, shared_ptr<const Face>) = 0;
virtual void
- OutNacks(shared_ptr<const Interest>, Ptr<const Face>) = 0;
-
- virtual void
- InNacks(shared_ptr<const Interest>, Ptr<const Face>) = 0;
-
- virtual void
- DropNacks(shared_ptr<const Interest>, Ptr<const Face>) = 0;
-
- virtual void
- OutData(shared_ptr<const Data>, bool fromCache, Ptr<const Face>) = 0;
-
- virtual void
- InData(shared_ptr<const Data>, Ptr<const Face>) = 0;
-
- virtual void
- DropData(shared_ptr<const Data>, Ptr<const Face>) = 0;
+ InData(shared_ptr<const Data>, shared_ptr<const Face>) = 0;
virtual void
SatisfiedInterests(Ptr<const pit::Entry>) = 0;
@@ -130,13 +115,8 @@
{
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;
m_satisfiedInterests = 0;
m_timedOutInterests = 0;
@@ -146,13 +126,8 @@
double m_inInterests;
double m_outInterests;
- double m_dropInterests;
- double m_inNacks;
- double m_outNacks;
- double m_dropNacks;
double m_inData;
double m_outData;
- double m_dropData;
double m_satisfiedInterests;
double m_timedOutInterests;
double m_outSatisfiedInterests;
diff --git a/wscript b/wscript
index 11b2d97..bafa76a 100644
--- a/wscript
+++ b/wscript
@@ -83,13 +83,18 @@
module_dirs = ['NFD', 'apps', 'helper', 'model', 'utils']
- module.source = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in module_dirs])
+ module.source = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in module_dirs],
+ excl=['model/ip-faces/*',
+ 'model/cs/*',
+ 'apps/*',
+ 'helper/*',
+ 'utils/**/*'])
module.full_headers = [p.path_from(bld.path) for p in bld.path.ant_glob(
['%s/**/*.hpp' % dir for dir in module_dirs])]
- if bld.env.ENABLE_EXAMPLES:
- bld.recurse ('examples')
+ # if bld.env.ENABLE_EXAMPLES:
+ # bld.recurse('examples')
bld.ns3_python_bindings()