How to Implement Vehicular NDN in ns2

To implement Vehicular Named Data Networking (V-NDN) in ns2 (Network Simulator 2) has several steps to follow. Basically the vehicular NDN in ns2 is vital task while the ns2 does not support directly to Named Data Networking (NDN) or vehicular network characteristics such as mobility and erratic connectivity. But, we can approximate some contexts of V-NDN by emulating the vehicular communication with content-centric networking features.

Implementation of Vehicular NDN in ns2 are done in a structured way by our developers we have the leading tools and resources to get your work done on high quality.  for your projects. Drop us a message to guide you more. Get project analysis done by our experts.

The given below is the procedure to implements the Vehicular Named Data Networking in ns2:

Step-by-Step Implementation:

Conceptual Overview

In a Vehicular NDN (V-NDN) scenario:

  1. Vehicles as NDN Nodes: Each vehicle is signifying as an NDN node capable of requesting and caching content.
  2. Interest and Data Packets: Vehicles interacts by sending interest packets (requests for content) and receiving data packets (the requested content).
  3. Mobility Models: Vehicles move based on a predefined or random mobility model those impacts their connectivity and communication patterns.

Step 1: Conceptualize the Vehicular NDN Simulation

In this simulation, we will generate a basic V-NDN scenario in which the vehicles move within a predefined area, requesting and receiving content based on their movement and connectivity.

Step 2: Create the Tcl Script

The given below is an example Tcl script that emulates a simplified Vehicular NDN scenario in ns2.

Example Tcl Script for Simulating Vehicular NDN in ns2

# Create a simulator object

set ns [new Simulator]

# Define the topography object for a large area to simulate vehicle movement

set topo [new Topography]

$topo load_flatgrid 2000 2000  # 2km x 2km area

# Create the General Operations Director (GOD) for wireless simulations

create-god 6  # Number of nodes (5 vehicles + 1 RSU or content source)

# Configure the nodes for Vehicular NDN using AODV as a base routing protocol

$ns node-config -adhocRouting AODV \

-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 vndn_out.tr w]

$ns trace-all $tracefile

set namfile [open vndn_out.nam w]

$ns namtrace-all-wireless $namfile 2000 2000

# 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 vndn_out.nam &

exit 0

}

# Create NDN nodes (vehicles) and a content source (RSU or fixed node)

set vehicle1 [$ns node]

set vehicle2 [$ns node]

set vehicle3 [$ns node]

set vehicle4 [$ns node]

set vehicle5 [$ns node]

set rsu [$ns node]  # RSU or content source

# Set initial positions for vehicles and RSU

$vehicle1 set X_ 100.0

$vehicle1 set Y_ 100.0

$vehicle1 set Z_ 0.0

$vehicle2 set X_ 300.0

$vehicle2 set Y_ 300.0

$vehicle2 set Z_ 0.0

$vehicle3 set X_ 500.0

$vehicle3 set Y_ 500.0

$vehicle3 set Z_ 0.0

$vehicle4 set X_ 700.0

$vehicle4 set Y_ 700.0

$vehicle4 set Z_ 0.0

$vehicle5 set X_ 900.0

$vehicle5 set Y_ 900.0

$vehicle5 set Z_ 0.0

$rsu set X_ 1000.0

$rsu set Y_ 1000.0

$rsu set Z_ 0.0

# Define mobility for vehicles

$ns at 1.0 “$vehicle1 setdest 1800.0 100.0 20.0”

$ns at 1.0 “$vehicle2 setdest 1600.0 300.0 20.0”

$ns at 1.0 “$vehicle3 setdest 1400.0 500.0 20.0”

$ns at 1.0 “$vehicle4 setdest 1200.0 700.0 20.0”

$ns at 1.0 “$vehicle5 setdest 1000.0 900.0 20.0”

# Define a custom procedure for sending and receiving NDN Interest and Data packets

proc send_interest {src dst content_name} {

global ns

# Create an agent to represent the NDN Interest packet

set udp [new Agent/UDP]

$ns attach-agent $src $udp

# Create a null agent at the destination to receive the data packet

set null [new Agent/Null]

$ns attach-agent $dst $null

$ns connect $udp $null

# Simulate the Interest packet being sent

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$cbr set packetSize_ 512

$cbr set rate_ 100Kb

$cbr start

}

proc send_data {src dst content_name} {

global ns

# Simulate the Data packet being sent in response to the Interest packet

set tcp [new Agent/TCP]

$ns attach-agent $src $tcp

set sink [new Agent/TCPSink]

$ns attach-agent $dst $sink

$ns connect $tcp $sink

set ftp [new Application/FTP]

$ftp attach-agent $tcp

$ftp start

}

# Simulate Interest packets being sent from vehicles to the RSU

$ns at 2.0 “send_interest $vehicle1 $rsu /content/video1”

$ns at 4.0 “send_interest $vehicle2 $rsu /content/video2”

$ns at 6.0 “send_interest $vehicle3 $rsu /content/video3”

# Simulate Data packets being sent from the RSU to the vehicles

$ns at 3.0 “send_data $rsu $vehicle1 /content/video1”

$ns at 5.0 “send_data $rsu $vehicle2 /content/video2”

$ns at 7.0 “send_data $rsu $vehicle3 /content/video3”

# 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 with a .tcl extension, for instance, vndn_simulation.tcl. Then, execute the script using the following command in terminal:

ns vndn_simulation.tcl

Step 4: Visualize the Simulation

To visualize the simulation, open the configured NAM file using:

nam vndn_out.nam

Script Explanation

  • Vehicles as NDN Nodes: The nodes vehicle1 to vehicle5 signifies the vehicles that act as NDN nodes, capable of sending interest packets and receiving data packets.
  • RSU or Content Source: The rsu node denotes a Roadside Unit (RSU) or a fixed content source that delivers the requested content.
  • Mobility: Vehicles move in straight lines via the simulation area, which is a simple but effective way to emulate the vehicular mobility.
  • Interest and Data Packets: The custom procedures send_interest and send_data to mimic the sending of interest and data packets, correspondingly among vehicles and the RSU.

Customization

  • Complex Mobility Models: Execute more complex mobility models like random waypoint, realistic vehicular mobility models to better emulate the vehicle movement in urban environments.
  • Caching: Execute caching strategies in which vehicles can cache data and respond to future interest packets, minimizing the latency and enhancing network performance.
  • Different Traffic Patterns: Test with numerous kinds of content and traffic patterns like CBR, FTP, and VoIP to emulate numerous V-NDN use cases.
  • Scalability: Add more vehicles and RSUs to emulate a larger V-NDN with more complex communication patterns.

Limitations

  • Simplified NDN Model: This script delivers a simplified model of NDN interaction and does not execute advanced NDN features such as content-based routing, in-network caching or adaptive forwarding strategies.
  • Basic Mobility: The mobility model used in this sample is simple and may not precisely reflect real-world vehicular mobility.
  • No Physical Layer Simulation: The script does not emulate the physical layer features particular to vehicular communication, like interference, signal fading, or multipath effects.

Finally, we explore the simple implementation procedures how to simulate the Vehicular Named Data Networking in ns2 tool and we also provide related information about Vehicular Named Data Networking.