[ndnSIM] Unexpected output for 3 nodes configuration using wifi

Otávio Augusto otavio.augusto.snc at gmail.com
Mon Jan 27 08:47:07 PST 2025


Hi everyone.

Now it's working. The main problem was that the interfaces were set to
point-to-point, which doesn't seem to work for a wireless network. To
function properly (thanks Djama for this):

1- Open the following file:
/home/ndnSIM/ns-3/src/ndnSIM/NFD/daemon/face/transport.hpp
2- Go to set link type method and assign ad hoc type directly:




*inline voidTransport::setLinkType(ndn::nfd::LinkType linkType){
m_linkType = ndn::nfd::LINK_TYPE_AD_HOC;}*

With this, the interfaces are now ad hoc:

NS_LOG=ndn-cxx.nfd.RibManager ./waf --run=multiples_ndn
Waf: Entering directory `/home/otavio20/ndnSIM/ns-3/build'
Waf: Leaving directory `/home/otavio20/ndnSIM/ns-3/build'
Build commands will be stored in build/compile_commands.json
'build' finished successfully (0.794s)
set position for nodes
+0.000000000s 0 ndn-cxx.nfd.RibManager:registerWithNfd(): [INFO ] Start
monitoring face create/destroy events
+0.000000000s 1 ndn-cxx.nfd.RibManager:registerWithNfd(): [INFO ] Start
monitoring face create/destroy events
+0.000000000s 2 ndn-cxx.nfd.RibManager:registerWithNfd(): [INFO ] Start
monitoring face create/destroy events
+0.000000000s 0 ndn-cxx.nfd.RibManager:operator()(): [DEBUG] Successfully
registered /localhost/nfd with NFD
+0.000000000s 0 ndn-cxx.nfd.RibManager:onNotification(): [LOGIC]
onNotification: FaceEvent(Kind: created,
          FaceId: 256,
          RemoteUri: internal://,
          LocalUri: internal://,
          FaceScope: local,
          FacePersistency: permanent,
*          LinkType: adhoc,*
          Flags: 0x1
          )
*...*

Below is my final code:

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/internet-module.h"

#include "ns3/ndnSIM-module.h"

using namespace std;
namespace ns3 {

NS_LOG_COMPONENT_DEFINE("wifi_3_nodes");

int
main(int argc, char* argv[])
{
  // disable fragmentation

Config::SetDefault("ns3::WifiRemoteStationManager::FragmentationThreshold",
StringValue("2200"));
  Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold",
StringValue("2200"));
  Config::SetDefault("ns3::WifiRemoteStationManager::NonUnicastMode",
                     StringValue("OfdmRate24Mbps"));

  CommandLine cmd;
  cmd.Parse(argc, argv);

  WifiHelper wifi;
  wifi.SetStandard(WIFI_STANDARD_80211a);
  wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode",
                               StringValue("OfdmRate24Mbps"));

  YansWifiChannelHelper wifiChannel;

wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
  wifiChannel.AddPropagationLoss("ns3::LogDistancePropagationLossModel");

  YansWifiPhyHelper wifiPhyHelper;
  wifiPhyHelper.SetChannel(wifiChannel.Create());

  WifiMacHelper wifiMacHelper;
  wifiMacHelper.SetType("ns3::AdhocWifiMac");

  MobilityHelper mobility;

  NodeContainer nodes;
  nodes.Create(3);

  ////////////////
  // 1. Install Wifi
  NetDeviceContainer wifiNetDevices = wifi.Install(wifiPhyHelper,
wifiMacHelper, nodes);

  // 2. Install Mobility model
  mobility.Install(nodes);

  std::cout << "set position for nodes" << std::endl;

  Ptr<ConstantPositionMobilityModel> s1 =
nodes.Get(0)->GetObject<ConstantPositionMobilityModel> ();
  Ptr<ConstantPositionMobilityModel> s2 =
nodes.Get(1)->GetObject<ConstantPositionMobilityModel> ();
  Ptr<ConstantPositionMobilityModel> s3 =
