22 #include "ndn-ip-faces-helper.h"
23 #include "ndn-ip-face-stack.h"
25 #include "ns3/ndn-stack-helper.h"
26 #include "ns3/node-container.h"
28 #include "ns3/simulator.h"
29 #include "ndn-tcp-face.h"
30 #include "ndn-udp-face.h"
32 NS_LOG_COMPONENT_DEFINE (
"ndn.IpFacesHelper");
40 IpFacesHelper::Install (Ptr<Node> node)
42 Ptr<IpFaceStack> stack = CreateObject<IpFaceStack> ();
43 node->AggregateObject (stack);
47 IpFacesHelper::Install (
const NodeContainer &nodes)
49 for (NodeContainer::Iterator node = nodes.Begin ();
58 IpFacesHelper::InstallAll ()
60 Install (NodeContainer::GetGlobal ());
76 ndn::StackHelper::AddRoute (m_node, m_prefix, face, m_metric);
85 ScheduledCreateTcp (Ptr<Node> node, Ipv4Address address,
const std::string &prefix, int16_t metric)
87 Ptr<IpFaceStack> stack = node->GetObject<
IpFaceStack> ();
88 NS_ASSERT_MSG (stack != 0,
"ndn::IpFaceStack needs to be installed on the node");
90 Ptr<Face> face = stack->GetTcpFaceByAddress (address);
93 Ptr<TcpPrefixRegistrator> registrator = Create<TcpPrefixRegistrator> (node, prefix, metric);
94 stack->CreateOrGetTcpFace (address, MakeCallback (&TcpPrefixRegistrator::Run, registrator));
98 ndn::StackHelper::AddRoute (node, prefix, face, metric);
103 IpFacesHelper::CreateTcpFace (
const Time &when, Ptr<Node> node, Ipv4Address address,
const std::string &prefix, int16_t metric)
105 Simulator::ScheduleWithContext (node->GetId (), when, ScheduledCreateTcp, node, address, prefix, metric);
109 ScheduledCreateUdp (Ptr<Node> node, Ipv4Address address,
const std::string &prefix, int16_t metric)
111 Ptr<IpFaceStack> stack = node->GetObject<
IpFaceStack> ();
112 NS_ASSERT_MSG (stack != 0,
"ndn::IpFaceStack needs to be installed on the node");
114 Ptr<Face> face = stack->CreateOrGetUdpFace (address);
115 ndn::StackHelper::AddRoute (node, prefix, face, metric);
119 IpFacesHelper::CreateUdpFace (
const Time &when, Ptr<Node> node, Ipv4Address address,
const std::string &prefix, int16_t metric)
121 Simulator::ScheduleWithContext (node->GetId (), when, ScheduledCreateUdp, node, address, prefix, metric);
Application that provides functionality of creating IP-based faces on NDN nodes.