[ndnSIM] Getting Interests from Consumer using an Intermediate node and Forward those Interests to next Intermediate Node or Producer

Spyridon (Spyros) Mastorakis mastorakis at cs.ucla.edu
Thu Oct 18 20:57:37 PDT 2018


Hi,

to further forward an Interest take a look here:

https://github.com/named-data-ndnSIM/ndnSIM/blob/master/apps/ndn-consumer.cpp#L201-L202 <https://github.com/named-data-ndnSIM/ndnSIM/blob/master/apps/ndn-consumer.cpp#L201-L202>

Thanks,

Spyridon (Spyros) Mastorakis
Personal Website: http://cs.ucla.edu/~mastorakis/ <http://cs.ucla.edu/~mastorakis/>
Internet Research Laboratory
Computer Science Department
UCLA

> On Oct 18, 2018, at 7:45 AM, Kamrul Morshed <shohanmk at yahoo.com> wrote:
> 
> Hello Spyridon,
> 
> Thank You very much for your advice. 
> 
> I have looked upon both Consumer and Producer App. I have used some functionalities from Producer App and therefore I was able to request the Interest from the Consumer App. However, I have been also through Consumer App but I am confused about the specific functionalities that will help me to forward these interests to the next intermediate node. 
> 
> I would like to find a way to forward these Interests to the next intermediate node, for example, it can be the Producer or the next Node. 
> 
> Would love to hear from you. 
> 
> I am sharing the code for my Forwarder App:
> 
> #include "ForwarderApp.h"
> 
> #include "ns3/ptr.h"
> #include "ns3/log.h"
> #include "ns3/simulator.h"
> #include "ns3/packet.h"
> #include "ns3/callback.h"
> #include "ns3/string.h"
> #include "ns3/boolean.h"
> #include "ns3/uinteger.h"
> #include "ns3/integer.h"
> #include "ns3/double.h"
> 
> #include "ns3/ndnSIM/helper/ndn-stack-helper.hpp"
> #include "ns3/ndnSIM/helper/ndn-fib-helper.hpp"
> #include "ns3/ndnSIM/model/ndn-common.hpp"
> 
> 
> #include "ns3/random-variable-stream.h"
> 
> 
> NS_LOG_COMPONENT_DEFINE("ForwarderApp");
> 
> namespace ns3 {
> namespace ndn {
> 
> // Necessary if you are planning to use ndn::AppHelper
> NS_OBJECT_ENSURE_REGISTERED(ForwarderApp);
> 
> TypeId
> ForwarderApp::GetTypeId()
> {
>   static TypeId tid = TypeId("ForwarderApp")
>   .SetGroupName("Ndn")
>   .SetParent<ndn::App>()
>   .AddConstructor<ForwarderApp>()
>   .AddAttribute("Prefix", "Prefix, for which producer has the data", StringValue("/"),
>                 MakeNameAccessor(&ForwarderApp::m_prefix), MakeNameChecker());
>   return tid;
> }
> 
> ForwarderApp::ForwarderApp()
> {
> }
> 
> void
> ForwarderApp::StartApplication()
> {
>   NS_LOG_FUNCTION_NOARGS();
> 
>   App::StartApplication();
> 
>   // equivalent to setting interest filter for "/prefix" prefix
>   ndn::FibHelper::AddRoute(GetNode(), "/prefix/world/", m_face, 0);
> 
> }
> 
> void
> ForwarderApp::StopApplication()
> {
>   NS_LOG_FUNCTION_NOARGS();
> 
>   App::StopApplication();
> }
> 
> void
> ForwarderApp::OnInterest(std::shared_ptr<const ndn::Interest> interest)
> {
>   ndn::App::OnInterest(interest); // forward call to perform app-level tracing
>   // do nothing else (receive interest from consumer)
>   NS_LOG_DEBUG("Requesting Interest from Consumer" << interest->getName());  
> }
> 
> 
> } //namespace ndn
> } // namespace ns3
> 
> The output partially looks like this:
> 
> 0.000000000s 4 ForwarderApp:StartApplication()
> +0.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%00
> +1.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%01
> +2.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%00
> +3.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%02
> +4.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%01
> +5.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%03
> +6.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%04
> +7.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%00
> +8.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%05
> +9.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%06
> +10.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%07
> +11.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%08
> +12.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%02
> +13.010039199s 4 ForwarderApp:OnInterest(): [DEBUG] Requesting Interest from Consumer/prefix/world/%FE%09
> 
>  
> Kamrul Morshed
> MS Student
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20181018/0a560daf/attachment-0001.html>


More information about the ndnSIM mailing list