nodes.Get(2)->GetObject<ConstantPositionMobilityModel> ();

  s1->SetPosition (Vector ( 0.0, 70.0, 0));
  s2->SetPosition (Vector ( 30.0, 75, 0));
  s3->SetPosition (Vector ( 60.0, 70.0, 0));

  // 3. Install NDN stack
  NS_LOG_INFO("Installing NDN stack");
  ndn::StackHelper ndnHelper;
  ndnHelper.setPolicy("nfd::cs::lru");
  ndnHelper.setCsSize(0);
  ndnHelper.SetDefaultRoutes(true);
  ndnHelper.Install(nodes);

  // Set strategy
  //ndn::StrategyChoiceHelper::Install(nodes.Get(0), "/",
"/localhost/nfd/strategy/best-route");
  //ndn::StrategyChoiceHelper::Install(nodes.Get(1), "/",
"/localhost/nfd/strategy/best-route");
  //ndn::StrategyChoiceHelper::Install(nodes.Get(1), "/",
"/localhost/nfd/strategy/multicast");
  //ndn::StrategyChoiceHelper::Install(nodes.Get(2), "/",
"/localhost/nfd/strategy/best-route");

  // 4. Set up applications
  NS_LOG_INFO("Installing Applications");

  ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
  consumerHelper.SetPrefix("/test/prefix");
  consumerHelper.SetAttribute("Frequency", DoubleValue(1.0));
  consumerHelper.Install(nodes.Get(0));

  ndn::AppHelper producerHelper("ns3::ndn::Producer");
  producerHelper.SetPrefix("/test/prefix");
  producerHelper.SetAttribute("PayloadSize", StringValue("1200"));
  producerHelper.Install(nodes.Get(2));

  Simulator::Stop(Seconds(10.0));

  Simulator::Run();
  Simulator::Destroy();

  return 0;
}

} // namespace ns3

int
main(int argc, char* argv[])
{
  return ns3::main(argc, argv);
}

*Note 1:* I changed the Propagation Model just for convenience.
*Note 2:* I commented on the strategy definition because it doesn't change
my result, so it doesn't seem necessary.

Using this code, I got what I expected, two hop counts:

NS_LOG=ndn.Consumer ./waf --run=email_list --vis
+0.000000000s 0 ndn.Consumer:StartApplication()
+0.000000000s 0 ndn.Consumer:SendPacket()
+0.000000000s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 0
+0.000000000s 0 ndn.Consumer:WillSendOutInterest(): [DEBUG] Trying to add 0
with +0ns. already 0 items
+0.001262404s 0 ndn.Consumer:OnData(0x55bd3bd26de0, 0x7ffa6c01c050)
+0.001262404s 0 ndn.Consumer:OnData(): [INFO ] < DATA for 0

*+0.001262404s 0 ndn.Consumer:OnData(): [DEBUG] Hop count: 2*+1.000000000s
0 ndn.Consumer:SendPacket()
+1.000000000s 0 ndn.Consumer:SendPacket(): [INFO ] > Interest for 1
+1.000000000s 0 ndn.Consumer:WillSendOutInterest(): [DEBUG] Trying to add 1
with +1e+09ns. already 0 items
+1.001253404s 0 ndn.Consumer:OnData(0x55bd3bd26de0, 0x7ffa6c0238f0)
+1.001253404s 0 ndn.Consumer:OnData(): [INFO ] < DATA for 1
*+1.001253404s 0 ndn.Consumer:OnData(): [DEBUG] Hop count: 2*

I appreciate all the support received. In particular, I would like to
extend a special thank you to Lixia Zhang, Sirapop Theeranantachai, and
Adel Djama for their contributions.

Thanks again,
Otávio da Cruz

Em sáb., 18 de jan. de 2025 às 16:03, Otávio Augusto <
otavio.augusto.snc at gmail.com> escreveu:

