apps: Adding ability to ndn::Producer to configure desired fake signature and key locator (key name)
Refs #1008 (http://redmine.named-data.net/)
diff --git a/apps/ndn-producer.cc b/apps/ndn-producer.cc
index 3442546..130b450 100644
--- a/apps/ndn-producer.cc
+++ b/apps/ndn-producer.cc
@@ -44,7 +44,7 @@
namespace ndn {
NS_OBJECT_ENSURE_REGISTERED (Producer);
-
+
TypeId
Producer::GetTypeId (void)
{
@@ -62,16 +62,24 @@
MakeNameChecker ())
.AddAttribute ("PayloadSize", "Virtual payload size for Content packets",
UintegerValue (1024),
- MakeUintegerAccessor(&Producer::m_virtualPayloadSize),
- MakeUintegerChecker<uint32_t>())
+ MakeUintegerAccessor (&Producer::m_virtualPayloadSize),
+ MakeUintegerChecker<uint32_t> ())
.AddAttribute ("Freshness", "Freshness of data packets, if 0, then unlimited freshness",
TimeValue (Seconds (0)),
MakeTimeAccessor (&Producer::m_freshness),
MakeTimeChecker ())
+ .AddAttribute ("Signature", "Fake signature, 0 valid signature (default), other values application-specific",
+ UintegerValue (0),
+ MakeUintegerAccessor (&Producer::m_signature),
+ MakeUintegerChecker<uint32_t> ())
+ .AddAttribute ("KeyLocator", "Name to be used for key locator. If root, then key locator is not used",
+ NameValue (),
+ MakeNameAccessor (&Producer::m_keyLocator),
+ MakeNameChecker ())
;
return tid;
}
-
+
Producer::Producer ()
{
// NS_LOG_FUNCTION_NOARGS ();
@@ -87,13 +95,13 @@
App::StartApplication ();
NS_LOG_DEBUG ("NodeID: " << GetNode ()->GetId ());
-
+
Ptr<Fib> fib = GetNode ()->GetObject<Fib> ();
-
+
Ptr<fib::Entry> fibEntry = fib->Add (m_prefix, m_face, 0);
fibEntry->UpdateStatus (m_face, fib::FaceMetric::NDN_FIB_GREEN);
-
+
// // make face green, so it will be used primarily
// StaticCast<fib::FibImpl> (fib)->modify (fibEntry,
// ll::bind (&fib::Entry::UpdateStatus,
@@ -118,13 +126,19 @@
NS_LOG_FUNCTION (this << interest);
if (!m_active) return;
-
+
Ptr<ContentObject> data = Create<ContentObject> (Create<Packet> (m_virtualPayloadSize));
Ptr<Name> dataName = Create<Name> (interest->GetName ());
dataName->Append (m_postfix);
data->SetName (dataName);
data->SetFreshness (m_freshness);
+ data->SetSignature (m_signature);
+ if (m_keyLocator.size () > 0)
+ {
+ data->SetKeyLocator (Create<Name> (m_keyLocator));
+ }
+
NS_LOG_INFO ("node("<< GetNode()->GetId() <<") respodning with ContentObject:\n" << data->GetName ());
// Echo back FwHopCountTag if exists
diff --git a/apps/ndn-producer.h b/apps/ndn-producer.h
index 42f65aa..8349ea2 100644
--- a/apps/ndn-producer.h
+++ b/apps/ndn-producer.h
@@ -41,10 +41,10 @@
*/
class Producer : public App
{
-public:
+public:
static TypeId
GetTypeId (void);
-
+
Producer ();
// inherited from NdnApp
@@ -63,6 +63,9 @@
Name m_postfix;
uint32_t m_virtualPayloadSize;
Time m_freshness;
+
+ uint32_t m_signature;
+ Name m_keyLocator;
};
} // namespace ndn
diff --git a/examples/ndn-simple-with-pcap.cc b/examples/ndn-simple-with-pcap.cc
index 03f3ef4..6499db7 100644
--- a/examples/ndn-simple-with-pcap.cc
+++ b/examples/ndn-simple-with-pcap.cc
@@ -84,10 +84,12 @@
// Producer will reply to all requests starting with /prefix
producerHelper.SetPrefix ("/prefix");
producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
+ producerHelper.SetAttribute ("Signature", UintegerValue (100));
+ producerHelper.SetAttribute ("KeyLocator", StringValue ("/unique/key/locator"));
producerHelper.Install (nodes.Get (2)); // last node
PcapWriter trace ("ndn-simple-trace.pcap");
- Config::ConnectWithoutContext ("/NodeList/*/$ns3::ndn::L3Protocol/FaceList/*/NdnTx",
+ Config::ConnectWithoutContext ("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/MacTx",
MakeCallback (&PcapWriter::TracePacket, &trace));
Simulator::Stop (Seconds (20.0));