Ns3 Projects for B.E/B.Tech M.E/M.Tech PhD Scholars.  Phone-Number:9790238391   E-mail: ns3simulation@gmail.com

How to Implement SDN NDN in NS3

To implement an SDN (Software Defined Networking) and NDN (Named Data Networking) integration in ns-3 by creating a network topology where SDN controllers manage the data flows, and the network uses NDN for data dissemination. This combination can provide flexible, efficient data management and routing in the network. The following steps will guide on how to set up SDN NDN in ns3.

Prerequisites

  • ns-3 installed on your system.
  • ndnSIM module integrated with ns-3 for NDN support.
  • Basic understanding of ns-3, C++, SDN, and NDN concepts.

Step-by-step to Implement SDN NDN in ns-3

  1. Install ns-3: Ensure you have ns-3 installed. You can download it from the official website and follow the installation instructions.

wget https://www.nsnam.org/release/ns-allinone-3.xx.tar.bz2

tar -xjf ns-allinone-3.xx.tar.bz2

cd ns-allinone-3.xx

./build.py –enable-examples –enable-tests

Integrate ndnSIM: Integrate ndnSIM with ns-3 for NDN support.

git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3

cd ns-3

git checkout ndnSIM

./waf configure –enable-examples

./waf

Include Necessary Headers: Include the required headers for SDN, NDN, and network modules.

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/mobility-module.h”

#include “ns3/internet-module.h”

#include “ns3/point-to-point-module.h”

#include “ns3/csma-module.h”

#include “ns3/applications-module.h”

#include “ns3/openflow-module.h”

#include “ns3/ndnSIM-module.h”

Create Network Topology: Create nodes representing the SDN controller, NDN routers, and end hosts.

NodeContainer controllerNode;

controllerNode.Create(1);

NodeContainer ndnRouters;

ndnRouters.Create(3);

NodeContainer endHosts;

endHosts.Create(2);

Set Up Point-to-Point Links: Configure point-to-point links for the network connections.

PointToPointHelper pointToPoint;

pointToPoint.SetDeviceAttribute(“DataRate”, StringValue(“10Gbps”));

pointToPoint.SetChannelAttribute(“Delay”, StringValue(“2ms”));

 

NetDeviceContainer routerDevices;

for (uint32_t i = 0; i < ndnRouters.GetN() – 1; ++i) {

    for (uint32_t j = i + 1; j < ndnRouters.GetN(); ++j) {

        NetDeviceContainer link = pointToPoint.Install(NodeContainer(ndnRouters.Get(i), ndnRouters.Get(j)));

        routerDevices.Add(link);

    }

}

NetDeviceContainer hostDevices;

for (uint32_t i = 0; i < endHosts.GetN(); ++i) {

    NetDeviceContainer link = pointToPoint.Install(NodeContainer(endHosts.Get(i), ndnRouters.Get(0)));

    hostDevices.Add(link);

}

Install Internet and OpenFlow Stack: Install the internet stack and OpenFlow on the nodes.

InternetStackHelper internet;

internet.Install(ndnRouters);

internet.Install(endHosts);

Ptr<ns3::ofi::Controller> controller = CreateObject<ns3::ofi::Controller>();

OpenFlowSwitchHelper ofSwitchHelper;

ofSwitchHelper.Install(ndnRouters, routerDevices, controllerNode.Get(0), controller);

Install NDN Stack: Install the ndnSIM stack on the routers and hosts.

ndn::StackHelper ndnHelper;

ndnHelper.Install(ndnRouters);

ndnHelper.Install(endHosts);

ndn::StrategyChoiceHelper::Install(ndnRouters, “/”, “/localhost/nfd/strategy/best-route”);

Set Up Mobility Model: Configure the mobility model to simulate the placement and movement of the nodes.

MobilityHelper mobility;

mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,

                              “MinX”, DoubleValue(0.0),

                              “MinY”, DoubleValue(0.0),

                              “DeltaX”, DoubleValue(10.0),

                              “DeltaY”, DoubleValue(10.0),

                              “GridWidth”, UintegerValue(3),

                              “LayoutType”, StringValue(“RowFirst”));

mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);

mobility.Install(ndnRouters);

mobility.Install(endHosts);

Create Applications: Create and install NDN applications to simulate data transmission between the end hosts.

