model: Removing more legacy code and make code to compile
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,