> Hi Sirapop,
>
> Yes, the communication between the nodes at 10,70 and 120,70 takes one
> hop, which makes sense. However, I expected the communication to use the
> intermediary node (in 70,70), in which case it would use two hops. I
> mean, I expected the interest packet to go through nodes 1, 2 and 3, and
> the data packet to go the other way around. I don't understand why I get
> so many "ndn.Consumer:OnTimeout" and why only direct communications between
> the nodes in 10,70 and 120,70 seems to work. It seems like the intermediary
> node isn't being used...
>
> Att,
>
> Em sáb., 18 de jan. de 2025 às 05:56, Sirapop Theeranantachai <
> sirapop741 at gmail.com> escreveu:
>
>> Hi Otávio,
>>
>> Are you configuring three nodes in a  presumedly multi-access wifi? Then
>> I believe a transmission from the node at (10,70) and the other node at
>> (120,70) would take one hop, no?
>>
>> You can trace packets with a regular ns-3 logging tool. (NetDevice and
>> Channel, for example).
>> https://www.nsnam.org/docs/release/3.37/manual/html/logging.html
>>
>>
>> On Fri, Jan 17, 2025, 5:08 AM Otávio Augusto via ndnSIM <
>> ndnsim at lists.cs.ucla.edu> wrote:
>>
>>> Hello.
>>>
>>> The contents of the ndn_wifi_3_nodes.cc file seem to be unavailable. So,
>>> here is the code:
>>>
>>> #include "ns3/core-module.h"
>>> #include "ns3/network-module.h"
>>> #include "ns3/applications-module.h"
>>> #include "ns3/wifi-module.h"
>>> #include "ns3/mobility-module.h"
>>> #include "ns3/internet-module.h"
>>>
>>> #include "ns3/ndnSIM-module.h"
>>>
>>> using namespace std;
>>> namespace ns3 {
>>>
>>> NS_LOG_COMPONENT_DEFINE("ndn.WifiExample1");
>>>
>>> int
>>> main(int argc, char* argv[])
>>> {
>>>   // disable fragmentation
>>>
>>> Config::SetDefault("ns3::WifiRemoteStationManager::FragmentationThreshold",
>>> StringValue("2200"));
>>>   Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold",
>>> StringValue("2200"));
>>>   Config::SetDefault("ns3::WifiRemoteStationManager::NonUnicastMode",
>>>                      StringValue("OfdmRate24Mbps"));
>>>
>>>   CommandLine cmd;
>>>   cmd.Parse(argc, argv);
>>>
>>>   WifiHelper wifi;
>>>   // wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
>>>   wifi.SetStandard(WIFI_STANDARD_80211a);
>>>   wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
>>> "DataMode",
>>>                                StringValue("OfdmRate24Mbps"));
>>>
>>>   YansWifiChannelHelper wifiChannel;
>>>
>>> wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
>>>
>>> wifiChannel.AddPropagationLoss("ns3::ThreeLogDistancePropagationLossModel");
>>>   wifiChannel.AddPropagationLoss("ns3::NakagamiPropagationLossModel");
>>>
>>>   YansWifiPhyHelper wifiPhyHelper;
>>>   wifiPhyHelper.SetChannel(wifiChannel.Create());
>>>   wifiPhyHelper.Set("TxPowerStart", DoubleValue(5));
>>>   wifiPhyHelper.Set("TxPowerEnd", DoubleValue(5));
>>>
>>>   WifiMacHelper wifiMacHelper;
>>>   wifiMacHelper.SetType("ns3::AdhocWifiMac");
>>>
>>>   MobilityHelper mobility;
>>>
>>>   NodeContainer nodes;
>>>   nodes.Create(3);
>>>
>>>   ////////////////
>>>   // 1. Install Wifi
>>>   NetDeviceContainer wifiNetDevices = wifi.Install(wifiPhyHelper,
>>> wifiMacHelper, nodes);
>>>
>>>   // 2. Install Mobility model
>>>   mobility.Install(nodes);
>>>
>>>   std::cout << "set position for nodes" << std::endl;
>>>
>>>   Ptr<ConstantPositionMobilityModel> s1 =
>>> nodes.Get(0)->GetObject<ConstantPositionMobilityModel> ();
>>>   Ptr<ConstantPositionMobilityModel> s2 =
>>> nodes.Get(1)->GetObject<ConstantPositionMobilityModel> ();
>>>   Ptr<ConstantPositionMobilityModel> s3 =
>>> nodes.Get(2)->GetObject<ConstantPositionMobilityModel> ();
>>>
>>>   s1->SetPosition (Vector ( 10.0, 70.0, 0));
>>>   s2->SetPosition (Vector ( 70.0, 70, 0));
>>>   s3->SetPosition (Vector ( 120.0, 70.0, 0));
>>>
>>>   // 3. Install NDN stack
>>>   NS_LOG_INFO("Installing NDN stack");
>>>   ndn::StackHelper ndnHelper;
>>>   // ndnHelper.AddNetDeviceFaceCreateCallback (WifiNetDevice::GetTypeId
>>> (), MakeCallback(MyNetDeviceFaceCallback));
>>>   ndnHelper.setPolicy("nfd::cs::lru");
>>>   ndnHelper.setCsSize(0);
>>>   ndnHelper.SetDefaultRoutes(true);
>>>   ndnHelper.Install(nodes);
>>>
>>>   // Set strategy
>>>   ndn::StrategyChoiceHelper::Install(nodes, "/",
>>> "/localhost/nfd/strategy/multicast");
>>>
>>>   // 4. Set up applications
>>>   NS_LOG_INFO("Installing Applications");
>>>
>>>   ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
>>>   consumerHelper.SetPrefix("/test/prefix");
>>>   consumerHelper.SetAttribute("Frequency", DoubleValue(1.0));
>>>   consumerHelper.Install(nodes.Get(0));
>>>
>>>   ndn::AppHelper producerHelper("ns3::ndn::Producer");
>>>   producerHelper.SetPrefix("/");
>>>   producerHelper.SetAttribute("PayloadSize", StringValue("1200"));
>>>   producerHelper.Install(nodes.Get(2));
>>>
>>>
>>>   Simulator::Stop(Seconds(30.0));
>>>
>>>   Simulator::Run();
>>>   Simulator::Destroy();
>>>
>>>   return 0;
>>> }
>>>
>>> } // namespace ns3
>>>
>>> int
>>> main(int argc, char* argv[])
>>> {
>>>   return ns3::main(argc, argv);
>>> }
>>>
>>>
>>> Att,
>>> Otávio
>>>
>>> Em qua., 15 de jan. de 2025 às 10:29, Otávio Augusto <
>>> otavio.augusto.snc at gmail.com> escreveu:
>>>
>>>> Hello everyone.
>>>>
>>>> I'm testing a multi-node with wifi connection in ndnSIM, the code is
>>>> attached (ndn_wifi_3_nodes.cc). In addition, I'm using ndnSIM from Windows
>>>> OS with WSL 2, Ubuntu 20.04  (I don't know if this is important).
>>>>
>>>> Using the following command I get some log information about the
>>>> consumer:
>>>>
>>>>
>>>> *NS_LOG=ndn.Consumer ./waf --run=ndn_wifi_3_nodes*
>>>> The output is in the out.txt attachment.
>>>> I expected the communication to go through the intermediary. However,
>>>> as you can see, many messages timed out and the data packets that reached
>>>> the consumer contain hop count equal to 1, which probably means that the
>>>> consumer and producer are communicating directly, without using the
>>>> intermediary node. Why did this happen?
>>>>
>>>> Note 1: in the 'ndn-simple-wifi' example the best-route strategy is
>>>> used, but for me it resulted in NACK, I don't know why. Because of this, I
>>>> used the multicast strategy.
>>>> Note 2: How can I see the ndn route log (intermediate node, node 1)? I
>>>> know how to check the consumer and producer logs, but I don't know what
>>>> name I use to check the ndn router log with *NS_LOG*.
>>>> --
>>>> Otávio da Cruz
>>>> Doctor student
>>>> Electrical Engineering at the Graduate Program in Electrical
>>>> Engineering of the Federal University of Rio Grande do Sul (UFRGS) - Brazil
>>>>
>>> _______________________________________________
>>> ndnSIM mailing list
>>> ndnSIM at lists.cs.ucla.edu
>>> https://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20250127/625ae47d/attachment-0001.htm>


More information about the ndnSIM mailing list