How to Implement Named Data Networking in ns2

To implement the Named Data Networking (NDN) using the simulation tool NS2 (Network Simulator 2) that needs a depth understanding of both NDN principles and the extensibility of the tool NS2. It is an original network architecture that concentrations on named data instead of host-to-host communication. Rather than sending packets to particular IP addresses, data is requested and routed based on the content names. We can execute NDN in NS2, we are usually want to follow the below steps:

Step-by-Step Implementations:

  1. Understand Named Data Networking (NDN)
  • Core Concepts:
    • Interest Packets: To send by consumers to request data by name.
    • Data Packets: We can sent by producers in reaction to the Interest packets, including the requested data.
    • Content Store (CS): A cache where stores the Data packets.
    • Pending Interest Table (PIT): We tracks the Interest packets that have been sent but are anticipating the Data packets.
    • Forwarding Information Base (FIB): We can be used to forward Interest packets to the data producer.
  • NDN Routing and Forwarding: Routing is based on content names instead of the IP addresses. Sending decisions are created based on the FIB, PIT, and CS.
  1. Set up the NS2 Environment
  • Install NS2: Make certain NS2 is installed and configured on the system.
  • Tcl Scripting: Acquaint ourselves with Tcl scripting in NS2 as we will use it to describe the network topology and simulation scenarios.
  1. Implement NDN Components in NS2

Since the simulation tool NS2 is not natively created for NDN, we want to make or expand classes to manage NDN’s unique operations:

  • Interest and Data Packets: To execute the packet structures for Interest and Data packets. We can enlarge the existing packet classes in the tool NS2.
  • Content Store (CS): We execute a caching mechanism within the nodes to store Data packets momentarily.
  • Pending Interest Table (PIT): To execute a table to keep track of forwarded Interest packets and these corresponding incoming interfaces.
  • Forwarding Information Base (FIB): Execute a table to forward Interest packets based on content names.

Example C++ Code for NDN Packet Structure (Pseudocode):

class NDNPacket : public Packet {

public:

string contentName;

int type; // 0 for Interest, 1 for Data

NDNPacket(string name, int t) : contentName(name), type(t) {}

};

  1. Extend NS2 with NDN Functionality
  • Custom NDN Agent: We can make an NDN agent that manages the Interest and Data packet processing. These agent will execute the core NDN logic, containing testing the CS, updating the PIT, and forwarding packets based on the FIB.

Example C++ Code for an NDN Agent (Pseudocode):

class NDNAgent : public Agent {

public:

map<string, Packet*> contentStore; // Content Store (CS)

map<string, vector<int>> pendingInterestTable; // Pending Interest Table (PIT)

map<string, int> forwardingInformationBase; // Forwarding Information Base (FIB)

NDNAgent() : Agent(PT_NDN) {}

void recv(Packet* p, Handler* h) {

NDNPacket* ndnPkt = (NDNPacket*)p;

if (ndnPkt->type == 0) { // Interest packet

handleInterest(ndnPkt);

} else if (ndnPkt->type == 1) { // Data packet

handleData(ndnPkt);

}

}

void handleInterest(NDNPacket* pkt) {

if (contentStore.find(pkt->contentName) != contentStore.end()) {

// Data available in CS, send it back

send(contentStore[pkt->contentName], 0);

} else if (pendingInterestTable.find(pkt->contentName) == pendingInterestTable.end()) {

// Forward the Interest packet

pendingInterestTable[pkt->contentName].push_back(pkt->getSrc());

forwardInterest(pkt);

}

}

void handleData(NDNPacket* pkt) {

// Store Data in CS

contentStore[pkt->contentName] = pkt;

// Forward Data to all pending Interest interfaces

for (int intf : pendingInterestTable[pkt->contentName]) {

send(pkt, intf);

}

// Clear PIT entry

pendingInterestTable.erase(pkt->contentName);

}

void forwardInterest(NDNPacket* pkt) {

// Forward Interest based on FIB

if (forwardingInformationBase.find(pkt->contentName) != forwardingInformationBase.end()) {

send(pkt, forwardingInformationBase[pkt->contentName]);

}

}

};

  1. Design the NDN Network Topology
  • Node Configuration: To make the nodes signifying NDN routers, consumers, and producers.
  • FIB Configuration: By hand set up the FIB for each node to state how Interest packets would be sent.

Example Tcl Script for a Simple NDN Network:

set ns [new Simulator]

set tracefile [open “ndn_trace.tr” w]

$ns trace-all $tracefile

# Create nodes

set consumer [$ns node]

set router [$ns node]

set producer [$ns node]

# Create links

$ns duplex-link $consumer $router 10Mb 10ms DropTail

$ns duplex-link $router $producer 10Mb 10ms DropTail

# Configure NDN Agent

set ndnConsumer [new Agent/NDN]

set ndnRouter [new Agent/NDN]

set ndnProducer [new Agent/NDN]

$ns attach-agent $consumer $ndnConsumer

$ns attach-agent $router $ndnRouter

$ns attach-agent $producer $ndnProducer

# Configure FIB entries (simplified)

$ndnRouter configure-fib “/content/” $producer

# Generate Interest packet

$ns at 5.0 “$ndnConsumer sendInterest /content/video1”

# Run the simulation

$ns run

  1. Simulate NDN Scenarios
  • Interest and Data Flow: To emulate the flow of Interest and Data packets among the consumers, routers, and producers.
  • Caching Behaviour: We monitor how the Content Store (CS) effects the network performance, particularly such as latency and bandwidth usage.
  1. Analyse Simulation Results
  • Trace File Analysis: We can use the NS2’s trace files to evaluate the NDN performance parameters like cache hit ratio, data retrieval delay, and network traffic.
  • Visualization: To visualize the network using the NAM (Network Animator) to understand how Interest and Data packets propagate via the network.
  1. Optimize and Extend
  • Advanced Routing: To execute more furthered NDN routing strategies, like adaptive FIB entries or dynamic cache management.
  • Security Considerations: Enlarge the execution to contain NDN security characteristics such as data packet signatures and Interest packet authorization.
  1. Document Your Implementation
  • Documentation: Document the execution details, containing the network setup, NDN agents, and performance analysis.
  • Reporting: If it is for academic or research purposes, make a report detailing the methodology, simulation setup, and results.
  1. Further Research and Extensions
  • NDN Extensions: Investigate the NDN-specific extensions such as in-network caching strategies, NDN-based multicast, or real-time data retrieval.
  • Scalability Testing: To mimic the large-scale NDN deployments to learn the scalability and effectiveness of the execution.

A comprehensive step-by-step approach was undertaken for Named Data Networking, utilizing the simulation tool ns2 for implementation and analysis. We will provide additional insights on this topic using the necessary simulation tools.

For top project assistance and implementation advice, reach out to ns2project.comfor the best outcomes.