How to Start SDN NDN Projects Using NS3
To start a combined SDN (Software-Defined Networking) and NDN (Named Data Networking) project using NS3 which consist of utilizing principles of SDN monitoring the network’s packet forwarding and using NDN to manage the content-centric routing. This method permits to replicate an environment in which network traffic is handled via centralized control (SDN), according to the content names (NDN) whereas data is requested and routed. Following is a step-by-step guide to configure and execute an SDN-NDN project in NS3.
Prerequisites
- Install NS3:
git clone https://gitlab.com/nsnam/ns-3-dev.git ns-3
cd ns-3
./waf configure –enable-examples –enable-tests
./waf build
- Install NDNsim: For NS3, NDNsim is a module which permits to replicate the Named Data Networking. Now, we install it by means of replicating and constructing the NDNsim repository:
git clone https://github.com/named-data/ndnSIM.git
cd ndnSIM
./waf configure
./waf
- Verify Installation: Verify installation by executing a basic NDN example.
./waf –run=ndn-simple
Steps to Start an SDN-NDN Project in NS3
- Define the Network Topology with SDN and NDN Nodes
Make a network, which aggregates the principles of SDN and NDN:
- SDN Part: We can utilize OpenFlow switches to manage by a central SDN controller.
- NDN Part: Configure NDN-enabled nodes, depends on the content names which will demand and work data.
- Configure SDN with OpenFlow
In NS3, SDN functionality can be inserting by OpenFlow. Below is an instance of configuring an SDN controller and OpenFlow switches.
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/openflow-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
CommandLine cmd;
cmd.Parse(argc, argv);
// Create nodes for SDN: one controller and two OpenFlow switches
NodeContainer controllerNode;
controllerNode.Create(1);
NodeContainer switchNodes;
switchNodes.Create(2);
// Create an OpenFlow controller
Ptr<ofi::LearningController> controller = CreateObject<ofi::LearningController>();
// Set up OpenFlow switches with the controller
OpenFlowSwitchHelper openFlowSwitch;
openFlowSwitch.Install(switchNodes.Get(0), controller);
openFlowSwitch.Install(switchNodes.Get(1), controller);
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Configure NDN with NDNsim
Here, we install the NDN stack at nodes, and then make consumer and producer applications requesting and to work for content by name.
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/ndnSIM-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
CommandLine cmd;
cmd.Parse(argc, argv);
// Create NDN nodes
NodeContainer ndnNodes;
ndnNodes.Create(2); // One consumer and one producer
// Install NDN stack on nodes
ndn::StackHelper ndnHelper;
ndnHelper.Install(ndnNodes);
// Set forwarding strategy for NDN
ndn::StrategyChoiceHelper::InstallAll(“/prefix”, “/localhost/nfd/strategy/best-route”);
// Install a consumer application
ndn::AppHelper consumerHelper(“ns3::ndn::ConsumerCbr”);
consumerHelper.SetPrefix(“/prefix/data”);
consumerHelper.SetAttribute(“Frequency”, StringValue(“10”)); // 10 interests per second
consumerHelper.Install(ndnNodes.Get(0));
// Install a producer application
ndn::AppHelper producerHelper(“ns3::ndn::Producer”);
producerHelper.SetPrefix(“/prefix”);
producerHelper.SetAttribute(“PayloadSize”, StringValue(“1024”)); // Size of data packets
producerHelper.Install(ndnNodes.Get(1));
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Connect SDN and NDN Nodes
Incorporate the SDN and NDN nodes by way of associating them via OpenFlow switches. The SDN controller can be handled routing paths, whereas NDN controls the content-based to send.
- Connect NDN Nodes to SDN Switches: Designate every NDN node to an OpenFlow switch. The SDN controller can be routed data needs via the network, and according to the data names, NDN handles content requests.
- Add NDN Strategy on Nodes: Configure the routing strategy for each NDN node utilizing NDN’s StrategyChoiceHelper.
Combined SDN-NDN Example
Here’s an instance to aggregate SDN including NDN, along with two OpenFlow switches, a controller, and two NDN nodes are associated via the switches.
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/openflow-module.h”
#include “ns3/ndnSIM-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
CommandLine cmd;
cmd.Parse(argc, argv);
// Create SDN nodes: controller and switches
Ptr<ofi::LearningController> controller = CreateObject<ofi::LearningController>();
NodeContainer switches;
switches.Create(2); // Two OpenFlow switches
// Create NDN nodes: one consumer and one producer
NodeContainer ndnNodes;
ndnNodes.Create(2);
// Create links between switches and NDN nodes
PointToPointHelper p2p;
p2p.SetDeviceAttribute(“DataRate”, StringValue(“1Gbps”));
p2p.SetChannelAttribute(“Delay”, StringValue(“10ms”));
// Connect consumer to switch 1, producer to switch 2
NetDeviceContainer consumerSwitch = p2p.Install(ndnNodes.Get(0), switches.Get(0));
NetDeviceContainer producerSwitch = p2p.Install(ndnNodes.Get(1), switches.Get(1));
// Install OpenFlow switches
OpenFlowSwitchHelper openFlowSwitch;
openFlowSwitch.Install(switches.Get(0), controller);
openFlowSwitch.Install(switches.Get(1), controller);
// Install NDN stack on NDN nodes
ndn::StackHelper ndnHelper;
ndnHelper.Install(ndnNodes);
// Configure NDN forwarding strategy
ndn::StrategyChoiceHelper::InstallAll(“/prefix”, “/localhost/nfd/strategy/best-route”);
// Set up consumer and producer applications
ndn::AppHelper consumerHelper(“ns3::ndn::ConsumerCbr”);
consumerHelper.SetPrefix(“/prefix/data”);
consumerHelper.SetAttribute(“Frequency”, StringValue(“10”));
consumerHelper.Install(ndnNodes.Get(0));
ndn::AppHelper producerHelper(“ns3::ndn::Producer”);
producerHelper.SetPrefix(“/prefix”);
producerHelper.SetAttribute(“PayloadSize”, StringValue(“1024”));
producerHelper.Install(ndnNodes.Get(1));
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Collect and Analyze Metrics
- Content Retrieval Metrics: For NDN content recovery, estimate the latency and packet delivery.
- Flow Monitoring: Monitor the SDN-controlled flows among nodes utilizing NS3’s flow monitor.
- Visualize and Extend the Simulation
- NetAnim: Envision the topology and traffic flows utilizing NetAnim.
- Custom Strategies: Test with custom NDN sending strategies or SDN policies enhancing the content delivery paths.
Here, we clearly discussed about the procedures that were utilized for SDN NDN Projects, set up and executed in NS3 tool and it contains the essential information like step-by step procedure, explanation along with coding. If you need more details then feel free to ask!
If you reach out to us, we can provide you with personalized help on setting up your SDN and NDN projects using NS3 simulation. Just visit phdprojects.org for unique results that we manage effectively. We also specialize in content-centric routing that is customized to fit your requirements.