22 #include "ns3/string.h" 23 #include "ns3/uinteger.h" 24 #include "ns3/packet.h" 25 #include "ns3/simulator.h" 32 NS_LOG_COMPONENT_DEFINE(
"ndn.Producer");
43 TypeId(
"ns3::ndn::Producer")
46 .AddConstructor<Producer>()
47 .AddAttribute(
"Prefix",
"Prefix, for which producer has the data", StringValue(
"/"),
51 "Postfix that is added to the output data (e.g., for adding producer-uniqueness)",
53 .AddAttribute(
"PayloadSize",
"Virtual payload size for Content packets", UintegerValue(1024),
54 MakeUintegerAccessor(&Producer::m_virtualPayloadSize),
55 MakeUintegerChecker<uint32_t>())
56 .AddAttribute(
"Freshness",
"Freshness of data packets, if 0, then unlimited freshness",
57 TimeValue(Seconds(0)), MakeTimeAccessor(&Producer::m_freshness),
61 "Fake signature, 0 valid signature (default), other values application-specific",
62 UintegerValue(0), MakeUintegerAccessor(&Producer::m_signature),
63 MakeUintegerChecker<uint32_t>())
64 .AddAttribute(
"KeyLocator",
65 "Name to be used for key locator. If root, then key locator is not used",
72 NS_LOG_FUNCTION_NOARGS();
79 NS_LOG_FUNCTION_NOARGS();
88 NS_LOG_FUNCTION_NOARGS();
98 NS_LOG_FUNCTION(
this << interest);
103 Name dataName(interest->getName());
107 auto data = make_shared<Data>();
108 data->setName(dataName);
111 data->setContent(make_shared< ::ndn::Buffer>(m_virtualPayloadSize));
114 SignatureInfo signatureInfo(static_cast< ::ndn::tlv::SignatureTypeValue>(255));
116 if (m_keyLocator.size() > 0) {
117 signatureInfo.setKeyLocator(m_keyLocator);
120 signature.setInfo(signatureInfo);
123 data->setSignature(signature);
125 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)
boost::posix_time::time_duration milliseconds(long duration)
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.
Block makeNonNegativeIntegerBlock(uint32_t type, uint64_t value)
Create a TLV block containing a non-negative integer.
virtual void StartApplication()
Called at time specified by Start.
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)
Ptr< const AttributeAccessor > MakeNameAccessor(T1 a1)
bool m_active
Flag to indicate that application is active (set by StartApplication and StopApplication) ...
uint32_t GetId() const
Get application ID (ID of applications face)