How to Implement Content centric network in ns2
To implement the Content-Centric Networking (CCN), also called as Named Data Networking (NDN) that is a novel networking model where the concentration shifts from host-based communication such as IP-based networking to content-based communication. In this network, data is focussed by its name instead of the location like IP address of the host. We can executing the CCN within ns2 that has contains mimicking how the content is invited and distributed based on names instead of traditional IP addresses. But the tool ns2 does not natively support to the CCN/NDN, we can be estimated it by using custom naming conventions and mimicking the procedure of content requests (interest packets) and data responses. Stay in touch with us to get topics on Content centric network with best implementation results.
Step-by-Step Implementations:
Step 1: Conceptualize the CCN Network Simulation
In a CCN/NDN set-up:
- CCN Nodes: The content centric network nodes are denote the network entities that can request (send interest packets) and deliver (send data packets) content.
- Interest Packets: The nodes are send interest packets to request particular content by name.
- Data Packets: Data packets nodes are have the demand content respond including data packets.
Step 2: Create the Tcl Script
The following is an instance for Tcl script that mimics a simple CCN scenario within ns2. This script is an estimate and doesn’t fully execute all CCN characteristics but the script is provides a simple idea of how to emulate the content-centric networking.
Example Tcl Script for Simulating Content-Centric Networking in ns2
# Create a simulator object
set ns [new Simulator]
# Define the topography object
set topo [new Topography]
$topo load_flatgrid 1000 1000 # 1km x 1km area
# Create the General Operations Director (GOD) for wireless simulations
create-god 5 # Number of nodes (4 CCN nodes + 1 content source)
# Configure the nodes for CCN communication
$ns node-config -llType LL \
-macType Mac/802_11 \
-ifqType Queue/DropTail/PriQueue \
-ifqLen 50 \
-antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround \
-phyType Phy/WirelessPhy \
-channelType Channel/WirelessChannel \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF
# Open trace and NAM files for recording the simulation
set tracefile [open ccn_out.tr w]
$ns trace-all $tracefile
set namfile [open ccn_out.nam w]
$ns namtrace-all-wireless $namfile 1000 1000
# Define a finish procedure to close files and end the simulation
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam ccn_out.nam &
exit 0
}
# Create CCN nodes (representing content consumers and forwarders)
set ccn_node1 [$ns node]
set ccn_node2 [$ns node]
set ccn_node3 [$ns node]
set ccn_node4 [$ns node]
# Create a content source node
set content_source [$ns node]
# Set initial positions for nodes
$ccn_node1 set X_ 100.0
$ccn_node1 set Y_ 500.0
$ccn_node1 set Z_ 0.0
$ccn_node2 set X_ 300.0
$ccn_node2 set Y_ 500.0
$ccn_node2 set Z_ 0.0
$ccn_node3 set X_ 500.0
$ccn_node3 set Y_ 500.0
$ccn_node3 set Z_ 0.0
$ccn_node4 set X_ 700.0
$ccn_node4 set Y_ 500.0
$ccn_node4 set Z_ 0.0
$content_source set X_ 900.0
$content_source set Y_ 500.0
$content_source set Z_ 0.0
# Define a custom procedure for CCN interest forwarding and data delivery
proc ccn_request {src dst content_name} {
global ns content_source
# Simulate sending an interest packet from src to dst
puts “Interest for [$content_name] sent from [$src] to [$dst]”
# Assuming the content is available at the content_source node
$ns at [expr $ns now + 0.01] “$src send-interest $dst $content_name”
$ns at [expr $ns now + 0.05] “$dst send-data $src $content_name”
}
# Define a function for sending interest packets
proc send-interest {dst content_name} {
global ns content_source
# Create a UDP agent to simulate interest packets
set udp [new Agent/UDP]
$ns attach-agent $dst $udp
# Simulate sending an interest packet to the content source
$ns at [expr $ns now + 0.01] “$udp send-interest-packet $content_name”
# Create a sink to receive the data packets in response
set sink [new Agent/Null]
$ns attach-agent $dst $sink
}
# Define a function for sending data packets
proc send-data {src content_name} {
global ns content_source
# Create a TCP agent at the content source to simulate data packets
set tcp [new Agent/TCP]
$ns attach-agent $content_source $tcp
# Create a TCP sink at the source to simulate receiving data
set sink [new Agent/TCPSink]
$ns attach-agent $src $sink
# Connect the content source to the requesting node
$ns connect $tcp $sink
# Simulate sending the data packet back to the requesting node
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp start
$ns at [expr $ns now + 0.1] “$ftp stop”
}
# Simulate content requests and data delivery in CCN
$ns at 2.0 “ccn_request $ccn_node1 $ccn_node2 content1”
$ns at 4.0 “ccn_request $ccn_node2 $ccn_node3 content1”
$ns at 6.0 “ccn_request $ccn_node3 $ccn_node4 content2”
$ns at 8.0 “ccn_request $ccn_node4 $ccn_node1 content3”
# Schedule the end of the simulation
$ns at 20.0 “finish”
# Run the simulation
$ns run
Step 3: Run the Tcl Script
Save the script including a .tcl extension, for instance, ccn_simulation.tcl. Next, we run the script using the below command in the terminal:
ns ccn_simulation.tcl
Step 4: Visualize the Simulation
We can visualize the simulation, open the created NAM file using:
nam ccn_out.nam
Script Explanation
- CCN Nodes: CCN nodes like ccn_node1, ccn_node2, ccn_node3, and ccn_node4 are denote the content consumers or forwarders in the network.
- Content Source Node: The content_source node that signifies a server or a node are has the essential content.
- Interest Forwarding and Data Delivery:
- Interest Packets: Interest packets’ nodes are send interest packets to need content by name.
- Data Packets: The content source responds to the interest with data packets containing the requested content.
- Custom Procedures: Nodes ccn_request, send-interest, and send-data are custom process that mimic the content-centric forwarding and data retrieval procedure.
Customization
- Multiple Content Names: Mimic requests for various content names by changing the ccn_request procedure.
- Cache Simulation: Execute the caching at middle nodes to mimic the in-network caching characteristic of CCN/NDN.
- Complex Topologies: Make more difficult network topologies including various ways among the nodes to investigate how the content needs and data sending work in larger networks.
- Different Traffic Patterns: Test with various traffic patterns to mimic several CCN use cases, like video streaming, file sharing, or real-time data retrieval.
Limitations
- Simplified Approximation: This emulation delivers a high-level estimate of the content centric network. It does not entirely execute the difficult characteristics of CCN/NDN, like content store, pending interest table (PIT), or forwarding information base (FIB).
- No Physical Layer Simulation: This script does not mimic the physical layer features particular to CCN/NDN, like link failures, changing link capacities, or channel conditions.
- Limited CCN Features: The tool ns2 is not created for CCN/NDN, so the simulation is limited to simple functionality and high-level abstractions.
Overall, you can understand how to execute and simulate the Content Centric Network and script explanation with the help of ns2 tool. More informations we will present of these implementations, if required.