22 #include "ns3/string.h" 23 #include "ns3/uinteger.h" 24 #include "ns3/packet.h" 25 #include "ns3/simulator.h" 33 NS_LOG_COMPONENT_DEFINE(
"ndn.Producer");
44 TypeId(
"ns3::ndn::Producer")
47 .AddConstructor<Producer>()
48 .AddAttribute(
"Prefix",
"Prefix, for which producer has the data", StringValue(
"/"),
52 "Postfix that is added to the output data (e.g., for adding producer-uniqueness)",
54 .AddAttribute(
"PayloadSize",
"Virtual payload size for Content packets", UintegerValue(1024),
55 MakeUintegerAccessor(&Producer::m_virtualPayloadSize),
56 MakeUintegerChecker<uint32_t>())
57 .AddAttribute(
"Freshness",
"Freshness of data packets, if 0, then unlimited freshness",
58 TimeValue(Seconds(0)), MakeTimeAccessor(&Producer::m_freshness),
62 "Fake signature, 0 valid signature (default), other values application-specific",
63 UintegerValue(0), MakeUintegerAccessor(&Producer::m_signature),
64 MakeUintegerChecker<uint32_t>())
65 .AddAttribute(
"KeyLocator",
66 "Name to be used for key locator. If root, then key locator is not used",
73 NS_LOG_FUNCTION_NOARGS();
80 NS_LOG_FUNCTION_NOARGS();
89 NS_LOG_FUNCTION_NOARGS();
99 NS_LOG_FUNCTION(
this << interest);
104 Name dataName(interest->getName());
108 auto data = make_shared<Data>();
109 data->setName(dataName);
110 data->setFreshnessPeriod(::ndn::time::milliseconds(m_freshness.GetMilliSeconds()));
112 data->setContent(make_shared< ::ndn::Buffer>(m_virtualPayloadSize));
115 SignatureInfo signatureInfo(static_cast< ::ndn::tlv::SignatureTypeValue>(255));
117 if (m_keyLocator.size() > 0) {
118 signatureInfo.setKeyLocator(m_keyLocator);
121 signature.setInfo(signatureInfo);
124 data->setSignature(signature);
126 NS_LOG_INFO(
"node(" << GetNode()->
GetId() <<
") responding with Data: " << data->getName());
Copyright (c) 2011-2015 Regents of the University of California.
virtual void StopApplication()
Called at time specified by Stop.
static TypeId GetTypeId(void)
virtual void StopApplication()
Called at time specified by Stop.
NS_OBJECT_ENSURE_REGISTERED(ContentStore)
virtual void StartApplication()
Called at time specified by Start.
static void AddRoute(Ptr< Node > node, const Name &prefix, shared_ptr< Face > face, int32_t metric)
Add forwarding entry to FIB.
void onReceiveData(const Data &data)
ndn Producer
Copyright (c) 2011-2015 Regents of the University of California.
virtual void StartApplication()
Called at time specified by Start.
Block nonNegativeIntegerBlock(uint32_t type, uint64_t value)
virtual void OnInterest(shared_ptr< const Interest > interest)
Method that will be called every time new Interest arrives.
Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< Face > m_face
TracedCallback< shared_ptr< const Data >, Ptr< App >, shared_ptr< Face > > m_transmittedDatas
App-level trace of transmitted Data.
virtual void OnInterest(shared_ptr< const Interest > interest)
Method that will be called every time new Interest arrives.
AppLinkService * m_appLink
Base class that all NDN applications should be derived from.
Ptr< const AttributeChecker > MakeNameChecker(void)
uint32_t GetId() const
Get application ID (ID of applications face)
Ptr< const AttributeAccessor > MakeNameAccessor(T1 a1)
bool m_active
Flag to indicate that application is active (set by StartApplication and StopApplication) ...