How to Start Named Data Networking Projects Using NS2

To start a Named Data Networking (NDN) project in NS2 that includes replicating the NDN’s data-centric interaction model. NS2 is utilised for traditional IP-based networks, it can be prolonged including NDN-specific aspects. NDN concentrates on data recovery using names instead of addresses, creating it which is appropriate for content-centric networking scenarios. We follow these steps to start and simulate the NDN projects using NS2.

Steps to Start NDN Projects in NS2

  1. Set Up NS2 for NDN
  1. Install NS2:
    • We should download and install NS2 on the system.
    • Make sure that NS2 is installed properly with example Tcl scripts.
  2. Patch NS2 for NDN:
    • NS2 doesn’t support NDN directly. We can install an NDN-specific extension like NDN-NDNsim or modify NS2 by means of integrating NDN functionality.
    • NDN-NDNsim is a robust simulator according to the NS3 however it offers inspiration to execute the NDN using NS2.
  3. Customize NS2 for NDN:
    • Change or make new components to support NDN functionality in NS2:
      • Interest Packets: For demanding content.
      • Data Packets: For content delivery.
      • Forwarding Information Base (FIB): It supports for routing interest packets.
      • Pending Interest Table (PIT): Monitoring pending interests.
      • Content Store (CS): It is used for caching data locally.
  1. Understand NDN Concepts
  • Interest Packet: It is utilised for demanding data by name.
  • Data Packet: Includes the requested information to satisfy the interest.
  • Content Name: The unique identifier within the network for data.
  • Caching: Middle nodes cache information for upcoming demands.
  1. Define the Network Topology

Make an NDN-enabled network topology using Tcl script.

Example: Basic NDN Network Topology

# Create a simulator instance

set ns [new Simulator]

# Trace and NAM files

set tracefile [open ndn.tr w]

set namfile [open ndn.nam w]

$ns trace-all $tracefile

$ns namtrace-all $namfile

# Define nodes

set producer [$ns node]

set router1 [$ns node]

set router2 [$ns node]

set consumer [$ns node]

# Define links

$ns duplex-link $producer $router1 1Mb 10ms DropTail

$ns duplex-link $router1 $router2 1Mb 10ms DropTail

$ns duplex-link $router2 $consumer 1Mb 10ms DropTail

# Set up NDN components

$producer add-ndn-component “ContentStore”

$router1 add-ndn-component “FIB PIT ContentStore”

$router2 add-ndn-component “FIB PIT ContentStore”

$consumer add-ndn-component “ConsumerApp”

# Define content generation at producer

$producer generate-content “/video/segment1” 1024

$producer generate-content “/video/segment2” 1024

# Consumer sends interest packets

$consumer send-interest “/video/segment1”

$consumer send-interest “/video/segment2”

# End simulation

$ns at 10.0 “finish”

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam ndn.nam &

exit 0

}

# Run simulation

$ns run

  1. Implement NDN Functionality

We can execute or utilise the extensions for replicating NDN:

  1. Forwarding Information Base (FIB):
    • Plots content names to leaving interfaces.
  2. Pending Interest Table (PIT):
    • Monitors the remaining interest packets.
  3. Content Store (CS):
    • Just caches inherited the data packets.
  4. Interest Forwarding:
    • Transmit interest packets according to the FIB.
  5. Data Packet Handling:
    • Reply to interest packets including cached or generated information.

Example C++ Logic for Interest Handling

void Node::handleInterestPacket(Packet *pkt) {

string contentName = pkt->getContentName();

if (contentStore.has(contentName)) {

// Reply with cached data

Packet *dataPkt = contentStore.get(contentName);

send(dataPkt, “out”);

} else if (forwardingTable.has(contentName)) {

// Forward interest to next hop

send(pkt, forwardingTable.getNextHop(contentName));

} else {

// Drop interest if no route

drop(pkt);

}

}

  1. Simulate Traffic

Integrate the consumer applications for making interest packets and producer applications to reply including information.

Example Traffic Configuration

# Consumer traffic generation

set consumerApp [new Application/Traffic/InterestApp]

$consumerApp setContentName “/video/segment1”

$consumerApp setInterestInterval 1.0

$ns attach-app $consumer $consumerApp

  1. Run and Visualize the Simulation
  1. We need to store the simulation script like ndn.tcl.
  2. Execute the simulation to utilise below code line:

ns ndn.tcl

  1. Envision the network topology using NAM:

nam ndn.nam

  1. Analyze Results
  • Trace File Analysis:
    • Examine the trace file as ndn.tr for packet events like interest transmit, data received, and caching events.
  • Metrics to Evaluate:
    • Cache Hit Ratio: Measure the ratio of interests that are functioned from caches.
    • Latency: Compute the duration for recovering content.
    • Bandwidth Utilization: Estimate the total data, which are sent through the network.

Example AWK Script for Cache Hit Analysis

awk ‘{

if ($1 == “cache_hit”) {

hits++

} else if ($1 == “interest_sent”) {

total++

}

} END {

print “Cache Hit Ratio:”, hits / total

}’ ndn.tr

  1. Extend the Project
  1. Routing Strategies:
    • Execute or experiment the routing strategies such as flooding, best-route, or multi-path.
  2. Caching Policies:
    • Experiment the caching strategies like Least Recently Used (LRU), Least Frequently Used (LFU), or random caching.
  3. QoS-Aware Forwarding:
    • Add performance parameters such as delay or bandwidth to sending decisions.
  4. Scalability Testing:
    • Maximize the volume of nodes, consumers, and content providers for estimating the performance.
  5. Security:
    • Execute security approaches for confirming data integrity and validity.

Here, we had shown from how to set up the necessary tools to how to simulate and analyse the Named Data Networking Projects using NS2 simulator that helps you to enhance this project further. If you want any doubt on this process, we will also clear it.