ndn::AppHelper consumerHelper(“ns3::ndn::ConsumerCbr”);

consumerHelper.SetPrefix(“/prefix”);

consumerHelper.SetAttribute(“Frequency”, StringValue(“10”));

consumerHelper.Install(endHosts.Get(0));

 

ndn::AppHelper producerHelper(“ns3::ndn::Producer”);

producerHelper.SetPrefix(“/prefix”);

producerHelper.SetAttribute(“PayloadSize”, StringValue(“1024”));

producerHelper.Install(endHosts.Get(1));

Run the Simulation: Finally, run the simulation and clean up.

Simulator::Stop(Seconds(20.0));

Simulator::Run();

Simulator::Destroy();

Example Complete Script

Below is an example complete script for setting up a basic SDN NDN network in ns-3:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/mobility-module.h”

#include “ns3/internet-module.h”

#include “ns3/point-to-point-module.h”

#include “ns3/applications-module.h”

#include “ns3/openflow-module.h”

#include “ns3/ndnSIM-module.h”

using namespace ns3;

int main(int argc, char *argv[])

{

    NodeContainer controllerNode;

    controllerNode.Create(1);

    NodeContainer ndnRouters;

    ndnRouters.Create(3);

    NodeContainer endHosts;

    endHosts.Create(2);

    PointToPointHelper pointToPoint;

    pointToPoint.SetDeviceAttribute(“DataRate”, StringValue(“10Gbps”));

    pointToPoint.SetChannelAttribute(“Delay”, StringValue(“2ms”));

    NetDeviceContainer routerDevices;

    for (uint32_t i = 0; i < ndnRouters.GetN() – 1; ++i) {

        for (uint32_t j = i + 1; j < ndnRouters.GetN(); ++j) {

            NetDeviceContainer link = pointToPoint.Install(NodeContainer(ndnRouters.Get(i), ndnRouters.Get(j)));

            routerDevices.Add(link);

        }

    }

    NetDeviceContainer hostDevices;

    for (uint32_t i = 0; i < endHosts.GetN(); ++i) {

        NetDeviceContainer link = pointToPoint.Install(NodeContainer(endHosts.Get(i), ndnRouters.Get(0)));

        hostDevices.Add(link);

    }

 

    InternetStackHelper internet;

    internet.Install(ndnRouters);

    internet.Install(endHosts);

    Ptr<ns3::ofi::Controller> controller = CreateObject<ns3::ofi::Controller>();

    OpenFlowSwitchHelper ofSwitchHelper;

    ofSwitchHelper.Install(ndnRouters, routerDevices, controllerNode.Get(0), controller);

    ndn::StackHelper ndnHelper;

    ndnHelper.Install(ndnRouters);

    ndnHelper.Install(endHosts);

    ndn::StrategyChoiceHelper::Install(ndnRouters, “/”, “/localhost/nfd/strategy/best-route”);

    MobilityHelper mobility;

    mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,

                                  “MinX”, DoubleValue(0.0),

                                  “MinY”, DoubleValue(0.0),

                                  “DeltaX”, DoubleValue(10.0),

                                  “DeltaY”, DoubleValue(10.0),

                                  “GridWidth”, UintegerValue(3),

                                 “LayoutType”, StringValue(“RowFirst”));

    mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);

    mobility.Install(ndnRouters);

    mobility.Install(endHosts);

 

    ndn::AppHelper consumerHelper(“ns3::ndn::ConsumerCbr”);

    consumerHelper.SetPrefix(“/prefix”);

    consumerHelper.SetAttribute(“Frequency”, StringValue(“10”));

    consumerHelper.Install(endHosts.Get(0));

    ndn::AppHelper producerHelper(“ns3::ndn::Producer”);

    producerHelper.SetPrefix(“/prefix”);

    producerHelper.SetAttribute(“PayloadSize”, StringValue(“1024”));

    producerHelper.Install(endHosts.Get(1));

    Simulator::Stop(Seconds(20.0));

    Simulator::Run();

    Simulator::Destroy();

    return 0;

}

Running the Script

Compile and run the script using the following commands:

./waf configure –enable-examples

./waf build

./waf –run <script-name>

Finally, Integration of an SDN (Software Defined Networking) and NDN (Named Data Networking) was implemented and described clearly. For anytype of network set up in in ns-3 get in touch with us.