How to Start Content Centric Network Projects Using NS2

To start a Content-Centric Network (CCN) project in NS2 that encompasses to replicate a Content-Centric Networking (CCN) architecture, which concentrates the content instead of the host or data position. In CCN, the network is constructed over the data to be detected by their name (rather than its IP address). CCNs general instance is Named Data Networking (NDN) that permits for data retrieval according to the content names instead of the data position.

While NS2 doesn’t directly have CCN or NDN then we will need to execute a CCN simulation by means of designing crucial behaviours of CCN like Interest and Data packets, routing, and content caching. Following is a detailed method to get started with a CCN project using NS2.

Key Concepts of Content-Centric Networks (CCN):

  1. Interest Packets: Users demand data by means of transmitting Interest packets with the name of the data.
  2. Data Packets: The requested information is reverted within Data packets. These packets transmit the content with name of the data.
  3. Forwarding: Routers send the Interest packets to the source, and according to the name of the content, data packets return to the requester.
  4. Caching: Routers need to store Data packets to get faster advanced recovery of the similar data.

Steps to Start a CCN Project in NS2

  1. Install NS2 and Required Tools

Initially, we make sure that NS2 is installed on the system. Unless, we adhere to the installation guidance based on the OS:

For Linux:

sudo apt-get install ns2

We will need to utilise the package managers such as Homebrew or Cygwin (for Windows) to install NS2 for macOS or Windows.

  1. Understand CCN (or NDN) Concepts

We must know the main concepts of Interest packets, Data packets, and Content Caching:

  • Interest: Demands for data that are detected by a name.
  • Data: The data reverted reply to an Interest packet.
  • Cache: Routers need to save the Data packets thus subsequent demands can be effectively replied for the similar information.
  1. Model CCN Traffic in NS2

NS2 doesn’t directly support for CCN, but we can design the CCNs crucial modules. I t can be done by way of making custom Interest and Data packets and executing name-based routing. Also, we can replicate the caching within routers.

Example: Creating Interest and Data Packets

  1. Interest Packet: It is a demand for data that has the name of the data.
  2. Data Packet: It is the reply to an Interest. It includes the real data together with their name.

# Initialize the simulator

set ns [new Simulator]

# Create nodes (routers and hosts)

set router1 [$ns node]

set router2 [$ns node]

set host1 [$ns node]

set host2 [$ns node]

# Define link between nodes (routers and hosts)

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

$ns duplex-link $router2 $host1 10Mb 10ms DropTail

$ns duplex-link $router2 $host2 10Mb 10ms DropTail

# Create a simple Interest packet from host1

set interestPacket [new Application/Traffic/CBR]

$interestPacket set name “data/file1”

$interestPacket attach-agent $host1

$ns at 1.0 “$interestPacket start”

# Create a Data packet response from host2

set dataPacket [new Application/Traffic/CBR]

$dataPacket set name “data/file1”

$dataPacket attach-agent $host2

$ns at 2.0 “$dataPacket start”

In this case:

  • Host1 transmits an Interest packet demanding information which is detected by data/file1.
  • Host2 makes a Data packet including the name data/file1 like a response.
  1. Simulate CCN Forwarding and Routing

Routers send the Interest packets to the data source in a CCN, and once the data is discovered then the Data packets are transmitted again to the requestor. We will need to replicate the forwarding by means of making Interest forwarding logic and Data packet returning according to the name.

Example: Basic Forwarding Logic

# Forward Interest packet based on name

proc forward-interest {interestPacket} {

# Simulate forwarding of Interest based on content name

global ns router1 router2

# Forward Interest from router1 to router2

if {$interestPacket name == “data/file1”} {

$ns at 1.5 “$router2 forward-interest $interestPacket”

}

}

# Simulate router forwarding the Interest packet

set interest1 [new Application/Traffic/CBR]

$interest1 set name “data/file1”

$interest1 attach-agent $host1

$ns at 1.0 “forward-interest $interest1”

In this case, the Interest packet is send according to their name for data/file1.

  1. Implement Caching Mechanism

CCN core aspects are caching. Routers can be saved Data packets within a cache and function them to advanced demands. We will want to execute a simple caching approach by way of connecting a cache with each router and caching the Data packets once they are inherited.

Example: Caching Data Packets

# Simple cache implementation for a router

proc cache-data {dataPacket} {

global router1 router2

# Store the Data packet in the cache (for simplicity, we use a list)

if {$dataPacket name == “data/file1”} {

set router1 cache $dataPacket

}

}

# Simulate storing a Data packet in cache

set data1 [new Application/Traffic/CBR]

$data1 set name “data/file1”

$data1 attach-agent $host2

$ns at 2.0 “cache-data $data1”

Once a Data packet attains at a router then it is saved within the router’s cache (in this example, a simple list is utilised for caching).

  1. Simulate Network Topology and Traffic Flows

Here, make a network topology including several routers and hosts. We can describe numerous routes for Interest packets being transmitted and then make certain that routers can be stored and operated the data as demanded.

# Network topology with multiple routers and hosts

set router1 [$ns node]

set router2 [$ns node]

set router3 [$ns node]

set host1 [$ns node]

set host2 [$ns node]

# Define links between routers and hosts

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

$ns duplex-link $router2 $router3 10Mb 10ms DropTail

$ns duplex-link $router3 $host1 10Mb 10ms DropTail

$ns duplex-link $router3 $host2 10Mb 10ms DropTail

# Create and forward Interest packets with caching enabled

set interestPacket [new Application/Traffic/CBR]

$interestPacket set name “data/file1”

$interestPacket attach-agent $host1

$ns at 1.0 “forward-interest $interestPacket”

In this scenario:

  • Hosts are transmitting the Interest packets.
  • Routers send those Interest packets to the succeeding router.
  • Data packets are transmit again to the demanding hosts.
  1. Monitor and Analyze the Simulation

When the simulation is configured then we execute the simulation and examine the outcome, verifying:

  • Data packet retrieval (whether Data packets are reverted to the correct requester).
  • Cache hit ratio (how frequently information is recovered from the cache).
  • Interest packet delivery ratio (whether Interests attain the source).
  • Routing efficiency (how rapidly packets are sent).

We can utilise the AWK or XGraph for executing and examining the outcomes:

# Example: Processing trace files

awk ‘{if ($1 == “r”) print $0}’ ccn_simulation.tr | awk ‘{total+=1} END {print total}’

  1. Extend the Simulation

When basic CCN simulation is executing then we can:

  • Launch numerous content items and replicate various Interest packets per capita.
  • Execute more advanced caching strategies like Least Recently Used (LRU) or Most Frequently Used (MFU).
  • Replicate the node mobility and then monitor how it affects the Interest forwarding and Data retrieval.
  • Depends on the content popularity or network load, enhance the routing.

Conclusion

Starting a Content-Centric Network (CCN) project in NS2:

  1. Make Interest and Data packets including content names.
  2. Replicate the forwarding Interest packets according to the content names.
  3. Execute caching for data retrieval in routers.
  4. Create a network topology that contains routers and hosts, and replicate the content demands.
  5. Observe crucial performance parameters such as packet delivery, cache hit ratio, and latency.

NS2 doesn’t directly support for CCN or NDN then we need to utilise the custom scripting for replicating crucial aspects of CCN like Interest/Data packet exchange and caching. If we are seeking a more advanced CCN/NDN simulation then we can deliberate to utilise want NS3 including ndnSIM that is particularly created for this purpose.

In conclusion, you have to utilize these simulation steps on how to simulate and examine the Content Centric Network Projects within NS2 network simulator. If you need any more details on this subject, we will provide it.